diff --git a/JAVA_MIGRATION.md b/JAVA_MIGRATION.md index c1831d1..0f94bb9 100644 --- a/JAVA_MIGRATION.md +++ b/JAVA_MIGRATION.md @@ -30,8 +30,9 @@ including client bounds/mask updates. `StackAnalyser` initialization and constan Java; retain its coordinated Scala class/companion/models. `FieldMixin.accessName` also delegates to Java while 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. The next bounded candidate is -`ScalaSignature.ClassSymbolRef.jInterfaces`, with characterization before extraction. +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. 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 4271425..ea7cc3f 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 -**456 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java +**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. Review follow-up: restored packet-scheduler callback mutation behavior with the original Scala hash-map traversal, @@ -24,17 +24,17 @@ 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.TMethodType.jDesc` delegates to `ScalaSignatureParser.methodDescriptor`. -Seven characterization tests were committed first as `d61aed2`. They pin literal descriptor assembly, ordered -parameter info/return-type reads, repeated queries, nulls, getter failures and the static trait helper. The Java -callback retains Scala collection mapping and finishes parameters before reading the method return type. -All 456 frozen JVM consumers pass; checks preserve 441 retained class/member APIs, all 17 ScalaSignature payloads, -3,732 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-method-descriptor-reference/`. -The preceding `TypeRef.jDesc` extraction is recorded in history and `run/migration-type-descriptor-reference/`. +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`. -**Next bounded candidate: `ScalaSignature.ClassSymbolRef.jInterfaces`.** Characterize virtual info/interface -lookup, ordered jName mapping, empty/null cases and failure order. Retain the trait/model declarations and List API. +**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. 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 3648069..39faade 100644 --- a/docs/migration/HISTORY.md +++ b/docs/migration/HISTORY.md @@ -1497,3 +1497,26 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m 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.jInterfaces`, retaining its List contract, virtual lookup, ordered mapping and failure behavior. + +### 2026-09-04 — ScalaSignature interface names + +- Committed seven JVM characterization cases first as `6ccb83f` against the untouched `ClassSymbolRef.jInterfaces`. + They pin ClassSymbol/ObjectSymbol parent exclusion, ordered names and duplicates, the empty List singleton, + string identity and null names, repeated queries, virtual info/interfaces/jName dispatch and failure boundaries. + A proxy also exercises the exact static trait-helper descriptor without an outer instance. +- Added `ReferenceScalaInterfaceNames`, compiled once with Scala 2.11.5 under Java 8 against the unchanged dev jar + at `240a788`. Its Scala caller and ClassSymbol/ClassType subclasses prove compatibility with old bytecode and + overridden path-dependent methods. 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 the mapping into `ScalaSignatureParser.interfaceNames(Object)`. The Java callback retains virtual + lookup and Scala List map/builder behavior, using the existing TraversableLike bridge pattern. The helper returns + `List`; Scala retains inferred types, trait/model declarations, forwarders and serialization shapes. +- Normal and clean validation pass 463 JVM tests, 463 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 441 retained class/member APIs, all 17 ScalaSignature payloads and 3,733 unrelated method + bodies. The sole inventory replacement is `ClassSymbolRef$$anonfun$jInterfaces$1` with `ScalaSignatureParser$2`, + covered by the existing unreferenced compiler-artifact ledger entry. No new effective divergence is introduced. +- Evidence is under ignored `run/migration-interface-names-reference/`, including the fixture/reference jars, + 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. diff --git a/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala b/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala index 18ccde7..88af3df 100644 --- a/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala +++ b/src/main/scala/codechicken/multipart/asm/ScalaSignature.scala @@ -56,7 +56,7 @@ class ScalaSignature(val bytes: Bytes) { def isObject = false def info: ClassType = evalT(infoId) def jParent = info.parent.jName - def jInterfaces = info.interfaces.map(_.jName) + def jInterfaces = ScalaSignatureParser.interfaceNames(this) } case class ClassSymbol( diff --git a/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java b/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java index 0771bc0..653f10a 100644 --- a/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java +++ b/src/main/scala/codechicken/multipart/asm/ScalaSignatureParser.java @@ -58,6 +58,19 @@ final class ScalaSignatureParser { return "(" + parameters.mkString() + ")" + method.returnType().jDesc(); } + @SuppressWarnings({ "unchecked", "rawtypes" }) + static List interfaceNames(Object value) { + ScalaSignature.ClassSymbolRef symbol = (ScalaSignature.ClassSymbolRef) value; + return (List) ((TraversableLike) symbol.info().interfaces()) + .map(new AbstractFunction1() { + + @Override + public String apply(ScalaSignature.TypeRef ref) { + return ref.jName(); + } + }, List$.MODULE$.canBuildFrom()); + } + static byte[] section(Bytes bytes) { byte[] array = bytes.arr(); int start = bytes.pos();