8296196: Class.getEnumConstants() throws undocumented ClassCastException and NullPointerException

Reviewed-by: darcy
This commit is contained in:
Adam Sotona 2022-11-10 06:20:57 +00:00
parent 78a08a0f21
commit e802b124b7
4 changed files with 119 additions and 1 deletions

View file

@ -3934,7 +3934,8 @@ public final class Class<T> implements java.io.Serializable,
// These can happen when users concoct enum-like classes
// that don't comply with the enum spec.
catch (InvocationTargetException | NoSuchMethodException |
IllegalAccessException ex) { return null; }
IllegalAccessException | NullPointerException |
ClassCastException ex) { return null; }
}
return constants;
}