Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-11-08 22:53:52 +0000
committerStephan Herrmann2018-11-09 22:36:28 +0000
commitd7dab33b1df21a757b4a698338d9f4cf4e29b52c (patch)
treecdfdd0ea95e89c4fcf5905d1e01e89565bffe82d
parent3a518b615c9be9a2836fe2691f5328950c1462b5 (diff)
downloadeclipse.jdt.core-d7dab33b1df21a757b4a698338d9f4cf4e29b52c.tar.gz
eclipse.jdt.core-d7dab33b1df21a757b4a698338d9f4cf4e29b52c.tar.xz
eclipse.jdt.core-d7dab33b1df21a757b4a698338d9f4cf4e29b52c.zip
Bug 534865 - [compiler][null] imports in Nullable.java are incorrectlyI20181112-0435I20181112-0320
flagged as unused. Change-Id: Id3af5931cc73d4b19af36c08e39af89af304cf23
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java54
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java3
2 files changed, 57 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
index d7f71e61f5..91ebdb5913 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java
@@ -5904,5 +5904,59 @@ public void testBug485092() throws CoreException, IOException, InterruptedExcept
deleteProject(project18);
}
}
+public void testBug534865() throws CoreException, IOException {
+ IJavaProject project18 = null;
+ try {
+ project18 = createJavaProject("Reconciler18", new String[] {"src"}, new String[] {"JCL18_LIB"}, "bin");
+ setUpProjectCompliance(project18, "1.8");
+ project18.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
+ createFolder("/Reconciler18/src/org/eclipse/jdt/annotation");
+ createFile(
+ "/Reconciler18/src/org/eclipse/jdt/annotation/Nullable.java",
+ "package org.eclipse.jdt.annotation;\n" +
+ "import static java.lang.annotation.ElementType.TYPE_USE;\n" +
+ "\n" +
+ "import java.lang.annotation.Documented;\n" +
+ "import java.lang.annotation.Retention;\n" +
+ "import java.lang.annotation.RetentionPolicy;\n" +
+ "import java.lang.annotation.Target;\n" +
+ "@Documented\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({ TYPE_USE })\n" +
+ "public @interface Nullable {\n" +
+ " // marker annotation with no members\n" +
+ "}\n"
+ );
+ String source =
+ "package org.eclipse.jdt.annotation;\n" +
+ "import static java.lang.annotation.ElementType.TYPE_USE;\n" +
+ "\n" +
+ "import java.lang.annotation.Documented;\n" +
+ "import java.lang.annotation.Retention;\n" +
+ "import java.lang.annotation.RetentionPolicy;\n" +
+ "import java.lang.annotation.Target;\n" +
+ "@Documented\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({ TYPE_USE })\n" +
+ "public @interface NonNull {\n" +
+ " // marker annotation with no members\n" +
+ "}\n";
+ createFile(
+ "/Reconciler18/src/org/eclipse/jdt/annotation/NonNull.java",
+ source
+ );
+ this.workingCopies = new ICompilationUnit[1];
+ this.problemRequestor.initialize(source.toCharArray());
+ this.workingCopies[0] = getCompilationUnit("/Reconciler18/src/org/eclipse/jdt/annotation/NonNull.java").getWorkingCopy(this.wcOwner, null);
+ assertProblems(
+ "Unexpected problems",
+ "----------\n" +
+ "----------\n"
+ );
+ } finally {
+ if (project18 != null)
+ deleteProject(project18);
+ }
+}
}
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 81179a7fe1..6ea3c6228b 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
@@ -362,6 +362,8 @@ void connectTypeHierarchy() {
this.topLevelTypes[i].scope.connectTypeHierarchy();
}
void faultInImports() {
+ if (this.tempImports != null)
+ 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;
@@ -491,6 +493,7 @@ void faultInImports() {
if (this.tempImports.length > this.importPtr)
System.arraycopy(this.tempImports, 0, this.tempImports = new ImportBinding[this.importPtr], 0, this.importPtr);
this.imports = this.tempImports;
+ this.tempImports = null;
int length = this.imports.length;
this.typeOrPackageCache = new HashtableOfObject(length);
for (int i = 0; i < length; i++) {

Back to the top