Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-116

Enum's outer class may not be loaded for EnumUtils

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0
    • 2.1
    • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            david@leppik.net david
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: