javap-escaped and line-separator string constants are not read as their exact values
Original description
By MelanX · October 24, 2026Crate: tools/minecraft-options
Commit: f844b107
Behavior
The options analyzer reads string constants from the comments in javap -c output, and javap does not print them verbatim:
- It escapes control characters. A constant
"x\n"prints as the commentString x\nand"t\t"asString t\t, soInsn.string()returns the literal backslash sequences instead of the real value. - It prints U+2028 and similar line-separator characters raw.
parse_memberssplits the text withstr.splitlines(), which also breaks on those characters, so theldcline is cut there and a constant such as"a<U+2028> "is read asa.
with_trailing_spaces already rewrites ldc String lines from the class constant pool, but only appends the trailing spaces javap drops.
Expected behavior
Insn.string() returns the exact constant. The exact values are already available from string_constants (class bytes, by constant pool index) and can replace the comment text for ldc String operands, and the listing is split on \n only.
Impact
Low for current Minecraft option defaults. A default or token containing such a character would be recorded with the wrong value.
Locations
tools/minecraft-options/analyze_options.pywith_trailing_spaces,Insn.string,parse_members,Disassembler.get
Validation and limitations
Reproduced with javac and javap 25 on a class holding these constants: javap prints // String x\n, // String t\t and a raw U+2028. Follows #604, whose fix restores empty and padded constants but not escaped or line-separator ones.