How to generate bytecode of existing class at Runtime in Java?
My Existing class is say Foo.java
public class Foo {
public String saySomething() {
return "Hello World";
}
}
Now I want to generate byte code of this existing class Foo.java
and probably use it in another instance of JVM. Please understand I am not creating a class at runtime since I already have an existing class called Foo.java
. Open to any libraries such as ASM or ByteBuddy etc.