refactor: port FieldMixin accessor names to Java

This commit is contained in:
Algent committed 2026-09-04 17:49:02 +02:00
1 parent ddeed2719a
commit ab5dc8af95
5 files changed
+56 -20

No files matched your search

+3 -2
View File
@@ -27,8 +27,9 @@ Work continues on `algent/java`. The low-coupling queue, core part/tile types, r
placement/render helpers, both generators and all built-in tile traits are Java. Common, face, corner, edge, post,
hollow and occlusion microblock traits retain Scala inheritance/state/super declarations over Java behavior,
including client bounds/mask updates. `StackAnalyser` initialization and constant-type classification delegate to
Java; retain its coordinated Scala class/companion/models. The next bounded candidate is
`ASMMixinCompiler.FieldMixin.accessName`, with characterization before extraction.
Java; retain its coordinated Scala class/companion/models. `FieldMixin.accessName` also delegates to Java while
retaining its case class. The next bounded candidate is `ASMMixinCompiler.MixinInfo.linearise`, 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.
+18 -14
View File
@@ -16,33 +16,33 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes
## Current state and next target
**415 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java
files and 9 Scala files / 767 nonblank Scala lines**. The packaged inventory has 444 classes.
**422 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java
files and 9 Scala files / 765 nonblank Scala lines**. The packaged inventory has 444 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: `StackAnalyser.Const.getType` delegates to `StackAnalyserLogic.constType`.
Eight characterization tests were committed first as `89f31e3`. They pin every boxed primitive, fresh null/String
types, unsupported values, repeated virtual `c` access and accessor/formatting failures. Success reads `c` once;
failure rereads it for the message without reclassifying the second value. Scala retains the complete case class,
companion, product/copy methods and serialization shape. All 415 frozen JVM consumers pass; checks preserve 443
retained class/member APIs, all 17 ScalaSignature payloads, 3,731 unrelated method bodies and all 116 generated
dumps. Only the package-private helper method and its private string-concatenation helper are added.
Evidence: `run/migration-stack-const-reference/`.
Latest bounded target: `ASMMixinCompiler.FieldMixin.accessName` delegates to `MixinClassGenerator.fieldAccessName`.
Seven characterization tests were committed first as `ddeed27`. They pin private-bit selection, literal owner/name
mangling, null handling, virtual accessor order and failures. The private branch transforms the owner before reading
the name; the other branch ignores the owner and returns the name directly. Scala retains the complete case class,
companion, inferred return type, product/copy methods and serialization shape. All 422 frozen JVM consumers pass;
checks preserve 443 retained class/member APIs, all 17 ScalaSignature payloads, 3,733 unrelated method bodies and all
116 generated dumps. Only one package-private Java helper method is added.
Evidence: `run/migration-field-access-reference/`.
**Next bounded candidate: `ASMMixinCompiler.FieldMixin.accessName`.** Characterize private-flag selection, owner
mangling, null handling and virtual accessor/failure ordering before extracting its body to an existing Java helper.
**Next bounded candidate: `ASMMixinCompiler.MixinInfo.linearise`.** Characterize recursive parent order, repeated
and diamond parents, virtual collection/parent dispatch and null/failure behavior before extracting its body.
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
generation, GPU output and full-pack checks remain manual.
The JVM Downgrader checkpoint now supports Java 21 method-body syntax in `StackAnalyserLogic` while retaining
Scala 2.11.5 on Java 8. The constant-type extraction uses that existing build stage; it adds no build configuration
or runtime dependencies. See `JVM_DOWNGRADER_HANDOFF.md` for the original 398-test integration checkpoint.
Scala 2.11.5 on Java 8. The field-name extraction stays in ordinary Java 8 joint compilation and adds no build
configuration or runtime dependencies. See `JVM_DOWNGRADER_HANDOFF.md` for the original 398-test integration checkpoint.
Finish the remaining useful behavior extractions and define the retained compilation boundary before a broad
modern-syntax pass. Removing every remaining Scala declaration still requires the documented consumer/ABI work.
@@ -227,6 +227,10 @@ three options: leave it in Scala, invent a Java type to hold its members, or inl
Scala either way; it is a method on `RenderBlocks` and Java needs the parentheses. It fails at compile time rather than
silently, but expect it in every remaining renderer conversion.
**Preserve inferred Scala return types.** Adding `: String` to `FieldMixin.accessName` changes its ScalaSignature
payload despite preserving the JVM descriptor. Let the Java delegate's return type remain inferred and compare the
metadata as well as callable signatures.
**Java 8 target.** Joint main sources and tests cannot use `List.of`, `var` or switch expressions. The scoped
`StackAnalyserLogic` stage supports verified Java 21 method bodies; its packaged output must still target Java 8.
+28
View File
@@ -1366,3 +1366,31 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m
- Sources now total 224 Java files and nine Scala files / 767 nonblank lines. The next bounded candidate is
`ASMMixinCompiler.FieldMixin.accessName`: characterize private-flag selection, owner mangling, null behavior and
virtual accessor/failure ordering while retaining the case-class model.
### 2026-09-04 — FieldMixin accessor names
- Committed seven JVM characterization cases first as `ddeed27`, against the untouched Scala `accessName` body.
They cover every access-flag bit and combinations, literal slash-to-dollar owner mangling, unchanged field names,
null owner/name behavior, virtual `access` then `name` reads, unused descriptors and unwrapped accessor failures.
Private fields process the owner before reading the name; a null private owner therefore fails between the two
reads. Non-private fields ignore the owner and return the exact name reference, including null.
- Moved the body to `MixinClassGenerator.fieldAccessName`, retaining virtual accessor calls and evaluation order.
The existing Java 8 joint-compilation path handles this helper; no modern-Java build change or dependency is
needed. Scala retains the complete case class, companion, product/copy methods and serialization shape. Its
return type remains inferred: an explicit Scala `String` annotation changes the ScalaSignature payload even
though the JVM descriptor stays the same.
- Normal and clean builds pass formatting/checkstyle, 422 JVM tests, all 422 frozen compiled JVM consumers, and
237 Java 8 Forge tests, with zero failures/errors/skips. The clean run follows a Gradle daemon stop. All 116
generated ASM dump names and hashes match, including Java/Scala trait registration and generated field access.
Dev/release jars contain 444 Java 8 classes and packaged edited sources match the source jar.
- Preserved all 443 retained class/member APIs, all 17 ScalaSignature payloads and 3,733 unrelated method bodies.
The Java helper retains every previous member and adds only the package-private `fieldAccessName` method.
No class is added or removed and no new effective divergence is introduced. The consumer source scan found no
direct `FieldMixin` or `accessName` references; generated trait behavior remains the integration contract.
- Evidence is saved under ignored `run/migration-field-access-reference/`: baseline jar/sources, frozen compiled
tests/resources, reports, generated dumps, logs, `Compare.java`, `VerifyVersions.java` and `verify.py`.
Use `frozen-consumers.gradle` and `VERSION` from `version.txt` for the frozen lane because two existing tests
inline the original version. Ordinary final builds use the actual Git version.
- Sources remain 224 Java files and nine Scala files / 765 nonblank lines. Next candidate:
`ASMMixinCompiler.MixinInfo.linearise`, with characterization of recursive parent order, repeated/diamond parents,
virtual collection/parent dispatch and null/failure behavior before extraction.
@@ -41,10 +41,8 @@ object ASMMixinCompiler {
def getMixinInfo(name: String) = mixinMap.get(name)
case class FieldMixin(name: String, desc: String, access: Int) {
def accessName(owner: String) = if ((access & ACC_PRIVATE) != 0)
owner.replace('/', '$') + "$$" + name
else
name
def accessName(owner: String) =
MixinClassGenerator.fieldAccessName(this, owner)
}
case class MixinInfo(
@@ -39,6 +39,11 @@ final class MixinClassGenerator {
private MixinClassGenerator() {}
static String fieldAccessName(FieldMixin field, String owner) {
if ((field.access() & ACC_PRIVATE) != 0) return owner.replace('/', '$') + "$$" + field.name();
return field.name();
}
static Class<?> mixinClasses(String name, String superClass, Seq<String> traits, Map<String, MixinInfo> mixins,
Function1<ClassInfo, Iterable<ClassInfo>> parents) throws ClassNotFoundException {
ASMMixinCompiler$ compiler = ASMMixinCompiler$.MODULE$;