Eclipse bug? Switching on a null with only default case

前端 未结 3 1792
离开以前
离开以前 2021-01-01 09:45

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):

3条回答
  •  迷失自我
    2021-01-01 10:33

    Yep. According to the JLS it's a bug:

    If the switch expression is of a reference type, such as a boxed primitive type or an enum, a run-time error will occur if the expression evaluates to null at run-time.

提交回复
热议问题