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

declared/synthetic class name conflict undetected

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.3.0
    • Fix Version/s: 1.3.1
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      ladybird
    • CPU:
      generic, sparc
    • OS:
      generic, solaris_7

      Backports

        Description

        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

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                gafter Neal Gafter
                Reporter:
                iris Iris Clark
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: