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 174560 Details for
Bug 133125
[compiler][null] need to report the null status of expressions and analyze them simultaneously
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed patch
Bug_133125.patch (text/plain), 4.09 KB, created by
Stephan Herrmann
on 2010-07-17 12:00:31 EDT
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2010-07-17 12:00:31 EDT
Size:
4.09 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java,v >retrieving revision 1.95 >diff -u -r1.95 ConditionalExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 15 Jul 2009 17:42:43 -0000 1.95 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 17 Jul 2010 15:50:15 -0000 >@@ -318,6 +318,17 @@ > if (ifTrueNullStatus == ifFalseNullStatus) { > return ifTrueNullStatus; > } >+ // is there a chance of null? -> potentially null >+ switch (ifTrueNullStatus) { >+ case FlowInfo.NULL: >+ case FlowInfo.POTENTIALLY_NULL: >+ return FlowInfo.POTENTIALLY_NULL; >+ } >+ switch (ifFalseNullStatus) { >+ case FlowInfo.NULL: >+ case FlowInfo.POTENTIALLY_NULL: >+ return FlowInfo.POTENTIALLY_NULL; >+ } > return FlowInfo.UNKNOWN; > // cannot decide which branch to take, and they disagree > } >#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 17 Jul 2010 15:50:30 -0000 >@@ -738,7 +738,7 @@ > // other path: use a tainted unknown expression status; does not seem to cope well > // with o = (o == null ? new Object() : o) > // TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125 >-public void _test0034_conditional_expression() { >+public void test0034_conditional_expression() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -749,12 +749,65 @@ > " o.toString();\n" + > " }\n" + > "}\n"}, >- "----------\n" + >- "1. ERROR in X.java (at line 4)\n" + >- " o.toString();\n" + >- " ^\n" + >- "The variable o may be null\n" + >- "----------\n"); >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " o.toString();\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable o may be null at this location\n" + >+ "----------\n"); >+} >+//null analysis -- conditional expression >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125 >+//variant with constant condition >+public void test0034_conditional_expression_2() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " boolean b;\n" + >+ " void foo() {\n" + >+ " Object o = false ? null : new Object();\n" + >+ " o.toString();\n" + >+ " }\n" + >+ "}\n"}, >+ ""); >+} >+//null analysis -- conditional expression >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125 >+//variant with dependency between condition and expression - LocalDeclaration >+// TODO(stephan) cannot analyse this flow dependency >+public void _test0034_conditional_expression_3() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " boolean b;\n" + >+ " void foo(Object u) {\n" + >+ " if (u == null) {}\n" + //taint >+ " Object o = (u == null) ? new Object() : u;\n" + >+ " o.toString();\n" + >+ " }\n" + >+ "}\n"}, >+ ""); >+} >+//null analysis -- conditional expression >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125 >+//variant with dependency between condition and expression - Assignment >+//TODO(stephan) cannot analyse this flow dependency >+public void _test0034_conditional_expression_4() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " boolean b;\n" + >+ " void foo(Object u) {\n" + >+ " if (u == null) {}\n" + //taint >+ " Object o;\n" + >+ " o = (u == null) ? new Object() : u;\n" + >+ " o.toString();\n" + >+ " }\n" + >+ "}\n"}, >+ ""); > } > > // null analysis -- conditional expression
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 133125
:
174560
|
177976