byte buddy学习笔记
public static void main(String[] args) {
DynamicType.Unloaded<?> dynamicType = new ByteBuddy()
.with(new NamingStrategy.AbstractBase() {
@Override
protected String name(TypeDescription typeDescription) {
return "." + typeDescription.getSimpleName();
}
})
.subclass(Object.class)
.make();
DynamicType.Unloaded<?> dynamicType1 = new ByteBuddy()
.with(new NamingStrategy.AbstractBase() {
@Override
protected String name(TypeDescription typeDescription) {
return "." + typeDescription.getSimpleName();
}
})
.subclass(Object.class)
.make();
System.out.println(dynamicType.getTypeDescription().getCanonicalName());
System.out.println(dynamicType1.getTypeDescription().getCanonicalName());
ByteBuddy byteBuddy = new ByteBuddy();
byteBuddy.with(new NamingStrategy.SuffixingRandom("suffix"));
DynamicType.Unloaded<?> dynamicType3 = byteBuddy.subclass(Object.class).make();
System.out.println(dynamicType3.getTypeDescription().getCanonicalName());
ByteBuddy byteBuddy1 = new ByteBuddy();
DynamicType.Unloaded<?> dynamicType4 = byteBuddy1.with(new NamingStrategy.SuffixingRandom("suffix")).
subclass(Object.class).make();
System.out.println(dynamicType4.getTypeDescription().getCanonicalName());
ByteBuddy byteBuddy3 = new ByteBuddy();
ByteBuddy suffix = byteBuddy3.with(new NamingStrategy.SuffixingRandom("suffix"));
DynamicType.Unloaded<?> dynamicType5 = suffix.
subclass(Object.class).make();
System.out.println(dynamicType5.getTypeDescription().getCanonicalName());
}