Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 61979 invoked from network); 14 Aug 2009 21:35:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Aug 2009 21:35:32 -0000 Received: (qmail 92346 invoked by uid 500); 14 Aug 2009 21:35:38 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 92252 invoked by uid 500); 14 Aug 2009 21:35:38 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 92242 invoked by uid 99); 14 Aug 2009 21:35:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Aug 2009 21:35:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Aug 2009 21:35:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1DE97234C48D for ; Fri, 14 Aug 2009 14:35:15 -0700 (PDT) Message-ID: <1027244782.1250285715121.JavaMail.jira@brutus> Date: Fri, 14 Aug 2009 14:35:15 -0700 (PDT) From: "Lew Bloch (JIRA)" To: issues@commons.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: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LANG-76?page=3Dcom.atlassian.ji= ra.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1274345= 5#action_12743455 ]=20 Lew Bloch commented on LANG-76: ------------------------------- It is egregious that the project refuses to fix a bug caused by its own int= entional violation of the Java Language Specification (JLS). It is also st= range that the powers that be think this library will never be used in a Ja= va 5+ environment - there are use cases for having a well-thought-out types= afe 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 co= ming 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 re= ferences to the 'class' literal was a bug, not a feature, and contravened t= he explicit statement in the JLS second edition, s.12.4.1: "A class or inte= rface will not be initialized under any other circumstance." (Statement fol= lows 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: 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: 2.4 > > > Hi, > I encountered with problem using EnumUtils.getEnum() in 1.5. It appears t= hat 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 =3D new TT(); > private TT(){ > System.out.println("Called TT" ); > } > } > =20 > public static void main(String[] args) { > Class cl =3D 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.=20 > Actually, according to the spec > (http://java.sun.com/docs/books/jls/second_edition/html/execution.doc.htm= l#57946), > this is right behavior of Java.=20 > 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, an= d we > try to move to 1.5 without too much changes --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.