Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShankha Banerjee2014-03-12 23:36:27 +0000
committerStephan Herrmann2014-03-12 23:39:28 +0000
commit36b688c7927454020434d559d15c8536a0c1af14 (patch)
treecb7b121406b84c855df785e2cfd6afe1b24db6fd
parent340d840f950775980b46fcf21979bc21f0e19016 (diff)
downloadeclipse.jdt.core-36b688c7927454020434d559d15c8536a0c1af14.tar.gz
eclipse.jdt.core-36b688c7927454020434d559d15c8536a0c1af14.tar.xz
eclipse.jdt.core-36b688c7927454020434d559d15c8536a0c1af14.zip
Bug 430219 - [1.8][compiler][null] NPE: Null Annotation on Parameter
Type Signed-off-by: Shankha Banerjee <shankhba@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java33
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java4
2 files changed, 37 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index f39c7ae98c..85b818079b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Stephan Herrmann - initial API and implementation
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -4342,4 +4343,36 @@ public void testBug429403() {
"Null type mismatch (type annotations): required \'List<@NonNull Person>\' but this expression has type \'ArrayList<@Nullable Person>\', corresponding supertype is \'List<@Nullable Person>\'\n" +
"----------\n");
}
+public void testBug430219() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "X.java",
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "@NonNullByDefault\n" +
+ "public class X {\n" +
+ " void foo(int @NonNull [] x) {}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " void foo(int @NonNull [] x) {}\n" +
+ " ^^^^^^^\n" +
+ "NonNull cannot be resolved to a type\n" +
+ "----------\n");
+}
+public void testBug430219a() {
+ runConformTestWithLibs(
+ new String[] {
+ "X.java",
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.TYPE_USE) @interface Marker{}\n" +
+ "@NonNullByDefault\n" +
+ "public class X {\n" +
+ " void foo(int @Marker[] x) {}\n" +
+ "}\n"
+ },
+ getCompilerOptions(),
+ "");
+}
}
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 99d3e96549..09219e8c99 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
@@ -968,6 +968,10 @@ public TypeBinding createAnnotatedType(TypeBinding type, AnnotationBinding[] new
AnnotationBinding[] filtered = new AnnotationBinding[newbies.length];
int count = 0;
for (int i = 0; i < newbies.length; i++) {
+ if (newbies[i] == null) {
+ filtered[count++] = null;
+ continue;
+ }
long tagBits = 0;
switch (newbies[i].type.id) {
case TypeIds.T_ConfiguredAnnotationNonNull : tagBits = TagBits.AnnotationNonNull; break;

Back to the top