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

Incorrect line numbers for generated default constructor

XMLWordPrintable

    • x86
    • windows_xp

      Name: rmT116609 Date: 06/10/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
      Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The bytecode of a class that contains only an main() method and an inner class (with no methods itself) contains incorrect information for the implicit default constructor for outer class.

      The first entry in the LineNumberTable for the constructor, X() in the test case, is the first line of the definition of the class X, since the constructor is implicit. The next entry is the source line number for first line of the on the inner class InnerX. This is incorrect. The default constructor of X never references InnerX, so it should not have that source line number in it's table. The pc is correct, pointing to the method return of X's constructor.

      If an explicit constructor for X is added, the second entry in the LineNumberTable for the consturctor correctly points to the source line that contains the closing bracket.

      This defect has been tested on multiple versions of the compiler, but does not occur under 1.3.1_05.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile source for class X.
      2. Run javap -c -l -s on class X.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The entry in the LineNumberTable that contains the instruction for the return of the constructor method should point to source line number 6.
      ACTUAL -
      C:\>javap -c -l -s -verbose -classpath . com.foo.test.X

      Compiled from X.java
      public class com.foo.test.X extends java.lang.Object {
          public com.foo.test.X();
              /* ()V */
              /* Stack=1, Locals=1, Args_size=1 */
          public static void main(java.lang.String[]);
              /* ([Ljava/lang/String;)V */
              /* Stack=0, Locals=1, Args_size=1 */
          public class com.foo.test.X. InnerX extends java.lang.Object
          /* ACC_SUPER bit NOT set */
      {
              public com.foo.test.X.InnerX(com.foo.test.X);
              /* (Lcom/foo/test/X;)V */
              /* Stack=2, Locals=2, Args_size=2 */
          }

      Method com.foo.test.X. InnerX(com.foo.test.X)
         0 aload_0
         1 invokespecial #1 <Method java.lang.Object()>
         4 aload_0
         5 aload_1
         6 putfield #2 <Field com.foo.test.X this$0>
         9 return

      Line numbers for method com.foo.test.X. InnerX(com.foo.test.X)
         line 8: 0
      }

      Method com.foo.test.X()
         0 aload_0
         1 invokespecial #1 <Method java.lang.Object()>
         4 return

      Line numbers for method com.foo.test.X()
         line 3: 0
         line 8: 4

      Method void main(java.lang.String[])
         0 return

      Line numbers for method void main(java.lang.String[])
         line 6: 0


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.foo.test;

      public class X {

      public static void main(String[] args) {
      }

      public class InnerX{
      }
      }
      ---------- END SOURCE ----------
      (Incident Review ID: 276334)
      ======================================================================

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: