diff --git a/JAVA_MIGRATION.md b/JAVA_MIGRATION.md index 0f94bb9..6f0484b 100644 --- a/JAVA_MIGRATION.md +++ b/JAVA_MIGRATION.md @@ -31,8 +31,8 @@ Java; retain its coordinated Scala class/companion/models. `FieldMixin.accessNam retaining its case class. `MixinInfo.linearise` and `ScalaSignature.Bytes.section` delegate traversal and array-copy behavior to Java. `TypeRef.jName`, `TypeRef.jDesc` and `TMethodType.jDesc` delegate name/descriptor conversion and method assembly while preserving virtual lookup and evaluation order. `ClassSymbolRef.jInterfaces` delegates -ordered interface-name mapping while retaining its Scala List contract. The next bounded candidate is -`ScalaSignature.ClassSymbolRef.toString`, with characterization before extraction. +ordered interface-name mapping while retaining its Scala List contract, and its formatter now delegates to Java. +The next bounded candidate is `ScalaSignature.MethodSymbol.toString`, with characterization before extraction. Java-trait rewriting and compiler startup also delegate to Java helpers. Abstract Java mixins and Java-path side-only filtering are complete; multiple Scala-trait inheritance still needs its metadata. Retain trait state/accessor/super bridges and the compiler/signature/analyser model shells. diff --git a/JAVA_MIGRATION_HANDOFF.md b/JAVA_MIGRATION_HANDOFF.md index ea7cc3f..bb0fba3 100644 --- a/JAVA_MIGRATION_HANDOFF.md +++ b/JAVA_MIGRATION_HANDOFF.md @@ -16,25 +16,24 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes ## Current state and next target -**463 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java -files and 9 Scala files / 749 nonblank Scala lines**. The packaged inventory has 443 classes. +**470 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java +files and 9 Scala files / 748 nonblank Scala lines**. The packaged inventory has 443 classes. Review follow-up: restored packet-scheduler callback mutation behavior with the original Scala hash-map traversal, virtual tile accessor dispatch throughout `TMultiPart`, and null-safe equality for scheduled-tick deduplication. Six JVM and two Forge regression cases cover the fixes. Callable signatures remain unchanged; the packet traversal callback adds one anonymous class. See the latest history entries for the individual fixes and validation. -Latest bounded target: `ScalaSignature.ClassSymbolRef.jInterfaces` delegates to `ScalaSignatureParser.interfaceNames`. -Seven characterization tests were committed first as `6ccb83f`, including a frozen Scala caller and subclasses -compiled against `240a788`. They pin virtual info/interfaces/jName reads, ordered mapping, duplicates, empty-list -and string identities, repeated queries, nulls, failures and the static trait helper. The Java callback retains the -Scala List builder and result contract. All 463 frozen JVM consumers pass; checks preserve 441 retained class/member -APIs, all 17 ScalaSignature payloads, 3,733 unrelated method bodies and all 116 generated dumps. One unreferenced -Scala callback is replaced by a Java callback; the total stays 443 classes. -Evidence: `run/migration-interface-names-reference/`; fixture provenance is in `src/test/fixtures/README.md`. +Latest bounded target: `ScalaSignature.ClassSymbolRef.toString` delegates formatting to +`ScalaSignatureParser.classSymbolString`. Seven characterization tests were committed first as `1234112`. They pin +concrete and anonymous runtime-name trimming, literal/null values, two's-complement hexadecimal flags, repeated +virtual getter order, owner formatting and failures, and the static trait helper. All 470 frozen JVM consumers pass; +checks preserve 442 retained class/member APIs, all 17 ScalaSignature payloads, 3,737 unrelated method bodies and all +116 generated dumps. No class is added or removed; the total stays 443 classes. +Evidence: `run/migration-class-symbol-string-reference/`. -**Next bounded candidate: `ScalaSignature.ClassSymbolRef.toString`.** Characterize class-name trimming, hexadecimal -flags, virtual name/owner/infoId reads and null/failure order while retaining the trait and case-class declarations. +**Next bounded candidate: `ScalaSignature.MethodSymbol.toString`.** Characterize exact formatting, hexadecimal flags, +virtual name/owner/infoId reads and null/failure order while retaining the case-class declaration and bridges. Keep case-class/product/serialization shapes and simple model accessors. Broader shell replacement and opcode algorithm fixes remain separate work. The external ProjectRed Scala-trait fixture and ScalaSignature model bridges remain required. Actual client diff --git a/docs/migration/HISTORY.md b/docs/migration/HISTORY.md index 39faade..1a529e7 100644 --- a/docs/migration/HISTORY.md +++ b/docs/migration/HISTORY.md @@ -1520,3 +1520,23 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m frozen tests/resources, reports and comparison tools. Frozen runs use its `version.txt`; final builds use the committed version. Sources remain 224 Java files and nine Scala files / 749 nonblank lines. Next: `ClassSymbolRef.toString`, preserving formatting, virtual reads and failure order. + +### 2026-09-04 — ScalaSignature class-symbol strings + +- Committed seven JVM characterization cases first as `1234112` against the untouched + `ClassSymbolRef.toString`. They cover concrete ClassSymbol/ObjectSymbol runtime names, anonymous suffix trimming, + punctuation and nulls, lowercase two's-complement hexadecimal flags, negative/limit info IDs, repeated virtual + reads, owner formatting and every getter/failure boundary. A proxy exercises the exact static trait-helper + descriptor without needing an outer ScalaSignature instance. +- Extracted formatting into `ScalaSignatureParser.classSymbolString(Object)`. Java retains the original greedy + class-name regular expression, left-to-right virtual getter order, object-to-string conversion and hexadecimal + representation. Scala keeps the inferred return type, trait/case-class declarations, forwarders, products and + serialization shapes. +- Normal and clean validation pass 470 JVM tests, 470 frozen consumers and 237 Java 8 Forge tests with zero + failures/errors/skips. All 116 generated dumps match. Both jars contain 443 Java 8 classes and matching sources; + comparison preserves 442 retained class/member APIs, all 17 ScalaSignature payloads and 3,737 unrelated method + bodies. The helper adds one package-private method; no class inventory or effective divergence changes. +- Evidence is under ignored `run/migration-class-symbol-string-reference/`, including the reference jar, frozen + tests/resources, reports and comparison tools. Frozen runs use its `version.txt`; final builds use the committed + version. Source totals are 224 Java files and nine Scala files / 748 nonblank lines. Next: + `MethodSymbol.toString`, preserving formatting, virtual reads and failure order. diff --git a/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala b/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala index 88af3df..e798a6b 100644 --- a/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala +++ b/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala @@ -50,8 +50,7 @@ class ScalaSignature(val bytes: Bytes) { def infoId: Int def full = owner.full + "." + name - override def toString = getClass.getName.replaceAll(".+\\$", "") + - "(" + name + "," + owner + "," + flags.toHexString + "," + infoId + ")" + override def toString = ScalaSignatureParser.classSymbolString(this) def isObject = false def info: ClassType = evalT(infoId) diff --git a/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java b/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java index 653f10a..eb3c2d8 100644 --- a/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java +++ b/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java @@ -71,6 +71,19 @@ final class ScalaSignatureParser { }, List$.MODULE$.canBuildFrom()); } + static String classSymbolString(Object value) { + ScalaSignature.ClassSymbolRef symbol = (ScalaSignature.ClassSymbolRef) value; + return symbol.getClass().getName().replaceAll(".+\\$", "") + "(" + + symbol.name() + + "," + + symbol.owner() + + "," + + Integer.toHexString(symbol.flags()) + + "," + + symbol.infoId() + + ")"; + } + static byte[] section(Bytes bytes) { byte[] array = bytes.arr(); int start = bytes.pos();