Skip to content

Commit 6a11334

Browse files
committed
Updating to work with java 1.6
1 parent 18af90c commit 6a11334

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/org/json/JSONObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,8 +3529,8 @@ public Map create() {
35293529
private <E extends Enum<E>> E stringToEnum(Class<?> enumClass, String value) throws JSONException {
35303530
try {
35313531
@SuppressWarnings("unchecked")
3532-
Method valueOfMethod = enumClass.getMethod("valueOf", String.class);
3533-
return (E) valueOfMethod.invoke(null, value);
3532+
Class<E> enumType = (Class<E>) enumClass;
3533+
return Enum.valueOf(enumType, value);
35343534
} catch (Exception e) {
35353535
throw new JSONException("Failed to convert string to enum: " + value + " for " + enumClass.getName(), e);
35363536
}

0 commit comments

Comments
 (0)