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 242883 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]
Patch
patch.patch3 (text/plain), 9.38 KB, created by
shankha banerjee
on 2014-05-09 04:34:15 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
shankha banerjee
Created:
2014-05-09 04:34:15 EDT
Size:
9.38 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..2c656f9 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 >@@ -5157,4 +5157,33 @@ public void testBug433586() { > 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 13)\n" + >+ " public Y foo() {\n" + >+ " ^\n" + >+ "The return type is incompatible with I<Y>.foo()\n" + >+ "----------\n"); >+} > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java >index b7c9cd5..95984b1 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullAnnotationMatching.java >@@ -364,7 +364,7 @@ public class NullAnnotationMatching { > * Problems are either reported directly (if scope != null) or by returning a ProblemMethodBinding. > */ > public static MethodBinding checkForContraditions( >- final MethodBinding method, final InvocationSite invocationSite, final Scope scope) { >+ final MethodBinding method, final InvocationSite invocationSite, final Scope scope, TypeBinding returnType) { > > class SearchContradictions extends TypeBindingVisitor { > ReferenceBinding typeWithContradiction; >@@ -389,8 +389,11 @@ public class NullAnnotationMatching { > SearchContradictions searchContradiction = new SearchContradictions(); > TypeBindingVisitor.visit(searchContradiction, method.returnType); > if (searchContradiction.typeWithContradiction != null) { >- if (scope == null) >- return new ProblemMethodBinding(method, method.selector, method.parameters, ProblemReasons.ContradictoryNullAnnotations); >+ if (scope == null) { >+ ProblemMethodBinding problem = new ProblemMethodBinding(method, method.selector, method.parameters, ProblemReasons.ContradictoryNullAnnotations); >+ problem.returnType = returnType; >+ return problem; >+ } > scope.problemReporter().contradictoryNullAnnotationsInferred(method, invocationSite); > // note: if needed, we might want to update the method by removing the contradictory annotations?? > return method; >@@ -402,8 +405,11 @@ public class NullAnnotationMatching { > for (int i = 0; i < method.parameters.length; i++) { > TypeBindingVisitor.visit(searchContradiction, method.parameters[i]); > if (searchContradiction.typeWithContradiction != null) { >- if (scope == null) >- return new ProblemMethodBinding(method, method.selector, method.parameters, ProblemReasons.ContradictoryNullAnnotations); >+ if (scope == null) { >+ ProblemMethodBinding problem = new ProblemMethodBinding(method, method.selector, method.parameters, ProblemReasons.ContradictoryNullAnnotations); >+ problem.returnType = method.returnType; >+ return problem; >+ } > if (arguments != null && i < arguments.length) > scope.problemReporter().contradictoryNullAnnotationsInferred(method, arguments[i]); > else >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java >index 2e6f8aa..0f8d255 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java >@@ -528,7 +528,7 @@ public class InferenceContext18 { > if (solutions != null) { > finalMethod = this.environment.createParameterizedGenericMethod(original, solutions); > if (this.scope.compilerOptions().isAnnotationBasedNullAnalysisEnabled) >- NullAnnotationMatching.checkForContraditions(finalMethod, invocation, this.scope); >+ NullAnnotationMatching.checkForContraditions(finalMethod, invocation, this.scope, null); > invocation.registerInferenceContext(finalMethod, this); > this.solutionsPerTargetType.put(targetType, new Solution(finalMethod, result)); > } >@@ -1446,10 +1446,12 @@ public class InferenceContext18 { > ReferenceBinding declaringClass = original.declaringClass; > TypeBinding[] arguments = getSolutions(declaringClass.typeVariables(), innerMessage, bounds); > declaringClass = this.environment.createParameterizedType(declaringClass, arguments, declaringClass.enclosingType()); >- original = ((ParameterizedTypeBinding)declaringClass).createParameterizedMethod(original); >+ ParameterizedMethodBinding parameterizedMethod = ((ParameterizedTypeBinding)declaringClass).createParameterizedMethod(original); > inner.checkAgainstFinalTargetType(innerTargetType, this.scope); >- if (this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled) >- NullAnnotationMatching.checkForContraditions(original, innerMessage, this.scope); >+ if (this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled) { >+ NullAnnotationMatching.checkForContraditions(parameterizedMethod, innerMessage, this.scope, null); >+ } >+ original = parameterizedMethod; > } > > // apply results of the combined inference onto the binding of the inner invocation: >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java >index fb5cbb3..2fb31dd 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java >@@ -162,7 +162,7 @@ public class ParameterizedGenericMethodBinding extends ParameterizedMethodBindin > } > if (invocationTypeInferred) { > if (compilerOptions.isAnnotationBasedNullAnalysisEnabled) >- NullAnnotationMatching.checkForContraditions(methodSubstitute, invocationSite, scope); >+ NullAnnotationMatching.checkForContraditions(methodSubstitute, invocationSite, scope, null); > infCtx18.rebindInnerPolies(result, methodSubstitute.parameters); > return methodSubstitute.boundCheck18(scope, arguments); > } else { >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >index d22336c..4bbc82b 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >@@ -672,8 +672,10 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi > for (int i = 0; i < length; i++) { > // substitute methods, so as to get updated declaring class at least > parameterizedMethods[i] = createParameterizedMethod(originalMethods[i]); >- if (useNullTypeAnnotations) >- parameterizedMethods[i] = NullAnnotationMatching.checkForContraditions(parameterizedMethods[i], null, null); >+ if (useNullTypeAnnotations) { >+ parameterizedMethods[i] = NullAnnotationMatching.checkForContraditions(parameterizedMethods[i], null, null, >+ originalMethods[i].returnType); >+ } > } > if (this.methods == null) { > MethodBinding[] temp = new MethodBinding[length]; >@@ -945,8 +947,9 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi > for (int i = 0; i < length; i++) { > // substitute all methods, so as to get updated declaring class at least > parameterizedMethods[i] = createParameterizedMethod(originalMethods[i]); >- if (useNullTypeAnnotations) >- parameterizedMethods[i] = NullAnnotationMatching.checkForContraditions(parameterizedMethods[i], null, null); >+ if (useNullTypeAnnotations) { >+ parameterizedMethods[i] = NullAnnotationMatching.checkForContraditions(parameterizedMethods[i], null, null, originalMethods[i].returnType); >+ } > } > > this.methods = parameterizedMethods;
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