Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Langer2019-05-20 09:22:16 -0400
committerStephan Herrmann2019-05-20 16:22:52 -0400
commit4236732223b1aca6b7f00e0723f59948f7043d5c (patch)
tree3e5aa6bec01757f02ef0f2a4787963ad93eb91f9
parent749a725533763687a087f7127f05425654a6ac4d (diff)
downloadeclipse.jdt.core-4236732223b1aca6b7f00e0723f59948f7043d5c.tar.gz
eclipse.jdt.core-4236732223b1aca6b7f00e0723f59948f7043d5c.tar.xz
eclipse.jdt.core-4236732223b1aca6b7f00e0723f59948f7043d5c.zip
Bug 547479 - Java 9+ (JPMS) Intermittent compilation error "The type...I20190521-1800I20190521-0600I20190520-1805
is not accessible". LookupEnvironment::reset() shall reset "this.stepCompleted" to 0. Change-Id: I6748f8cf08f460f5e47c39dadd0f52099e03edf6 Signed-off-by: Christoph Langer <christoph.langer@sap.com> Also-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java56
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java1
2 files changed, 57 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
index 8c1afe12ba..5b8459fd96 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
@@ -8648,6 +8648,62 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
deleteProject("lib");
}
}
+ public void testBug547479() throws CoreException {
+ int max = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE;
+
+ IJavaProject prjA = createJava9Project("A");
+ IJavaProject prjB = createJava9Project("B");
+ try {
+ createFile("A/src/module-info.java",
+ "module A {\n" +
+ "}\n");
+
+ addModularProjectEntry(prjB, prjA);
+ // prepare files to be compiled in two batches à 2 files:
+ org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = 2;
+ // ---1---
+ createFolder("B/src/b");
+ createFile("B/src/b/Class1.java",
+ "package b;\n" +
+ "import java.sql.Connection;\n" +
+ "public class Class1 {\n" +
+ " Connection connection;\n" +
+ "}\n");
+ createFile("B/src/b/Class2.java",
+ "package b;\n" +
+ "import java.sql.Connection;\n" +
+ "public class Class2 {\n" +
+ " Connection connection;\n" +
+ "}\n");
+ // ---2---
+ createFile("B/src/module-info.java",
+ "module B {\n" +
+ " requires java.sql;\n" +
+ " requires A;\n" +
+ "}\n");
+ String bPath = "B/src/b/Class3.java";
+ String bSource =
+ "package b;\n" + // <= this triggered createPackage in an inconsistent state
+ "import java.sql.Connection;\n" +
+ "public class Class3 {\n" +
+ " Connection connection;\n" +
+ "}\n";
+ createFile(bPath, bSource);
+ getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ assertNoErrors();
+
+ this.problemRequestor.initialize(bSource.toCharArray());
+ getCompilationUnit(bPath).getWorkingCopy(this.wcOwner, null);
+ assertProblems("unexpected problems",
+ "----------\n" +
+ "----------\n",
+ this.problemRequestor);
+ } finally {
+ org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = max;
+ deleteProject(prjA);
+ deleteProject(prjB);
+ }
+ }
protected void assertNoErrors() throws CoreException {
for (IProject p : getWorkspace().getRoot().getProjects()) {
int maxSeverity = p.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
index bf84ff6884..3acb8552eb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
@@ -2122,6 +2122,7 @@ public void reset() {
this.root.reset();
return;
}
+ this.stepCompleted = 0;
this.knownModules = new HashtableOfModule();
this.UnNamedModule = new ModuleBinding.UnNamedModule(this);
this.module = this.UnNamedModule;

Back to the top