Force UnsafeBufferHelper to be classloaded at startup
This commit is contained in:
parent
e36ba04921
commit
93fbbfe2d1
|
|
@ -5,6 +5,9 @@ import org.embeddedt.modernfix.ModernFix;
|
|||
import org.embeddedt.modernfix.render.UnsafeBufferHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
|
@ -14,6 +17,14 @@ public class BufferBuilderMixin {
|
|||
|
||||
private static boolean leakReported = false;
|
||||
|
||||
/**
|
||||
* Ensure UnsafeBufferHelper is classloaded early, to avoid Forge's event transformer showing an error in the log.
|
||||
*/
|
||||
@Inject(method = "<clinit>", at = @At(value = "RETURN"))
|
||||
private static void initUnsafeBufferHelper(CallbackInfo ci) {
|
||||
UnsafeBufferHelper.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ public class UnsafeBufferHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
||||
}
|
||||
|
||||
public static void free(ByteBuffer buf) {
|
||||
if(UNSAFE != null && ADDRESS >= 0) {
|
||||
// set the address to 0 to prevent double free
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user