In Java, with Sun JDK 1.6, with an enumeration such as this:
public enum MyEnum { FIRST_MEMBER { public void foo() { } }, SECOND_MEMBER { public void foo() { } }, THIRD_MEMBER { public void foo() { } }; }
Compiled files:
MyEnum$1.class MyEnum$2.class MyEnum$3.class MyEnum.class
It also means that a stack trace showing foo() or a method call printed in JVisualVM etc. will have something like this at the top:
mypackage.MyEnum$1.run()
$1 in the class name is because enumeration members are compiled into anonymous inner classes. I wonder if it can be assumed that the numbers used in these class names correspond to the order in which the members of the enum are defined? If this is not the case, is there a standard guaranteed way to find an enumeration member from a number used as the name of an anonymous class?
EDIT
As for the listing design, this was used for illustration only. The real enum implements the interface, and each member provides a different implementation of the methods. Please don't pay too much attention to what admittedly looks a bit odd.
CHANGE No. 2
To clarify, I am not trying to do anything with this information programmatically (for example, a strange absurd absurdity). Rather, I look at the stack trace and profiling information and try to map a method call to an enumeration member (shown as an anonymous class call) against the actual enumeration member in the source code.
source share