13
0
geforkt von Mirrors/Paper

#1425: Fix bytecode transformation taking care of class-to-interface compatibility.

By: Jannyboy11 <Jannyboy11@gmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2024-06-18 19:19:15 +10:00
Ursprung ac95e0b210
Commit e43f607e6a

Datei anzeigen

@ -67,8 +67,8 @@ public class Commodore {
"org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent" "org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent"
); );
private static final Set<String> CLASS_TO_INTERFACE = Set.of( private static final Map<String, String> CLASS_TO_INTERFACE = Map.of(
"org/bukkit/inventory/InventoryView" "org/bukkit/inventory/InventoryView", "org/bukkit/craftbukkit/inventory/CraftAbstractInventoryView"
); );
private static Map<String, RerouteMethodData> createReroutes(Class<?> clazz) { private static Map<String, RerouteMethodData> createReroutes(Class<?> clazz) {
@ -159,6 +159,10 @@ public class Commodore {
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
className = name; className = name;
isInterface = (access & Opcodes.ACC_INTERFACE) != 0; isInterface = (access & Opcodes.ACC_INTERFACE) != 0;
String craftbukkitClass = CLASS_TO_INTERFACE.get(superName);
if (craftbukkitClass != null) {
superName = craftbukkitClass;
}
super.visit(version, access, name, signature, superName, interfaces); super.visit(version, access, name, signature, superName, interfaces);
} }
@ -292,7 +296,11 @@ public class Commodore {
return; return;
} }
if (CLASS_TO_INTERFACE.contains(owner)) { String craftbukkitClass = CLASS_TO_INTERFACE.get(owner);
if (craftbukkitClass != null) {
if (opcode == Opcodes.INVOKESPECIAL || opcode == Opcodes.H_INVOKESPECIAL) {
owner = craftbukkitClass;
} else {
if (opcode == Opcodes.INVOKEVIRTUAL) { if (opcode == Opcodes.INVOKEVIRTUAL) {
opcode = Opcodes.INVOKEINTERFACE; opcode = Opcodes.INVOKEINTERFACE;
} }
@ -300,8 +308,10 @@ public class Commodore {
if (opcode == Opcodes.H_INVOKEVIRTUAL) { if (opcode == Opcodes.H_INVOKEVIRTUAL) {
opcode = Opcodes.H_INVOKEINTERFACE; opcode = Opcodes.H_INVOKEINTERFACE;
} }
itf = true; itf = true;
} }
}
// SPIGOT-4496 // SPIGOT-4496
if (owner.equals("org/bukkit/map/MapView") && name.equals("getId") && desc.equals("()S")) { if (owner.equals("org/bukkit/map/MapView") && name.equals("getId") && desc.equals("()S")) {