カスタム コンストラクターで ByteBuddy を使用してクラスを動的に作成しようとしています。Byte Buddy を使用した Intercepting デフォルト コンストラクターを読み、それに基づいて次のコード ベースを作成しました。
Class<?> dynamicType = new ByteBuddy().subclass(Object.class, ConstructorStrategy.Default.NO_CONSTRUCTORS)
.name("foo").defineConstructor(Modifier.PUBLIC).withParameters(int.class)
.intercept(
to(new Object() {
public void construct() throws Exception {
System.out.println("before constructor");
}
})
.andThen(MethodCall.invoke(Object.class.getConstructor()))
.andThen(to(new Object() {
public void construct() throws Exception {
System.out.println("after constructor");
}})
))
.make()
.load(Main.class.getClassLoader(), INJECTION)
.getLoaded();
dynamicType.getConstructor(int.class).newInstance(3);
私の質問は、スーパーコンストラクターを呼び出す前後に追加したカスタムコードで、「foo」コンストラクターの整数引数にどのようにアクセスできるかです。