mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-22 13:09:44 +00:00
refactor: port scratch bit set to Java
This commit is contained in:
1 parent
59edc66a91
commit
47a4700bee
6 files changed
+108
-29
No files matched your search
@@ -1221,3 +1221,12 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec
|
||||
- A clean build passes all 262 plain-JVM tests and the Java 8 Forge server passes all 116 tests. Both supported public
|
||||
surfaces match the reference. `multipart/asm/ScratchBitSet.scala` is the next isolated support target; the generated
|
||||
microblock traits still require the documented abstract-Java-mixin and side-only-member prerequisites.
|
||||
- Characterized `ScratchBitSet` against untouched Scala. Four plain-JVM cases freeze the exact interface/helper
|
||||
surface, lazy allocation, repeated accessor calls, owner/thread isolation, bit preservation/clearing, storage
|
||||
replacement/reinitialization and `freshBitSet` dispatch through an overridden `getBitSet`.
|
||||
- Ported the interface and `$class` helper directly to Java without changing either generator. All seven callable
|
||||
methods, their abstract/static modifiers and both binary names remain exact; no new API or default methods are
|
||||
introduced. Neither downstream audit contains a reference to this support trait.
|
||||
- A clean build passes all 266 plain-JVM tests and the Java 8 Forge server passes all 116 tests. The two-type ABI and
|
||||
both generator companions' disassembly match the reference. `multipart/asm/ByteCodecs.scala` is next as an isolated
|
||||
codec port, leaving signature parsing and trait compilation for separate targets.
|
||||
@@ -3093,3 +3093,42 @@ a `LinkedHashSet`; part iteration uses the existing Scala iterator without extra
|
||||
- Java 8 Forge dedicated-server suite: 116 tests, 0 failures, 0 errors.
|
||||
- Raw `javap` comparison confirms identical callable public names/descriptors and the expected six-closure removal.
|
||||
- Real client conversion packets/render rebinding and GuideNH/Schematica previews remain manual checkpoints.
|
||||
|
||||
## 2026-09-02 — Scratch bit-set Java port
|
||||
|
||||
`ScratchBitSet` and `ScratchBitSet$class` are now Java. The multipart and microblock generator companions continue
|
||||
using the same interface, storage accessors and helper calls without any source changes.
|
||||
|
||||
### Observable behavior
|
||||
|
||||
No known runtime divergence. Initialization installs a new ordinary `ThreadLocal` through the public setter; the
|
||||
first read on each thread lazily allocates a `BitSet`, and subsequent reads reuse it without clearing. Each owner and
|
||||
thread has independent storage. `freshBitSet` clears and returns the same set via the owner's virtual `getBitSet`,
|
||||
preserving overrides instead of directly calling the helper's implementation.
|
||||
|
||||
The lazy-allocation path still reads the storage accessor twice. Public setter replacement and repeated `$init$`
|
||||
calls still replace storage, without eagerly allocating a set or clearing the previous storage's contents.
|
||||
|
||||
### ABI and source compatibility
|
||||
|
||||
The interface retains its four abstract methods, including the exact mangled getter and raw `ThreadLocal` setter.
|
||||
The abstract helper class retains all three static methods and their descriptors. Neither type acquires fields,
|
||||
and both generator companions have unchanged `javap -p -c -s` output. Neither downstream audit identifies a direct
|
||||
consumer of this trait, so no new frozen Scala consumer is needed.
|
||||
|
||||
Accepted classfile differences are removed Scala marker/signature attributes and a private Java helper constructor
|
||||
(the original helper had no constructor). Recompiled Scala can no longer inherit implementations merely by mixing
|
||||
in this Java interface: it must implement the methods and initialize storage explicitly, as the existing Java
|
||||
generator companions do. Previously compiled helper calls retain their binary entry points.
|
||||
|
||||
### Compiler artifacts
|
||||
|
||||
None. The reference and port jars contain the same two `ScratchBitSet` classes.
|
||||
|
||||
### Validation
|
||||
|
||||
- `ScratchBitSetCharacterizationTest`: 4 plain-JVM tests, unchanged from the Scala baseline.
|
||||
- Clean complete plain-JVM suite: 266 tests, 0 failures, 0 errors.
|
||||
- Java 8 Forge dedicated-server suite: 116 tests, 0 failures, 0 errors, including both generator families.
|
||||
- Raw `javap` comparison confirms the same public names, descriptors, modifiers and class list.
|
||||
- No new manual checkpoint; existing generator/client integration checks remain on the checklist.
|
||||
@@ -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`. 150 commits including the API-cleanup plan and separate characterization and
|
||||
port commits through the multipart generator.
|
||||
Branch: `algent/java`. Base: `master`. 152 commits including the API-cleanup plan and separate characterization and
|
||||
port commits through the scratch bit-set helper.
|
||||
|
||||
## The one rule that matters
|
||||
|
||||
@@ -67,7 +67,7 @@ awk -F'"' '/<testsuite /{t+=$4;f+=$8;e+=$10} END{print "tests="t" failures="f" e
|
||||
grep -o 'tests="[0-9]*" skipped="[0-9]*" failures="[0-9]*" errors="[0-9]*"' run/server/junit-out/TEST-*.xml
|
||||
```
|
||||
|
||||
Current baseline: **262 plain-JVM tests and 116 Java 8 Forge dedicated-server tests passing.** The ignored local server
|
||||
Current baseline: **266 plain-JVM tests and 116 Java 8 Forge dedicated-server tests passing.** The ignored local server
|
||||
EULA is accepted in this checkout. GitHub Actions runs the same self-validating Forge suite in a dependent job after
|
||||
the shared GTNH build; keep both jobs required.
|
||||
|
||||
@@ -272,7 +272,7 @@ across the port. It is also where the two shim constraints in the gotchas list w
|
||||
`rayTraceAll`'s index production is now characterized, closing the gap the read-path cleanup left: the index written
|
||||
into `ExtendedMOP.data` is what `reduceMOP` hands back to every click, activate, harvest and pick block.
|
||||
|
||||
191 Java files, 14 Scala files, 2,588 Scala lines left (non-blank; that is the metric this figure has always used).
|
||||
193 Java files, 13 Scala files, 2,571 Scala lines left (non-blank; that is the metric this figure has always used).
|
||||
|
||||
## What is left, and in what order
|
||||
|
||||
@@ -527,7 +527,7 @@ trait/helper disassembly is bytecode-identical; only the private shrink traversa
|
||||
load-bearing static `MicroOcclusion.recalcBounds(JMicroShrinkRender, Cuboid6)` call remains exact.
|
||||
|
||||
The microblock generator is now a Java facade, companion and real nested material interface over the unchanged Scala
|
||||
`ASMMixinFactory` and `ScratchBitSet`. Three plain-JVM cases freeze all three runtime surfaces, scratch replacement
|
||||
`ASMMixinFactory` and the now-Java `ScratchBitSet`. Three plain-JVM cases freeze all three runtime surfaces, scratch replacement
|
||||
and clearing, and the load-bearing call opcodes. One Forge case covers the previously missing full path from an
|
||||
`IGeneratedMaterial` callback through registered external Scala-trait initialization and dispatch. The runtime class
|
||||
list and all callable public descriptors remain exact for ProjectRed and GuideNH.
|
||||
@@ -538,9 +538,15 @@ and failed registration, scratch clearing, registered-class snapshots, generated
|
||||
downgrades, vanilla torch conversion and a frozen Scala consumer. The generator compiler is unchanged: its callback
|
||||
merely spells `MultipartGenerator$.MODULE$` explicitly. Six private Scala closures disappear.
|
||||
|
||||
**Next: `multipart/asm/ScratchBitSet.scala`.** Both implementors are now Java, so this is a small, isolated support
|
||||
trait before the compiler work. Preserve its public mangled getter/setter and existing helper linkage, and freeze
|
||||
per-thread isolation, lazy allocation, clearing and setter replacement. Do not combine it with `ASMMixinFactory`.
|
||||
`ScratchBitSet` is now a Java interface and `$class` implementation helper. Its four abstract interface methods and
|
||||
three helper statics remain exact. Four plain-JVM cases freeze lazy allocation, owner/thread isolation, reuse,
|
||||
replacement/reinitialization and override dispatch. Neither generator needed a source change, and no emitted class
|
||||
disappears. The existing Forge generator fixtures remain green.
|
||||
|
||||
**Next: `multipart/asm/ByteCodecs.scala`.** This standalone byte codec can be characterized and ported without
|
||||
changing trait registration or the signature parser. Freeze golden byte vectors, all 7/8-bit remainder cases,
|
||||
zero escaping, in-place mutation, malformed-input behavior and the documented extra decoded padding byte before
|
||||
changing it. Keep its Scala-signature callers and the external Scala-trait Forge fixtures unchanged.
|
||||
The remaining generated microblock traits still need the Phase 7 abstract-Java-mixin and side-only-member support
|
||||
before their Java mixin inputs are safe; do not bypass those prerequisites by flattening their inheritance.
|
||||
|
||||
@@ -548,7 +554,7 @@ before their Java mixin inputs are safe; do not bypass those prerequisites by fl
|
||||
narrow generator relaxation: Java-trait parent linearization, explicit field-accessor recognition, and exclusion of
|
||||
transient runtime caches from generated copying.
|
||||
|
||||
**Phase 6/7, last.** The retained generated microblock traits and all of `multipart/asm/`.
|
||||
**Phase 6/7, last.** The retained generated microblock traits and the remaining Scala in `multipart/asm/`.
|
||||
Keep the ASM compiler last, apart from the prerequisite fixes needed by those traits; freeze generated-class fixtures
|
||||
before changing it.
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package codechicken.multipart.asm;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/** Shared implementation retaining the original Scala trait-helper entry points. */
|
||||
public abstract class ScratchBitSet$class {
|
||||
|
||||
private ScratchBitSet$class() {}
|
||||
|
||||
public static BitSet getBitSet(ScratchBitSet owner) {
|
||||
BitSet bitset = owner.codechicken$multipart$asm$ScratchBitSet$$bitSets().get();
|
||||
if (bitset == null) {
|
||||
bitset = new BitSet();
|
||||
owner.codechicken$multipart$asm$ScratchBitSet$$bitSets().set(bitset);
|
||||
}
|
||||
return bitset;
|
||||
}
|
||||
|
||||
public static BitSet freshBitSet(ScratchBitSet owner) {
|
||||
BitSet bitset = owner.getBitSet();
|
||||
bitset.clear();
|
||||
return bitset;
|
||||
}
|
||||
|
||||
public static void $init$(ScratchBitSet owner) {
|
||||
owner.codechicken$multipart$asm$ScratchBitSet$_setter_$codechicken$multipart$asm$ScratchBitSet$$bitSets_$eq(
|
||||
new ThreadLocal<BitSet>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package codechicken.multipart.asm;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/** Per-owner, per-thread scratch storage used by both generators. */
|
||||
public interface ScratchBitSet {
|
||||
|
||||
void codechicken$multipart$asm$ScratchBitSet$_setter_$codechicken$multipart$asm$ScratchBitSet$$bitSets_$eq(
|
||||
ThreadLocal value);
|
||||
|
||||
ThreadLocal<BitSet> codechicken$multipart$asm$ScratchBitSet$$bitSets();
|
||||
|
||||
BitSet getBitSet();
|
||||
|
||||
BitSet freshBitSet();
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package codechicken.multipart.asm
|
||||
import java.util.BitSet
|
||||
|
||||
trait ScratchBitSet {
|
||||
private val bitSets = new ThreadLocal[BitSet]
|
||||
|
||||
def getBitSet = bitSets.get match {
|
||||
case null =>
|
||||
val bitset = new BitSet
|
||||
bitSets.set(bitset)
|
||||
bitset
|
||||
case bitset => bitset
|
||||
}
|
||||
|
||||
def freshBitSet = {
|
||||
val bitset = getBitSet
|
||||
bitset.clear()
|
||||
bitset
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user