sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1640611 - /sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
Date Wed, 19 Nov 2014 17:39:42 GMT
Author: desruisseaux
Date: Wed Nov 19 17:39:41 2014
New Revision: 1640611

URL: http://svn.apache.org/r1640611
Log:
Replace usage of reflection by a more efficient call to a method available in java.lang.Class.

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1640611&r1=1640610&r2=1640611&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8]
Wed Nov 19 17:39:41 2014
@@ -540,12 +540,8 @@ public final class Types extends Static 
         if (name != null && !name.isEmpty()) try {
             return Enum.valueOf(enumType, name);
         } catch (IllegalArgumentException e) {
-            final Enum<?>[] values;
-            try {
-                values = (Enum<?>[]) enumType.getMethod("values", (Class[]) null).invoke((Object[])
null);
-            } catch (ReflectiveOperationException | ClassCastException r) {
-                // Should never happen, except if 'enumType' is not an Enum.
-                e.addSuppressed(r);
+            final T[] values = enumType.getEnumConstants();
+            if (values == null) {
                 throw e;
             }
             if (values instanceof Enumerated[]) {



Mime
View raw message