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

java compiler generates inaccurate LineNumberTable attribute

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      hopper
    • CPU:
      sparc
    • OS:
      solaris_7

      Description

      1-14


      ======================================================================


      Name: dkC59003 Date: 01/13/2000



      See below the java source code with line numbers and the corresponding
      class files compiled by the JDK 1.3.OR and JDK 1.2.2 compilers.

      This is the LineNumberTable for the <clinit> method compiled
      by the JDK 1.3.OR compiler:

                    [] { // LineNumberTable
                      0 23;
                      5 24;
                      16 27;
                      25 21;
      The last line is questionable: the code index value 25
      corresponds to the return instruction (byte code B1)
      but the line number indicates the first line of this method.
      This LineNumberTable item differs from the one for
      the test_method() method:

                    [] { // LineNumberTable
                      0 11;
                      2 12;
                      10 13;
      where the line number (13) looks right.



      This is the LineNumberTable for the <clinit> method compiled
      by the JDK 1.2.2 compiler:

                    [] { // LineNumberTable
                      0 22;
                      0 23;
                      5 24;
                      13 22;
                      16 26;
                      17 27;
                      25 1;
      The LineNumberTable items in the fourth and in the last lines
      look invalid.

      The last line in the LineNumberTable for the test_method() method
      compiled by the JDK 1.2.2 compiler:
                    [] { // LineNumberTable
                      0 11;
                      2 12;
                      10 10;
      looks invalid too.


      ------------------------- java source --------------------------
       1 public class b4301835 {
       2
       3 public static int run(String argv[], java.io.PrintStream out) {
       4 if ( checkLineNumberTable() == -1 ) {
       5 return 2/*STATUS_FAILED*/;
       6 }
       7 return 0/*STATUS_PASSED*/;
       8 }
       9
      10 static void test_method() {
      11 int localInt = 3;
      12 System.out.println("----> b4301835: test_method is running");
      13 }
      14
      15 public static void main(String argv[]) {
      16 System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
      17 }
      18
      19 native static int checkLineNumberTable();
      20
      21 static {
      22 try {
      23 System.loadLibrary("b4301835");
      24 System.out.println("----> loadLibrary(\"b4301835\") - COMPLETED");
      25 }
      26 catch (UnsatisfiedLinkError ule) {
      27 System.out.println("----> Could not load b4301835 library");
      28 }
      29 }
      30
      31 } // end of b4301835 class
      ------------------------- java source end --------------------------

      -------------- class file compiled by JDK 1.3.0R compiler ----------
      class b4301835 {
        0xCAFEBABE;
        3; // minor version
        45; // version
        [] { // Constant Pool
          ; // first element is empty
          Method #14 #29; // #1
          Method #13 #30; // #2
          Field #31 #32; // #3
          String #33; // #4
          Method #34 #35; // #5
          Method #13 #36; // #6
          Method #31 #37; // #7
          String #38; // #8
          Method #31 #39; // #9
          String #40; // #10
          class #41; // #11
          String #42; // #12
          class #38; // #13
          class #43; // #14
          Utf8 "<init>"; // #15
          Utf8 "()V"; // #16
          Utf8 "Code"; // #17
          Utf8 "LineNumberTable"; // #18
          Utf8 "run"; // #19
          Utf8 "([Ljava/lang/String;Ljava/io/PrintStream;)I"; // #20
          Utf8 "test_method"; // #21
          Utf8 "main"; // #22
          Utf8 "([Ljava/lang/String;)V"; // #23
          Utf8 "checkLineNumberTable"; // #24
          Utf8 "()I"; // #25
          Utf8 "<clinit>"; // #26
          Utf8 "SourceFile"; // #27
          Utf8 "b4301835.java"; // #28
          NameAndType #15 #16; // #29
          NameAndType #24 #25; // #30
          class #44; // #31
          NameAndType #45 #46; // #32
          Utf8 "----> b4301835: test_method is running"; // #33
          class #47; // #34
          NameAndType #48 #49; // #35
          NameAndType #19 #20; // #36
          NameAndType #50 #51; // #37
          Utf8 "b4301835"; // #38
          NameAndType #52 #49; // #39
          Utf8 "----> loadLibrary(\"b4301835\") - COMPLETED"; // #40
          Utf8 "java/lang/UnsatisfiedLinkError"; // #41
          Utf8 "----> Could not load b4301835 library"; // #42
          Utf8 "java/lang/Object"; // #43
          Utf8 "java/lang/System"; // #44
          Utf8 "out"; // #45
          Utf8 "Ljava/io/PrintStream;"; // #46
          Utf8 "java/io/PrintStream"; // #47
          Utf8 "println"; // #48
          Utf8 "(Ljava/lang/String;)V"; // #49
          Utf8 "exit"; // #50
          Utf8 "(I)V"; // #51
          Utf8 "loadLibrary"; // #52
        } // Constant Pool

        0x0021; // access
        #13;// this_cpx
        #14;// super_cpx

        [] { // Interfaces
        } // Interfaces

        [] { // fields
        } // fields

        [] { // methods
          { // Member
            0x0001; // access
            #15; // name_cpx
            #16; // sig_cpx
            [] { // Attributes
              Attr(#17) { // Code
                1; // max_stack
                1; // max_locals
                Bytes[] {
                  0x2AB70001B1;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#18) { // LineNumberTable
                    [] { // LineNumberTable
                      0 1;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0009; // access
            #19; // name_cpx
            #20; // sig_cpx
            [] { // Attributes
              Attr(#17) { // Code
                2; // max_stack
                2; // max_locals
                Bytes[] {
                  0xB8000202A0000505;
                  0xAC03AC;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#18) { // LineNumberTable
                    [] { // LineNumberTable
                      0 4;
                      7 5;
                      9 7;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0008; // access
            #21; // name_cpx
            #16; // sig_cpx
            [] { // Attributes
              Attr(#17) { // Code
                2; // max_stack
                1; // max_locals
                Bytes[] {
                  0x063BB200031204B6;
                  0x0005B1;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#18) { // LineNumberTable
                    [] { // LineNumberTable
                      0 11;
                      2 12;
                      10 13;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0009; // access
            #22; // name_cpx
            #23; // sig_cpx
            [] { // Attributes
              Attr(#17) { // Code
                2; // max_stack
                1; // max_locals
                Bytes[] {
                  0x2AB20003B8000610;
                  0x5F60B80007B1;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#18) { // LineNumberTable
                    [] { // LineNumberTable
                      0 16;
                      13 17;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0108; // access
            #24; // name_cpx
            #25; // sig_cpx
            [] { // Attributes
            } // Attributes
          } // Member
          ;
          { // Member
            0x0008; // access
            #26; // name_cpx
            #16; // sig_cpx
            [] { // Attributes
              Attr(#17) { // Code
                2; // max_stack
                1; // max_locals
                Bytes[] {
                  0x1208B80009B20003;
                  0x120AB60005A7000C;
                  0x4BB20003120CB600;
                  0x05B1;
                };
                [] { // Traps
                  0 13 16 11;
                } // end Traps
                [] { // Attributes
                  Attr(#18) { // LineNumberTable
                    [] { // LineNumberTable
                      0 23;
                      5 24;
                      16 27;
                      25 21;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
        } // methods

        [] { // Attributes
          Attr(#27) { // SourceFile
            #28;
          } // end SourceFile
        } // Attributes
      } // end class b4301835

      --------------------------------------------------------------------

      -------------- class file compiled by JDK 1.2.2 compiler ----------
      class b4301835 {
        0xCAFEBABE;
        3; // minor version
        45; // version
        [] { // Constant Pool
          ; // first element is empty
          String #30; // #1
          String #31; // #2
          String #32; // #3
          String #39; // #4
          class #39; // #5
          class #43; // #6
          class #44; // #7
          class #45; // #8
          class #46; // #9
          Method #7 #17; // #10
          Method #5 #18; // #11
          Method #8 #19; // #12
          Method #8 #20; // #13
          Field #8 #21; // #14
          Method #6 #22; // #15
          Method #5 #23; // #16
          NameAndType #34 #25; // #17
          NameAndType #41 #24; // #18
          NameAndType #42 #26; // #19
          NameAndType #47 #27; // #20
          NameAndType #49 #37; // #21
          NameAndType #50 #27; // #22
          NameAndType #51 #29; // #23
          Utf8 "()I"; // #24
          Utf8 "()V"; // #25
          Utf8 "(I)V"; // #26
          Utf8 "(Ljava/lang/String;)V"; // #27
          Utf8 "([Ljava/lang/String;)V"; // #28
          Utf8 "([Ljava/lang/String;Ljava/io/PrintStream;)I"; // #29
          Utf8 "----> Could not load b4301835 library"; // #30
          Utf8 "----> b4301835: test_method is running"; // #31
          Utf8 "----> loadLibrary(\"b4301835\") - COMPLETED"; // #32
          Utf8 "<clinit>"; // #33
          Utf8 "<init>"; // #34
          Utf8 "Code"; // #35
          Utf8 "LineNumberTable"; // #36
          Utf8 "Ljava/io/PrintStream;"; // #37
          Utf8 "SourceFile"; // #38
          Utf8 "b4301835"; // #39
          Utf8 "b4301835.java"; // #40
          Utf8 "checkLineNumberTable"; // #41
          Utf8 "exit"; // #42
          Utf8 "java/io/PrintStream"; // #43
          Utf8 "java/lang/Object"; // #44
          Utf8 "java/lang/System"; // #45
          Utf8 "java/lang/UnsatisfiedLinkError"; // #46
          Utf8 "loadLibrary"; // #47
          Utf8 "main"; // #48
          Utf8 "out"; // #49
          Utf8 "println"; // #50
          Utf8 "run"; // #51
          Utf8 "test_method"; // #52
        } // Constant Pool

        0x0021; // access
        #5;// this_cpx
        #7;// super_cpx

        [] { // Interfaces
        } // Interfaces

        [] { // fields
        } // fields

        [] { // methods
          { // Member
            0x0008; // access
            #33; // name_cpx
            #25; // sig_cpx
            [] { // Attributes
              Attr(#35) { // Code
                2; // max_stack
                0; // max_locals
                Bytes[] {
                  0x1204B8000DB2000E;
                  0x1203B6000FA7000C;
                  0x57B2000E1201B600;
                  0x0FB1;
                };
                [] { // Traps
                  0 13 16 9;
                } // end Traps
                [] { // Attributes
                  Attr(#36) { // LineNumberTable
                    [] { // LineNumberTable
                      0 22;
                      0 23;
                      5 24;
                      13 22;
                      16 26;
                      17 27;
                      25 1;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0001; // access
            #34; // name_cpx
            #25; // sig_cpx
            [] { // Attributes
              Attr(#35) { // Code
                1; // max_stack
                1; // max_locals
                Bytes[] {
                  0x2AB7000AB1;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#36) { // LineNumberTable
                    [] { // LineNumberTable
                      0 1;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0108; // access
            #41; // name_cpx
            #24; // sig_cpx
            [] { // Attributes
            } // Attributes
          } // Member
          ;
          { // Member
            0x0009; // access
            #48; // name_cpx
            #28; // sig_cpx
            [] { // Attributes
              Attr(#35) { // Code
                2; // max_stack
                1; // max_locals
                Bytes[] {
                  0x2AB2000EB8001010;
                  0x5F60B8000CB1;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#36) { // LineNumberTable
                    [] { // LineNumberTable
                      0 16;
                      13 15;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0009; // access
            #51; // name_cpx
            #29; // sig_cpx
            [] { // Attributes
              Attr(#35) { // Code
                2; // max_stack
                2; // max_locals
                Bytes[] {
                  0xB8000B02A0000505;
                  0xAC03AC;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#36) { // LineNumberTable
                    [] { // LineNumberTable
                      0 4;
                      7 5;
                      9 7;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
          ;
          { // Member
            0x0008; // access
            #52; // name_cpx
            #25; // sig_cpx
            [] { // Attributes
              Attr(#35) { // Code
                2; // max_stack
                1; // max_locals
                Bytes[] {
                  0x063BB2000E1202B6;
                  0x000FB1;
                };
                [] { // Traps
                } // end Traps
                [] { // Attributes
                  Attr(#36) { // LineNumberTable
                    [] { // LineNumberTable
                      0 11;
                      2 12;
                      10 10;
                    }
                  } // end LineNumberTable
                } // Attributes
              } // end Code
            } // Attributes
          } // Member
        } // methods

        [] { // Attributes
          Attr(#38) { // SourceFile
            #40;
          } // end SourceFile
        } // Attributes
      } // end class b4301835
      --------------------------------------------------------------------


      ======================================================================

      Name: dkC59003 Date: 01/14/2000



      Addition:

      The LineNumberTable items for the <clinit> method compiled
      by the JDK 1.2.2 compiler:

                      16 26;
                      17 27;
      look more preferable than the item for the <clinit> method
      compiled by the JDK 1.3.OR compiler:

                      16 27;

      The code index value 16 corresponds to the beginning of the catch block
      and the corresponding source line is

      26 catch (UnsatisfiedLinkError ule) {

      The code index value 17 corresponds to the beginning of the println(...)
      method call and the corresponding source line is

      27 System.out.println("----> Could not load b4301835 library");


      ###@###.### 2000-0

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gafter Neal Gafter
              Reporter:
              dkhukhrosunw Dmitry Khukhro (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: