ByteBuddyを使用してString.classやInteger.classなどのjava.langパッケージのクラスを再定義しようとしていますが、成功しません。私の質問はそれが可能なのだろうか?ByteBuddyでjava.langクラスを再定義する
これは私が私のJavaエージェントにしようとしているコードです:
public static void premain(String agentArgs, Instrumentation inst) {
new AgentBuilder.Default()
.type(named("java.lang.String"))
.transform((builder, typeDescription, classLoader) ->
builder.method(named("toString"))
.intercept(FixedValue.value("toString() got hacked!")))
.with(AgentBuilder.Listener.StreamWriting.toSystemOut())
.with(AgentBuilder.RedefinitionStrategy.REDEFINITION)
.with(AgentBuilder.TypeStrategy.Default.REDEFINE)
.installOn(inst);
}
私は、ログの出力をチェックして、私はStringクラスについて参照するとき:
[Byte Buddy] IGNORE [[Ljava.lang.String; [null, null]
[Byte Buddy] COMPLETE [[Ljava.lang.String; [null, null]
いこれは、ByteBuddyがStringクラスを再定義していないことを意味しますか?それも可能ですか?
多くのありがとうございます。