提交 79613478 编写于 作者: oldratlee's avatar oldratlee 🔥

simplify CtNewMethod.copy invocation

上级 2cb6fba4
......@@ -44,12 +44,11 @@ public class TtlForkJoinTransformlet implements JavassistTransformlet {
clazz.addField(capturedField, "com.alibaba.ttl.TransmittableThreadLocal.Transmitter.capture();");
logger.info("add new field " + capturedFieldName + " to class " + className);
final String doExec_methodName = "doExec";
final CtMethod doExecMethod = clazz.getDeclaredMethod(doExec_methodName, new CtClass[0]);
final CtMethod new_doExecMethod = CtNewMethod.copy(doExecMethod, doExec_methodName, clazz, null);
final CtMethod doExecMethod = clazz.getDeclaredMethod("doExec", new CtClass[0]);
final CtMethod new_doExecMethod = CtNewMethod.copy(doExecMethod, clazz, null);
// rename original doExec method, and set to private method(avoid reflect out renamed method unexpectedly)
final String original_doExec_method_rename = "original$doExec$method$renamed$by$ttl";
final String original_doExec_method_rename = "original$" + doExecMethod.getName()+ "$method$renamed$by$ttl";
doExecMethod.setName(original_doExec_method_rename);
doExecMethod.setModifiers(doExecMethod.getModifiers() & ~Modifier.PUBLIC /* remove public */ | Modifier.PRIVATE /* add private */);
......
......@@ -58,10 +58,10 @@ public class TtlTimerTaskTransformlet implements JavassistTransformlet {
logger.info("add new field " + capturedFieldName + " to class " + className);
final CtMethod runMethod = clazz.getDeclaredMethod(RUN_METHOD_NAME, new CtClass[0]);
final CtMethod new_runMethod = CtNewMethod.copy(runMethod, RUN_METHOD_NAME, clazz, null);
final CtMethod new_runMethod = CtNewMethod.copy(runMethod, clazz, null);
// rename original run method, and set to private method(avoid reflect out renamed method unexpectedly)
final String original_run_method_rename = "original$run$method$renamed$by$ttl";
final String original_run_method_rename = "original$" + runMethod.getName() + "$method$renamed$by$ttl";
runMethod.setName(original_run_method_rename);
runMethod.setModifiers(runMethod.getModifiers() & ~Modifier.PUBLIC /* remove public */ | Modifier.PRIVATE /* add private */);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册