javac 7 is able to generate inner class that can't be verified

Rémi Forax forax at
Thu Jul 5 04:00:13 PDT 2012

Hi Maurizio, hi all,
there is a dubious code in javac that try to reuse existing inner class 
(or create one)
when a constructor accessor need to be generated (see 

Used in conjunction with the fact that the inner class exists but
is created in a block guarded by 'if(false)' leads to a half baked 
generated class
(no code for method run()) so the inner-class doesn't pass the verifier 

Code to reproduce:
public class EmptyClassWithFakeConstructor {
   private static class Foo {
     // need to generate an accessor method

   public static void main(String[] args) {
     new Foo();  // call the accessor

     if(false) {
       new Runnable() {
         public void run() {   // the code of this method is not generated

javap -c EmptyClassWithFakeConstructor\$1.class
Compiled from ""
final class EmptyClassWithFakeConstructor$1 implements java.lang.Runnable {

   public void run();

as you see, the method run is empty (but not abstract).


More information about the compiler-dev mailing list