I got some weird exception when trying to compile this:
Byte b = 2;
if (b < new Integer(5)) {
...
}
Is it a valid check (unboxing-implicit cast - unboxing)?
I got some weird exception when trying to compile this:
Byte b = 2;
if (b < new Integer(5)) {
...
}
Is it a valid check (unboxing-implicit cast - unboxing)?
public class test
{
public static void main( String[] args )
{
Byte b = 2;
if( b < new Integer(5) )
{
System.out.println( "Working." );
}
}
}
Works for me. (Java 1.6.0_17).
If you're getting an Internal Compiler Error (ICE), it's a bug in the Java compiler itself, not necessarily anything wrong with your code.
Your code snippet compiles fine on a recent OpenJDK. What Java compiler are you using?
My compiler version used is: 1.6.0_16-b01 for 6.0 compliant It looks like the problem disappears if I switch to 5.0 compliant code.
If there is a bug in your compiler, here's what you do:
In general, it's not useful to post about random bugs in software products on Q&A sites.
As an aside, consider using Integer.valueOf(5)
in place of new Integer(5)
; the former is generally more efficient.