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

Javac generates corrupt bytecode if redundant cast included in source.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • tools
    • x86
    • windows_2000


      ###@###.### 2004-04-22

      J2SE Version (please include all output from java -version flag):
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b46)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b46, mixed mode)


      Does this problem occur on J2SE 1.4 or 1.4.1 or 1.4.2? Yes / No (pick one)
      No


      Operating System Configuration Information (be specific):
      Windows 2000 sp2


      Hardware Configuration Information (be specific):
      Pentium 4 3GHz with 1GB RAM


      Bug Description:
      Javac generates corrupt bytecode if redundant cast included in source.


      Steps to Reproduce (be specific):

      1) Compile the following source using the options.

      //////////////////////////////////////////////////
      public class TestCase0 {
         public static void main(String args[]) throws Exception {
            doIt();
            System.out.println("Terminated normally");
         }
         public static void doIt() {
            Holder<Integer> association = new Holder<Integer>(new Integer(0));
            Integer sizeHolder = (Integer)(association.getValue()); //Cast to Integer is redundant!!!
            System.out.println(sizeHolder.intValue());
         }
         static class Holder<V> {
            V value;
            Holder(V value) {
               this.value = value;
            }
            V getValue() {
               return value;
            }
         }
      }
      //////////////////////////////////////////////////

      2) Execute the class TestCase0

      java TestCase0

      3) You get the following VerifyError

      Exception in thread "main" java.lang.VerifyError: (class: TestCase0, method:
      doIt signature: ()V) Incompatible object argument for function call

      If the redundant cast to Integer is removed then there is no problem.




            gafter Neal Gafter (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: