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 173727 Details for
Bug 319201
[null] no warning when unboxing SingleNameReference causes NPE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed patch with a few tests
bug_319201.patch (text/plain), 5.50 KB, created by
Stephan Herrmann
on 2010-07-07 20:32:17 EDT
(
hide
)
Description:
proposed patch with a few tests
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2010-07-07 20:32:17 EDT
Size:
5.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java,v >retrieving revision 1.88 >diff -u -r1.88 Assignment.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 7 Mar 2009 00:58:57 -0000 1.88 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 8 Jul 2010 00:19:26 -0000 >@@ -37,6 +37,9 @@ > // a field reference, a blank final field reference, a field of an enclosing instance or > // just a local variable. > LocalVariableBinding local = this.lhs.localVariableBinding(); >+ if ((this.expression.implicitConversion & TypeIds.UNBOXING) != 0) { >+ this.expression.checkNPE(currentScope, flowContext, flowInfo); >+ } > int nullStatus = this.expression.nullStatus(flowInfo); > if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) { > if (nullStatus == FlowInfo.NULL) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java,v >retrieving revision 1.71 >diff -u -r1.71 LocalDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 23 Oct 2009 15:15:26 -0000 1.71 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 8 Jul 2010 00:19:26 -0000 >@@ -40,6 +40,9 @@ > if (this.initialization == null) { > return flowInfo; > } >+ if ((this.initialization.implicitConversion & TypeIds.UNBOXING) != 0) { >+ this.initialization.checkNPE(currentScope, flowContext, flowInfo); >+ } > int nullStatus = this.initialization.nullStatus(flowInfo); > flowInfo = > this.initialization >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v >retrieving revision 1.146 >diff -u -r1.146 MessageSend.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 18 Jan 2010 12:40:18 -0000 1.146 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 8 Jul 2010 00:19:27 -0000 >@@ -65,6 +65,9 @@ > if (this.arguments != null) { > int length = this.arguments.length; > for (int i = 0; i < length; i++) { >+ if ((this.arguments[i].implicitConversion & TypeIds.UNBOXING) != 0) { >+ this.arguments[i].checkNPE(currentScope, flowContext, flowInfo); >+ } > flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo).unconditionalInits(); > } > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v >retrieving revision 1.95 >diff -u -r1.95 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 16 Mar 2010 14:36:08 -0000 1.95 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 8 Jul 2010 00:19:43 -0000 >@@ -11662,4 +11662,72 @@ > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201 >+// unboxing raises an NPE >+public void testBug319201() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " Integer i = null;\n" + >+ " int j = i;\n" + // should warn >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " int j = i;\n" + >+ " ^\n" + >+ "Null pointer access: The variable i can only be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201 >+//unboxing could raise an NPE >+public void testBug319201a() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void foo(Integer i) {\n" + >+ " if (i == null) {};\n" + >+ " int j;\n" + >+ " j = i;\n" + // should warn >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " j = i;\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable i may be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201 >+//unboxing raises an NPE >+public void testBug319201b() { >+ if (this.complianceLevel < ClassFileConstants.JDK1_5) >+ return; >+ runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void foo() {\n" + >+ " Boolean bo = null;;\n" + >+ " bar(bo);\n" + // should warn >+ " }\n" + >+ " void bar(boolean b) {}\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " bar(bo);\n" + >+ " ^^\n" + >+ "Null pointer access: The variable bo can only be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} > } >\ No newline at end of file
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 319201
:
173727
|
174412
|
174950
|
174994
|
175518