You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/09/15 11:20:40 UTC

DO NOT REPLY [Bug 36666] New: - EnumUtils.getEnum() doesn't work well in 1.5

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36666>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36666

           Summary: EnumUtils.getEnum() doesn't work well in 1.5
           Product: Commons
           Version: 2.1 Final
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: major
          Priority: P2
         Component: Lang
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: igorl@qlusters.com


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( TT.one);
  //  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
(http://java.sun.com/docs/books/jls/second_edition/html/execution.doc.html#57946),
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

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org