refactor: port ScalaSignature method descriptors

This commit is contained in:
Algent committed 2026-09-04 19:25:12 +02:00
1 parent d61aed2cfe
commit 240a7889e7
5 files changed
+55 -16

No files matched your search

+3 -3
View File
@@ -29,9 +29,9 @@ hollow and occlusion microblock traits retain Scala inheritance/state/super decl
including client bounds/mask updates. `StackAnalyser` initialization and constant-type classification delegate to
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` and `TypeRef.jDesc` delegate normalization and descriptor conversion while
preserving virtual lookup. The next bounded candidate is `ScalaSignature.TMethodType.jDesc`, with characterization
before extraction.
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.
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.
+12 -10
View File
@@ -16,23 +16,25 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes
## Current state and next target
**449 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java
files and 9 Scala files / 751 nonblank Scala lines**. The packaged inventory has 443 classes.
**456 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,
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.TypeRef.jDesc` delegates to `ScalaSignatureParser.typeDescriptor`.
Seven characterization tests were committed first as `b3b3f10`. They pin primitive/array matches, unmatched names
(including the legacy Char descriptor), virtual name/jName lookup, repeated symbol reads, nulls, failures and the
static trait helper. TypeRefType's array override and SingleType's super shell remain Scala. All 449 frozen JVM
consumers pass; checks preserve 442 retained class/member APIs, all 17 ScalaSignature payloads, 3,734 unrelated
method bodies and all 116 generated dumps. Evidence: `run/migration-type-descriptor-reference/`.
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/`.
**Next bounded candidate: `ScalaSignature.TMethodType.jDesc`.** Characterize ordered parameter info/return-type
reads, descriptor concatenation, nulls, failures and the static trait helper before extracting method assembly.
**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.
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
+22
View File
@@ -1475,3 +1475,25 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m
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 / 751 nonblank lines. Next: `TMethodType.jDesc` assembly,
preserving parameter/return lookup order, nulls, failures and the retained trait/models.
### 2026-09-04 — ScalaSignature method descriptors
- Committed seven JVM characterization cases first as `d61aed2` against the untouched `TMethodType.jDesc`. They
cover MethodType/ParameterlessType assembly, ordered virtual parameter info/return-type/descriptor reads,
repeated parameters and queries, literal null/invalid descriptors, each getter failure and null-chain boundary,
plus the legacy static trait helper using an independent proxy. Parameter `jDesc` and nested `params` must not
be used; the method return type is read only after every parameter descriptor completes.
- Extracted assembly into `ScalaSignatureParser.methodDescriptor(Object)`. Its Java callback retains the original
Scala List builder, map and mkString semantics, using the existing TraversableLike bridge pattern to resolve
javac's ambiguous Scala List map overloads. Path-dependent models stay inside method bodies; Scala trait/model
declarations, forwarders, generic signatures and serialization shapes remain unchanged.
- Normal and clean validation pass 456 JVM tests, 456 frozen consumers and 237 Java 8 Forge tests with zero
failures/errors/skips. All 116 generated dumps match the reference; both jars contain 443 Java 8 classes and
matching packaged sources. Comparison preserves 441 retained class/member APIs, all 17 ScalaSignature payloads
and 3,732 unrelated method bodies. The sole inventory replacement is `TMethodType$$anonfun$jDesc$1` with
`ScalaSignatureParser$1`, covered by the existing unreferenced compiler-artifact ledger entry. The helper gains
one package-private method; no new effective divergence is introduced.
- Evidence is under ignored `run/migration-method-descriptor-reference/`, including the reference jar, 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.jInterfaces`,
retaining its List contract, virtual lookup, ordered mapping and failure behavior.
@@ -101,9 +101,7 @@ class ScalaSignature(val bytes: Bytes) {
}
trait TMethodType {
def jDesc = "(" + params
.map(m => m.info.returnType.jDesc)
.mkString + ")" + returnType.jDesc
def jDesc = ScalaSignatureParser.methodDescriptor(this)
def returnType: TypeRef
def params: List[MethodSymbol]
}
@@ -9,11 +9,14 @@ import scala.None$;
import scala.Option;
import scala.Some;
import scala.collection.Iterator;
import scala.collection.TraversableLike;
import scala.collection.TraversableOnce;
import scala.collection.immutable.IndexedSeq;
import scala.collection.immutable.IndexedSeq$;
import scala.collection.immutable.List;
import scala.collection.immutable.List$;
import scala.collection.mutable.Builder;
import scala.runtime.AbstractFunction1;
/** Parser implementation behind the retained Scala case-class and path-dependent API. */
final class ScalaSignatureParser {
@@ -41,6 +44,20 @@ final class ScalaSignatureParser {
return "L" + ref.jName() + ";";
}
@SuppressWarnings({ "unchecked", "rawtypes" })
static String methodDescriptor(Object value) {
ScalaSignature.TMethodType method = (ScalaSignature.TMethodType) value;
TraversableOnce<?> parameters = (TraversableOnce<?>) ((TraversableLike) method.params())
.map(new AbstractFunction1<ScalaSignature.MethodSymbol, String>() {
@Override
public String apply(ScalaSignature.MethodSymbol parameter) {
return parameter.info().returnType().jDesc();
}
}, List$.MODULE$.canBuildFrom());
return "(" + parameters.mkString() + ")" + method.returnType().jDesc();
}
static byte[] section(Bytes bytes) {
byte[] array = bytes.arr();
int start = bytes.pos();