Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2017-09-28 07:12:56 +0000
committerTill Brychcy2017-09-28 17:19:02 +0000
commitead103ad7c36e3aef324ce63c4500c4a7ba3557c (patch)
tree08b310db2dc54a0e75fcf4184c94ea355a43eb87
parentf8770d508aeb5800826e9043ddb68269cfb486d1 (diff)
downloadeclipse.jdt.core-ead103ad7c36e3aef324ce63c4500c4a7ba3557c.tar.gz
eclipse.jdt.core-ead103ad7c36e3aef324ce63c4500c4a7ba3557c.tar.xz
eclipse.jdt.core-ead103ad7c36e3aef324ce63c4500c4a7ba3557c.zip
Bug 522671 - [9] Types are not found in the Editor
- restore patch for bug 522327 Change-Id: I783b4675517f109b4055e0722f9fe365c33aa578
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java82
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java14
2 files changed, 92 insertions, 4 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 cbadd372bc..df82c75ff8 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
@@ -5850,6 +5850,88 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
deleteProject("test");
}
}
+ public void testBug522671b() throws CoreException {
+ if (!isJRE9) return;
+ try {
+ String[] sources = new String[] {
+ "src/nonmodular1/HasConstructorWithProperties.java",
+ "package nonmodular1;\n" +
+ "\n" +
+ "import java.util.Properties;\n" +
+ "\n" +
+ "public class HasConstructorWithProperties {\n" +
+ "\n" +
+ " public HasConstructorWithProperties(Properties loadedProperties) {\n" +
+ " }\n" +
+ "\n" +
+ " protected Properties method() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "",
+ "src/nonmodular1/HasPropertiesField.java",
+ "package nonmodular1;\n" +
+ "\n" +
+ "import java.util.Properties;\n" +
+ "\n" +
+ "public class HasPropertiesField {\n" +
+ " Properties properties;\n" +
+ "}\n" +
+ "",
+ };
+ IJavaProject p1 = setupModuleProject("nonmodular1", sources);
+
+ String[] sources2 = new String[] {
+ "src/java/util/dummy/Dummy.java",
+ "package java.util.dummy;\n" +
+ "\n" +
+ "public class Dummy {\n" +
+ "}\n" +
+ "\n" +
+ "",
+ };
+ IJavaProject p2 = setupModuleProject("nonmodular2", sources2);
+ p2.setOption(JavaCore.COMPILER_COMPLIANCE, "1.8"); // compile with 1.8 compliance to avoid error about package conflict
+
+ IClasspathEntry dep1 = JavaCore.newProjectEntry(p1.getPath(), null, false,
+ new IClasspathAttribute[] {},
+ false/*not exported*/);
+ IClasspathEntry dep2 = JavaCore.newProjectEntry(p2.getPath(), null, false,
+ new IClasspathAttribute[] {},
+ false/*not exported*/);
+ String[] src = new String[] {
+ "src/test/a/UsesHasPropertiesField.java",
+ "package test.a;\n" +
+ "\n" +
+ "import nonmodular1.HasPropertiesField;\n" +
+ "\n" +
+ "public class UsesHasPropertiesField extends HasPropertiesField {\n" +
+ "}\n" +
+ "",
+ "src/test/b/Test.java",
+ "package test.b;\n" +
+ "\n" +
+ "import java.util.Properties;\n" +
+ "\n" +
+ "import nonmodular1.HasConstructorWithProperties;\n" +
+ "\n" +
+ "public final class Test {\n" +
+ " public static Object test(Properties cassandraConf) {\n" +
+ " return new HasConstructorWithProperties(cassandraConf);\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ };
+ IJavaProject p3 = setupModuleProject("nonmodular3", src, new IClasspathEntry[] { dep1, dep2 });
+ p3.getProject().getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ assertNoErrors();
+ } finally {
+ deleteProject("nonmodular1");
+ deleteProject("nonmodular2");
+ deleteProject("nonmodular3");
+ }
+ }
protected void assertNoErrors() throws CoreException {
for (IProject p : getWorkspace().getRoot().getProjects()) {
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 247b1cd49f..61c2688c08 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
@@ -1661,11 +1661,17 @@ private ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean
ReferenceBinding binding = getCachedType(compoundName);
if (binding == null) {
PackageBinding packageBinding = computePackageFrom(compoundName, false /* valid pkg */);
- binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
- if (wasMissingType) {
- binding.tagBits |= TagBits.HasMissingType; // record it was bound to a missing type
+ if(this.useModuleSystem) {
+ // the package might not have been seen in getCachedType, so retry
+ binding = packageBinding.getType0(compoundName[compoundName.length - 1]);
+ }
+ if(binding == null) {
+ binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
+ if (wasMissingType) {
+ binding.tagBits |= TagBits.HasMissingType; // record it was bound to a missing type
+ }
+ packageBinding.addType(binding);
}
- packageBinding.addType(binding);
} else if (binding == TheNotFoundType) {
// report the missing class file first
if (!wasMissingType) {

Back to the top