I'm currently trying to redefine the CraftPlayer
class in spigot to add more events. I'm using Byte-Buddy and ASM to edit the classes using this utility class. However, even when running CraftPlayer::class.java.redefine { }
(which doesn't change the class at all) I get a java.lang.VerifyError
without any message.
I've tried running the same code on other large, complicated classes and didn't get an error. The only difference between these classes and CraftPlayer
is that they don't have any inner classes.
Full Exception:
java.lang.VerifyError: null
at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method) ~[?:?]
at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:194) ~[?:?]
at xyz.xenondevs.lib.bytebase.RuntimeUtilsKt.insertInstructions$redefineClasses(RuntimeUtils.kt:41) ~[?:?]
at xyz.xenondevs.lib.bytebase.RuntimeUtilsKt.access$insertInstructions$redefineClasses(RuntimeUtils.kt:1) ~[?:?]
at xyz.xenondevs.lib.bytebase.RuntimeUtilsKt$insertInstructions$2.invoke(RuntimeUtils.kt:41) ~[?:?]
at xyz.xenondevs.lib.bytebase.RuntimeUtilsKt$insertInstructions$2.invoke(RuntimeUtils.kt:41) ~[?:?]
at xyz.xenondevs.lib.bytebase.RuntimeUtilsKt$sam$java_util_function_Consumer$0.accept(RuntimeUtils.kt) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
at xyz.xenondevs.lib.bytebase.RuntimeUtilsKt.insertInstructions(RuntimeUtils.kt:41) ~[?:?]
at xyz.xenondevs.test.TestPlugin.onEnable(TestPlugin.kt:11) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:511) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:425) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot-1.17.1.jar:3241-Spigot-6c1c1b2-1492826]
at java.lang.Thread.run(Thread.java:831) [?:?]
I'm running Java 16 build 16.0.1+9-24
Why does the JVM fail to verify the CraftPlayer
class even though nothing has changed?
Seems to have been a JVM/asm bug. Just tried it again with Java 17 and updated dependencies but the exact same code, and it appears to be working now.