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

declared/synthetic class name conflict undetected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.3.1
    • 1.3.0
    • tools
    • ladybird
    • generic, sparc
    • generic, solaris_7

        If you declare the classes in this order:

        class HiddenFieldBug$Inner {
            int j = 2;
        }

        class HiddenFieldBug {
            class Inner {
        int i = 1;
            }
        }

        only one class file for HiddenFieldBug$Inner is generated, corresponding to the
        second declaration of HiddenFieldBug$Inner.

        If you declare the classes in the reverse order, a duplicate class declaration
        is reported.

        $ javac -verbose HiddenFieldBug.java
        HiddenFieldBug.java:11: duplicate class: HiddenFieldBug.Inner
        class HiddenFieldBug$Inner {
        ^
        1 error

        iris.garcia@eng 2000-01-05

        A similar problem ocurs in this example:

        public class Example {

          Example() {
            class Inner{}
          }

          Object anon = new Object() {
            class Inner{}
          };

        }

        The classfiles Example.class, Example$1.class, and Example$1$Inner.class
        are generated, with the latter corresponding to the inner class of the
        anonymous class Example$1. No code is generated for the inner class of
        Example itself. Reversing the order of the declarations of anon and the
        constructor Example, however, produces an additional class file Example$2$Inner.class as expected. It looks as if the name for the inner
        class of the anonymous class is chosen without checking first for an
        exisiting class.

        This example is taken from 4196251, however, this is a different issue.

        william.maddox@Eng 2000-01-13

              gafter Neal Gafter (Inactive)
              iris Iris Clark
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: