Community
Participate
Working Groups
Build ID: M20060921-0945 Steps To Reproduce: Compile and run the following program with Eclipse: public class Playground { public static void main(String[] args) { if (false) { String string; System.out.println(string); } } } It compiles, runs, and does nothing. Try to compile the program with javac - fails with the message: Playground.java:8: variable string might not have been initialized System.out.println(string); ^ 1 error More information: I just ran an Eclipse update. Here's an excerpt from my Configuration Details: org.eclipse.jdt.apt.core_3.2.1.R32x_v20060822-2100.jar org.eclipse.jdt.apt.ui_3.2.1.R32x_v20060822-2100.jar org.eclipse.jdt.core.manipulation_1.0.1.r321_v20060721.jar org.eclipse.jdt.core_3.2.2.jar org.eclipse.jdt.debug.ui_3.2.1.r321_v20060918.jar org.eclipse.jdt.debug_3.2.1.r321_v20060731/ org.eclipse.jdt.doc.isv_3.2.1.r321_v20060907.jar org.eclipse.jdt.doc.user_3.2.0.v20060605-1400.jar org.eclipse.jdt.junit.runtime_3.2.1.r321_v20060721/ org.eclipse.jdt.junit4.runtime_1.0.1.r321_v20060905.jar org.eclipse.jdt.junit_3.2.1.r321_v20060810/ org.eclipse.jdt.launching_3.2.1.r321_v20060731.jar org.eclipse.jdt.source_3.2.1.r321_v20060905-R4CM1Znkvre9wC-/ org.eclipse.jdt.ui_3.2.1.r321_v20060907.jar org.eclipse.jdt_3.2.1.r321_v20060823.jar
Maxime - pls show me the patch once available. Feels to me like a regression.
NOTE: this code must not yield an error. We should thus distinguish based on the scope of the variable (defined within/outside fake reachable code). public class X { public static void main(String[] args) { String string; if (false) { System.out.println(string); } } }
Need to also check subscopes scenarii (where more than one level of scope is defined within fake reachable land).
Released FlowAnalysisTest#37 (inactive) and 38. All javac levels behave the same.
Created attachment 55031 [details] Suggested fix + test cases Suggested fix (under test) checks if the declaration is within reachable code. Added test cases for the final locals, for which our behavior was OK.
Released for 3.3 M4.
Maxime - pls backport to 3.2.2.
Released for 3.2.2.
Verified for 3.3M4 with I20061211-1119 by Olivier at 2006-12-11 Verified for 3.2.2 using build M20070112-1200