Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2019-07-03 13:51:31 -0400
committerStephan Herrmann2019-07-03 16:47:03 -0400
commitf8480ac357ea4ce5d95c6e2a05c65fefd02632cd (patch)
treedf0fa26a1833f2ccb2c454fab0e769e8d21f37da
parent1d58555841ff864b4a406f5a0c2f38db486aa6a8 (diff)
downloadeclipse.jdt.core-f8480ac357ea4ce5d95c6e2a05c65fefd02632cd.tar.gz
eclipse.jdt.core-f8480ac357ea4ce5d95c6e2a05c65fefd02632cd.tar.xz
eclipse.jdt.core-f8480ac357ea4ce5d95c6e2a05c65fefd02632cd.zip
Bug 547181 - [9][impl] Reconsider representation and lookup of packagesI20190703-1800
(SplitPackageBinding) More simplifications: - MB.getTopLevelPackage already handles the LE package cache, so directly forward to it from LE.getToplevelPackage - Reduce places where LE.TheNotFoundPackage is returned and handled - More usages of PlainPackageBinding - MB.getVisiblePackage already does addPackage, remove in MB.getPackage Also adds a fix to make sure that ReconcilerTests9.testBug547113 doesn't fail pre java 9 Change-Id: Ie28c61b531bc0992f047a634bbd856f9a79c9f62
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests9.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java20
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java12
4 files changed, 18 insertions, 20 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 25fff8343f..4f85147bfc 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
@@ -852,6 +852,8 @@ public void testBug544306() throws Exception {
}
}
public void testBug547113() throws CoreException {
+ if (!isJRE9)
+ return;
IJavaProject unnamed = createJava9Project("unnamed");
IJavaProject a = createJava9Project("a");
IJavaProject b = createJava9Project("b");
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
index 18a9dd08ee..97e45e5d3b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
@@ -40,7 +40,7 @@ public class CompilationUnitScope extends Scope {
public LookupEnvironment environment;
public CompilationUnitDeclaration referenceContext;
public char[][] currentPackageName;
- public PackageBinding fPackage;
+ public PlainPackageBinding fPackage;
public ImportBinding[] imports;
public int importPtr;
public HashtableOfObject typeOrPackageCache; // used in Scope.getTypeOrPackage()
@@ -132,7 +132,7 @@ void buildTypeBindings(AccessRestriction accessRestriction) {
problemReporter().unnamedPackageInNamedModule(module());
}
} else {
- if ((this.fPackage = this.environment.createPackage(this.currentPackageName)) == null) {
+ if ((this.fPackage = this.environment.createPlainPackage(this.currentPackageName)) == null) {
if (this.referenceContext.currentPackage != null) {
problemReporter().packageCollidesWithType(this.referenceContext); // only report when the unit has a package statement
}
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 7082388ce7..0f3f6d2f13 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
@@ -83,7 +83,7 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants {
public ModuleBinding UnNamedModule;
public ModuleBinding JavaBaseModule;
public ModuleBinding module;
- public PackageBinding defaultPackage;
+ public PlainPackageBinding defaultPackage;
/** All visible toplevel packages, i.e. observable packages associated with modules read by the current module. */
HashtableOfPackage knownPackages;
private int lastCompletedUnitIndex = -1; // ROOT_ONLY
@@ -1086,6 +1086,9 @@ public MissingTypeBinding createMissingType(PackageBinding packageBinding, char[
* 3. Create the method bindings
*/
public PackageBinding createPackage(char[][] compoundName) {
+ return createPlainPackage(compoundName);
+}
+public PlainPackageBinding createPlainPackage(char[][] compoundName) {
PackageBinding packageBinding = this.module.getDeclaredPackage(CharOperation.concatWith(compoundName, '.'));
if (packageBinding != null && packageBinding.isValidBinding()) {
// restart from the toplevel package to proceed with clash analysis below
@@ -1637,22 +1640,17 @@ public ReferenceBinding getResolvedJavaBaseType(char[][] compoundName, Scope sco
* Answer null if the package cannot be found.
*/
PackageBinding getTopLevelPackage(char[] name) {
+ if (this.useModuleSystem) {
+ return this.module.getTopLevelPackage(name);
+ }
PackageBinding packageBinding = getPackage0(name);
if (packageBinding != null) {
if (packageBinding == TheNotFoundPackage)
return null;
return packageBinding;
}
- if (this.useModuleSystem) {
- packageBinding = this.module.getTopLevelPackage(name);
- } else {
- if (this.nameEnvironment.isPackage(null, name)) {
- this.knownPackages.put(name, packageBinding = new PlainPackageBinding(name, this, this.module));
- }
- }
- if (packageBinding != null) {
- if (packageBinding == TheNotFoundPackage)
- return null;
+ if (this.nameEnvironment.isPackage(null, name)) {
+ this.knownPackages.put(name, packageBinding = new PlainPackageBinding(name, this, this.module));
return packageBinding;
}
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 3fd3111b1b..5b481021e3 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
@@ -541,7 +541,7 @@ public class ModuleBinding extends Binding implements IUpdatableModule {
// check cache:
PackageBinding binding = this.environment.getPackage0(name);
if (binding != null)
- return binding;
+ return binding == LookupEnvironment.TheNotFoundPackage ? null : binding;
binding = getVisiblePackage(null, name);
// remember:
if (binding != null) {
@@ -658,13 +658,13 @@ public class ModuleBinding extends Binding implements IUpdatableModule {
}
PackageBinding parent = getTopLevelPackage(qualifiedPackageName[0]);
- if (parent == null || parent == LookupEnvironment.TheNotFoundPackage)
+ if (parent == null)
return null;
// check each sub package
for (int i = 1; i < qualifiedPackageName.length; i++) {
PackageBinding binding = getVisiblePackage(parent, qualifiedPackageName[i]);
- if (binding == null || binding == LookupEnvironment.TheNotFoundPackage) {
+ if (binding == null) {
return null;
}
parent = binding;
@@ -688,12 +688,10 @@ public class ModuleBinding extends Binding implements IUpdatableModule {
}
PackageBinding binding = null;
PackageBinding parent = getVisiblePackage(parentPackageName);
- if (parent != null && parent != LookupEnvironment.TheNotFoundPackage) {
+ if (parent != null) {
binding = getVisiblePackage(parent, packageName);
}
- if (binding != null)
- return addPackage(binding, false);
- return null;
+ return binding;
}
/**

Back to the top