We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhanceMethod方法中的字节码增强建议修改为CtBehavior.insert*方法 。 之前那种方式在增强方法中有调用其他类方法时,可能会有问题 // 前置增强: 打入时间戳 method.addLocalVariable("start", CtClass.longType); method.insertBefore("start = System.nanoTime();"); final StringBuilder source = new StringBuilder(); // 保留原有的代码处理逻辑 // 后置增强,计算输出方法执行耗时 source .append("System.out.print("method:[") .append(methodName).append("]");").append("\n") .append("System.out.println(" cost:[" +(System.nanoTime() - start)+ "ns]");") ; method.insertAfter(source.toString());
The text was updated successfully, but these errors were encountered:
No branches or pull requests
enhanceMethod方法中的字节码增强建议修改为CtBehavior.insert*方法 。 之前那种方式在增强方法中有调用其他类方法时,可能会有问题
// 前置增强: 打入时间戳
method.addLocalVariable("start", CtClass.longType);
method.insertBefore("start = System.nanoTime();");
final StringBuilder source = new StringBuilder();
// 保留原有的代码处理逻辑
// 后置增强,计算输出方法执行耗时
source
.append("System.out.print("method:[")
.append(methodName).append("]");").append("\n")
.append("System.out.println(" cost:[" +(System.nanoTime() - start)+ "ns]");")
;
method.insertAfter(source.toString());
The text was updated successfully, but these errors were encountered: