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

Javac allows inner classes to have the same name as an enclosing class.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.4, 1.2.0
    • tools
    • None
    • generic
    • generic

      Javac allows an inner class to have the same simple name as that of
      one of it's enclosing classes. The language specification disallows
      this situation.

      The problem was discovered in Modena tests niner069, niner070,
      and niner072. Both of the following sample source codes compile
      even though they should not.

      class X {
       static {
          class X {}
        }
      }


      class Y {
       void func() {
         class Y {}
       }
      }



      allan.jacobs@Eng 1997-11-21

      Also fails with Modena test niner130.

      class Z {
          class I {
            void f() {
               class I{}
            }
          }
      }


      allan.jacobs@Eng 1997-11-21

            wmaddoxsunw William Maddox (Inactive)
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: