diff --git a/arclight-api/src/main/java/io/izzel/arclight/api/Unsafe.java b/arclight-api/src/main/java/io/izzel/arclight/api/Unsafe.java index e5d9a880..25dd5339 100644 --- a/arclight-api/src/main/java/io/izzel/arclight/api/Unsafe.java +++ b/arclight-api/src/main/java/io/izzel/arclight/api/Unsafe.java @@ -120,96 +120,6 @@ public class Unsafe { unsafe.putDouble(o, l, v); } - @Deprecated - public static int getInt(Object o, int i) { - return unsafe.getInt(o, i); - } - - @Deprecated - public static void putInt(Object o, int i, int i1) { - unsafe.putInt(o, i, i1); - } - - @Deprecated - public static Object getObject(Object o, int i) { - return unsafe.getObject(o, i); - } - - @Deprecated - public static void putObject(Object o, int i, Object o1) { - unsafe.putObject(o, i, o1); - } - - @Deprecated - public static boolean getBoolean(Object o, int i) { - return unsafe.getBoolean(o, i); - } - - @Deprecated - public static void putBoolean(Object o, int i, boolean b) { - unsafe.putBoolean(o, i, b); - } - - @Deprecated - public static byte getByte(Object o, int i) { - return unsafe.getByte(o, i); - } - - @Deprecated - public static void putByte(Object o, int i, byte b) { - unsafe.putByte(o, i, b); - } - - @Deprecated - public static short getShort(Object o, int i) { - return unsafe.getShort(o, i); - } - - @Deprecated - public static void putShort(Object o, int i, short i1) { - unsafe.putShort(o, i, i1); - } - - @Deprecated - public static char getChar(Object o, int i) { - return unsafe.getChar(o, i); - } - - @Deprecated - public static void putChar(Object o, int i, char c) { - unsafe.putChar(o, i, c); - } - - @Deprecated - public static long getLong(Object o, int i) { - return unsafe.getLong(o, i); - } - - @Deprecated - public static void putLong(Object o, int i, long l) { - unsafe.putLong(o, i, l); - } - - @Deprecated - public static float getFloat(Object o, int i) { - return unsafe.getFloat(o, i); - } - - @Deprecated - public static void putFloat(Object o, int i, float v) { - unsafe.putFloat(o, i, v); - } - - @Deprecated - public static double getDouble(Object o, int i) { - return unsafe.getDouble(o, i); - } - - @Deprecated - public static void putDouble(Object o, int i, double v) { - unsafe.putDouble(o, i, v); - } - public static byte getByte(long l) { return unsafe.getByte(l); } @@ -340,7 +250,7 @@ public class Unsafe { public static Class defineClass(String s, byte[] bytes, int i, int i1, ClassLoader classLoader, ProtectionDomain protectionDomain) { try { - return (Class) defineClass.bindTo(classLoader).invoke(s, bytes, i , i1, protectionDomain); + return (Class) defineClass.bindTo(classLoader).invoke(s, bytes, i, i1, protectionDomain); } catch (Throwable throwable) { throwException(throwable); return null; @@ -498,4 +408,18 @@ public class Unsafe { public static void fullFence() { unsafe.fullFence(); } + + public static Class getCallerClass() { + return INSTANCE.getClassContext()[3]; + } + + private static final CallerClass INSTANCE = new CallerClass(); + + private static class CallerClass extends SecurityManager { + + @Override + public Class[] getClassContext() { + return super.getClassContext(); + } + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/remapper/generated/ArclightReflectionHandler.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/remapper/generated/ArclightReflectionHandler.java index c9f95ffe..5e5395e4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/remapper/generated/ArclightReflectionHandler.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/remapper/generated/ArclightReflectionHandler.java @@ -26,7 +26,7 @@ public class ArclightReflectionHandler extends ClassLoader { // bukkit -> srg public static Class redirectForName(String cl) throws ClassNotFoundException { - return redirectForName(cl, true, remapper.getClassLoader()); + return redirectForName(cl, true, Unsafe.getCallerClass().getClassLoader()); } // bukkit -> srg @@ -93,7 +93,7 @@ public class ArclightReflectionHandler extends ClassLoader { public static String redirectClassGetName(Class cl) { String internalName = Type.getInternalName(cl); Type type = Type.getObjectType(remapper.toBukkitRemapper().mapType(internalName)); - return type.getClassName(); + return type.getInternalName().replace('/', '.'); } // srg -> bukkit