if (type.isAssignableFrom(obj.getClass())) {
return (Enum<?>) obj;
}
+
+ if (!(obj instanceof String)) {
+ throw new ELException(MessageFactory.get("error.convert",
+ obj, obj.getClass(), type));
+ }
+
Enum<?> result;
try {
- result = Enum.valueOf(type, obj.toString());
+ result = Enum.valueOf(type, (String) obj);
} catch (IllegalArgumentException iae) {
throw new ELException(MessageFactory.get("error.convert",
obj, obj.getClass(), type));
Object output = null;
try {
output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumC.class);
- } finally {
- assertEquals(TestEnumC.VALA1, output);
+ } catch (ELException ele) {
+ // Ignore
}
+ assertNull(output);
}
private static void testIsSame(Object value) {