Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasikanth Bharadwaj2014-05-22 03:44:57 +0000
committerJayaprakash Arthanareeswaran2014-05-22 03:44:57 +0000
commit17cb72936c7817f00ee632f41ae5246b6b9db5dd (patch)
tree9d5b1100737ccdf65bce376cf20dcfa81e038850
parent7d530ea80eaf0c8a945cfb41d1521a9832dec42f (diff)
downloadeclipse.jdt.core-17cb72936c7817f00ee632f41ae5246b6b9db5dd.tar.gz
eclipse.jdt.core-17cb72936c7817f00ee632f41ae5246b6b9db5dd.tar.xz
eclipse.jdt.core-17cb72936c7817f00ee632f41ae5246b6b9db5dd.zip
Bug 433825 - [1.8][compiler] Internal compiler error:
NullPointerException in AllocationExpression#resolvePart3 Signed-off-by: Sasikanth Bharadwaj<saammana@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java64
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java4
2 files changed, 68 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
index 23b8a3afe2..0060ea8674 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java
@@ -3116,4 +3116,68 @@ public void _testBug432626() {
"}\n"
});
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=433825 [1.8][compiler] Internal compiler error: NullPointerException in AllocationExpression#resolvePart3
+public void testBug433825() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.ArrayList;\n" +
+ "import java.util.Collection;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public void bla() {\n" +
+ " boolean b = Boolean.TRUE.booleanValue();\n" +
+ " List<String> c1 = new ArrayList<>();\n" +
+ " new Bar(b ? c1 : new ArrayList<>()); // this line crashes ecj (4.4 I20140429-0800), but not ecj (eclipse 3.8.2) and javac\n" +
+ " }\n" +
+ " private static class Bar {\n" +
+ " public Bar(Collection<?> col) { }\n" +
+ " }\n" +
+ "}"
+ });
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=433825 [1.8][compiler] Internal compiler error: NullPointerException in AllocationExpression#resolvePart3
+public void testBug433825a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.ArrayList;\n" +
+ "import java.util.Collection;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ " public void bla() {\n" +
+ " boolean b = Boolean.TRUE.booleanValue();\n" +
+ " new Bar(b ? 0 : new ArrayList<>());\n" +
+ " }\n" +
+ " private static class Bar {\n" +
+ " public Bar(Collection<String> col) { }\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " new Bar(b ? 0 : new ArrayList<>());\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The constructor X.Bar((b ? 0 : new ArrayList<>())) is undefined\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " new Bar(b ? 0 : new ArrayList<>());\n" +
+ " ^\n" +
+ "Type mismatch: cannot convert from int to Collection<String>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 9)\n" +
+ " new Bar(b ? 0 : new ArrayList<>());\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from ArrayList<Object> to Collection<String>\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 12)\n" +
+ " public Bar(Collection<String> col) { }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The constructor X.Bar(Collection<String>) is never used locally\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index c102fa70ce..019ad8101d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -725,6 +725,10 @@ public MethodBinding binding(TypeBinding targetType, boolean reportErrors, Scope
return this.binding;
}
public TypeBinding checkAgainstFinalTargetType(TypeBinding targetType, Scope scope) {
+ if (this.binding == null && this.suspendedResolutionState != null && !this.suspendedResolutionState.hasReportedError) {
+ // Attempt to resolve half resolved diamond
+ resolvePart2(this.suspendedResolutionState);
+ }
// confer MessageSend.checkAgainstFinalTargetType(,,):
if (this.binding instanceof ParameterizedGenericMethodBinding) {
InferenceContext18 ctx = getInferenceContext((ParameterizedMethodBinding) this.binding);

Back to the top