diff --git a/JAVA_MIGRATION.md b/JAVA_MIGRATION.md index a9b5282..069d988 100644 --- a/JAVA_MIGRATION.md +++ b/JAVA_MIGRATION.md @@ -744,3 +744,14 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec callback classes. No frozen binary or audited source consumer names those implementation classes. - All 156 plain-JVM tests and all 79 Java 8 Forge dedicated-server tests pass. This initialization-only hook is not a meaningful target for the focused allocation benchmark; successful MCPC integration remains environment-dependent. +- Characterized `MultipartMod` against untouched Scala. Two plain-JVM cases freeze both annotated singleton types, + all ten lifecycle methods and annotations, plus the `MultipartPH.channel` companion descriptor and identity; two + Forge cases freeze FML's companion mod instance, completed initialization and server-stop cleanup. +- Ported the singleton to an annotated Java facade/companion pair while retaining `modLanguage = "scala"`. The one + source use of the object as a value now names `MultipartMod$.MODULE$` explicitly, leaving the compiled packet-handler + field and accessor unchanged. +- Found that the inherited `MultipartProxy.postInit` static forwarder carries `@SideOnly(CLIENT)` and is stripped on a + dedicated server. The Java companion therefore invokes `MultipartProxy$.MODULE$` directly, matching the reference + Scala bytecode and allowing virtual resolution to reach the server implementation. +- All 158 plain-JVM tests and all 81 Java 8 Forge dedicated-server tests pass. Mod lifecycle dispatch is startup-only, + so it is not a meaningful focused throughput or allocation target. diff --git a/JAVA_MIGRATION_DIVERGENCES.md b/JAVA_MIGRATION_DIVERGENCES.md index 17a63e8..9f64173 100644 --- a/JAVA_MIGRATION_DIVERGENCES.md +++ b/JAVA_MIGRATION_DIVERGENCES.md @@ -1786,3 +1786,46 @@ closure implementation details with no consumer reference. The four public facad - Raw `javap` comparison confirms identical public names and descriptors for all four public types. - The successful reflective path requires an MCPC-patched `World` and remains an environment-specific integration check; the stock development server covers its failure fallback only. + +## 2026-08-30 — MultipartMod Java port + +The ForgeMultipart FML entry point is now an annotated Java facade/companion pair. It deliberately remains a +`modLanguage = "scala"` mod: FML's Scala language adapter loads `MultipartMod$.MODULE$`, which is also the identity +CodeChickenLib uses for the multipart packet channel. + +### Observable behavior + +No known runtime divergence. Pre-initialization still passes the event's configuration directory and logger to the +proxy; initialization still delegates directly; post-initialization still finalizes the registry and proxy only when +multipart registration is required; server startup still rebuilds the part ID map; and server shutdown still clears +the loading-world reference and control-key map. + +The proxy calls use `MultipartProxy$.MODULE$`, matching the original Scala bytecode. This is required on a dedicated +server: the raw `MultipartProxy.postInit()` static forwarder inherits `@SideOnly(CLIENT)` from the client override and +Forge strips it. Calling that facade from common Java compiles but fails at runtime with `NoSuchMethodError`; companion +dispatch survives stripping and resolves to the server superclass method. + +### ABI, annotations and source compatibility + +`MultipartMod` retains the exact five public static event methods. `MultipartMod$` retains `MODULE$` and the matching +five public instance methods. Both classes still carry the same `@Mod` values, and every method still carries +`@Mod.EventHandler`. Public names and descriptors are identical to the reference. + +The in-repo Scala expression `val channel = MultipartMod` becomes `MultipartMod$.MODULE$`. The compiled +`MultipartPH.channel` field and accessor remain typed as `MultipartMod$`, so packet identity and binary compatibility +are unchanged. No frozen external consumer names either mod class. + +Accepted divergence: the Scala signature/marker attributes disappear, and the static Java facade gains only a private +constructor. These do not change the runtime annotation data or callable public surface. The emitted class list remains +exactly `MultipartMod.class` and `MultipartMod$.class`. + +### Validation + +- `MultipartModCharacterizationTest`: 2 plain-JVM tests, unchanged from the Scala baseline. +- `MultipartModFunctionalTest`: 2 Forge tests, unchanged from the Scala baseline. +- Complete plain-JVM suite: 158 tests, 0 failures, 0 errors. +- Java 8 Forge dedicated-server suite: 81 tests, 0 failures, 0 errors. +- The Forge run loads all nine mods, identifies `MultipartMod$.MODULE$` as the ForgeMultipart instance, completes every + startup phase, reaches server-started tests, and shuts down cleanly. +- Raw `javap` comparison confirms identical public names/descriptors for `MultipartMod`, `MultipartMod$` and + `MultipartPH`; reflection confirms identical FML annotations. diff --git a/JAVA_MIGRATION_HANDOFF.md b/JAVA_MIGRATION_HANDOFF.md index 6219cf3..a36fae0 100644 --- a/JAVA_MIGRATION_HANDOFF.md +++ b/JAVA_MIGRATION_HANDOFF.md @@ -12,8 +12,8 @@ what breaks, and what is left. The other documents hold the reasoning. | `JAVA_MIGRATION_MANUAL_CHECKS.md` | What no automated test can cover, and must be checked by hand in a client | | `JAVA_MIGRATION_PROFILE.md` | The focused baseline, first measured result, findings, and exact rerun command | -Branch: `algent/java`. Base: `master`. 87 commits including separate characterization and port commits for -`MultipartCompatiblity`/`MCPCCompatModule`. +Branch: `algent/java`. Base: `master`. 89 commits including separate characterization and port commits for +`MultipartMod`. ## The one rule that matters @@ -67,7 +67,7 @@ awk -F'"' '/