From 64f5abce6f28bd8e80d7bd6aa591c3fc63e5c162 Mon Sep 17 00:00:00 2001 From: Algent Date: Fri, 4 Sep 2026 20:57:30 +0200 Subject: [PATCH] refactor: port class symbol full names to Java --- JAVA_MIGRATION_HANDOFF.md | 20 +++++++++--------- docs/migration/HISTORY.md | 21 +++++++++++++++++++ .../multipart/asm/ScalaSignature.scala | 2 +- .../multipart/asm/ScalaSignatureParser.java | 5 +++++ 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/JAVA_MIGRATION_HANDOFF.md b/JAVA_MIGRATION_HANDOFF.md index 95f9b64..4ba1ae9 100644 --- a/JAVA_MIGRATION_HANDOFF.md +++ b/JAVA_MIGRATION_HANDOFF.md @@ -16,7 +16,7 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes ## Current state and next target -**484 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java +**491 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java files and 9 Scala files / 744 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, @@ -24,16 +24,16 @@ virtual tile accessor dispatch throughout `TMultiPart`, and null-safe equality f 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.TypeRefType.jDesc` delegates applied-type descriptor routing to -`ScalaSignatureParser.appliedTypeDescriptor`. Seven characterization tests were committed first as `5493086`. They -pin array argument and fallback routing, two/three virtual name reads, repeated uncached reads, malformed/null type -arguments, failure order and the retained method-type view. A frozen Scala 2.11.5 caller and subclass preserve the -old descriptor. All 484 frozen JVM consumers pass; checks preserve 442 retained class/member APIs, all 17 -ScalaSignature payloads, 3,739 unrelated method bodies and all 116 generated dumps. No class is added or removed; -the total stays 443 classes. Evidence: `run/migration-applied-type-descriptor-reference/`. +Latest bounded target: `ScalaSignature.ClassSymbolRef.full` delegates owner/name concatenation to +`ScalaSignatureParser.classSymbolFull`. Seven characterization tests were committed first as `05c2792`. They pin +literal/null results, owner/full/name read order, repeated uncached reads, failure boundaries, unused member access +and the legacy static trait helper descriptor. A frozen Scala 2.11.5 caller and direct trait implementation preserve +the old `$class.full` bridge. All 491 frozen JVM consumers pass; checks preserve 442 retained class/member APIs, all +17 ScalaSignature payloads, 3,740 unrelated method bodies and all 116 generated dumps. No class is added or removed; +the total stays 443 classes. Evidence: `run/migration-class-symbol-full-reference/`. -**Next bounded candidate: `ScalaSignature.ClassSymbolRef.full`.** Characterize owner/name concatenation, virtual -read order, nulls and failures while retaining the trait, case-class and path-dependent declarations. +**Next bounded candidate: `ScalaSignature.MethodSymbol.full`.** Characterize owner/name concatenation, virtual read +order, nulls and failures while retaining the case-class and path-dependent declarations. 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 922f40f..8218852 100644 --- a/docs/migration/HISTORY.md +++ b/docs/migration/HISTORY.md @@ -1580,3 +1580,24 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m frozen tests/resources, reports, logs 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 / 744 nonblank lines. Next: `ClassSymbolRef.full`, preserving owner/name concatenation, virtual reads and failure order. + +### 2026-09-04 — ScalaSignature class-symbol full names + +- Committed seven JVM characterization cases first as `05c2792` against the untouched `ClassSymbolRef.full`. They + pin concrete class/object names, punctuation, literal null full/name results, repeated owner/full/name read order, + null-owner and getter failure boundaries, unused symbol members and the exact static trait-helper descriptor. +- Added `ReferenceScalaClassSymbolFull`, compiled once with Scala 2.11.5 under Java 8 against the unchanged dev jar + at `24c7723`. Its frozen Scala caller and direct `ClassSymbolRef` implementation preserve the old `$class.full` + forwarder and virtual overrides. Source, encoded classes and SHA-256 provenance are committed under + `src/test/fixtures/` and `src/test/resources/compat/`; do not regenerate them against the port. +- Extracted concatenation into `ScalaSignatureParser.classSymbolFull(Object)`. Java retains owner getter, virtual + owner `full()` and name getter order plus Java/Scala null string conversion. Scala keeps the inferred return type, + trait helper, case-class forwarders, path-dependent declarations, products and serialization shapes. +- Normal and clean validation pass 491 JVM tests, all 491 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,740 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-full-reference/`, including the reference/fixture jars, + frozen tests/resources, reports, logs and comparison tools. Frozen runs use its `version.txt`; final builds use the + committed version. Sources remain 224 Java files and nine Scala files / 744 nonblank lines. Next: + `MethodSymbol.full`, preserving owner/name concatenation, 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 7bf069e..2b1b989 100644 --- a/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala +++ b/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala @@ -49,7 +49,7 @@ class ScalaSignature(val bytes: Bytes) { def flags: Int def infoId: Int - def full = owner.full + "." + name + def full = ScalaSignatureParser.classSymbolFull(this) override def toString = ScalaSignatureParser.classSymbolString(this) def isObject = false diff --git a/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java b/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java index 13d5847..60fd999 100644 --- a/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java +++ b/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java @@ -77,6 +77,11 @@ final class ScalaSignatureParser { }, List$.MODULE$.canBuildFrom()); } + static String classSymbolFull(Object value) { + ScalaSignature.ClassSymbolRef symbol = (ScalaSignature.ClassSymbolRef) value; + return symbol.owner().full() + "." + symbol.name(); + } + static String classSymbolString(Object value) { ScalaSignature.ClassSymbolRef symbol = (ScalaSignature.ClassSymbolRef) value; return symbol.getClass().getName().replaceAll(".+\\$", "") + "("