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

Wrong LineNumberTable for default constructors

XMLWordPrintable

    • b37
    • Verified

        Given a class containing a method switching on an enum, like this:

        1: public class WeirdConstructorLinenumber
        2: {
        3: public void consider(java.math.RoundingMode mode) {
        4: switch ( mode ) {}
        5: }
        6: }

        javac generates a default constructor as expected.

        But the generated constructor returns from line 4 (which really belongs to the "consider" method).

        $ javac WeirdConstructorLinenumber.java
        $ javap -c -l -classpath . WeirdConstructorLinenumber
        Compiled from "WeirdConstructorLinenumber.java"
        public class WeirdConstructorLinenumber {
          public WeirdConstructorLinenumber();
            Code:
               0: aload_0
               1: invokespecial #1 // Method java/lang/Object."<init>":()V
               4: return
            LineNumberTable:
              line 1: 0
              line 4: 4

           [...]
        }

              mcimadamore Maurizio Cimadamore
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: