commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lew Bloch (JIRA)" <>
Subject [jira] Commented: (LANG-76) [lang] EnumUtils.getEnum() doesn't work well in 1.5
Date Fri, 14 Aug 2009 21:35:15 GMT


Lew Bloch commented on LANG-76:

It is egregious that the project refuses to fix a bug caused by its own intentional violation
of the Java Language Specification (JLS).  It is also strange that the powers that be think
this library will never be used in a Java 5+ environment - there are use cases for having
a well-thought-out typesafe enumeration that can do things not available to standard 'enum'
classes, e.g., inherit from other enumerations or interoperate with legacy pre-1.5 systems.
 This shunning of responsibility is a saddening disappointment coming from an Apache project,
especially one so fundamental and widely used as commons-lang.  Palming the bug off as "[r]elying
on ... an undocumented feature" is especially disingenuous.  That classes used to initialize
on references to the 'class' literal was a bug, not a feature, and contravened the explicit
statement in the JLS second edition, s.12.4.1: "A class or interface will not be initialized
under any other circumstance." (Statement follows list of class-initialization triggers that
does not include reference to the 'class' literal.)  For shame.

> [lang] EnumUtils.getEnum() doesn't work well in 1.5
> ---------------------------------------------------
>                 Key: LANG-76
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.1
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Igor Laberov
>             Fix For: 2.4
> Hi,
> I encountered with problem using EnumUtils.getEnum() in 1.5. It appears that my
> Enum class should be accessed first so constructor will be called. In 1.4 it was
> enough to have myClass.class, so all static members were initialized. In 1.5 it
> doesn't work.
> I noticed that static members are not initialized anymore while acessing to
> class definition. See the code
> public class Test {
>     public static final class TT{
>         public static final TT one = new TT();
>         private TT(){
>             System.out.println("Called TT" );
>         }
>     }
>     public static void main(String[] args) {
>      Class cl = TT.class;
>    // System.out.println(;
>   //  System.out.println(TT.class.isAssignableFrom(String.class));
>     }
> }
> In 1.4 constructor of TT is called, while in 1.5 is not. 
> Actually, according to the spec
> (,
> this is right behavior of Java. 
> Unfortunately, I didn't succeded to think about good solution..
> P.s. I know that in 1.5 we have enum built-in, but it is not the same, and we
> try to move to 1.5 without too much changes

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message