L
Lee Fesperman
Sun's 1.4 javac gave me a "variable might not have been initialized" error on the code
below ... when it shouldn't have.
I don't have 1.5 installed. Could someone try it on 1.5 for me?
Code:
public class Test120
{
public static void main(String[] args)
{
boolean retain ;
long physicalId ;
String ref ;
if (retain = (physicalId = 1) > 0 &&
(ref = String.valueOf(physicalId)) != null)
System.out.println(ref) ;
}
}
1.4 javac output:
Test120.java:10: variable ref might not have been initialized
System.out.println(ref) ;
^
1 error
If Test120 works on 1.5, try this one:
public class Test121
{
public static void main(String[] args)
{
Long id ;
boolean retain ;
long physicalId ;
String ref ;
if (retain = (id = new Long(1)) != null &&
(physicalId = id.longValue()) > 0 &&
(ref = String.valueOf(physicalId)) != null)
System.out.println(ref) ;
}
}
Lastly, this one works on 1.4 but not 1.2, so Sun seems to be making progress in this
area:
public class Test122
{
public static void main(String[] args)
{
boolean retain ;
String ref ;
if (retain = 1 > 0 && (ref = System.getProperty("user.home")) != null)
System.out.println(ref) ;
}
}
Thanks.
below ... when it shouldn't have.
I don't have 1.5 installed. Could someone try it on 1.5 for me?
Code:
public class Test120
{
public static void main(String[] args)
{
boolean retain ;
long physicalId ;
String ref ;
if (retain = (physicalId = 1) > 0 &&
(ref = String.valueOf(physicalId)) != null)
System.out.println(ref) ;
}
}
1.4 javac output:
Test120.java:10: variable ref might not have been initialized
System.out.println(ref) ;
^
1 error
If Test120 works on 1.5, try this one:
public class Test121
{
public static void main(String[] args)
{
Long id ;
boolean retain ;
long physicalId ;
String ref ;
if (retain = (id = new Long(1)) != null &&
(physicalId = id.longValue()) > 0 &&
(ref = String.valueOf(physicalId)) != null)
System.out.println(ref) ;
}
}
Lastly, this one works on 1.4 but not 1.2, so Sun seems to be making progress in this
area:
public class Test122
{
public static void main(String[] args)
{
boolean retain ;
String ref ;
if (retain = 1 > 0 && (ref = System.getProperty("user.home")) != null)
System.out.println(ref) ;
}
}
Thanks.