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

Adam Sotona asotona at openjdk.org
Thu Nov 10 06:23:48 UTC 2022


On Wed, 9 Nov 2022 10:14:45 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> When `Class.getEnumConstants()` is called on a bad enum class where `values()` is an instance method, or returns a non‑array, then it throws `NullPointerException` or `ClassCastException` respectively. 
> 
> This patch fixes `Class.getEnumConstants()` method to handle above mentioned bad enums and adds relevant tests.
> 
> Please review.
> 
> Thanks,
> Adam

This pull request has now been integrated.

Changeset: e802b124
Author:    Adam Sotona <asotona at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e802b124b7a363ca4cb56f8072b4dde5176ef96a
Stats:     119 lines in 4 files changed: 118 ins; 0 del; 1 mod

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

Reviewed-by: darcy

-------------

PR: https://git.openjdk.org/jdk/pull/11056


More information about the core-libs-dev mailing list