mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 20:43:54 +00:00
Merge branch 'chore/main/deprecate-unsafe-utils'
This commit is contained in:
@ -6,7 +6,7 @@ import com.fastasyncworldedit.core.internal.exception.FaweClipboardVersionMismat
|
||||
import com.fastasyncworldedit.core.jnbt.streamer.IntValueReader;
|
||||
import com.fastasyncworldedit.core.math.IntTriple;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.fastasyncworldedit.core.util.UnsafeUtility;
|
||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -332,7 +332,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
if (cb == null || !cb.isDirect()) {
|
||||
return;
|
||||
}
|
||||
UnsafeUtility.getUNSAFE().invokeCleaner(cb);
|
||||
ReflectionUtils.getUnsafe().invokeCleaner(cb);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,9 @@ import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* This is an internal class not meant to be used outside the FAWE internals.
|
||||
*/
|
||||
public class ReflectionUtils {
|
||||
|
||||
private static Unsafe UNSAFE;
|
||||
@ -134,5 +137,11 @@ public class ReflectionUtils {
|
||||
UNSAFE.putObject(base, UNSAFE.objectFieldOffset(field), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an instance of {@link Unsafe}
|
||||
*/
|
||||
public static Unsafe getUnsafe() {
|
||||
return UNSAFE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package com.fastasyncworldedit.core.util;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* This is an internal class not meant to be used outside the FAWE internals.
|
||||
*/
|
||||
public class UnsafeUtility {
|
||||
|
||||
private static final Unsafe UNSAFE;
|
||||
|
||||
static {
|
||||
try {
|
||||
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
theUnsafe.setAccessible(true);
|
||||
UNSAFE = (Unsafe) theUnsafe.get(null);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new ExceptionInInitializerError("Cannot access Unsafe");
|
||||
}
|
||||
}
|
||||
|
||||
public static Unsafe getUNSAFE() {
|
||||
return UNSAFE;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user