Duplicate :
|
FULL PRODUCT VERSION : java version "1.6.0_02" Java(TM) SE Runtime Environment (build 1.6.0_02-b05) Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows XP [Version 5.1.2600] A DESCRIPTION OF THE PROBLEM : javap shows 2 checkcast instructions for my example Test.java compiled with JDK 6 compiler. Test.java: public class Test implements Externalizable { private Object[] centerData; public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { centerData = (Object[])in.readObject(); } 'javap -c' output for readExternal(): public void readExternal(java.io.ObjectInput) throws java.io.IOException, java.lang.ClassNotFoundException; Code: 0: aload_0 1: aload_1 2: invokeinterface #2, 1; //InterfaceMethod java/io/ObjectInput.readObject:()Ljava/lang/Object; 7: checkcast #3; //class "[Ljava/lang/Object;" 10: checkcast #3; //class "[Ljava/lang/Object;" 13: putfield #4; //Field centerData:[Ljava/lang/Object; 16: return STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : compile example Test.java run javap -c Test EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - checkcast instruction appears only once ACTUAL - checkcast instruction appears twice REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.*; public class Test implements Externalizable { private Object[] centerData; public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { centerData = (Object[])in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(centerData); } } ---------- END SOURCE ----------