Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2013-09-17 11:19:24 +0000
committerStephan Herrmann2013-10-08 14:03:21 +0000
commit39b64f412ebb05fcab9e4c92294ffc1b5633130a (patch)
tree095d086cfeea6faa05598d4ebdfef56689e07e40
parent5b7f891f7f9c876174516ca4901ac977f93c7d19 (diff)
downloadeclipse.jdt.core-39b64f412ebb05fcab9e4c92294ffc1b5633130a.tar.gz
eclipse.jdt.core-39b64f412ebb05fcab9e4c92294ffc1b5633130a.tar.xz
eclipse.jdt.core-39b64f412ebb05fcab9e4c92294ffc1b5633130a.zip
Bug 416267 - NPE in QualifiedAllocationExpression.resolveType
- incl. test from bug 418843
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java38
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java3
2 files changed, 40 insertions, 1 deletions
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 890711fd31..1d5beac673 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
@@ -6289,4 +6289,42 @@ public void testBug413460() {
"Null type mismatch: required \'@NonNull String\' but the provided value is null\n" +
"----------\n");
}
+public void testBug416267() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void test() {\n" +
+ " Missing m = new Missing() { };\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Missing m = new Missing() { };\n" +
+ " ^^^^^^^\n" +
+ "Missing cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Missing m = new Missing() { };\n" +
+ " ^^^^^^^\n" +
+ "Missing cannot be resolved to a type\n" +
+ "----------\n");
+}
+// duplicate of bug 416267
+public void testBug418843() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "TestEnum.java",
+ "public enum TestEnum {\n" +
+ " TestEntry(1){};\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in TestEnum.java (at line 2)\n" +
+ " TestEntry(1){};\n" +
+ " ^^^^^^^^^\n" +
+ "The constructor TestEnum(int) is undefined\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index e351b7dd4a..1d2b0126c2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -17,6 +17,7 @@
* bug 388996 - [compiler][resource] Incorrect 'potential resource leak'
* bug 395977 - [compiler][resource] Resource leak warning behavior possibly incorrect for anonymous inner class
* bug 403147 - [compiler][null] FUP of bug 400761: consolidate interaction between unboxing, NPE, and deferred checking
+ * Bug 416267 - NPE in QualifiedAllocationExpression.resolveType
* Jesper S Moller <jesper@selskabet.org> - Contributions for
* bug 378674 - "The method can be declared as static" is wrong
* Till Brychcy - Contributions for
@@ -269,7 +270,7 @@ public class QualifiedAllocationExpression extends AllocationExpression {
return super.resolveType(scope);
}
TypeBinding result=resolveTypeForQualifiedAllocationExpression(scope);
- if(result != null) {
+ if(result != null && this.binding != null) {
final CompilerOptions compilerOptions = scope.compilerOptions();
if (compilerOptions.isAnnotationBasedNullAnalysisEnabled && (this.binding.tagBits & TagBits.IsNullnessKnown) == 0) {
new ImplicitNullAnnotationVerifier(compilerOptions.inheritNullAnnotations)

Back to the top