I'm exploring if Byte Buddy is the right tool for me to use. I was looking at this answer which talks about how with Byte Buddy, one can take a class Foo
loaded with class loader A
, rename it to Bar
and redefine it on another class loader B
. That's incredible.
My question is:
Is it possible to have an object which was created from
Foo
on class loaderA
and convert toBar
's object which is coming from class loaderB
? The solution which I have in mind right now is to basically serialize the object fromFoo
and then edit the serialized bytes to rename the name of the class. It would be nice if I can do it safely with Byte Buddy. Another solution would be to use Transloader.Is java-agent or any special instrumentation required for doing all the things that was described in the above SO answer
Thank you so much.