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

Anonymous class is generated when instantiating private inner class

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 6, 7, 8, 9
    • tools
    • x86_64
    • linux_ubuntu

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux dmitry-m-d 3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      When compiling class that contains private inner class without explicitly defined constructor, compiler treats creation of instances of the inner class as creation of anonymous class.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile attached source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      2 class files - A.class and A$B.class
      ACTUAL -
      3 class files - A.class, A$B.class and excessive A$1.class

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package p;

      class A {
          void test() {
              new B();
          }

          private class B {
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Adding empty default constructor suppresses issue.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: