Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 2799 invoked from network); 26 Jun 2007 19:28:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jun 2007 19:28:49 -0000 Received: (qmail 80640 invoked by uid 500); 26 Jun 2007 19:28:50 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 80570 invoked by uid 500); 26 Jun 2007 19:28:50 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 80552 invoked by uid 99); 26 Jun 2007 19:28:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jun 2007 12:28:50 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jun 2007 12:28:46 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 24A13714062 for ; Tue, 26 Jun 2007 12:28:26 -0700 (PDT) Message-ID: <21750341.1182886106147.JavaMail.jira@brutus> Date: Tue, 26 Jun 2007 12:28:26 -0700 (PDT) From: "Joe Kelly (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Commented: (LANG-76) [lang] EnumUtils.getEnum() doesn't work well in 1.5 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-76?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12508298 ] Joe Kelly commented on LANG-76: ------------------------------- I like Marcus Schulte's suggestion. EnumUtils.getEnum() should force class initialization. > [lang] EnumUtils.getEnum() doesn't work well in 1.5 > --------------------------------------------------- > > Key: LANG-76 > URL: https://issues.apache.org/jira/browse/LANG-76 > Project: Commons Lang > Issue Type: Bug > Affects Versions: 2.1 > Environment: Operating System: other > Platform: Other > Reporter: Igor Laberov > Fix For: 3.0 > > > 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 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org