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 77975 Details for
Bug 201182
[compiler][null] Null pointer access compiler warning fails when "throw null"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Suggested fix + test cases
patch.txt (text/plain), 4.33 KB, created by
Maxime Daniel
on 2007-09-10 07:45:17 EDT
(
hide
)
Description:
Suggested fix + test cases
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-09-10 07:45:17 EDT
Size:
4.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java,v >retrieving revision 1.34 >diff -u -r1.34 ThrowStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java 6 Mar 2007 02:38:48 -0000 1.34 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java 10 Sep 2007 11:46:17 -0000 >@@ -32,6 +32,7 @@ > > public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { > this.exception.analyseCode(currentScope, flowContext, flowInfo); >+ this.exception.checkNPE(currentScope, flowContext, flowInfo); > // need to check that exception thrown is actually caught somewhere > flowContext.checkExceptionHandlers(this.exceptionType, this, flowInfo, currentScope); > return FlowInfo.DEAD_END; >#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.70 >diff -u -r1.70 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 10 Sep 2007 11:10:35 -0000 1.70 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 10 Sep 2007 11:46:20 -0000 >@@ -5597,6 +5597,99 @@ > ""); > } > >+// null analysis - throw >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201182 >+public void test0595_throw() { >+ runTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) throws Throwable {\n" + >+ " Throwable t = null;\n" + >+ " throw t;\n" + >+ " }\n" + >+ "}\n" >+ }, >+ true /* expectingCompilerErrors */, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " throw t;\n" + >+ " ^\n" + >+ "Null pointer access: The variable t can only be null at this location\n" + >+ "----------\n" /* expectedCompilerLog */, >+ "" /* expectedOutputString */, >+ false /* forceExecution */, >+ null /* classLib */, >+ true /* shouldFlushOutputDirectory */, >+ null /* vmArguments */, >+ null /* customOptions */, >+ null /* clientRequestor */, >+ true /* skipJavac */); >+} >+ >+// null analysis - throw >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201182 >+// variant - potential NPE >+public void test0596_throw() { >+ runTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) throws Throwable {\n" + >+ " Throwable t = null;\n" + >+ " if (args.length > 0) {\n" + >+ " t = new Throwable();\n" + >+ " }\n" + >+ " throw t;\n" + >+ " }\n" + >+ "}\n" >+ }, >+ true /* expectingCompilerErrors */, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " throw t;\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable t may be null at this location\n" + >+ "----------\n" /* expectedCompilerLog */, >+ "" /* expectedOutputString */, >+ false /* forceExecution */, >+ null /* classLib */, >+ true /* shouldFlushOutputDirectory */, >+ null /* vmArguments */, >+ null /* customOptions */, >+ null /* clientRequestor */, >+ true /* skipJavac */); >+} >+ >+ >+// null analysis - throw >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201182 >+// variant - unknown >+public void test0597_throw() { >+ runTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void foo() throws Throwable {\n" + >+ " throw t();\n" + >+ " }\n" + >+ " Throwable t() {\n" + >+ " return new Throwable();\n" + >+ " }\n" + >+ "}\n" >+ }, >+ false /* expectingCompilerErrors */, >+ "" /* expectedCompilerLog */, >+ "" /* expectedOutputString */, >+ false /* forceExecution */, >+ null /* classLib */, >+ true /* shouldFlushOutputDirectory */, >+ null /* vmArguments */, >+ null /* customOptions */, >+ null /* clientRequestor */, >+ true /* skipJavac */); >+} >+ > // null analysis -- do while > public void test0601_do_while() { > this.runNegativeTest(
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 201182
: 77975