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 80561 Details for
Bug 192875
[compiler][options][null] Set "Null pointer access" to warning by default
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix + test cases
patch.txt (text/plain), 9.77 KB, created by
Maxime Daniel
on 2007-10-17 09:50:50 EDT
(
hide
)
Description:
Fix + test cases
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2007-10-17 09:50:50 EDT
Size:
9.77 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.127 >diff -u -r1.127 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Oct 2007 07:43:33 -0000 1.127 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Oct 2007 12:57:41 -0000 >@@ -1121,7 +1121,7 @@ > " nls string literal lacking non-nls tag //$NON-NLS-<n>$\n" + > " noEffectAssign + assignment without effect\n" + > " null potential missing or redundant null check\n" + >- " nullDereference missing null check\n" + >+ " nullDereference + missing null check\n" + > " over-ann missing @Override annotation\n" + > " paramAssign assignment to a parameter\n" + > " pkgDefaultMethod + attempt to override package-default method\n" + >@@ -1265,7 +1265,7 @@ > " <option key=\"org.eclipse.jdt.core.compiler.problem.noEffectAssignment\" value=\"warning\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\n" + >- " <option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"ignore\"/>\n" + >+ " <option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"warning\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" + >@@ -5436,6 +5436,52 @@ > "", > true); > } >+// http://bugs.eclipse.org/bugs/show_bug.cgi?id=192875 >+// default in now on for nullDereference >+public void test150_null_ref_options() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void foo() {\n" + >+ " String s = null;\n" + >+ " s.toString();\n" + >+ " }\n" + >+ " // Zork z;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "X.java\"" >+ + " -proc:none -d \"" + OUTPUT_DIR + "\"", >+ "", >+ "----------\n" + >+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + >+ " s.toString();\n" + >+ " ^\n" + >+ "Null pointer access: The variable s can only be null at this location\n" + >+ "----------\n" + >+ "1 problem (1 warning)", >+ true); >+} >+// http://bugs.eclipse.org/bugs/show_bug.cgi?id=192875 >+// default in now on for nullDereference >+public void test151_null_ref_options() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void foo() {\n" + >+ " String s = null;\n" + >+ " s.toString();\n" + >+ " }\n" + >+ " // Zork z;\n" + >+ "}", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "X.java\"" >+ + " -warn:-nullDereference -proc:none -d \"" + OUTPUT_DIR + "\"", >+ "", >+ "", >+ true); >+} > public static Class testClass() { > return BatchCompilerTest.class; > } >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.72 >diff -u -r1.72 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 16 Oct 2007 10:24:50 -0000 1.72 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 17 Oct 2007 12:57:42 -0000 >@@ -77,7 +77,7 @@ > "Null pointer access: The variable o can only be null at this location\n" + > "----------\n"); > } >- >+ > // null analysis -- simple case for field > // the current design leaves fields out of the analysis altogether > public void test0002_simple_field() { >@@ -8627,10 +8627,12 @@ > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=170704 > // adding distinct options to control null checks in more detail > // default for null options is Ignore >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=192875 >+// changed default for null access to warning > public void test1050_options_all_default() { > try { > setNullRelatedOptions = false; >- this.runConformTest( >+ runTest( > new String[] { > "X.java", > "public class X {\n" + >@@ -8643,7 +8645,23 @@ > " o.toString();\n" + > " p.toString();\n" + > " }\n" + >- "}\n"}); >+ "}\n" >+ } /* testFiles */, >+ false /* expectingCompilerErrors */, >+ "----------\n" + >+ "1. WARNING in X.java (at line 8)\n" + >+ " o.toString();\n" + >+ " ^\n" + >+ "Null pointer access: The variable o can only be null at this location\n" + >+ "----------\n" /* expectedCompilerLog */, >+ "" /* expectedOutputString */, >+ false /* forceExecution */, >+ null /* classLib */, >+ true /* shouldFlushOutputDirectory */, >+ null /* vmArguments */, >+ null /* customOptions */, >+ null /* clientRequestor */, >+ false /* skipJavac */); > } > finally { > setNullRelatedOptions = true; >#P org.eclipse.jdt.core >Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v >retrieving revision 1.675 >diff -u -r1.675 messages.properties >--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 16 Oct 2007 19:37:44 -0000 1.675 >+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 17 Oct 2007 12:57:49 -0000 >@@ -256,7 +256,7 @@ > \ nls string literal lacking non-nls tag //$NON-NLS-<n>$\n\ > \ noEffectAssign + assignment without effect\n\ > \ null potential missing or redundant null check\n\ >-\ nullDereference missing null check\n\ >+\ nullDereference + missing null check\n\ > \ over-ann missing @Override annotation\n\ > \ paramAssign assignment to a parameter\n\ > \ pkgDefaultMethod + attempt to override package-default method\n\ >Index: model/org/eclipse/jdt/core/JavaCore.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v >retrieving revision 1.588 >diff -u -r1.588 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 17 Oct 2007 10:33:38 -0000 1.588 >+++ model/org/eclipse/jdt/core/JavaCore.java 17 Oct 2007 12:57:51 -0000 >@@ -2345,7 +2345,7 @@ > * > * - option id: "org.eclipse.jdt.core.compiler.problem.potentialNullReference" > * - possible values: { "error", "warning", "ignore" } >- * - default: "ignore" >+ * - default: "warning" > * > * COMPILER / Reporting Redundant Null Check > * When enabled, the compiler will issue an error or a warning whenever a >Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v >retrieving revision 1.190 >diff -u -r1.190 CompilerOptions.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 16 Oct 2007 16:40:31 -0000 1.190 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 17 Oct 2007 12:57:49 -0000 >@@ -242,7 +242,7 @@ > | UnusedPrivateMember > | UnusedLabel > | UnusedTypeArgumentsForMethodInvocation >- /*| NullReference -- keep JavaCore#getDefaultOptions comment in sync */; >+ | NullReference; > > // By default only lines and source attributes are generated. > public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES; >#P org.eclipse.jdt.core.tests.model >Index: workspace/Converter/src/test0605/X.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Converter/src/test0605/X.java,v >retrieving revision 1.1 >diff -u -r1.1 X.java >--- workspace/Converter/src/test0605/X.java 21 Apr 2005 13:07:24 -0000 1.1 >+++ workspace/Converter/src/test0605/X.java 17 Oct 2007 12:58:16 -0000 >@@ -3,7 +3,7 @@ > public class X { > > void foo() { >- int[] a= null; >+ int[] a= {1}; > int lenA= a.length; > int lenB = this.a.length; > C c = new C(); >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v >retrieving revision 1.254 >diff -u -r1.254 ASTConverter15Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 13 Sep 2007 19:19:57 -0000 1.254 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 17 Oct 2007 12:58:16 -0000 >@@ -4393,7 +4393,7 @@ > "\n" + > "class Use {\n" + > " public static void main(String[] args) {\n" + >- " X<String> i= null;\n" + >+ " X<String> i= new X<String>();\n" + > " i.foo(\"Eclipse\");\n" + > " }\n" + > "}";
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 192875
:
80232
|
80340
| 80561