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

False detection of duplicate local class declaration

XMLWordPrintable

    • mantis
    • generic, x86
    • solaris_8, windows_98
    • Verified



      Name: ddT132432 Date: 12/18/2001


      FULL PRODUCT VERSION :
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed
      mode)


      FULL OPERATING SYSTEM VERSION :
      Windows 98 [Version 4.10.1998]

      ADDITIONAL OPERATING SYSTEMS :
      All OS's - the problem is platform independent


      A DESCRIPTION OF THE PROBLEM :
      The javac compiler mistakenly reports a duplicate class
      declaration in the example below, when a member class
      inside an anonymous class shadows the declaration of a
      local class by the same name. According to JLS 14.3, the
      shadowing is legal since the two classes of the same simple
      name are declared in different innermost enclosing classes.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. compile the program listed below


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected: The compiler should complete without error.

      Actual: Compilation fails:
      Foo.java:5: duplicate class: Local
              class Local {}
              ^
      1 error


      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Foo {
        void foo() {
          class Local {} // local class
          new Object() {
            class Local {} // member class
          };
        }
      }

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

      CUSTOMER WORKAROUND :
      Do not attempt to reuse names, even though it is legal.
      (Review ID: 137418)
      ======================================================================

            gafter Neal Gafter (Inactive)
            ddressersunw Daniel Dresser (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: