diff options
| author | Till Brychcy | 2016-01-08 21:04:35 +0000 |
|---|---|---|
| committer | Stephan Herrmann | 2016-02-14 19:20:01 +0000 |
| commit | 5959bbf385fc1f797d392576c0a27049452fc9d1 (patch) | |
| tree | a4c7569ed2a302638666762d0d194e9b4107da38 | |
| parent | 1f1e13eb5623dc708dfab88fa9a29cff703f1034 (diff) | |
| download | eclipse.jdt.core-5959bbf385fc1f797d392576c0a27049452fc9d1.tar.gz eclipse.jdt.core-5959bbf385fc1f797d392576c0a27049452fc9d1.tar.xz eclipse.jdt.core-5959bbf385fc1f797d392576c0a27049452fc9d1.zip | |
Bug 485465 - [1.8][null] null annotations completely broken for classesI20160216-1400I20160216-0800
that are resolved in lambda
Change-Id: I7f121927ee588748e48727386d16e32a8415dacf
Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
2 files changed, 59 insertions, 5 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 16aecad460..2c7694a7c3 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 @@ -10491,5 +10491,64 @@ public void testBug485027() { " }\n" +
"}"
}, getCompilerOptions(), "");
+} +public void testBug485565() {
+ runConformTestWithLibs(
+ new String[] {
+ "test2/ClassWithRegistry.java",
+ "package test2;\n" +
+ "\n" +
+ "import java.rmi.registry.Registry;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.Nullable;\n" +
+ "\n" +
+ "public class ClassWithRegistry {\n" +
+ " @Nullable\n" +
+ " public Registry registry;\n" +
+ "}\n"
+ },
+ getCompilerOptions(),
+ ""
+ );
+ runConformTestWithLibs(
+ new String[] {
+ "test1/ClassWithLambda.java",
+ "package test1;\n" +
+ "\n" +
+ "import test2.ClassWithRegistry;\n" +
+ "\n" +
+ "// must be compiled before ZClassWithBug\n" +
+ "public class ClassWithLambda {\n" +
+ " interface Lambda {\n" +
+ " void f();\n" +
+ " }\n" +
+ "\n" +
+ " public static void invoke(Lambda lambda) {\n" +
+ " lambda.f();\n" +
+ " }\n" +
+ "\n" +
+ " public void f() {\n" +
+ " new ClassWithRegistry(); // must be accessed as class file\n" +
+ " invoke(() -> java.rmi.registry.Registry.class.hashCode());\n" +
+ " }\n" +
+ "}\n",
+ "test1/ZClassWithBug.java",
+ "package test1;\n" +
+ "\n" +
+ "import java.rmi.registry.Registry;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "import org.eclipse.jdt.annotation.Nullable;\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "public abstract class ZClassWithBug {\n" +
+ "\n" +
+ " @Nullable\n" +
+ " public Registry rmiregistry;\n" +
+ "}\n"
+ },
+ getCompilerOptions(),
+ ""
+ );
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java index 7227965876..dd4fc9632a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java @@ -65,7 +65,6 @@ import org.eclipse.jdt.internal.compiler.flow.ExceptionInferenceFlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.impl.Constant; import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding; @@ -879,10 +878,7 @@ public class LambdaExpression extends FunctionalExpression implements IPolyExpre copy = this.copiesPerTargetType.values().iterator().next(); } } - final CompilerOptions compilerOptions = this.enclosingScope.compilerOptions(); - boolean analyzeNPE = compilerOptions.isAnnotationBasedNullAnalysisEnabled; IErrorHandlingPolicy oldPolicy = this.enclosingScope.problemReporter().switchErrorHandlingPolicy(silentErrorHandlingPolicy); - compilerOptions.isAnnotationBasedNullAnalysisEnabled = false; try { if (copy == null) { copy = copy(); @@ -907,7 +903,6 @@ public class LambdaExpression extends FunctionalExpression implements IPolyExpre copy.analyzeExceptions(); return copy; } finally { - compilerOptions.isAnnotationBasedNullAnalysisEnabled = analyzeNPE; this.enclosingScope.problemReporter().switchErrorHandlingPolicy(oldPolicy); } } |
