Java 类org.objectweb.asm.commons.MethodRemapper 实例源码
项目:glowroot
文件:WeavingClassVisitor.java
@RequiresNonNull("type")
private void addMixin(ClassNode mixinClassNode) {
List<FieldNode> fieldNodes = mixinClassNode.fields;
for (FieldNode fieldNode : fieldNodes) {
fieldNode.accept(this);
}
List<MethodNode> methodNodes = mixinClassNode.methods;
for (MethodNode mn : methodNodes) {
if (mn.name.equals("<init>")) {
continue;
}
String[] exceptions = Iterables.toArray(mn.exceptions, String.class);
MethodVisitor mv =
cw.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions);
mn.accept(new MethodRemapper(mv,
new SimpleRemapper(mixinClassNode.name, type.getInternalName())));
}
}
项目:NeptuneMod
文件:DeobfuscationTransformer.java
@Override
protected MethodVisitor createMethodRemapper(MethodVisitor mv) {
return new MethodRemapper(mv, RemappingAdapter.this.remapper) {
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
String type = this.remapper.mapType(owner);
String fieldName = this.remapper.mapFieldName(owner, name, desc);
String newDesc = this.remapper.mapDesc(desc);
if (opcode == Opcodes.GETSTATIC && type.startsWith("net/minecraft/") && newDesc
.startsWith("Lnet/minecraft/")) {
String replDesc = getStaticFieldType(owner, name, type, fieldName);
if (replDesc != null) {
newDesc = this.remapper.mapDesc(replDesc);
}
}
if (this.mv != null) {
this.mv.visitFieldInsn(opcode, type, fieldName, newDesc);
}
}
};
}