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 53625 Details for
Bug 162918
[compiler] Illegal usage of a local inside a switch statement is not rejected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fix plus test cases - option 1
org.eclipse.jdt.core_01.txt (text/plain), 6.08 KB, created by
Maxime Daniel
on 2006-11-10 10:08:28 EST
(
hide
)
Description:
Fix plus test cases - option 1
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2006-11-10 10:08:28 EST
Size:
6.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.58 >diff -u -r1.58 UnconditionalFlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 26 Sep 2006 12:04:03 -0000 1.58 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 10 Nov 2006 15:04:13 -0000 >@@ -696,10 +696,6 @@ > if ((this.tagBits & UNREACHABLE) != 0) { > return true; > } >- // final constants are inlined, and thus considered as always initialized >- if (local.constant() != Constant.NotAConstant) { >- return true; >- } > return isDefinitelyAssigned(local.id + this.maxFieldCount); > } > >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.91 >diff -u -r1.91 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 13 Oct 2006 19:20:46 -0000 1.91 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 10 Nov 2006 15:04:12 -0000 >@@ -160,7 +160,10 @@ > break; > case Binding.LOCAL : // reading a local variable > LocalVariableBinding localBinding; >- if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) binding)) { >+ if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) binding) && >+ !(localBinding.constant() != Constant.NotAConstant && >+ currentScope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_3)) { >+ // up to JDK 1.3 included, final constants are inlined, and thus considered as always initialized > currentScope.problemReporter().uninitializedLocalVariable(localBinding, this); > } > if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java,v >retrieving revision 1.16 >diff -u -r1.16 FlowAnalysisTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 9 Nov 2006 11:07:10 -0000 1.16 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 10 Nov 2006 15:04:15 -0000 >@@ -1032,24 +1032,43 @@ > ""); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=162918 >-public void _test034() { >- this.runNegativeTest( >- new String[] { >- "X.java", >- "public class X {\n" + >- " void foo1() {\n" + >- " switch (1) {\n" + >- " case 0:\n" + >- " final int i = 1;\n" + >- " case i: // should complain: i not initialized\n" + >- " System.out.println(i); // should complain: i not initialized\n" + >- " }\n" + >- " }\n" + >- "}", >- }, >- "----------\n" + >- "2 ERRORS" + >- "----------\n"); >+public void test034() { >+ String src = >+ "public class X {\n" + >+ " void foo1() {\n" + >+ " switch (1) {\n" + >+ " case 0:\n" + >+ " final int i = 1;\n" + >+ " case i: // should complain: i not initialized\n" + >+ " System.out.println(i); // should complain: i not initialized\n" + >+ " }\n" + >+ " }\n" + >+ "}"; >+ if (complianceLevel.compareTo(COMPLIANCE_1_3) <= 0) { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ src >+ }, >+ ""); >+ } else { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ src >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " case i: // should complain: i not initialized\n" + >+ " ^\n" + >+ "The local variable i may not have been initialized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " System.out.println(i); // should complain: i not initialized\n" + >+ " ^\n" + >+ "The local variable i may not have been initialized\n" + >+ "----------\n"); >+ } > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=162918 > // variant >@@ -1076,30 +1095,42 @@ > "----------\n"); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=162918 >-// variant >-public void _test036() { >- this.runNegativeTest( >- new String[] { >- "X.java", >- "public class X {\n" + >- " void foo3() {\n" + >- " switch (1) {\n" + >- " case 0:\n" + >- " class Local {\n" + >- " }\n" + >- " ;\n" + >- " case 1:\n" + >- " new Local(); // should complain: Local undefined\n" + >- " }\n" + >- " }\n" + >- "}", >- }, >- "----------\n" + >- "1. ERROR in X.java (at line 9)\n" + >- " new Local(); // should complain: Local undefined\n" + >- " ^^^^^\n" + >- "Local cannot be resolved to a type\n" + >- "----------\n"); >+// variant - not a flow analysis issue per se, contrast with 34 and 35 above >+public void test036() { >+ String src = >+ "public class X {\n" + >+ " void foo3() {\n" + >+ " switch (1) {\n" + >+ " case 0:\n" + >+ " class Local {\n" + >+ " }\n" + >+ " ;\n" + >+ " case 1:\n" + >+ " new Local();\n" + // complain for compliance >= 1.4 >+ " }\n" + >+ " }\n" + >+ "}"; >+ if (complianceLevel.compareTo(COMPLIANCE_1_3) <= 0) { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ src >+ }, >+ "" >+ ); >+ } else { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ src >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " new Local();\n" + >+ " ^^^^^\n" + >+ "Local cannot be resolved to a type\n" + >+ "----------\n"); >+ } > } > public static Class testClass() { > return FlowAnalysisTest.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 162918
:
53625
|
53626