Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6585476

Duplicate checkcast instruction with array types

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • tools
    • x86
    • windows_xp

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

            wtaosunw Wei Tao (Inactive)
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: