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

javac generates inner class that can't be verified

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b77
    • CPU:
      unknown
    • OS:
      generic
    • Verification:
      Verified

      Description

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

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

      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() {
              @Override
              public void run() { // the code of this method is not generated
                System.out.println();
              }
            }.run();
          }
        }
      }

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

        public void run();
      }

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                mcimadamore Maurizio Cimadamore
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: