Skip to content

Commit 4f67189

Browse files
committed
Updating to work with java 1.6
1 parent 6a11334 commit 4f67189

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,11 +3526,12 @@ public Map create() {
35263526
/**
35273527
* Converts a String to an Enum value.
35283528
*/
3529-
private <E extends Enum<E>> E stringToEnum(Class<?> enumClass, String value) throws JSONException {
3529+
private <E> E stringToEnum(Class<?> enumClass, String value) throws JSONException {
35303530
try {
35313531
@SuppressWarnings("unchecked")
35323532
Class<E> enumType = (Class<E>) enumClass;
3533-
return Enum.valueOf(enumType, value);
3533+
Method valueOfMethod = enumType.getMethod("valueOf", String.class);
3534+
return (E) valueOfMethod.invoke(null, value);
35343535
} catch (Exception e) {
35353536
throw new JSONException("Failed to convert string to enum: " + value + " for " + enumClass.getName(), e);
35363537
}

0 commit comments

Comments
 (0)