Created
March 2, 2015 21:47
-
-
Save Mumfrey/d346c41afe3b2e2d541d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.asm; | |
import org.objectweb.asm.ClassVisitor; | |
import org.objectweb.asm.FieldVisitor; | |
import org.objectweb.asm.MethodVisitor; | |
import org.objectweb.asm.Opcodes; | |
public class MyClassVisitor extends ClassVisitor { | |
public MyClassVisitor(int api, ClassVisitor cv) { | |
super(api, cv); | |
} | |
@Override | |
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { | |
String newName = this.remapFieldName(name); | |
String newSignature = this.remapFieldSignature(signature); | |
return super.visitField(access, newName, desc, newSignature, value); | |
} | |
@Override | |
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { | |
MethodVisitor superVisitor = super.visitMethod(access, name, desc, signature, exceptions); | |
return new MethodVisitor(Opcodes.ASM5, superVisitor) { | |
@Override | |
public void visitFieldInsn(int opcode, String owner, String name, String desc) { | |
String newName = MyClassVisitor.this.remapFieldName(name); | |
String newSignature = MyClassVisitor.this.remapFieldSignature(desc); | |
super.visitFieldInsn(opcode, owner, newName, newSignature); | |
} | |
}; | |
} | |
protected String remapFieldName(String name) { | |
return null; // whatever | |
} | |
protected String remapFieldSignature(String signature) { | |
return null; // whatever | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment