Fix several remapper issue (#138)

This commit is contained in:
IzzelAliz 2021-02-06 23:42:52 +08:00
parent 6475823180
commit dd80a19c27
2 changed files with 17 additions and 93 deletions

View File

@ -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);
}
@ -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();
}
}
}

View File

@ -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