Bytecode manipulation

I'm interested in some bytecode manipulation and want to develop a simple library which would allow you to inject annotated code into a different method(similiar to Spongepowered Mixins). The thing is that I don't know how should I approach the bytecode at first. I can:
  • Create an agent, which would be loaded and would transform the bytecode
    • disadvantage is that the user would have to specify the agent to be loaded, the idea was that it should've been done automatically
  • Use custom gradle plugin to transform the bytecode while the jar is making
    • disadvantage is that it would only support code inside the jar, so any method in classpath wouldn't work(the idea was it could be injected into any method in classpath)
      Maybe there is a different approach I could use, heard fabric uses some sort of custom classloaders but I don't really know how it works
Was this page helpful?