Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-11-20 04:27:55 +0000
committerManoj Palat2020-11-20 04:27:55 +0000
commite630d940429f56b09511af009b4734afe9ef6bf9 (patch)
treea7bd1d04644260afdb9c0fc0aaeed5c9eefaa72f
parent494515e0d4dc5b9242fa3b7ba806ab9688802431 (diff)
downloadeclipse.jdt.core-I20201122-0600.tar.gz
eclipse.jdt.core-I20201122-0600.tar.xz
eclipse.jdt.core-I20201122-0600.zip
Bug 568959 - NPE when parsing .java file (build and edition assistanceI20201122-1800I20201122-0600I20201121-1800I20201121-0600I20201120-1800I20201120-0320
broken) Change-Id: I636512094fe88338c3c50ea87909513b144d17ec Signed-off-by: Manoj Palat <manpalat@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java25
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java2
2 files changed, 26 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java
index 2a09e1b7ec..bd8fd95364 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java
@@ -794,6 +794,31 @@ public void testBug361039() {
"f cannot be resolved or is not a field\n" +
"----------\n");
}
+public void testBug568959_001() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_8) return; // lambda
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public void foo(Object o) {\n"+
+ " I i = () -> {\n"+
+ " while (o.eq) {\n"+
+ " // nothing\n"+
+ " }\n"+
+ " };\n"+
+ " }\n"+
+ "}\n"+
+ "interface I { \n"+
+ " public abstract void run();\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " while (o.eq) {\n" +
+ " ^^\n" +
+ "eq cannot be resolved or is not a field\n" +
+ "----------\n");
+}
public static Class testClass() {
return FieldAccessTest.class;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
index bf9d86975e..b1bf2cdf22 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
@@ -928,7 +928,7 @@ public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FieldBindi
@Override
public Constant optimizedBooleanConstant() {
- if (this.binding.isValidBinding()) {
+ if (this.binding.isValidBinding() && this.resolvedType != null) {
switch (this.resolvedType.id) {
case T_boolean :
case T_JavaLangBoolean :

Back to the top