Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2017-11-13 23:13:06 +0000
committerStephan Herrmann2017-11-14 13:08:25 +0000
commit18348948ff9ec7a6afd3cac11e858687ae9f50de (patch)
treef62ab52807a61d6cf2ab2074c9be2267d3a9b242
parent2a52cfb1eae4cba77312aac2a85298c0eb423b79 (diff)
downloadeclipse.jdt.core-18348948ff9ec7a6afd3cac11e858687ae9f50de.tar.gz
eclipse.jdt.core-18348948ff9ec7a6afd3cac11e858687ae9f50de.tar.xz
eclipse.jdt.core-18348948ff9ec7a6afd3cac11e858687ae9f50de.zip
Bug 526940: [9] The package x.y.z does not exist or is empty - 2nd
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java77
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java6
2 files changed, 83 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
index d24a74777a..28aaf1141b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
@@ -3748,4 +3748,81 @@ public void testBug521362_emptyFile() {
false,
OUTPUT_DIR + File.separator + out);
}
+ public void testBug522472c() {
+ File outputDirectory = new File(OUTPUT_DIR);
+ Util.flushDirectoryContent(outputDirectory);
+ String out = "bin";
+ String directory = OUTPUT_DIR + File.separator + "src";
+ File srcDir = new File(directory);
+ String moduleLoc = directory + File.separator + "mod.one";
+ List<String> files = new ArrayList<>();
+ writeFileCollecting(files, moduleLoc,
+ "module-info.java",
+ "module mod.one { \n" +
+ " exports x.y.z;\n" +
+ " exports a.b.c;\n" +
+ "}");
+ writeFileCollecting(files, moduleLoc + File.separator + "x" + File.separator + "y" + File.separator + "z",
+ "X.java",
+ "package x.y.z;\n");
+ writeFileCollecting(files, moduleLoc + File.separator + "a" + File.separator + "b" + File.separator + "c",
+ "A.java",
+ "package a.b.c;\n" +
+ "public class A {}");
+
+ moduleLoc = directory + File.separator + "mod.one.a";
+ writeFileCollecting(files, moduleLoc,
+ "module-info.java",
+ "module mod.one.a { \n" +
+ " exports x.y.z;\n" +
+ "}");
+ writeFileCollecting(files, moduleLoc + File.separator + "x" + File.separator + "y" + File.separator + "z",
+ "X.java",
+ "package x.y.z;\n" +
+ "public class X {}\n");
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("-d " + OUTPUT_DIR + File.separator + out )
+ .append(" -9 ")
+ .append(" -classpath \"")
+ .append(Util.getJavaClassLibsAsString())
+ .append("\" ")
+ .append(" --module-source-path " + "\"" + directory + "\" ");
+
+ runConformModuleTest(files,
+ buffer,
+ "",
+ "",
+ false);
+
+ Util.flushDirectoryContent(srcDir);
+ files.clear();
+ moduleLoc = directory + File.separator + "mod.two";
+ writeFileCollecting(files, moduleLoc,
+ "module-info.java",
+ "module mod.two { \n" +
+ " requires mod.one;\n" +
+ " requires mod.one.a;\n" +
+ "}");
+ writeFileCollecting(files, moduleLoc + File.separator + "p" + File.separator + "q" + File.separator + "r",
+ "Main.java",
+ "package p.q.r;\n" +
+ "import a.b.c.*;\n" +
+ "import x.y.z.*;\n" +
+ "@SuppressWarnings(\"unused\")\n" +
+ "public class Main {"
+ + "}");
+ buffer = new StringBuffer();
+ buffer.append("-d " + OUTPUT_DIR + File.separator + out )
+ .append(" -9 ")
+ .append(" -classpath \"")
+ .append(Util.getJavaClassLibsAsString())
+ .append("\" ")
+ .append(" --module-path " + "\"" + OUTPUT_DIR + File.separator + out + "\" ")
+ .append(" --module-source-path " + "\"" + directory + "\" ");
+ runConformModuleTest(files,
+ buffer,
+ "",
+ "",
+ false);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index b8c8f75508..6bff4deb61 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -5983,6 +5983,8 @@ protected void consumePackageDeclaration() {
// flush comments defined prior to import statements
impt.declarationEnd = this.endStatementPosition;
impt.declarationSourceEnd = flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
+ if (this.firstToken == TokenNameQUESTION)
+ this.unstackedAct = ACCEPT_ACTION; // force termination at goal
}
protected void consumePackageDeclarationName() {
// PackageDeclarationName ::= PackageComment 'package' Name RejectTypeAnnotations
@@ -11665,6 +11667,10 @@ try {
consumeRule(act);
act = this.unstackedAct;
+ if (act == ACCEPT_ACTION) {
+ break ProcessTerminals;
+ }
+
if (DEBUG_AUTOMATON) {
if (act <= NUM_RULES) {
System.out.print(" - "); //$NON-NLS-1$

Back to the top