Enum extraction mis-assigns ids, skips constants with bodies, and mixes codecs
closedOpened by MelanX on
Original description
By MelanX · October 23, 2026Crate: tools/minecraft-options
Commit: 2b2af1e4f8166d02e4732d19e040a53745d97a51
Behavior
extract_enum has several independent defects, none of which affects a shipped codec today:
- A constant is closed at the first
invokespecial <init>of any owner. A constructor argument such asnew TextComponentTranslation(...)ends it early, soconstructor_descriptor,id, and the string set are wrong. 1.12.2 to 1.15.2mainHandreports LEFT id 0 and RIGHT id 0, andMusicFrequencyids are the delays 20/10/0.idis the first extra int, with no tie to the codec or an accessor, andenum_domainemits it aspersistedforinteger_id. - Constants are recognized only when
newnames the enum itself, sonew Enum$1constants with bodies are silently skipped. A partial list is returned as complete, with no check against$VALUESor the$values()array (HumanoidModel$ArmPoseyields 10 of 11). - The codec form is read from
window[-40:], which is not reset per field, so a second codec inherits the first one's evidence and string checks win.PermissionLevel.INT_CODEC,Direction.LEGACY_ID_CODEC, and everySTREAM_CODECare reportedstring_token. - An obfuscated
fromEnumcodec isstring_tokenonly if a constant carries a dotless string, so computed names stayunknown(musicFrequencyin 1.21.6 to 1.21.10, while it resolves in 1.21.11+). token_bindingsbinds a literal to the nearest precedinggetstaticwithout looking at the branch opcode, sox != A ? "b" : "a"swaps the map, andcomplete_token_mapfills in the remainder with no low-confidence signal.enum_string_lambdatakes the firstEnum -> Stringmethod.
Expected behavior
Constants end at the <init> of their own class, bodies are included and checked against $VALUES, each codec field only sees its own initializer, and inverted conditions and ambiguous accessors lower confidence.
Impact
An option whose enum is persisted by integer id, or has a constant body or an extra int parameter, would silently get wrong ids or an incomplete domain in the next release that introduces one.
Locations
tools/minecraft-options/analyze_options.pyextract_enum(539-620),token_bindings(623-647),enum_string_lambda(662-675),enum_domain(699-713)
Validation and limitations
Reproduced with extract_enum against the cached 1.12.2, 26.1, and 26.3 JARs and synthetic instruction input.