Generated constructor returns from line number of other method

Eirik Bjørsnøs eirbjo at
Tue Oct 21 22:19:31 UTC 2014


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).

I could only make this happen by having my consider method switc on an
enum. If I remove the switch or switch on something different, like an int,
the constructor is generated with a single line and returns at line 1 as

Could this be a javac bug? Or is there something I'm just completely

$ javac
$ javap -c -l -classpath . WeirdConstructorLinenumber
Compiled from ""
public class WeirdConstructorLinenumber {
  public WeirdConstructorLinenumber();
       0: aload_0
       1: invokespecial #1                  // Method
       4: return
      line 1: 0
      line 4: 4


Eirik Bjørsnøs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list