Skip to content

Fix EnumMap lookups for enum constants with class bodies - #1190

Merged
jknack merged 1 commit into
jknack:masterfrom
MoChiUaena:codex/fix-enum-map-constant-lookup
Oct 3, 2026
Merged

jknack merged 1 commit into
jknack:masterfrom
MoChiUaena:codex/fix-enum-map-constant-lookup

Conversation

@MoChiUaena

Copy link
Copy Markdown
Contributor

EnumMap lookups fail when the first key is an enum constant with a class body. Its runtime class is a subclass of the enum, so passing getClass() to Enum.valueOf rejects valid keys.

Use getDeclaringClass() to resolve the key against the enum type. Add regression tests for dotted and bracketed paths, the lookup helper, missing and null values, empty maps, and unknown constant names.

Fixes #1083.

Validation:

  • Full reactor: clean install -DskipTests, then clean package, on JDK 17 and 21. Each package run completed with 1,173 tests passed and 3 existing skips.
  • Issue1083, Issue237 and Issue418: 11 tests passed on JDK 17. Before the fix, 6 of the 8 new cases failed with the reported exception.
  • Spotless check passed for the two changed files. The unfiltered check reports formatting differences in six unchanged core files; the same files fail on the original base revision.

@jknack jknack added the bug label Oct 3, 2026
@jknack jknack added this to the 4.5.6 milestone Oct 3, 2026
@jknack
jknack merged commit 3b7b3b3 into jknack:master Oct 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken feature: EnumMap lookup

2 participants