Skip to main content
FORGEJO ERA / ISSUE #623

javap-escaped and line-separator string constants are not read as their exact values

closedOpened by MelanX on

Original description​

By MelanX · October 24, 2026

Crate: 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 comment String x\n and "t\t" as String t\t, so Insn.string() returns the literal backslash sequences instead of the real value.
  • It prints U+2028 and similar line-separator characters raw. parse_members splits the text with str.splitlines(), which also breaks on those characters, so the ldc line is cut there and a constant such as "a<U+2028> " is read as a.

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.py with_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.