I create an Source object instance using the following code
Source source = new ByteBuddy()
.subclass(Source.class)
.method(named("hello"))
.intercept(MethodDelegation.to(Target.class))
.defineMethod("myNewMethod", void.class)
.intercept(MethodDelegation.to(Target.class))
.make()
.load(Source.class.getClassLoader())
.getLoaded()
.newInstance();
How can I tell when I analyse a Source object if is created by ByteBuddy ? Is it any marker interface that is implemented or something like this ? The actual class of the generated object is something like Source$ByteBuddy$HFuwCkIQ Thanks !
Byte Buddy does not leave any traces in its generated code unless you put such traces into the generated classes. By default, when creating subclasses, Byte Buddy's default naming strategy adds $ByteBuddy$ into the subclass's name but this configuration can change. The easiest way for you to mark your classes would probably be to implement an interface for any class that you generate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With