Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-11-06 17:46:46 +0000
committerStephan Herrmann2018-11-06 19:18:21 +0000
commit04e41961470fd11a6f9c97ce199f6d3349b99f39 (patch)
tree341a14d2cff6f2f8d018bb36ba247135ebb12d5d
parent41d84c5cf54ba6247b680d88014859456532ff27 (diff)
downloadeclipse.jdt.core-04e41961470fd11a6f9c97ce199f6d3349b99f39.tar.gz
eclipse.jdt.core-04e41961470fd11a6f9c97ce199f6d3349b99f39.tar.xz
eclipse.jdt.core-04e41961470fd11a6f9c97ce199f6d3349b99f39.zip
Bug 540541 - Interactive compilation of project that depends onI20181107-0200I20181106-1800
java.base as project fails to resolve java.base correctly Change-Id: I2946bbfa505c4b491db23ae6845c62ad49b904ab
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java57
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests9.java6
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java7
3 files changed, 60 insertions, 10 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
index 92d89696bb..919c45ef17 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java
@@ -16,8 +16,15 @@ package org.eclipse.jdt.core.tests.model;
import java.io.IOException;
+import java.util.Hashtable;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IProblemRequestor;
@@ -393,4 +400,54 @@ public void testTerminalDeprecation2() throws CoreException, IOException {
deleteProject("P1");
}
}
+public void testBug540541() throws CoreException, IOException {
+ if (!isJRE9) return;
+ IJavaProject project1 = null;
+ IJavaProject project2 = null;
+ Hashtable<String, String> options = JavaCore.getOptions();
+ try {
+ project1 = createJava9Project("java.base", "9");
+ createFile("/java.base/src/module-info.java",
+ "module java.base {\n" +
+ " exports java.lang;\n" +
+ "}");
+ createFolder("/java.base/src/java/lang");
+ createFile("/java.base/src/java/lang/Object.java",
+ "package java.lang;\n" +
+ "public class Object {\n" +
+ "}\n");
+
+ project1.setRawClasspath(new IClasspathEntry[] {JavaCore.newSourceEntry(new Path("/java.base/src"))}, null);
+ project1.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = project1.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers on java.base", "", markers);
+
+ project2 = createJava9Project("client", "9");
+ IClasspathAttribute[] attributes = new IClasspathAttribute[] { JavaCore.newClasspathAttribute("module", "true") };
+ IClasspathEntry projectEntry = JavaCore.newProjectEntry(project1.getPath(), null, false, attributes, false);
+ project2.setRawClasspath(new IClasspathEntry[] {projectEntry, JavaCore.newSourceEntry(new Path("/client/src"))}, null);
+ createFolder("/client/src/p");
+ createFile("/client/src/p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ "}\n");
+ this.workingCopy = getCompilationUnit("client/src/p/X.java").getWorkingCopy(this.wcOwner, null);
+ this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray());
+ this.workingCopy.reconcile(AST_INTERNAL_JLS11, true, this.wcOwner, null);
+ assertProblems("Expecting no problems",
+ "----------\n" +
+ "----------\n",
+ this.problemRequestor);
+
+ markers = project2.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+ assertMarkers("Unexpected markers on client", "", markers);
+ } finally {
+ if (project1 != null)
+ deleteProject(project1);
+ if (project2 != null)
+ deleteProject(project2);
+ JavaCore.setOptions(options);
+ }
+}
+
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests9.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests9.java
index 4f369a718a..1af2c2f400 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests9.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests9.java
@@ -267,13 +267,11 @@ public class ResolveTests9 extends AbstractJavaModelTests {
int length = selection.length();
waitUntilIndexesReady();
- // once indexes are ready, there's no second try and since
- // SelectionOnQualifiedTypeReference ("test.ITest") cannot be resolved,
- // we don't recognize the selection:
+ // even after indexes are built we meanwhile (after bug 540541) find the selected type
IJavaElement[] elements = this.wc.codeSelect(start, length);
assertElementsEqual(
"Unexpected elements",
- "",
+ "ITest [in ITest.java [in test [in src [in Resolve]]]]",
elements
);
} finally {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
index d47c3a2ca4..4bc371272d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
@@ -92,12 +92,7 @@ public class SearchableEnvironment
this.workingCopies = workingCopies;
this.nameLookup = project.newNameLookup(workingCopies, excludeTestCode);
if (CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_COMPLIANCE, true)) >= ClassFileConstants.JDK9) {
- for (IPackageFragmentRoot root : project.getPackageFragmentRoots()) {
- if (root.getModuleDescription() != null) {
- this.knownModuleLocations = new HashMap<>();
- break;
- }
- }
+ this.knownModuleLocations = new HashMap<>();
}
if (CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_COMPLIANCE, true)) >= ClassFileConstants.JDK9) {
this.moduleUpdater = new ModuleUpdater(project);

Back to the top