From 0de728345a88ed2d5db27c1a5e63f3557e1b6aec Mon Sep 17 00:00:00 2001 From: Algent Date: Fri, 14 Aug 2026 21:30:14 +0200 Subject: [PATCH] refactor: port TEdgePart to Java Replaces TEdgePart.scala with a Java interface and retains the TEdgePart$class bridge for OpenComputers. The interface is descriptor-identical to the reference, the bridge adds only a private constructor, and the emitted class-file set for this area is unchanged. TMultiPart does not declare conductsRedstone and neither does anything in the microblock superclass chain, so it becomes a real default method and no in-repo Scala needed changing. The generated microblock classes now resolve the interface default instead of a Scala trait forwarder, which the functional generation case added during the TFacePart port covers. conductsRedstone is kept on the bridge even though OpenComputers only links against $init$, since the bridge class is being kept regardless. Validated with 61 plain-JVM tests, a clean build, and the Java 8 Forge dedicated-server suite. --- JAVA_MIGRATION_DIVERGENCES.md | 32 +++++++++++++++++++ .../multipart/TEdgePart$class.java | 17 ++++++++++ .../codechicken/multipart/TEdgePart.java | 14 ++++++++ .../codechicken/multipart/TEdgePart.scala | 11 ------- 4 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 src/main/scala/codechicken/multipart/TEdgePart$class.java create mode 100644 src/main/scala/codechicken/multipart/TEdgePart.java delete mode 100644 src/main/scala/codechicken/multipart/TEdgePart.scala diff --git a/JAVA_MIGRATION_DIVERGENCES.md b/JAVA_MIGRATION_DIVERGENCES.md index c9a197f..b28d5ec 100644 --- a/JAVA_MIGRATION_DIVERGENCES.md +++ b/JAVA_MIGRATION_DIVERGENCES.md @@ -411,3 +411,35 @@ private static method rather than a closure class in both versions. - Clean `spotlessApply checkstyleTest build`: passing. - Java 8 Forge dedicated-server suite: 3 tests, 0 failures, 0 errors. - Real placement into a world needs a client or a server scenario and stays on the functional and manual layers. + +## 2026-08-14 — TEdgePart Java port + +### Observable behavior + +No known divergence. `conductsRedstone` still returns false and `TEdgePart` still extends `TSlottedPart`. + +### Default method, same test as TFacePart + +`TMultiPart` does not declare `conductsRedstone`, and nothing in the microblock superclass chain does either, so the +member is emitted as a real Java `default`. `EdgeMicroblock` never declared its own forwarder even in the reference, +because it is a Scala trait rather than a concrete class, and the generated concrete classes now resolve the interface +default instead of a Scala trait forwarder. The functional microblock generation case added during the `TFacePart` +port already covers that resolution path. + +No in-repo Scala needed changing. + +### Supported JVM API + +- `TEdgePart` is descriptor-identical to the reference. +- `TEdgePart$class` keeps both statics and adds only a private constructor. OpenComputers links against `$init$` only, + but `conductsRedstone` is retained because the bridge class is being kept regardless and dropping one static from a + live bridge would be a gratuitous shape change. +- The emitted class-file set for this area is unchanged; the Scala implementation generated no closure classes here. + +### Validation + +- `EdgePartCharacterizationTest`: 3 tests, 0 failures, 0 errors, unchanged from the Scala baseline. +- `TEdgePartBinaryCompatibilityTest`: 1 test, 0 failures, 0 errors. +- Complete plain-JVM suite: 61 tests, 0 failures, 0 errors. +- Clean `spotlessApply checkstyleTest build`: passing. +- Java 8 Forge dedicated-server suite: 3 tests, 0 failures, 0 errors. diff --git a/src/main/scala/codechicken/multipart/TEdgePart$class.java b/src/main/scala/codechicken/multipart/TEdgePart$class.java new file mode 100644 index 0000000..1ffb403 --- /dev/null +++ b/src/main/scala/codechicken/multipart/TEdgePart$class.java @@ -0,0 +1,17 @@ +package codechicken.multipart; + +/** + * Binary bridge for Scala implementations compiled against the original trait. Their forwarders call these statics + * directly, so the body cannot delegate back to the instance method without recursing. + */ +@Deprecated +public abstract class TEdgePart$class { + + private TEdgePart$class() {} + + public static boolean conductsRedstone(TEdgePart part) { + return false; + } + + public static void $init$(TEdgePart part) {} +} diff --git a/src/main/scala/codechicken/multipart/TEdgePart.java b/src/main/scala/codechicken/multipart/TEdgePart.java new file mode 100644 index 0000000..7f39db6 --- /dev/null +++ b/src/main/scala/codechicken/multipart/TEdgePart.java @@ -0,0 +1,14 @@ +package codechicken.multipart; + +/** + * Interface which must be implemented by parts that go in an edge slot. + *

+ * TMultiPart does not declare conductsRedstone, so it can safely be a default method. + */ +public interface TEdgePart extends TSlottedPart { + + /** Return true if this part can conduct redstone signal or let redstone signal pass through it. */ + default boolean conductsRedstone() { + return false; + } +} diff --git a/src/main/scala/codechicken/multipart/TEdgePart.scala b/src/main/scala/codechicken/multipart/TEdgePart.scala deleted file mode 100644 index 6f81250..0000000 --- a/src/main/scala/codechicken/multipart/TEdgePart.scala +++ /dev/null @@ -1,11 +0,0 @@ -package codechicken.multipart - -/** Interface which must be implemented by parts that go in an edge slot. - */ -trait TEdgePart extends TSlottedPart { - - /** Return true if this part can conduct redstone signal or let redstone - * signal pass through it. - */ - def conductsRedstone = false -}