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

qualified new syntax is not applicable for static inner classes

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_2.5.1, solaris_2.6, windows_95, windows_nt

      Description



      Name: ouC59006 Date: 05/11/98



      JDK-1.2beta4-E fails to pass new JCK test icls05992m8.

      Inner Classes specification says:

      "A new expression may define an anonymous class by specifying its body.
      Independently, the type of a new expression may specified as the
      simple name of an inner class, if an instance of the immediately
      enclosing class is given as a qualifying expression before the keyword
      new. The qualifying instance becomes the enclosing instance of the new
      object."

      Since static (top-level) inner classes can't have enclosing instance,
      it is illegal to qualify 'new' keyword to create instance of static
      inner class.

      In concise form of the test (see source code below), compiler
      allows to qualify 'new' keyword to create instance of static
      inner class:

      > java -fullversion
      java full version "JDK1.1.6N"
      > javac a.java
      > jdk12e
      > java -fullversion
      java full version "JDK-1.2beta4-E"
      > javaÓ a.java
      >

      --------------------a.java----------------------
      class A {
      static class B {}
      A a = new A();
      A.B b = a.new B();
      }
      --------------------------------------------------------------------------------

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              wmaddoxsunw William Maddox (Inactive)
              Reporter:
              oulyankisunw Oleg Ulyankin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: