Eclipse bug? Switching on a null with only default case
Posted
by polygenelubricants
on Stack Overflow
See other posts from Stack Overflow
or by polygenelubricants
Published on 2010-05-28T05:42:45Z
Indexed on
2010/05/28
6:01 UTC
Read the original article
Hit count: 171
I was experimenting with enum
, and I found that the following compiles and runs fine on Eclipse (Build id: 20090920-1017, not sure exact compiler version):
public class SwitchingOnAnull {
enum X { ,; }
public static void main(String[] args) {
X x = null;
switch(x) {
default: System.out.println("Hello world!");
}
}
}
When compiled and run with Eclipse, this prints "Hello world!"
and exits normally.
With the javac
compiler, this throws a NullPointerException
as expected.
So is there a bug in Eclipse Java compiler?
© Stack Overflow or respective owner