Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 243022 Details for
Bug 433478
[compiler][null] NPE in ReferenceBinding.isCompatibleWith
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
minimal patch
Bug-433478--compilernull-NPE-in-ReferenceBindingisCo.patch (text/plain), 4.29 KB, created by
Stephan Herrmann
on 2014-05-13 08:52:03 EDT
(
hide
)
Description:
minimal patch
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2014-05-13 08:52:03 EDT
Size:
4.29 KB
patch
obsolete
>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 246dfda..5be1265 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 >@@ -3220,6 +3220,47 @@ > "Null type safety (type annotations): The expression of type \'X<String>\' needs unchecked conversion to conform to \'X<@Nullable String>\'\n" + > "----------\n"); > } >+ >+ // introduce unrelated method lookup before the bogus one >+ public void testBug416182a() { >+ runNegativeTestWithLibs( >+ new String[] { >+ "X.java", >+ "import org.eclipse.jdt.annotation.NonNull;\n" + >+ "import org.eclipse.jdt.annotation.Nullable;\n" + >+ "\n" + >+ "public class X<T> {\n" + >+ " T foo(@NonNull T t) {\n" + >+ " return t;\n" + >+ " }\n" + >+ " void foo() {}\n" + >+ " public static void main(String[] args) {\n" + >+ " X<@Nullable String> xs = new X<String>();\n" + >+ " xs.foo();\n" + >+ " xs.foo(null);\n" + >+ " }\n" + >+ " \n" + >+ " public void test(X<String> x) {\n" + >+ " X<@Nullable String> xs = x;\n" + >+ " xs.bar(null);\n" + >+ " }\n" + >+ " public void bar(T t) {}\n" + >+ "\n" + >+ "}\n" >+ }, >+ getCompilerOptions(), >+ "----------\n" + >+ "1. ERROR in X.java (at line 12)\n" + >+ " xs.foo(null);\n" + >+ " ^^^^^^^^^^^^\n" + >+ "Contradictory null annotations: method was inferred as \'@Nullable String foo(@NonNull @Nullable String)\', but only one of \'@NonNull\' and \'@Nullable\' can be effective at any location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 16)\n" + >+ " X<@Nullable String> xs = x;\n" + >+ " ^\n" + >+ "Null type safety (type annotations): The expression of type \'X<String>\' needs unchecked conversion to conform to \'X<@Nullable String>\'\n" + >+ "----------\n"); >+ } > > public void testBug416183() { > runConformTestWithLibs( >@@ -5157,4 +5198,33 @@ > getCompilerOptions(), > ""); > } >+// NPE without the fix. >+public void testBug433478() { >+ runNegativeTestWithLibs( >+ new String[] { >+ "X.java", >+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" + >+ "import org.eclipse.jdt.annotation.Nullable;\n" + >+ "\n" + >+ "@NonNullByDefault class Y { }\n" + >+ "\n" + >+ "interface I<T> {\n" + >+ " @Nullable T foo();\n" + >+ "}\n" + >+ "\n" + >+ "@NonNullByDefault \n" + >+ "class X implements I<Y> {\n" + >+ " @Override\n" + >+ " public Y foo() {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 14)\n" + >+ " return null;\n" + >+ " ^^^^\n" + >+ "Null type mismatch: required \'@NonNull Y\' but the provided value is null\n" + >+ "----------\n"); >+} > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java >index 0597a5f..ae26b61 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java >@@ -34,7 +34,10 @@ > public ProblemMethodBinding(MethodBinding closestMatch, char[] selector, TypeBinding[] args, int problemReason) { > this(selector, args, problemReason); > this.closestMatch = closestMatch; >- if (closestMatch != null && problemReason != ProblemReasons.Ambiguous) this.declaringClass = closestMatch.declaringClass; >+ if (closestMatch != null && problemReason != ProblemReasons.Ambiguous) { >+ this.declaringClass = closestMatch.declaringClass; >+ this.returnType = closestMatch.returnType; >+ } > } > /* API > * Answer the problem id associated with the receiver.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 433478
:
242301
|
242882
|
242883
| 243022