Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.0
-
None
-
None
-
Operating System: other
Platform: Other
-
23374
Description
I have a class with an Enum inner class, and I call MyClass.MyEnum.getEnumList()
in a JSP page (with Tomcat 3.3.1). I'm using enums pretty much exactly as
described in Enum's javadoc. It returns an empty Collection, even though I have
defined several enums. At any point in the JSP page after I reference a
specific Enum, the list shows up properly populated.
What's happening is presumably a classloader issue, where
MyClass.MyEnum.getEnumList() can be called without loading this class. Perhaps
Tomcat's multiple classloaders make this possible. In any case, the workaround
is easy. I changed:
public static List getEnumList()
{ return getEnumList(MyEnum.class); }to:
public static List getEnumList()
{ new MyParentClass(); return getEnumList(MyEnum.class); }for all the methods that need to access the enums.