Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java47
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java12
2 files changed, 57 insertions, 2 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 725f615ff1..b80de70c73 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
@@ -7992,6 +7992,53 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
Util.flushDirectoryContent(outputDir);
}
}
+
+ public void testBug544432() throws CoreException {
+ IJavaProject prjA = createJava9Project("A");
+ IJavaProject prjB = createJava9Project("B");
+ try {
+ createFolder("A/src/com/a");
+ createFile("A/src/com/a/A.java",
+ "package com.a;\n" +
+ "\n" +
+ "public class A {}\n");
+ createFile("A/src/module-info.java",
+ "open module com.a {\n" +
+ " exports com.a;\n" +
+ "}\n");
+
+ addModularProjectEntry(prjB, prjA);
+ createFolder("B/src/com/a/b");
+ String bPath = "B/src/com/a/b/B.java";
+ String bSource =
+ "package com.a.b;\n" +
+ "import com.a.A;\n" +
+ "public class B {\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " A a = new A();\n" +
+ " System.out.println(a);\n" +
+ " }\n" +
+ "}\n";
+ createFile(bPath, bSource);
+ createFile("B/src/module-info.java",
+ "open module com.a.b {\n" +
+ " requires com.a;\n" +
+ "}\n");
+ 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 {
+ deleteProject(prjA);
+ deleteProject(prjB);
+ }
+ }
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/ModuleBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
index 32df973735..3b31a807a4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java
@@ -564,8 +564,16 @@ public class ModuleBinding extends Binding implements IUpdatableModule {
declaringModuleNames = moduleEnv.getUniqueModulesDeclaringPackage(parentName, name, nameForLookup());
if (declaringModuleNames != null) {
if (CharOperation.containsEqual(declaringModuleNames, this.moduleName)) {
- // declared here, not yet known, so create it now:
- binding = new PackageBinding(subPkgCompoundName, parent, this.environment, this);
+ if (parent instanceof SplitPackageBinding) {
+ // parent.getPackage0() may have been too shy, so drill into the split:
+ PackageBinding singleParent = ((SplitPackageBinding) parent).getIncarnation(this);
+ if (singleParent != null)
+ binding = singleParent.getPackage0(name);
+ }
+ if (binding == null) {
+ // declared here, not yet known, so create it now:
+ binding = new PackageBinding(subPkgCompoundName, parent, this.environment, this);
+ }
} else if (considerRequiredModules) {
// visible but foreign (when current is unnamed or auto):
for (char[] declaringModuleName : declaringModuleNames) {

Back to the top