Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-03-26 21:50:01 +0000
committerJay Arthanareeswaran2019-04-02 06:34:45 +0000
commit6c19f59ccc7eddfcbe29da18a067179f04929983 (patch)
treec1abe9041a823d7439785110a0e93cf766a7041e
parent11c8aa046b654035396fabe27672bbab88bb0fda (diff)
downloadeclipse.jdt.core-6c19f59ccc7eddfcbe29da18a067179f04929983.tar.gz
eclipse.jdt.core-6c19f59ccc7eddfcbe29da18a067179f04929983.tar.xz
eclipse.jdt.core-6c19f59ccc7eddfcbe29da18a067179f04929983.zip
Bug 535819 - possible NPE when using ecj >3.13.0 with annotation
processor - sketch of a fix but without a test Change-Id: I9f83c6134076c81444eda848f2676482b08e8730 Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ModuleBinding.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java5
5 files changed, 19 insertions, 12 deletions
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
index d4aca24a4c..3f8515c1d2 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/RoundEnvImpl.java
@@ -60,9 +60,9 @@ public class RoundEnvImpl implements RoundEnvironment
AnnotationDiscoveryVisitor visitor = new AnnotationDiscoveryVisitor(_processingEnv);
if (_units != null) {
for (CompilationUnitDeclaration unit : _units) {
- unit.scope.suppressImportErrors = true;
+ unit.scope.environment.suppressImportErrors = true;
unit.traverse(visitor, unit.scope);
- unit.scope.suppressImportErrors = false;
+ unit.scope.environment.suppressImportErrors = false;
}
}
_annoToUnit = visitor._annoToElement;
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 8993942d9b..08404fd14c 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
@@ -53,12 +53,6 @@ public class CompilationUnitScope extends Scope {
private ImportBinding[] tempImports; // to keep a record of resolved imports while traversing all in faultInImports()
/**
- * Flag that should be set during annotation traversal or similar runs
- * to prevent caching of failures regarding imports of yet to be generated classes.
- */
- public boolean suppressImportErrors;
-
- /**
* Skips import caching if unresolved imports were
* found last time.
*/
@@ -365,7 +359,7 @@ void faultInImports() {
return; // faultInImports already in progress
boolean unresolvedFound = false;
// should report unresolved only if we are not suppressing caching of failed resolutions
- boolean reportUnresolved = !this.suppressImportErrors;
+ boolean reportUnresolved = !this.environment.suppressImportErrors;
if (this.typeOrPackageCache != null && !this.skipCachingImports)
return; // can be called when a field constant is resolved before static imports
@@ -506,7 +500,7 @@ void faultInImports() {
if (!binding.onDemand && binding.resolvedImport instanceof ReferenceBinding || binding instanceof ImportConflictBinding)
this.typeOrPackageCache.put(binding.compoundName[binding.compoundName.length - 1], binding);
}
- this.skipCachingImports = this.suppressImportErrors && unresolvedFound;
+ this.skipCachingImports = this.environment.suppressImportErrors && unresolvedFound;
}
public void faultInTypes() {
faultInImports();
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 9192ea0855..41f6dee869 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
@@ -137,6 +137,12 @@ public class LookupEnvironment implements ProblemReasons, TypeConstants {
/** Global access to the outermost active inference context as the universe for inference variable interning. */
InferenceContext18 currentInferenceContext;
+ /**
+ * Flag that should be set during annotation traversal or similar runs
+ * to prevent caching of failures regarding imports of yet to be generated classes.
+ */
+ public boolean suppressImportErrors; // per module
+
final static int BUILD_FIELDS_AND_METHODS = 4;
final static int BUILD_TYPE_HIERARCHY = 1;
final static int CHECK_AND_SET_IMPORTS = 2;
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 f9ee9dba24..953bcebc3a 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
@@ -625,7 +625,11 @@ public class ModuleBinding extends Binding implements IUpdatableModule {
&& !packageMayBeIncomplete // don't remember package that may still lack some siblings
&& !(parent instanceof SplitPackageBinding)) // don't store problem into SPB, because from different focus things may look differently
{
- parent.knownPackages.put(name, binding == null ? LookupEnvironment.TheNotFoundPackage : binding);
+ if (binding == null) {
+ parent.addNotFoundPackage(name);
+ } else {
+ parent.knownPackages.put(name, binding);
+ }
}
return null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
index 33a2218c93..0bd0e50cbb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
@@ -77,9 +77,12 @@ public PackageBinding(LookupEnvironment environment) {
this(CharOperation.NO_CHAR_CHAR, null, environment, environment.module);
}
protected void addNotFoundPackage(char[] simpleName) {
- this.knownPackages.put(simpleName, LookupEnvironment.TheNotFoundPackage);
+ if (!this.environment.suppressImportErrors)
+ this.knownPackages.put(simpleName, LookupEnvironment.TheNotFoundPackage);
}
private void addNotFoundType(char[] simpleName) {
+ if (this.environment.suppressImportErrors)
+ return;
if (this.knownTypes == null)
this.knownTypes = new HashtableOfType(25);
this.knownTypes.put(simpleName, LookupEnvironment.TheNotFoundType);

Back to the top