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

[lang] Can't XMLDecode an Enum

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0
    • 2.3
    • None
    • None
    • Operating System: Windows 2000
      Platform: PC

    • 33965

    Description

      I am encoding and decoding Enums using java.beans.XMLEncoder/Decoder.

      When an Enum is decoded, I am using the following to get the instance. The
      enumClass name and the enum name are stored in the serialized XML file, then
      used to restore the bean at read time
      return EnumUtils.getEnum(enumClass, name);

      The problem is that the Enum.cEnumClasses map may not contain an entry for the
      Enum class yet, despite the fact that the Class for the enum has been loaded.

      If I loop through the Class.fields using reflection and get(null) the value for
      each one, then the cEnumClasses is populated and getEnum works.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kevin.gilpin@alum.mit.edu Kevin Gilpin
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: