Name: inR10064 Date: 06/12/2000
Javac (build 1.3.0-C (fcs)) compiles the source icls02001.java (see below)
without complains but classfile for inner class IC of anonymous class overwrites
classfile for local class IC. So execution of example fails with the message :
___ java -showversion -cp clss icls02001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
Exception in thread "main" java.lang.NoSuchMethodError
at icls02001.get(icls02001.java:18)
at icls02001.main(icls02001.java:4)
Local class IC obtains full name icls02001$1$IC and the same name
is constructed for second class IC because its outer class is anonymous
and it in turn gets the name icls02001$1.
Oldjavac and compilers in previous jdk report errors on this valid source
( see #4196251, closed now ).
___ oldjavac -J-showversion -d clss icls02001.java
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
icls02001.java:23: Class icls02001. 1.IC already defined in icls02001.java.
class IC {
^
icls02001.java:18: No enclosing instance of local class icls02001. 1 is in scope; an explicit one must be provided when creating inner class icls02001. 1.IC, as in "outer. new Inner()" or "outer. super()".
return new IC();
^
icls02001.java:18: Incompatible type for constructor. Can't convert icls02001 to icls02001.1.
return new IC();
^
3 errors
New JCK (Tweety) test
lang/ICLS/icls020/icls02001/icls02001.html
written after #4196251 will be excluded with the number of reported bug.
Note that icls02001.java doesn't contain names with '$' char so this case
differs from the matter of #4302890 (Synopsis: declared/synthetic class
name conflict undetected).
--------------------------------------=== icls02001.java
public class icls02001 {
public static void main(String argv[]) {
Object ref = new icls02001().get();
System.out.println("ref = " + ref);
System.out.println("stRef = " + stRef);
}
String loc = "local class";
Object get() {
class IC {
public String toString() {
return loc;
}
}
return new IC();
}
static Object stRef = new Object() {
String inr;
class IC {
public String toString() {
return inr;
}
}
public String toString() {
inr = "local class";
return "anonymous with " + new IC();
}
};
}
--------------------------------------===
======================================================================
- duplicates
-
JDK-4302890 declared/synthetic class name conflict undetected
-
- Resolved
-
- relates to
-
JDK-4196251 incorrect (?) handling of inner classes
-
- Closed
-