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 177820 Details for
Bug 292478
Report potentially null across variable assignment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
same fix with few modifications
patch292478.txt (text/plain), 22.64 KB, created by
Ayushman Jain
on 2010-08-31 06:06:04 EDT
(
hide
)
Description:
same fix with few modifications
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-08-31 06:06:04 EDT
Size:
22.64 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java,v >retrieving revision 1.90 >diff -u -r1.90 Assignment.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 12 Aug 2010 16:58:28 -0000 1.90 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 31 Aug 2010 08:57:45 -0000 >@@ -8,7 +8,8 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Genady Beriozkin - added support for reporting assignment with no effect >- * Stephan Herrmann - Contribution for bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE >+ * and bug 292478 - Report potentially null across variable assignment > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -59,6 +60,9 @@ > case FlowInfo.NON_NULL : > flowInfo.markAsDefinitelyNonNull(local); > break; >+ case FlowInfo.POTENTIALLY_NULL : >+ flowInfo.markAsPotentiallyNull(local); >+ break; > default: > flowInfo.markAsDefinitelyUnknown(local); > } >@@ -70,6 +74,9 @@ > case FlowInfo.NON_NULL : > flowContext.initsOnFinally.markAsDefinitelyNonNull(local); > break; >+ case FlowInfo.POTENTIALLY_NULL : >+ flowContext.initsOnFinally.markAsPotentiallyNull(local); >+ break; > default: > flowContext.initsOnFinally.markAsDefinitelyUnknown(local); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java,v >retrieving revision 1.128 >diff -u -r1.128 Expression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 7 Jan 2010 20:18:49 -0000 1.128 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 31 Aug 2010 08:57:45 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 292478 - Report potentially null across variable assignment > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -829,11 +830,11 @@ > this.bits |= ASTNode.IsNonNull; > } > >- public int nullStatus(FlowInfo flowInfo) { >+public int nullStatus(FlowInfo flowInfo) { > >- if (/* (this.bits & IsNonNull) != 0 || */ >- this.constant != null && this.constant != Constant.NotAConstant) >- return FlowInfo.NON_NULL; // constant expression cannot be null >+ if (/* (this.bits & IsNonNull) != 0 || */ >+ this.constant != null && this.constant != Constant.NotAConstant) >+ return FlowInfo.NON_NULL; // constant expression cannot be null > > LocalVariableBinding local = localVariableBinding(); > if (local != null) { >@@ -841,6 +842,8 @@ > return FlowInfo.NULL; > if (flowInfo.isDefinitelyNonNull(local)) > return FlowInfo.NON_NULL; >+ if (flowInfo.isPotentiallyNull(local)) >+ return FlowInfo.POTENTIALLY_NULL; > return FlowInfo.UNKNOWN; > } > return FlowInfo.NON_NULL; >Index: compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java,v >retrieving revision 1.72 >diff -u -r1.72 LocalDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 12 Aug 2010 16:58:28 -0000 1.72 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 31 Aug 2010 08:57:45 -0000 >@@ -7,7 +7,8 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Stephan Herrmann - Contribution for bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE >+ * and bug 292478 - Report potentially null across variable assignment > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -63,6 +64,9 @@ > case FlowInfo.NON_NULL : > flowInfo.markAsDefinitelyNonNull(this.binding); > break; >+ case FlowInfo.POTENTIALLY_NULL : >+ flowInfo.markAsPotentiallyNull(this.binding); >+ break; > default: > flowInfo.markAsDefinitelyUnknown(this.binding); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.117 >diff -u -r1.117 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 7 Apr 2010 12:47:50 -0000 1.117 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 31 Aug 2010 08:57:45 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 292478 - Report potentially null across variable assignment > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -774,6 +775,8 @@ > return FlowInfo.NULL; > if (flowInfo.isDefinitelyNonNull(local)) > return FlowInfo.NON_NULL; >+ if (flowInfo.isPotentiallyNull(local)) >+ return FlowInfo.POTENTIALLY_NULL; > return FlowInfo.UNKNOWN; > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java,v >retrieving revision 1.30 >diff -u -r1.30 ConditionalFlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java 24 Feb 2010 20:12:41 -0000 1.30 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java 31 Aug 2010 08:57:45 -0000 >@@ -157,6 +157,11 @@ > this.initsWhenFalse.markAsDefinitelyNull(local); > } > >+public void markAsPotentiallyNull(LocalVariableBinding local) { >+ this.initsWhenTrue.markAsPotentiallyNull(local); >+ this.initsWhenFalse.markAsPotentiallyNull(local); >+} >+ > public void markAsDefinitelyUnknown(LocalVariableBinding local) { > this.initsWhenTrue.markAsDefinitelyUnknown(local); > this.initsWhenFalse.markAsDefinitelyUnknown(local); >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java,v >retrieving revision 1.42 >diff -u -r1.42 FlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 21 Jul 2010 07:08:55 -0000 1.42 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 31 Aug 2010 08:57:45 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 292478 - Report potentially null across variable assignment > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.flow; > >@@ -25,6 +26,7 @@ > public final static int UNKNOWN = 0; > public final static int NULL = 1; > public final static int NON_NULL = -1; >+ public final static int POTENTIALLY_NULL = 2; > > public static final UnconditionalFlowInfo DEAD_END; // Represents a dead branch status of initialization > static { >@@ -246,6 +248,11 @@ > * Record a local got definitely assigned to null. > */ > abstract public void markAsDefinitelyNull(LocalVariableBinding local); >+ >+ /** >+ * Record a local may have got assigned to null. >+ */ >+ abstract public void markAsPotentiallyNull(LocalVariableBinding local); > > /** > * Record a local got definitely assigned. >Index: compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java,v >retrieving revision 1.66 >diff -u -r1.66 UnconditionalFlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 19 Aug 2010 10:38:46 -0000 1.66 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 31 Aug 2010 08:57:45 -0000 >@@ -7,7 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 320170 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bugs 320170 and 292478 > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.flow; > >@@ -1330,6 +1330,39 @@ > } > } > >+public void markAsPotentiallyNull(LocalVariableBinding local) { >+ if (this != DEAD_END) { >+ this.tagBits |= NULL_FLAG_MASK; >+ int position; >+ long mask; >+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) { >+ // use bits >+ this.nullBit1 &= ~(mask = 1L << position); >+ this.nullBit2 |= mask; >+ this.nullBit3 &= ~mask; >+ this.nullBit4 &= ~mask; >+ if (COVERAGE_TEST_FLAG) { >+ if(CoverageTestId == 40) { >+ this.nullBit4 = ~0; >+ } >+ } >+ } else { >+ // use extra vector >+ int vectorIndex ; >+ this.extra[2][vectorIndex = (position / BitCacheSize) - 1] >+ &= ~(mask = 1L << (position % BitCacheSize)); >+ this.extra[3][vectorIndex] |= mask; >+ this.extra[4][vectorIndex] &= (mask = ~mask); >+ this.extra[5][vectorIndex] &= mask; >+ if (COVERAGE_TEST_FLAG) { >+ if(CoverageTestId == 41) { >+ this.extra[5][vectorIndex] = ~0; >+ } >+ } >+ } >+ } >+} >+ > public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) { > if ((otherInits.tagBits & UNREACHABLE) != 0 && this != DEAD_END) { > if (COVERAGE_TEST_FLAG) { >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java,v >retrieving revision 1.10 >diff -u -r1.10 NullReferenceImplTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java 19 Aug 2010 10:38:43 -0000 1.10 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java 31 Aug 2010 08:57:50 -0000 >@@ -25,6 +25,10 @@ > import java.util.SortedMap; > import java.util.TreeMap; > >+import junit.framework.AssertionFailedError; >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ > import org.eclipse.jdt.internal.compiler.flow.FlowInfo; > import org.eclipse.jdt.internal.compiler.flow.NullInfoRegistry; > import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo; >@@ -34,10 +38,6 @@ > import org.eclipse.jdt.internal.compiler.lookup.PackageBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; > >-import junit.framework.AssertionFailedError; >-import junit.framework.Test; >-import junit.framework.TestSuite; >- > /** > * A tests series especially meant to validate the internals of our null > * reference analysis. See NullReferenceTest for tests targetted at >@@ -559,6 +559,11 @@ > assertTrue("nb of failures: " + failures, failures == 0); > } > >+public void test2058_markAsPotentiallyNull() { >+ int failures = NullReferenceImplTransformations.markAsPotentiallyNull.test(); >+ assertTrue("nb of failures: " + failures, failures == 0); >+} >+ > public void test2060_addInitializationsFrom() { > int failures = NullReferenceImplTransformations.addInitializationsFrom.test(); > assertTrue("nb of failures: " + failures, failures == 0); >@@ -854,7 +859,7 @@ > // Note: coverage tests tend to fill the console with messages, and the > // instrumented code is slower, so never release code with active > // coverage tests. >-private static int coveragePointsNb = 39; >+private static int coveragePointsNb = 41; > > // PREMATURE reactivate coverage tests > // Coverage by state transition tables methods. >@@ -870,6 +875,7 @@ > test2055_markAsDefinitelyNonNull(); > test2056_markAsDefinitelyNull(); > test2057_markAsDefinitelyUnknown(); >+ test2058_markAsPotentiallyNull(); > test2060_addInitializationsFrom(); > test2061_addPotentialInitializationsFrom(); > test2062_mergedWith(); >@@ -891,6 +897,7 @@ > test2055_markAsDefinitelyNonNull(); > test2056_markAsDefinitelyNull(); > test2057_markAsDefinitelyUnknown(); >+ test2058_markAsPotentiallyNull(); > test2060_addInitializationsFrom(); > test2061_addPotentialInitializationsFrom(); > test2062_mergedWith(); >@@ -1098,6 +1105,11 @@ > super.markAsDefinitelyUnknown(local); > } > >+public void markAsPotentiallyNull(LocalVariableBinding local) { >+ grow(local.id + this.maxFieldCount); >+ super.markAsPotentiallyNull(local); >+} >+ > /** > * Return a fake unconditional flow info which bit fields represent the given > * null bits for a local variable of id 0 within a class that would have no >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java,v >retrieving revision 1.5 >diff -u -r1.5 NullReferenceImplTransformations.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java 28 Apr 2009 17:17:34 -0000 1.5 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java 31 Aug 2010 08:57:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2009 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 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 >@@ -242,6 +242,50 @@ > return result; > } > }, >+ markAsPotentiallyNull = >+ // markAsDefinitelyNull DEFINITION START >+ // start => pot. null >+ // prot. non null => pot. null >+ // prot. null => pot. null >+ // pot. unknown => pot. null >+ // pot. non null => pot. null >+ // pot. nn & prot. nn => pot. null >+ // pot. nn & pot. un => pot. null >+ // pot. null => pot. null >+ // pot. n & prot. n => pot. null >+ // pot. n & pot. un => pot. null >+ // pot. n & pot. nn => pot. null >+ // def. unknown => pot. null >+ // def. non null => pot. null >+ // def. null => pot. null >+ // markAsPotentiallyNull DEFINITION END >+ // PREMATURE add 'catch rules' >+ new TwoDimensionalTransformation("markAsPotentiallyNull", >+ new byte[][] { >+ // markAsPotentiallyNull INITIALIZER START >+ {0x00,0x08}, >+ {0x04,0x08}, >+ {0x08,0x08}, >+ {0x0C,0x08}, >+ {0x10,0x08}, >+ {0x14,0x08}, >+ {0x18,0x08}, >+ {0x24,0x08}, >+ {0x28,0x08}, >+ {0x2C,0x08}, >+ {0x30,0x08}, >+ {0x34,0x08}, >+ {0x38,0x08}, >+ {0x3C,0x08}, >+ // markAsPotentiallyNull INITIALIZER END >+ }) { >+ UnconditionalFlowInfo output(UnconditionalFlowInfo input, >+ TestLocalVariableBinding local) { >+ UnconditionalFlowInfo result = (UnconditionalFlowInfo)input.copy(); >+ result.markAsPotentiallyNull(local); >+ return result; >+ } >+ }, > addInitializationsFrom = > // addInitializationsFrom DEFINITION START > // def. non null + def. non null => def. non null >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.99 >diff -u -r1.99 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 23 Aug 2010 08:41:32 -0000 1.99 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 31 Aug 2010 08:57:51 -0000 >@@ -7,7 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bugs 319201 and 320170 >+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bugs 292478, 319201 and 320170 > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -13021,4 +13021,136 @@ > "}"}, > "Compiler good Compiler good"); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment >+// LocalDeclaration >+public void testBug292478() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void foo(Object o) {\n" + >+ " if (o != null) {/* */}\n" + >+ " Object p = o;\n" + >+ " p.toString();\n" + // complain here >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " p.toString();\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable p may be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment >+// Assignment >+public void testBug292478a() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void foo(Object o) {\n" + >+ " Object p;" + >+ " if (o != null) {/* */}\n" + >+ " p = o;\n" + >+ " p.toString();\n" + // complain here >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " p.toString();\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable p may be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment >+// Assignment after definite null >+public void testBug292478b() { >+this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void foo(Object o) {\n" + >+ " Object p = null;\n" + >+ " if (o != null) {/* */}\n" + >+ " p = o;\n" + >+ " p.toString();\n" + // complain here >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " p.toString();\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable p may be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment >+// Assignment after definite null - many locals >+public void testBug292478c() { >+this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void foo(Object o) {\n" + >+ " int i00, i01, i02, i03, i04, i05, i06, i07, i08, i09;\n" + >+ " int i10, i11, i12, i13, i14, i15, i16, i17, i18, i19;\n" + >+ " int i20, i21, i22, i23, i24, i25, i26, i27, i28, i29;\n" + >+ " int i30, i31, i32, i33, i34, i35, i36, i37, i38, i39;\n" + >+ " int i40, i41, i42, i43, i44, i45, i46, i47, i48, i49;\n" + >+ " int i50, i51, i52, i53, i54, i55, i56, i57, i58, i59;\n" + >+ " int i60, i61, i62, i63, i64, i65, i66, i67, i68, i69;\n" + >+ " Object p = null;\n" + >+ " if (o != null) {/* */}\n" + >+ " p = o;\n" + >+ " p.toString();\n" + // complain here >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 13)\n" + >+ " p.toString();\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable p may be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment >+// Assignment affects initsOnFinally >+public void testBug292478d() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " X bar() {\n" + >+ " return null;\n" + >+ " }\n" + >+ " Object foo() {\n" + >+ " X x = null;\n" + >+ " X y = new X();\n" + >+ " X u = null;\n" + >+ " try {\n" + >+ " u = bar();\n" + >+ " x = bar();\n" + >+ " if (x==null) { }\n" + >+ " y = x;\n" + // this makes y potentially null >+ " if (x==null) { y=bar();} else { y=new X(); }\n" + >+ " return x;\n" + >+ " } finally {\n" + >+ " y.toString();\n" + // must complain against potentially null, although normal exist of tryBlock says differently (unknown or non-null) >+ " }\n" + >+ " }\n" + >+ "}\n"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 17)\n" + >+ " y.toString();\n" + >+ " ^\n" + >+ "Potential null pointer access: The variable y may 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 292478
:
174559
|
177820
|
178454
|
178458
|
178468
|
178507
|
178515
|
178528