refactor: drop unused IDWriter and JPartialOcclusion Scala bridges

The downstream ABI inventory scanned 240 mod jars in GTNH daily
2026-08-14+678 and found no consumer of either bridge. Both were written
speculatively, before the inventory existed.

IDWriter had no downstream reference at all, so its four Scala function
accessors are removed and the class now selects a carrier width directly.
That also removes the Integer boxing and Function1/Function2 allocation
per read and write that the first port had preserved. Calling write or
read before setMax now throws IllegalStateException rather than
NullPointerException; no caller reaches that state.

JPartialOcclusion$class had no downstream reference either. The two
consumers that touch JPartialOcclusion only call getPartialOcclusionBoxes,
and the two jars that implement the interface emit no call to the helper.
The interface and both of its method descriptors are unchanged. The
ReferenceScalaPartialOcclusion fixture is removed with the helper it
existed to verify.

Validated with 27 plain-JVM tests, a clean checkstyleTest build with
Spotless re-enabled, and the Java 8 Forge dedicated-server suite.
This commit is contained in:
Algent committed 2026-08-14 19:52:28 +02:00
1 parent 78959e70e9
commit 246dafffda
9 files changed
+99 -157

No files matched your search

@@ -2,6 +2,7 @@ package codechicken.multipart;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -9,6 +10,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.lang.reflect.Proxy;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
@@ -36,7 +38,7 @@ class IDWriterCharacterizationTest {
private static byte[] encode(IDWriter writer, int value) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
MCDataOutput output = new MCDataOutputWrapper(new DataOutputStream(bytes));
writer.write().apply(output, value);
writer.write(output, value);
return bytes.toByteArray();
}
@@ -58,11 +60,19 @@ class IDWriterCharacterizationTest {
}
});
int value = (Integer) writer.read().apply(input);
int value = writer.read(input);
assertEquals(0, data.available(), "The selected reader must consume its whole carrier");
return value;
}
@Test
void rejectsUseBeforeSetMax() {
IDWriter writer = new IDWriter();
assertThrows(IllegalStateException.class, () -> writer.write(null, 0));
assertThrows(IllegalStateException.class, () -> writer.read(null));
}
private static byte[] hex(String value) {
String[] octets = value.split(" ");
byte[] bytes = new byte[octets.length];
@@ -1,47 +0,0 @@
package codechicken.multipart;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Objects;
import java.util.Scanner;
import org.junit.jupiter.api.Test;
class JPartialOcclusionBinaryCompatibilityTest {
@Test
void loadsScalaImplementorCompiledAgainstReferenceJar() throws Exception {
byte[] bytecode = loadFixture();
Class<?> fixtureClass = new FixtureClassLoader(JPartialOcclusion.class.getClassLoader()).define(bytecode);
Object fixture = fixtureClass.getDeclaredConstructor().newInstance();
assertTrue(fixture instanceof JPartialOcclusion);
JPartialOcclusion part = (JPartialOcclusion) fixture;
assertFalse(part.allowCompleteOcclusion());
assertFalse(part.getPartialOcclusionBoxes().iterator().hasNext());
}
private static byte[] loadFixture() {
InputStream input = Objects.requireNonNull(
JPartialOcclusionBinaryCompatibilityTest.class
.getResourceAsStream("/compat/ReferenceScalaPartialOcclusion.class.b64"));
try (Scanner scanner = new Scanner(input, StandardCharsets.US_ASCII.name()).useDelimiter("\\A")) {
return Base64.getMimeDecoder().decode(scanner.next());
}
}
private static final class FixtureClassLoader extends ClassLoader {
private FixtureClassLoader(ClassLoader parent) {
super(parent);
}
private Class<?> define(byte[] bytecode) {
return defineClass(null, bytecode, 0, bytecode.length);
}
}
}