3

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 !

Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192
Liviu Carausu
  • 61
  • 1
  • 5

1 Answers1

4

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.

Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192