Skip to content

#3815: generated Java keeps national names legally and builds as UTF-8 - #3896

Merged
squid-protocol merged 1 commit into
mainfrom
fleet/3815-java-unicode
Sep 27, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fleet/3815-java-unicode

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #3815

What changed

  • java_identifier / java_class_base / container_var (cobol_to_java_common.py, cobol_to_java_names.py):
    • NFC-normalise the name first, so a decomposed name (from a macOS path, for example) gives the same field, class and .java file as its composed form. The result is normalised again after the v / Legacy prefix, because a prefix placed before a leading combining mark composes with it.
    • National letters are kept. java_class_base split on [^A-Za-z0-9], so ØKONOMI became the class Konomi, the same as KONOMI. It now splits on ASCII punctuation only.
    • Any non-ASCII character Java rejects in an identifier becomes _ instead of being dropped (KUNDE§NR → kunde_nr, which cannot collide with KUNDENR or KUNDE-NR). The check uses Java's isJavaIdentifierStart/Part categories.
    • Case mapping keeps one letter per letter: ß stays ß rather than becoming Ss, which would make STRASSE-ß the same name as STRASSE-SS. For every other character the new helpers return exactly what str.lower/title/capitalize return. A fuzz of 200k random non-expanding BMP strings found no difference.
    • Pure-ASCII output is byte-identical. A fuzz of 300k random printable-ASCII names matches origin/main for all three functions, and the refraction snapshots do not move.
  • Gradle: build.gradle now sets options.encoding = 'UTF-8' on every JavaCompile task. Spring Boot's Gradle plugin already defaults to UTF-8, and the generated project compiled without the setting. The setting removes the dependence on the plugin: a plain java Gradle build with -Dfile.encoding=windows-1252 fails on ØkonomiService.java without it and passes with it.
  • Maven: no change was needed. The generated pom always uses spring-boot-starter-parent, which sets project.build.sourceEncoding=UTF-8, and a test asserts that parent.
  • cobol_jcl_forge.analyze_cobol_intent: the SELECT/ASSIGN and PROGRAM-ID patterns now accept non-ASCII letters, with ASCII behaviour unchanged. Before, SELECT KUNDER-ÆØÅ ASSIGN TO FILEA was missed, so the program was treated as transactional instead of batch. Its controller then asked for a FileaDTO that nothing generates, and the national estate did not compile.

Proof

  • New tests/cobol_mainframe/test_java_unicode_names.py (37 tests):
    • ÆØÅ / ÄÖÜ / § / Ñ / नाम / NFD é give legal NFC names;
    • NFD and NFC forms give the same name;
    • no collisions from § or ß;
    • ASCII values are pinned;
    • Gradle and Maven builds use UTF-8;
    • the national SELECT is still read as a batch file;
    • JDK 17 javac -encoding UTF-8 compiles a class ØkonomiService with national fields.
  • tests/tools/java_target_matrix.py <estate> --scan --only default gradle plain-classes plain-records on a national estate reports PASS for all four configs (Maven and Gradle 8.10.2, JDK 17). The estate is the unicode_gauntlet mainframe seed's cbl, jcl and csd files, with names renamed by unicode_gauntlet.renamer: programs ØKONOMI / RÆKNING, file KUNDER-ÆØÅ, record KUNDREC-ÄÖÜ, fields KUNDNR-Ø / KUNDNAVN-ÆØÅ / WS-BELØB / WS-STRAßE, paragraph 100-RÆKNE. It generates ØkonomiService.java, KundrecÄöü.java, private String kundnavnÆøå; and so on.
    • Before the SELECT fix, default and gradle failed with cannot find symbol FileaDTO.
    • gradle-plain-21 could not run on this box because its JDK 21 is a JRE only (no javac).
  • Gates: pr_gates.py passes every gate: lint, audits, secrets, xray, gauntlet, golden (222s) and suite (716s).

Not done

  • java_url_segment still splits on [^A-Za-z0-9], so ØKONOMI maps to /api/v1/konomi. This still compiles, but it can collide with KONOMI. A non-ASCII @RequestMapping needs its own decision about percent-encoding.
  • Several forges still build names ad hoc (DD-name params in the api_contract/service forges, test_forge class names, spring_forge line 112) instead of calling these functions.
  • cobol_dag_architect._SELECT / _PROGRAM_ID and cobol_compiler_forge's SELECT pattern are still ASCII-only.
  • ASCII # / @ in a name are still passed through unchanged, which is illegal Java. That is left alone to keep ASCII output byte-identical.

🤖 Generated with Claude Code

- java_identifier / java_class_base / container_var: NFC-normalise, keep
  national letters (`ØKONOMI` was the class `Konomi`), replace characters
  Java rejects (`§`) with `_` instead of dropping them, and case-map one
  letter per letter (`ß` no longer becomes `Ss`). Pure-ASCII output is
  byte-identical (fuzzed against origin/main).
- Gradle build sets options.encoding = 'UTF-8' on every JavaCompile; the
  Maven pom already inherits UTF-8 from spring-boot-starter-parent.
- cobol_jcl_forge: SELECT/ASSIGN and PROGRAM-ID accept national letters,
  so a national-named file keeps the program batch and its controller
  compiles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant