[cal10n-dev] Trivial problem about Enum#getClass()

Takeshi Kondo takeshi.kondo at gmail.com
Tue Sep 1 20:16:03 CEST 2009


Hi

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().

Takeshi Kondo
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/cal10n-dev/attachments/20090902/b0b44a34/attachment.htm>


More information about the cal10n-dev mailing list