diff --git a/classpath/java/lang/Enum.java b/classpath/java/lang/Enum.java index db1c7fa496..b1c57ca925 100644 --- a/classpath/java/lang/Enum.java +++ b/classpath/java/lang/Enum.java @@ -26,20 +26,21 @@ public abstract class Enum> implements Comparable { } public static > T valueOf(Class enumType, String name) { - if (name != null) { - try { - Method method = enumType.getMethod("values"); - Enum values[] = (Enum[])(method.invoke(null)); - for (Enum value : values) { - if (name.equals(value.name)) { - return (T) value; - } + if (name == null) throw new NullPointerException(); + + try { + Method method = enumType.getMethod("values"); + Enum values[] = (Enum[]) (method.invoke(null)); + for (Enum value: values) { + if (name.equals(value.name)) { + return (T) value; } - } catch (Exception ex) { - throw new RuntimeException(ex); } + } catch (Exception ex) { + throw new RuntimeException(ex); } - return null; + + throw new IllegalArgumentException(name); } public int ordinal() {