Get Java class bytecode from memory(After multiple transforms)

前端 未结 1 535
借酒劲吻你
借酒劲吻你 2021-01-24 19:18

I\'m working on a coremod for Minecraft, and transform a lot of the classes as they are loaded. The problem however is that there are multiple coremods which also transform the

相关标签:
1条回答
  • 2021-01-24 19:44

    As far as I know, the only interface for runtime access to bytecode is provided by Java Agents. This is also how you create classfile transformers in the first place, so you should already be using one. Just modify it to dump the classfile.

    Edit: As far as the order of transformation, according to the docs, it is

    Retransformation incapable transformers
    Retransformation incapable native transformers
    Retransformation capable transformers
    Retransformation capable native transformers
    

    So ideally you'd want a retransformation capable native transformer. But writing native code is a pain. Setting your transformer to enable retransformation will help a lot, but it's still possible for another retransformer registered later to run after you. The best option I can think of is to register your agent again. Or find all calls to register a transformer and insert yours afterwards.

    0 讨论(0)
提交回复
热议问题