Uploaded image for project: 'CAL10N'
  1. CAL10N
  2. CAL-1

Enum#getClass() not always correct

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • None
    • None

    Description

      As reported by Takeshi Kondo in http://www.qos.ch/pipermail/cal10n-dev/2009-September/000280.html

      Quoting Takeshi:

      I found a trivial bug.

      >> MessageConveyor #68
      > String resouceBundleName =
      AnnotationExtractor.getResourceBundleName(key
      > .getClass());

      Enum#getClass() is specific as follows.


      public enum MSG{
      A,
      B

      { // override method }

      }

      public static void main(String[] args){
      System.out.println(MSG.A.getClass()); // -> $MSG
      System.out.println(MSG.B.getClass()); // -> $MSG$1
      System.out.println(MSG.B.getDeclaringClass()); // $MSG
      }


      If we need to get enum class form instance, we have to call
      Enum#getDeclaringClass().

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            ceki Ceki Gülcü
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: