我知道如何创建BEFORE构造函数拦截器:
return builder.constructor(isDeclaredBy(typeDescription))
.intercept(MethodDelegation.to(constructorInterceptor)
.andThen(SuperMethodCall.INSTANCE));
Run Code Online (Sandbox Code Playgroud)
我知道如何创建一个AFTER构造函数拦截器:
return builder.constructor(isDeclaredBy(typeDescription))
.intercept(SuperMethodCall.INSTANCE
.andThen(MethodDelegation.to(constructorInterceptor)));
Run Code Online (Sandbox Code Playgroud)
使用以下拦截器:
public void intercept(@Origin Constructor<?> constructor) {
System.out.println("intercepted " + constructor.getName());
}
Run Code Online (Sandbox Code Playgroud)
但是我不知道如何创建一个前/后拦截器.这是我尝试的(基于已经为方法工作的天真方法):
return builder.constructor(isDeclaredBy(typeDescription))
.intercept(MethodDelegation.to(constructorInterceptor));
Run Code Online (Sandbox Code Playgroud)
使用此方法委托:
public void intercept(@Origin Constructor<?> constructor, @SuperCall Callable<?> zuper) throws Exception {
System.out.println("before " + constructor.getName());
zuper.call();
System.out.println("after " + constructor.getName());
}
Run Code Online (Sandbox Code Playgroud)
通过这种设置,我得到:
java.lang.ClassFormatError: Bad method name at constant pool index 23 in class file com/flow/agent/test/Foo$auxiliary$syFGNB3u
Run Code Online (Sandbox Code Playgroud)
完整堆栈跟踪:
java.lang.IllegalStateException: Error invoking java.lang.ClassLoader#findClass
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Resolved.loadClass(ClassInjector.java:392)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.inject(ClassInjector.java:201)
at net.bytebuddy.agent.builder.AgentBuilder$InitializationStrategy$SelfInjection$Dispatcher$Split.register(AgentBuilder.java:1017)
at net.bytebuddy.agent.builder.AgentBuilder$Default$Transformation$Simple$Resolution.apply(AgentBuilder.java:2795)
at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.transform(AgentBuilder.java:3081)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at …Run Code Online (Sandbox Code Playgroud) 在 cytoscape.js 中,compoundNode.remove() 从图中删除复合节点及其后代。
有没有办法只删除复合节点并保留后代?