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 188421 Details for
Bug 332838
Bogus potential null pointer access warning (regression; works with 3.6)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v1.0 + regression tests
patch332838.txt (text/plain), 4.03 KB, created by
Ayushman Jain
on 2011-02-07 02:24:23 EST
(
hide
)
Description:
proposed fix v1.0 + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-02-07 02:24:23 EST
Size:
4.03 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java,v >retrieving revision 1.66 >diff -u -r1.66 AssertStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 22 Oct 2010 04:15:15 -0000 1.66 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 7 Feb 2011 07:21:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -86,7 +86,9 @@ > CompilerOptions compilerOptions = currentScope.compilerOptions(); > if (!compilerOptions.includeNullInfoFromAsserts) { > // keep just the initializations info, don't include assert's null info >- return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()); >+ // merge initialization info's and then add back the null info from flowInfo to >+ // make sure that the empty null info of assertInfo doesnt change flowInfo's null info. >+ return ((flowInfo.nullInfoLessUnconditionalCopy()).mergedWith(assertInfo.nullInfoLessUnconditionalCopy())).addNullInfoFrom(flowInfo); > } > return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()). > addInitializationsFrom(assertWhenTrueInfo.discardInitializationInfo()); >#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.109 >diff -u -r1.109 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 19 Jan 2011 05:29:57 -0000 1.109 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 7 Feb 2011 07:21:52 -0000 >@@ -13832,4 +13832,49 @@ > "}"}, > ""); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=332838 >+// Null info of assert statements should not affect flow info >+// when CompilerOptions.OPTION_IncludeNullInfoFromAsserts is disabled. >+public void testBug332838() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_IncludeNullInfoFromAsserts, CompilerOptions.DISABLED); >+ this.runNegativeTest( >+ new String[] { >+ "Info.java", >+ "public class Info {\n" + >+ " public void test(Info[] infos) {\n" + >+ " for (final Info info : infos) {\n " + >+ " if (info != null) {\n" + >+ " assert info.checkSomething();\n" + >+ " info.doSomething();\n" + // no warning >+ " }\n" + >+ " }\n" + >+ " for (final Info info : infos) {\n " + >+ " if (info == null) {\n" + >+ " assert info.checkSomething();\n" + >+ " info.doSomething();\n" + // warn NPE, not pot. NPE >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ " void doSomething() {}\n" + >+ " boolean checkSomething() {return true;}\n" + >+ "}\n"}, >+ "----------\n" + >+ "1. ERROR in Info.java (at line 11)\n" + >+ " assert info.checkSomething();\n" + >+ " ^^^^\n" + >+ "Null pointer access: The variable info can only be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in Info.java (at line 12)\n" + >+ " info.doSomething();\n" + >+ " ^^^^\n" + >+ "Null pointer access: The variable info can only be null at this location\n" + >+ "----------\n", >+ null, >+ true, >+ compilerOptions); >+ } >+} > } >\ 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 332838
: 188421