mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
support MethodInfo binding
This commit is contained in:
@@ -312,6 +312,21 @@ public abstract class Binding {
|
||||
}
|
||||
}
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@java.lang.annotation.Target(ElementType.PARAMETER)
|
||||
@BindingParserHandler(parser = MethodInfoBindingParser.class)
|
||||
public static @interface MethodInfo {
|
||||
boolean optional() default false;
|
||||
}
|
||||
|
||||
public static class MethodInfoBindingParser implements BindingParser {
|
||||
@Override
|
||||
public Binding parse(Annotation annotation) {
|
||||
return new MethodDeclarationBinding();
|
||||
}
|
||||
}
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@java.lang.annotation.Target(ElementType.PARAMETER)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.taobao.arthas.bytekit.asm.binding;
|
||||
|
||||
import com.alibaba.arthas.deps.org.objectweb.asm.Type;
|
||||
import com.alibaba.arthas.deps.org.objectweb.asm.tree.InsnList;
|
||||
import com.alibaba.arthas.deps.org.objectweb.asm.tree.MethodNode;
|
||||
import com.taobao.arthas.bytekit.asm.MethodProcessor;
|
||||
import com.taobao.arthas.bytekit.utils.AsmOpUtils;
|
||||
|
||||
/**
|
||||
* method name | method desc 的方式组织
|
||||
*
|
||||
* TODO 是否要有 line number ?
|
||||
*
|
||||
* @author hengyunabc 2020-05-16
|
||||
*
|
||||
*/
|
||||
public class MethodInfoBinding extends Binding {
|
||||
|
||||
@Override
|
||||
public void pushOntoStack(InsnList instructions, BindingContext bindingContext) {
|
||||
MethodProcessor methodProcessor = bindingContext.getMethodProcessor();
|
||||
MethodNode methodNode = methodProcessor.getMethodNode();
|
||||
AsmOpUtils.ldc(instructions, methodNode.name + methodNode.desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType(BindingContext bindingContext) {
|
||||
return Type.getType(String.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user