Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-04-16 15:46:50 -0400
committerStephan Herrmann2019-04-16 15:49:06 -0400
commitbd2710396dddf798a364e0bd043e4dbe8ad7156c (patch)
tree28b6302b3b639b052a2a4b742812cc7240e048d4
parentfcfd0b7a8086bb7c045999dbfed0f02e4bf593f0 (diff)
downloadeclipse.jdt.core-bd2710396dddf798a364e0bd043e4dbe8ad7156c.tar.gz
eclipse.jdt.core-bd2710396dddf798a364e0bd043e4dbe8ad7156c.tar.xz
eclipse.jdt.core-bd2710396dddf798a364e0bd043e4dbe8ad7156c.zip
Bug 542795 - NPE in ProblemReporter.deprecatedSinceValue(...)I20190416-1800
Change-Id: Ib993ac655af27f5caf14c3037b25144d47e070b2 Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java47
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java53
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java3
3 files changed, 103 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java
index 6f12b7dd0e..460219383c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated9Test.java
@@ -960,6 +960,53 @@ public class Deprecated9Test extends AbstractRegressionTest9 {
"CMissing cannot be resolved to a type\n" +
"----------\n");
}
+ public void testBug542795() throws Exception {
+ Runner runner = new Runner();
+ runner.customOptions = new HashMap<>();
+ runner.customOptions.put(JavaCore.COMPILER_PB_DEPRECATION, CompilerOptions.ERROR);
+ runner.testFiles = new String[] {
+ "test/ReaderWarningView.java",
+ "package test;\n" +
+ "@java.lang.Deprecated\n" +
+ "public class ReaderWarningView {}\n",
+ "Test.java",
+ "public class Test implements test.Screen.Component {}\n",
+ "test/Screen.java",
+ "package test;\n" +
+ "@interface Annot{ Class<?> value(); }\n" +
+ "@Annot(test.Screen.Component.class)\n" +
+ "@java.lang.Deprecated\n" +
+ "public final class Screen {\n" +
+ " @java.lang.Deprecated\n" +
+ " public interface Component extends test.ReaderWarningView.Component {\n" +
+ " }\n" +
+ "}\n",
+ };
+ runner.expectedCompilerLog =
+ "----------\n" +
+ "1. ERROR in Test.java (at line 1)\n" +
+ " public class Test implements test.Screen.Component {}\n" +
+ " ^^^^\n" +
+ "The hierarchy of the type Test is inconsistent\n" +
+ "----------\n" +
+ "2. ERROR in Test.java (at line 1)\n" +
+ " public class Test implements test.Screen.Component {}\n" +
+ " ^^^^^^\n" +
+ "The type Screen is deprecated\n" +
+ "----------\n" +
+ "3. ERROR in Test.java (at line 1)\n" +
+ " public class Test implements test.Screen.Component {}\n" +
+ " ^^^^^^^^^\n" +
+ "The type Screen.Component is deprecated\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in test\\Screen.java (at line 7)\n" +
+ " public interface Component extends test.ReaderWarningView.Component {\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "test.ReaderWarningView.Component cannot be resolved to a type\n" +
+ "----------\n";
+ runner.runNegativeTest();
+ }
public static Class<?> testClass() {
return Deprecated9Test.class;
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
index 550672a29e..276625417f 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter9Test.java
@@ -1503,5 +1503,58 @@ public class ASTConverter9Test extends ConverterTestSetup {
deleteProject(p);
}
}
+ public void testBug542795() throws Exception {
+ IJavaProject p = createJavaProject("Foo", new String[] {"src"}, new String[] {jcl9lib}, "bin", "11");
+ try {
+ createFolder("/Foo/src/test");
+ createFile("/Foo/src/test/ReaderWarningView.java",
+ "package test;\n" +
+ "@java.lang.Deprecated\n" +
+ "public class ReaderWarningView {}\n");
+ String source =
+ "public class Test implements test.Screen.Component {}\n";
+ createFile("/Foo/src/Test.java", source);
+ createFile("/Foo/src/test/Screen.java",
+ "package test;\n" +
+ "@interface Annot{ Class<?> value(); }\n" +
+ "@Annot(test.Screen.Component.class)\n" +
+ "@java.lang.Deprecated\n" +
+ "public final class Screen {\n" +
+ " @java.lang.Deprecated\n" +
+ " public interface Component extends test.ReaderWarningView.Component {\n" +
+ " }\n" +
+ "}\n");
+ ICompilationUnit cuD = getCompilationUnit("/Foo/src/Test.java");
+
+ p.setOption(JavaCore.COMPILER_PB_DEPRECATION, JavaCore.ERROR);
+ ASTParser parser = ASTParser.newParser(AST_INTERNAL_JLS11);
+ parser.setProject(p);
+ parser.setSource(cuD);
+ parser.setResolveBindings(true);
+ parser.setStatementsRecovery(true);
+ parser.setBindingsRecovery(true);
+ org.eclipse.jdt.core.dom.CompilationUnit cuAST = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
+ IProblem[] problems = cuAST.getProblems();
+ assertProblems("Unexpected problems",
+ "1. ERROR in /Foo/src/Test.java (at line 1)\n" +
+ " public class Test implements test.Screen.Component {}\n" +
+ " ^^^^\n" +
+ "The hierarchy of the type Test is inconsistent\n" +
+ "----------\n" +
+ "2. ERROR in /Foo/src/Test.java (at line 1)\n" +
+ " public class Test implements test.Screen.Component {}\n" +
+ " ^^^^^^\n" +
+ "The type Screen is deprecated\n" +
+ "----------\n" +
+ "3. ERROR in /Foo/src/Test.java (at line 1)\n" +
+ " public class Test implements test.Screen.Component {}\n" +
+ " ^^^^^^^^^\n" +
+ "The type Screen.Component is deprecated\n" +
+ "----------\n",
+ problems, source.toCharArray());
+ } finally {
+ deleteProject(p);
+ }
+ }
// Add new tests here
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
index 5b74b22c5a..a9d93097a3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
@@ -108,6 +108,9 @@ public class QualifiedTypeReference extends TypeReference {
return this.resolvedType;
}
Binding binding = scope.getPackage(this.tokens);
+ if (this.resolvedType != null) { // recheck in case we had re-entrance
+ return this.resolvedType;
+ }
if (binding != null && !binding.isValidBinding()) {
if (binding instanceof ProblemReferenceBinding && binding.problemId() == ProblemReasons.NotFound) {
ProblemReferenceBinding problemBinding = (ProblemReferenceBinding) binding;

Back to the top