diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java index 279b70c..19b79ef 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java @@ -52,7 +52,7 @@ // Static initializer to specify tests subset using TESTS_* static variables // All specified tests which do not belong to the class are skipped... static { -// TESTS_NAMES = new String[] { "test_illegal_annotation_00" }; +// TESTS_NAMES = new String[] { "test_illegal_annotation_007" }; // TESTS_NUMBERS = new int[] { 561 }; // TESTS_RANGE = new int[] { 1, 2049 }; } @@ -1812,6 +1812,42 @@ "----------\n"); } +// a configured annotation type does not exist +// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=186342#c133 +public void test_illegal_annotation_007() { + Map customOptions = getCompilerOptions(); + runNegativeTestWithLibs( + new String[] { + "p/Test.java", + "package p;\n" + + "import org.eclipse.jdt.annotation.*;\n" + + "interface TestInt{\n" + + " @NonNull Object foo();\n" + + "}\n" + + "\n" + + "public class Test { \n" + + " void bar() {" + + " new TestInt() {\n" + + " @org public Object foo() {\n" + + " }\n" + + " };\n" + + " }\n" + + "}" + }, + customOptions, + "----------\n" + + "1. ERROR in p\\Test.java (at line 9)\n" + + " @org public Object foo() {\n" + + " ^^^\n" + + "org cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in p\\Test.java (at line 9)\n" + + " @org public Object foo() {\n" + + " ^^^^^^\n" + + "The return type is incompatible with the @NonNull return from TestInt.foo()\n" + + "----------\n"); +} + public void test_default_nullness_002() { Map customOptions = getCompilerOptions(); // customOptions.put(CompilerOptions.OPTION_ReportPotentialNullSpecViolation, JavaCore.ERROR); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index a21174e..f3e8a5a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -8128,7 +8128,7 @@ Annotation[] annotations = methodDecl.annotations; if (annotations != null) { for (int i=0; i