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 192941 Details for
Bug 342300
[null]Spurious "null pointer access" warning on unboxing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v1.0 + tests
patch342300.txt (text/plain), 3.48 KB, created by
Ayushman Jain
on 2011-04-11 11:37:24 EDT
(
hide
)
Description:
proposed fix v1.0 + tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-04-11 11:37:24 EDT
Size:
3.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java,v >retrieving revision 1.56 >diff -u -r1.56 LoopingFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 8 Mar 2011 16:46:01 -0000 1.56 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 11 Apr 2011 15:22:37 -0000 >@@ -548,7 +548,10 @@ > case CAN_ONLY_NULL | IN_ASSIGNMENT: > case CAN_ONLY_NULL | IN_INSTANCEOF: > if (flowInfo.isPotentiallyNonNull(local) >- || flowInfo.isPotentiallyUnknown(local)) { >+ || flowInfo.isPotentiallyUnknown(local) >+ || flowInfo.isProtectedNonNull(local)) { >+ // if variable is not null, we are not interested in recording null reference for deferred checks. >+ // This is because CAN_ONLY_NULL means we're only interested in cases when variable can be null. > return; > } > if (flowInfo.isDefinitelyNull(local)) { >#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.118 >diff -u -r1.118 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 9 Mar 2011 13:57:50 -0000 1.118 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 11 Apr 2011 15:22:39 -0000 >@@ -14530,4 +14530,52 @@ > "Dead code\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=342300 >+public void testBug342300() throws Exception { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void initPattern(String p, Character escapeChar) {\n" + >+ " int len = p.length();\n" + >+ " for (int i = 0; i < len; i++) {\n" + >+ " char c = p.charAt(i);\n" + >+ " if (escapeChar != null && escapeChar == c) {\n" + // quiet >+ " c = p.charAt(++i);\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ }, >+ ""); >+ } >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=342300 >+// To make sure only the redundant null check is given and not a potential NPE >+public void testBug342300b() throws Exception { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void initPattern(String p, Character escapeChar) {\n" + >+ " int len = p.length();\n" + >+ " for (int i = 0; i < len; i++) {\n" + >+ " char c = p.charAt(i);\n" + >+ " if (escapeChar != null && escapeChar != null) {\n" + // look here >+ " c = p.charAt(++i);\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " if (escapeChar != null && escapeChar != null) {\n" + >+ " ^^^^^^^^^^\n" + >+ "Redundant null check: The variable escapeChar cannot be null at this location\n" + >+ "----------\n"); >+ } >+} > } >\ 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 342300
: 192941 |
192964