< prev index next >

src/jdk.jfr/share/classes/jdk/jfr/internal/instrument/JIMethodMergeAdapter.java

Print this page
rev 52456 : imported patch asm.additional


  47  *
  48  * @author Staffan Larsen
  49  */
  50 @Deprecated
  51 final class JIMethodMergeAdapter extends ClassVisitor {
  52 
  53     private final ClassNode cn;
  54     private final List<Method> methodFilter;
  55     private final Map<String, String> typeMap;
  56 
  57     /**
  58      * Methods in methodFilter that exist in cn will be merged into cv. If the method already exists,
  59      * the original method will be deleted.
  60      *
  61      * @param cv
  62      * @param cn - a ClassNode with Methods that will be merged into this class
  63      * @param methodFilter - only methods in this list will be merged
  64      * @param typeMappings - while merging, type references in the methods will be changed according to this map
  65      */
  66     public JIMethodMergeAdapter(ClassVisitor cv, ClassNode cn, List<Method> methodFilter, JITypeMapping[] typeMappings) {
  67         super(Opcodes.ASM5, cv);
  68         this.cn = cn;
  69         this.methodFilter = methodFilter;
  70 
  71         this.typeMap = new HashMap<>();
  72         for (JITypeMapping tm : typeMappings) {
  73             typeMap.put(tm.from().replace('.', '/'), tm.to().replace('.', '/'));
  74         }
  75     }
  76 
  77     @Override
  78     public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
  79         super.visit(version, access, name, signature, superName, interfaces);
  80         typeMap.put(cn.name, name);
  81     }
  82 
  83     @Override
  84     public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
  85         if(methodInFilter(name, desc)) {
  86             // If the method is one that we will be replacing, delete the method
  87             Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Deleting " + name + desc);




  47  *
  48  * @author Staffan Larsen
  49  */
  50 @Deprecated
  51 final class JIMethodMergeAdapter extends ClassVisitor {
  52 
  53     private final ClassNode cn;
  54     private final List<Method> methodFilter;
  55     private final Map<String, String> typeMap;
  56 
  57     /**
  58      * Methods in methodFilter that exist in cn will be merged into cv. If the method already exists,
  59      * the original method will be deleted.
  60      *
  61      * @param cv
  62      * @param cn - a ClassNode with Methods that will be merged into this class
  63      * @param methodFilter - only methods in this list will be merged
  64      * @param typeMappings - while merging, type references in the methods will be changed according to this map
  65      */
  66     public JIMethodMergeAdapter(ClassVisitor cv, ClassNode cn, List<Method> methodFilter, JITypeMapping[] typeMappings) {
  67         super(Opcodes.ASM7, cv);
  68         this.cn = cn;
  69         this.methodFilter = methodFilter;
  70 
  71         this.typeMap = new HashMap<>();
  72         for (JITypeMapping tm : typeMappings) {
  73             typeMap.put(tm.from().replace('.', '/'), tm.to().replace('.', '/'));
  74         }
  75     }
  76 
  77     @Override
  78     public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
  79         super.visit(version, access, name, signature, superName, interfaces);
  80         typeMap.put(cn.name, name);
  81     }
  82 
  83     @Override
  84     public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
  85         if(methodInFilter(name, desc)) {
  86             // If the method is one that we will be replacing, delete the method
  87             Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Deleting " + name + desc);


< prev index next >