-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
ladybird
-
generic, sparc
-
generic, solaris_7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2031089 | 1.4.0 | Neal Gafter | P3 | Closed | Fixed | merlin |
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
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
- backported by
-
JDK-2031089 declared/synthetic class name conflict undetected
- Closed
- duplicates
-
JDK-4344812 Inner class of anonymous class overwrites local class with the same name
- Closed
- relates to
-
JDK-4030356 Source code can refer to synthetic names like "this$Foo".
- Closed