bytekit
bytekit copied to clipboard
Java Bytecode Kit
记录一下: ``` Exception in thread "main" java.lang.VerifyError: Illegal type at constant pool entry 328 in class org.apache.http.impl.client.InternalHttpClient Exception Details: Location: org/apache/http/impl/client/InternalHttpClient.doExecute(Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/client/methods/CloseableHttpResponse; @29: invokestatic Reason: Constant pool index 328 is invalid...
 如上逻辑,store -> callback ->load,理论上,调用完callback,栈顶数据应该是原来的数据啊,比如return指令之前插入的callback,那callback执行完后栈顶应该是return的值。感觉store->load看上去是多余的。所以这对操作的作用是什么,防止一些异常情况污染操作数栈?
ByteKit是否无法干预原有逻辑,比如在‘Before’位置或异常catch时直接返回一个预定值。
https://github.com/alibaba/one-java-agent/issues/26
bytekit 后续可以拓展增强注解方面的 binding 操作,比如方便获取方法注解,类注解等等。
类似arthas的Enhancer.reset,场景是在某种情况下想临时在类上加些内容,完成之后再还原回去。
目前是用asm tree api的,对于绝大部分 byte[] ,是否要找一种更高效的方式来读取解析? https://github.com/bleathem/mojarra/blob/master/jsf-ri/src/main/java/com/sun/faces/config/JavaClassScanningAnnotationScanner.java https://github.com/rmuller/infomas-asl
目前在工作中用 ByteBuddy 比较多,最近看到 ByteKit ,发现 大部分功能是重合的