I'm making an application server and in it I need to use some bytecode manipulation (e.g. inserting custom equals
and hashCode
methods to classes annotated with @Entity
). Now I give the JVM a Java Agent (the -javaagent option) which does bytecode transformations using ASM.
I've been considering using OSGi, but I don't know whether it allows me to do the necessary bytecode manipulation.
- Is it possible to do bytecode manipulation when using OSGi? How?
- Is it possible for a bundle to declare itself, that it requires some bytecode manipulation for it to work? For example the application server requires that some of its own core classes are manipulated.
- Is it possible to specify that some other bundle requires some bytecode manipulation, without that bundle knowing about it? For example all applications which run on the server must be manipulated, but the applications don't need to know about it.
- Is it possible for a bundle to declare itself, that all bundles which depend on it must be bytecode manipulated? This would make it easy for me to declare that all who depend on the API bundle which contains the
@Entity
annotation, must be manipulated.