mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-21 12:42:51 +00:00
refactor: port StackAnalyser constant types to Java
This commit is contained in:
1 parent
89f31e3565
commit
8671b0d185
5 files changed
+62
-29
No files matched your search
+3
-2
@@ -26,8 +26,9 @@ No trustworthy tool will produce a maintainable Java port automatically. A decom
|
||||
Work continues on `algent/java`. The low-coupling queue, core part/tile types, registries, handlers, factories,
|
||||
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. The next bounded target is `StackAnalyser` constructor initialization;
|
||||
retain the coordinated Scala class/companion/models and characterize initialization before extraction.
|
||||
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-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.
|
||||
|
||||
+15
-14
@@ -16,32 +16,32 @@ migration checkout; `codex/tile-compatibility-fixes` was deleted after its fixes
|
||||
|
||||
## Current state and next target
|
||||
|
||||
**407 plain-JVM tests and 237 Java 8 Forge tests pass, with zero failures/errors/skips.** Sources total **224 Java
|
||||
files and 9 Scala files / 779 nonblank Scala lines**. The packaged inventory has 444 classes.
|
||||
**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.
|
||||
|
||||
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` delegates constructor control flow to `StackAnalyserLogic.initialize`.
|
||||
Nine characterization tests were committed first as `929a704`. They pin constructor argument use, virtual
|
||||
`pushL`/`setL` ordering, descriptor mutation/parsing failures, wide slots, partial publication and handler behavior.
|
||||
Scala retains the class/companion/models, field initialization, default-argument bridges and a handler callback
|
||||
that preserves its mangled virtual map accessor. Handler traversal retains Scala-backed buffers' `foreach` dispatch.
|
||||
All 407 frozen JVM consumers pass; checks preserve 443 retained class/member APIs, all 17 ScalaSignature payloads,
|
||||
3,727 unrelated method bodies and all 116 generated dumps. The obsolete parameter-loop closure disappears;
|
||||
the handler callback changes only its compiler number. Evidence: `run/migration-stack-initialization-reference/`.
|
||||
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/`.
|
||||
|
||||
**Next bounded candidate: `StackAnalyser.Const.getType`.** Characterize boxed constant classification, null/String
|
||||
handling, unsupported-value formatting/failure and virtual `c` access before extracting to the existing helper.
|
||||
**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.
|
||||
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 constructor extraction uses that existing build stage; it adds no build configuration
|
||||
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.
|
||||
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,7 +227,8 @@ 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.
|
||||
|
||||
**Java 8 target.** No `List.of`, no `var`, no switch expressions in main or test sources.
|
||||
**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.
|
||||
|
||||
**Two test classes sharing global registry state** must guard their registrations, and the registries' error paths call
|
||||
a logger that is null until `preInit`, so they cannot run headless at all.
|
||||
|
||||
@@ -1339,3 +1339,30 @@ differences belong in the [divergence ledger](../../JAVA_MIGRATION_DIVERGENCES.m
|
||||
Scala files / 779 nonblank lines. Next bounded candidate: `StackAnalyser.Const.getType`, preserving its
|
||||
case-class, product and serialization contracts. The simple model getters and full Scala shell replacement
|
||||
remain separate from useful behavior extraction.
|
||||
|
||||
### 2026-09-04 — StackAnalyser constant types
|
||||
|
||||
- Committed eight JVM characterization cases first as `89f31e3`, against the untouched Scala `Const.getType`.
|
||||
They cover all eight boxed primitive classes without numeric coercion, fresh object types for null and strings,
|
||||
unsupported numbers/ASM types/unit/arrays/string-like objects, virtual accessor read counts, message formatting
|
||||
and unwrapped accessor/formatting failures. The unsupported branch reads `c` a second time for its message;
|
||||
even a supported second value is formatted without reclassification. A null-returning `toString` prints `null`.
|
||||
- Extracted classification into the existing package-private `StackAnalyserLogic.constType`, using direct type
|
||||
checks and a second virtual accessor call only for failures. Scala retains the entire case class, companion,
|
||||
product/copy methods and serialization shape. The scoped modern Java build is reused without configuration or
|
||||
dependency changes; the only extra compiler method handles the failure string concatenation.
|
||||
- The build, formatting, checkstyle, frozen-consumer lane and Java 8 Forge tests pass, including verification from
|
||||
a clean build after stopping the Gradle daemon: 415 JVM tests, 415 frozen JVM consumers and 237 Forge tests, with
|
||||
zero failures/errors/skips. All 116 generated ASM dump names and hashes match. Both jars contain 444 Java 8
|
||||
classes, their five `@Mod` versions match their filenames, and both edited sources match the source jar.
|
||||
- Preserved all 443 retained class/member APIs, all 17 ScalaSignature payloads and 3,731 unrelated method bodies.
|
||||
The helper retains every previous member and adds only `constType` and its private synthetic concatenation
|
||||
method. No class is added or removed, no JVM Downgrader runtime-stub reference is introduced, and there is no new
|
||||
effective compatibility divergence. The consumer source scan found no direct `StackAnalyser` references.
|
||||
- Baseline jar/sources, frozen compiled tests/resources, JVM/Forge reports, generated dumps, comparison tools and
|
||||
build logs are saved under ignored `run/migration-stack-const-reference/`. Rerun `frozen-consumers.gradle` with
|
||||
`VERSION` from `version.txt` to preserve the two existing frozen tests' inlined version assertions; ordinary final
|
||||
builds still use the actual Git version. `verify.py`, `Compare.java` and `VerifyVersions.java` check the artifacts.
|
||||
- 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.
|
||||
@@ -29,19 +29,7 @@ object StackAnalyser {
|
||||
}
|
||||
|
||||
case class Const(c: Any)(implicit insn: AbstractInsnNode) extends StackEntry {
|
||||
def getType = c match {
|
||||
case o: Byte => BYTE_TYPE
|
||||
case o: Short => SHORT_TYPE
|
||||
case o: Int => INT_TYPE
|
||||
case o: Long => LONG_TYPE
|
||||
case o: Float => FLOAT_TYPE
|
||||
case o: Double => DOUBLE_TYPE
|
||||
case o: Char => CHAR_TYPE
|
||||
case o: Boolean => BOOLEAN_TYPE
|
||||
case o: String => getObjectType("java/lang/String")
|
||||
case null => getObjectType("java/lang/Object")
|
||||
case _ => throw new IllegalArgumentException("Unknown const " + c)
|
||||
}
|
||||
def getType: Type = StackAnalyserLogic.constType(this)
|
||||
}
|
||||
case class Load(e: LocalEntry)(implicit insn: AbstractInsnNode)
|
||||
extends StackEntry {
|
||||
|
||||
@@ -54,6 +54,22 @@ final class StackAnalyserLogic {
|
||||
|
||||
private StackAnalyserLogic() {}
|
||||
|
||||
static Type constType(Const constant) {
|
||||
Object value = constant.c();
|
||||
if (value instanceof Byte) return BYTE_TYPE;
|
||||
if (value instanceof Short) return SHORT_TYPE;
|
||||
if (value instanceof Integer) return INT_TYPE;
|
||||
if (value instanceof Long) return LONG_TYPE;
|
||||
if (value instanceof Float) return FLOAT_TYPE;
|
||||
if (value instanceof Double) return DOUBLE_TYPE;
|
||||
if (value instanceof Character) return CHAR_TYPE;
|
||||
if (value instanceof Boolean) return BOOLEAN_TYPE;
|
||||
if (value instanceof String) return getObjectType("java/lang/String");
|
||||
if (value == null) return getObjectType("java/lang/Object");
|
||||
// The failure message rereads the virtual accessor after classification.
|
||||
throw new IllegalArgumentException("Unknown const " + constant.c());
|
||||
}
|
||||
|
||||
static void initialize(StackAnalyser a, Type owner, MethodNode method,
|
||||
Function1<TryCatchBlockNode, Option<TryCatchBlockNode>> addHandler) {
|
||||
if ((method.access & ACC_STATIC) == 0) a.pushL(new This(owner));
|
||||
|
||||
Reference in new issue
Block a user