-
Bug
-
Resolution: Won't Fix
-
P4
-
1.3.0
-
x86
-
linux
Name: tb29552 Date: 03/28/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
Create a class with inner classes as in the example at the bottom of this test.
When you try to retrieve nested types of the outer class, the method
"nestedTypes()" returns not only the named inner class of the outer class but
also the anonymous inner class of the named inner class:
OuterClass.nestedTypes() = [
OuterClass$1
OuterClass$InnerClass
]
And if you try to get nested types of the named inner class, the method
"nestedTypes()" returns an empty list:
OuterClass$InnerClass.nestedTypes() = []
I think that this is caused by Javac because it produces strange .class files:
OuterClass
OuterClass$1
OuterClass$InnerClass
FastJavac produces another .class files for the same sources:
OuterClass
OuterClass$InnerClass
OuterClass$InnerClass$1
But the "nestedTypes()" method does not work well even if you compile sources
with FastJavac. It then correctly recognizes the anonymous inner class to be the
nested type of the named InnerClass:
OuterClass$InnerClass.nestedTypes = [
OuterClass$InnerClass$1
]
but it still returns bad data because - it returns also nested types of nested
types:
OuterClass.nestedTypes = [
OuterClass$InnerClass
OuterClass$InnerClass$1
]
-----------------------------------------------------------------
Source code example follows...
-----------------------------------------------------------------
package test;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class OuterClass {
class InnerClass {
ActionListener anonymouslistener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Action performed!");
}
};
}
public void test() {
InnerClass innerClass1 = new InnerClass(); //Loads all classes.
//
// Try to retrieve nestedTypes of the OuterClass.
//
}
public static void main(String args[]) {
new OuterClass().test();
}
}
(Review ID: 119682)
======================================================================
- relates to
-
JDK-4921247 RFE: JDI&JDWP: Use InnerClass attribute to get the true inner class information
- Closed