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 181440 Details for
Bug 328361
[1.4][compiler] variable initialized within an assert expression are no longer reported as potential non initialized
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v1.0 + regression tests
patch328361.txt (text/plain), 5.82 KB, created by
Ayushman Jain
on 2010-10-21 15:29:23 EDT
(
hide
)
Description:
proposed fix v1.0 + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-10-21 15:29:23 EDT
Size:
5.82 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.65 >diff -u -r1.65 AssertStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 29 Sep 2010 16:43:28 -0000 1.65 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 21 Oct 2010 19:17:40 -0000 >@@ -86,7 +86,7 @@ > CompilerOptions compilerOptions = currentScope.compilerOptions(); > if (!compilerOptions.includeNullInfoFromAsserts) { > // keep just the initializations info, don't include assert's null info >- return flowInfo.addInitializationsFrom(assertInfo.nullInfoLessUnconditionalCopy()); >+ return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()); > } > return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()). > addInitializationsFrom(assertWhenTrueInfo.discardInitializationInfo()); >#P org.eclipse.jdt.core.tests >Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java,v >retrieving revision 1.128 >diff -u -r1.128 InitializationTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 27 May 2010 14:12:25 -0000 1.128 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 21 Oct 2010 19:17:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 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 >@@ -15,7 +15,7 @@ > import java.util.Map; > > import org.eclipse.jdt.core.ToolFactory; >-import org.eclipse.jdt.core.tests.compiler.regression.*; >+import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest; > import org.eclipse.jdt.core.tests.util.Util; > import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >@@ -6253,6 +6253,110 @@ > }, > ""); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 >+public void test205() throws Exception { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " static final int i;\n" + >+ " static {\n" + >+ " assert (i = 0) == 0;\n" + >+ " System.out.println(i);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 2)\n" + >+ " static final int i;\n" + >+ " ^\n" + >+ "The blank final field i may not have been initialized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 5)\n" + >+ " System.out.println(i);\n" + >+ " ^\n" + >+ "The blank final field i may not have been initialized\n" + >+ "----------\n"); >+ } >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 >+public void test206() throws Exception { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " void method1() {\n" + >+ " int i;" + >+ " assert (i = 0) == 0;\n" + >+ " System.out.println(i);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " System.out.println(i);\n" + >+ " ^\n" + >+ "The local variable i may not have been initialized\n" + >+ "----------\n"); >+ } >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 >+public void test207() throws Exception { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public int bar() {\n" + >+ " return 1;\n" + >+ " }\n" + >+ " void method1() {\n" + >+ " int i;" + >+ " assert (i = this.bar()) == 0;\n" + >+ " System.out.println(i);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " System.out.println(i);\n" + >+ " ^\n" + >+ "The local variable i may not have been initialized\n" + >+ "----------\n"); >+ } >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=328361 >+public void test208() throws Exception { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public int bar() {\n" + >+ " return 1;\n" + >+ " }\n" + >+ " void method1() {\n" + >+ " int i;\n" + >+ " assert i++ == 0;\n" + >+ " System.out.println(i);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 7)\n" + >+ " assert i++ == 0;\n" + >+ " ^\n" + >+ "The local variable i may not have been initialized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " System.out.println(i);\n" + >+ " ^\n" + >+ "The local variable i may not have been initialized\n" + >+ "----------\n"); >+ } >+} > public static Class testClass() { > return InitializationTest.class; > }
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 328361
:
181440
|
181442
|
181445