pf_miles
pf_miles

Reputation: 927

Can I redefine which super class to extend in ByteBuddy?

As the title reads, can I redefine the extends clause when redefining a class using ByteBuddy?

That is, redefining class A from A extends B to A extends C for example.

I've read the javadoc and it only suggests a DynamicType.Builder.implement mechanism which only accepts additional interfaces, but it's not for superclasses.

Is there someone tried this?

thanks.

Upvotes: 1

Views: 215

Answers (1)

Rafael Winterhalter
Rafael Winterhalter

Reputation: 44007

That's a rather difficult translation as this affects a significant portion of the class when it comes to super class access and super method calls.

You can register a ClassVisitorWrapper and change the property using ASM on the ClassVisitor's visit method.

Upvotes: 1

Related Questions