FULL PRODUCT VERSION : java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows XP [Version 5.1.2600] A DESCRIPTION OF THE PROBLEM : When i execute following code i get a NullPointerException. import java.util.*; public class Main { public static void main(String[] args) throws Exception { Object hashInputRule = new Object(); Byte l = null; Byte rule = ((hashInputRule == null) ? ((byte) 0) : l); } } If change this line Byte rule = ((hashInputRule == null) ? ((byte) 0) : l); to Byte rule = ((hashInputRule == null) ? ((byte) 0) : null); NPE doesn't apper. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : D:\temp\java_bug>java -version java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing) D:\temp\java_bug>javac Main.java D:\temp\java_bug>java Main Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:8) EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - I expect that NPE doesn't apper. ACTUAL - Actually i get NPE. ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:8) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.util.*; public class Main { public static void main(String[] args) throws Exception { Object hashInputRule = new Object(); Byte l = null; Byte rule = ((hashInputRule == null) ? ((byte) 0) : l); } } ---------- END SOURCE ----------
|