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

-target 1.2 generates code rejected by 1.2 VMs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.3.0
    • tools
    • beta
    • x86
    • windows_nt
    • Verified



      Name: skT45625 Date: 11/27/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      I believe this problem is similar to bug #4285499.

      Compile the following test program using this command line:

      javac -target 1.3 -g BugTest

      Then run the program like this:

      java BugTest

      Which should cause the following output:

      java.lang.AbstractMethodError
              at BugTest.runTest(BugTest.java:13)
              at BugTest.main(BugTest.java:5)

      Now compile like this:

      javac -target 1.1 -g BugTest.java

      and rerun the program to obtain this output:

      Success

      Using the javap tool you can see that at instruction #11 there is a difference
      between the target 1.3 and target 1.1 code. I take this to indicate a code
      generation problem, but I suppose it could be a problem with the JVM if the
      instruction at #11 is really correct code.

      Code from -target 1.3:

      Method void runTest()
         0 new #5 <Class BugTest. Test>
         3 dup
         4 aload_0
         5 aconst_null
         6 invokespecial #6 <Method BugTest. Test(BugTest,BugTest$1)>
         9 astore_1
        10 aload_1
        11 invokeinterface (args 1) #7 <InterfaceMethod null>
        16 checkcast #8 <Interface BugTest. Interface2>
        19 astore_2
        20 getstatic #9 <Field java.io.PrintStream out>
        23 ldc #10 <String "Success">
        25 invokevirtual #11 <Method void println(java.lang.String)>
        28 goto 36
        31 astore_1
        32 aload_1
        33 invokevirtual #13 <Method void printStackTrace()>
        36 return

      Code from -target 1.1:

      Method void runTest()
         0 new #5 <Class BugTest. Test>
         3 dup
         4 aload_0
         5 aconst_null
         6 invokespecial #6 <Method BugTest. Test(BugTest,BugTest$1)>
         9 astore_1
        10 aload_1
        11 invokeinterface (args 1) #7 <InterfaceMethod java.lang.Object clone()>
        16 checkcast #8 <Interface BugTest. Interface2>
        19 astore_2
        20 getstatic #9 <Field java.io.PrintStream out>
        23 ldc #10 <String "Success">
        25 invokevirtual #11 <Method void println(java.lang.String)>
        28 goto 36
        31 astore_1
        32 aload_1
        33 invokevirtual #13 <Method void printStackTrace()>
        36 return

      Here is the program:
      //--------Program follows-----------------
      public class BugTest
      {
          public static void main( String[] args )
          {
              new BugTest().runTest();
          }
          
          public void runTest()
          {
              try
              {
                  Interface2 a = new Test();
                  Interface2 b = ( Interface2 )a.clone();
                  System.out.println( "Success" );
              }
              catch( Throwable xx )
              {
                  xx.printStackTrace();
              }
          }
          
          private interface Interface1
          {
              public Object clone();
          }
          
          private interface Interface2 extends Interface1
          {
          }
          
          private class Test implements Cloneable, Interface2
          {
              private int m_junk = 0;
              
              public Object clone()
              {
                  try
                  {
                      Test clone = ( Test )super.clone();
                      clone.m_junk = m_junk;
                      return( clone );
                  }
                  catch( CloneNotSupportedException xx )
                  {
                      throw new InternalError();
                  }
              }
          }
      }
      (Review ID: 112883)
      ======================================================================

            gafter Neal Gafter (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: