Search code examples
javaspringosgicglib

Java, creating interface dynamically?


I'm looking for a solution to create an interface in runtime. I don't really know if this is possible in anyway.

Problem:

I've got a OSGi service which publishes a Map<String,String> where the key defines an action for this service. I want to publish this service directly as Hessianservice with spring but for this, I need to delcare an interface. Now I would like to create this interface at runtime.


Solution

  • It's possible to create interfaces dynamically for example by generating it with a bytecode manipulation library such as ASM. But it won't be possible to use that interface, because no code can be compiled against it (unless you generate dynamically also the code which uses it).

    What is it that you are trying to do?