From 4761336d7bfd576aafe23121ffd367f59cc84cba Mon Sep 17 00:00:00 2001 From: Algent Date: Tue, 1 Sep 2026 18:46:14 +0200 Subject: [PATCH] refactor: port Angelica compat to Java --- JAVA_MIGRATION.md | 7 ++++ JAVA_MIGRATION_DIVERGENCES.md | 34 ++++++++++++++++++ JAVA_MIGRATION_HANDOFF.md | 19 ++++++---- .../microblock/AngelicaCompat.java | 35 +++++++++++++++++++ .../microblock/AngelicaCompat.scala | 26 -------------- 5 files changed, 89 insertions(+), 32 deletions(-) create mode 100644 src/main/scala/codechicken/microblock/AngelicaCompat.java delete mode 100644 src/main/scala/codechicken/microblock/AngelicaCompat.scala diff --git a/JAVA_MIGRATION.md b/JAVA_MIGRATION.md index 11d86bc..ae74788 100644 --- a/JAVA_MIGRATION.md +++ b/JAVA_MIGRATION.md @@ -1113,3 +1113,10 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec - Added a dependent GitHub Actions job that accepts the EULA in its ephemeral runner and invokes the existing self-validating `runFunctionalTestServer` task after the shared GTNH build. The Forge suite now gates pull requests and pushes instead of being local-only. +- Characterized `AngelicaCompat` against untouched Scala. Two plain-JVM cases freeze its exact non-final public + surface, unusual `Object` return descriptors, `CapturingTessellator` guard, Iris calls and caught + `ClassCastException` fallback. +- Ported the sole class directly to Java while retaining `BoxedUnit.UNIT` on the normal path and `Unit$.MODULE$` on + the fallback path. Both jars contain the same runtime class and every callable descriptor matches the reference. +- A clean build passes all 230 plain-JVM tests and the Java 8 Forge server passes all 103 tests. + `microblock/ItemSaw.scala` is next. diff --git a/JAVA_MIGRATION_DIVERGENCES.md b/JAVA_MIGRATION_DIVERGENCES.md index 951ccce..675b4cf 100644 --- a/JAVA_MIGRATION_DIVERGENCES.md +++ b/JAVA_MIGRATION_DIVERGENCES.md @@ -2538,3 +2538,37 @@ and the downstream inventory contains no references to them. - Clean reference/port jars retain the same two supported types; the seven compiler artifacts above disappear, and raw `javap` comparison confirms identical callable public names/descriptors. - File parsing, registration and IMC behavior are automated; this port adds no new client-only manual check. + +## 2026-09-01 — AngelicaCompat Java port + +The optional Angelica shader-material adapter is now Java. + +### Observable behavior + +No known runtime divergence. Both methods still act only when `Tessellator.instance` is a +`CapturingTessellator`, call the matching Iris shader-material hook, and catch only `ClassCastException`. The public +methods deliberately continue to return `Object`: the normal path returns `BoxedUnit.UNIT`, while the caught fallback +returns `Unit$.MODULE$`, exactly as the Scala bytecode did. + +### ABI and reflection compatibility + +`AngelicaCompat` remains a public, non-final class with one public no-argument constructor, no fields or interfaces, +and exactly these two callable methods: + +- `setShaderMaterialOverride(Block, int): Object` +- `resetShaderMaterialOverride(): Object` + +The downstream inventory contains no reference to this class, so no frozen consumer fixture is needed. Accepted +classfile-only differences are the removed Scala signature/marker attributes and the Java source-file marker. + +### Compiler artifacts + +No runtime class is added or removed; both clean jars contain only `AngelicaCompat.class` for this source unit. + +### Validation + +- `AngelicaCompatCharacterizationTest`: 2 plain-JVM tests, unchanged from the Scala baseline. +- Clean complete plain-JVM suite: 230 tests, 0 failures, 0 errors. +- Java 8 Forge dedicated-server suite: 103 tests, 0 failures, 0 errors. +- Raw `javap` comparison confirms identical class modifiers, constructor and callable public names/descriptors. +- Live shader-material selection and reset with Angelica remain on the manual checklist. diff --git a/JAVA_MIGRATION_HANDOFF.md b/JAVA_MIGRATION_HANDOFF.md index 081f29e..5c8fb27 100644 --- a/JAVA_MIGRATION_HANDOFF.md +++ b/JAVA_MIGRATION_HANDOFF.md @@ -67,7 +67,7 @@ awk -F'"' '/ Unit - } - } - - def resetShaderMaterialOverride() = { - try { - if (Tessellator.instance.isInstanceOf[CapturingTessellator]) - Iris.resetShaderMaterialOverride() - } catch { - case ex: ClassCastException => Unit - } - } -}