commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <niall.pember...@gmail.com>
Subject Re: svn commit: r912292 - in /commons/proper/lang/branches/LANG_2_X: ./ src/main/java/org/apache/commons/lang/enum/ src/main/java/org/apache/commons/lang/enums/ src/test/java/org/apache/commons/lang/enums/
Date Sun, 21 Feb 2010 20:17:39 GMT
On Sun, Feb 21, 2010 at 8:03 PM, sebb <sebbaz@gmail.com> wrote:
> On 21/02/2010, niallp@apache.org <niallp@apache.org> wrote:
>> Author: niallp
>>  Date: Sun Feb 21 02:52:56 2010
>>  New Revision: 912292
>>
>>  URL: http://svn.apache.org/viewvc?rev=912292&view=rev
>>  Log:
>>  LANG-76 EnumUtils.getEnum() doesn't work in 1.5+ - force initialization of the
Enum class using Class.forName() thanks to Marcus Schulte for the solution
>>  (Note: for JDK 1.5+ the Ant build compiles EnumUtilsLang76Test with source/target
1.5 which causes this problem to occur)
>>
>>  Added:
>>     commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/enums/EnumUtilsLang76Test.java
  (with props)
>>  Modified:
>>     commons/proper/lang/branches/LANG_2_X/build.xml
>>     commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enum/Enum.java
>>     commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enums/Enum.java
>>     commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/enums/EnumUtilsTest.java
>>
> ...
>>  Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enum/Enum.java
>>  URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enum/Enum.java?rev=912292&r1=912291&r2=912292&view=diff
>>  ==============================================================================
>>  --- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enum/Enum.java
(original)
>>  +++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enum/Enum.java
Sun Feb 21 02:52:56 2010
>>  @@ -484,6 +484,17 @@
>>              throw new IllegalArgumentException("The Class must be a subclass
of Enum");
>>          }
>>          Entry entry = (Entry) cEnumClasses.get(enumClass);
>>  +
>>  +        if (entry == null) {
>>  +            try {
>>  +                // LANG-76 - try to force class initialization for JDK
1.5+
>>  +                Class.forName(enumClass.getName(), true, enumClass.getClassLoader());
>>  +                entry = (Entry) cEnumClasses.get(enumClass);
>>  +            } catch (Throwable t) {
>>  +                // Ignore
>
> Not a good idea to ignore Throwable.

OK I've changed it to Exception:

http://svn.apache.org/viewvc?view=revision&revision=912394

Niall

>>  +            }
>>  +        }
>>  +
>>          return entry;
>>      }
>>
>>
>>  Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enums/Enum.java
>>  URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enums/Enum.java?rev=912292&r1=912291&r2=912292&view=diff
>>  ==============================================================================
>>  --- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enums/Enum.java
(original)
>>  +++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/enums/Enum.java
Sun Feb 21 02:52:56 2010
>>  @@ -530,6 +530,17 @@
>>              throw new IllegalArgumentException("The Class must be a subclass
of Enum");
>>          }
>>          Entry entry = (Entry) cEnumClasses.get(enumClass);
>>  +
>>  +        if (entry == null) {
>>  +            try {
>>  +                // LANG-76 - try to force class initialization for JDK
1.5+
>>  +                Class.forName(enumClass.getName(), true, enumClass.getClassLoader());
>>  +                entry = (Entry) cEnumClasses.get(enumClass);
>>  +            } catch (Throwable t) {
>>  +                // Ignore
>
> Ditto.
>
>>  +            }
>>  +        }
>>  +
>>          return entry;
>>      }
>>
>>
>
> ...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


Mime
View raw message