当前位置: 动力学知识库 > 问答 > 编程问答 >

reflection - Java transformed class isAssignableFrom

问题描述:

I transformed specific class using ASM.

Changed only method's code. everything else is the same (ex class name, package..)

and I have two class object.

Object original;

Object transformed;

I tried original.isAssignableFrom(transformed) but it is false.

What does isAssignableFrom compare based on?

How do I get true from isAssignable()?

The reason for this is that an exception is thrown when using reflection.

sun.reflect.UnsafeFieldAccessorImpl.ensureObj seems use isAssignableFrom().

Reflection code is ClassName.class.getDeclaredField("fieldName") I should not change this. (ex object.getClass().getDeclaredField("fieldName"))

Exception stacktrace:

[22:15:29 WARN]: java.lang.IllegalArgumentException: Can not set final org.bukkit.command.SimpleCommandMap field org.bukkit.plugin.SimplePluginManager.commandMap to org.bukkit.plugin.SimplePluginManager

[22:15:29 WARN]: at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)

[22:15:29 WARN]: at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)

[22:15:29 WARN]: at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)

[22:15:29 WARN]: at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(Unknown Source)

[22:15:29 WARN]: at java.lang.reflect.Field.get(Unknown Source)

[22:15:29 WARN]: at com.github.lyokofirelyte.VariableTriggers.Manager.VTRegistry.registerCommands(VTRegistry.java:37)

[22:15:29 WARN]: at com.github.lyokofirelyte.VariableTriggers.VTSetup.start(VTSetup.java:145)

[22:15:29 WARN]: at com.github.lyokofirelyte.VariableTriggers.VariableTriggers.onEnable(VariableTriggers.java:51)

[22:15:29 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:271)

[22:15:29 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:316)

[22:15:29 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:407)

[22:15:29 WARN]: at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugin(CraftServer.java:378)

[22:15:29 WARN]: at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugins(CraftServer.java:328)

[22:15:29 WARN]: at net.minecraft.server.v1_11_R1.MinecraftServer.t(MinecraftServer.java:437)

[22:15:29 WARN]: at net.minecraft.server.v1_11_R1.MinecraftServer.l(MinecraftServer.java:398)

[22:15:29 WARN]: at net.minecraft.server.v1_11_R1.MinecraftServer.a(MinecraftServer.java:336)

[22:15:29 WARN]: at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:276)

[22:15:29 WARN]: at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:603)

[22:15:29 WARN]: at java.lang.Thread.run(Unknown Source)

分享给朋友:
您可能感兴趣的文章:
随机阅读: