0
我試圖獲取應用程序的執行路徑。爲了與ByteBuddy保持聯繫,我使用下面的代碼實現了一個代理,但它不打印任何東西。誰能幫我?獲取ByteBuddy的執行路徑
public static void premain(String arg, Instrumentation inst) throws Exception {
new AgentBuilder.Default()
.type(ElementMatchers.nameContains("Application"))
.transform(new AgentBuilder.Transformer() {
@Override
public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader, JavaModule javaModule) {
return builder.method(ElementMatchers.any()).intercept(MethodDelegation.to(LogInterceptor.class));
}
})
.installOn(inst);
}
public static class LogInterceptor {
static void log(@Origin Method method) {
System.out.println(method.toString() + " was called");
}
}