Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display generated bytebuddy bytecode

Tags:

I am using ByteBuddy to create a class at runtime with dynamically generated byte code. The generated class does what it is intended to do, but I want to manually inspect the generated byte code, to ensure it is correct.

For example

Class<?> dynamicType = new ByteBuddy()
        .subclass(MyAbstractClass.class)
        .method(named("mymethod"))
        .intercept(new MyImplementation(args))
        .make()
        .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER)
        .getLoaded();

where MyImplementation chains multiple StackManipulation commands together to create the dynamically generated code.

Can I write the generated class out to a file, (so I can manually inspect with a IDE), or otherwise print out the bytecode for the generated class?