use of org.objectweb.asm.commons.MethodRemapper in project drill by apache.
the class MergeAdapter method visitEnd.
@Override
public void visitEnd() {
// add all the fields of the class we're going to merge.
// Special handling for nested classes. Drill uses non-static nested
// "inner" classes in some templates. Prior versions of Drill would
// create the generated nested classes as static, then this line
// would copy the "this$0" field to convert the static nested class
// into a non-static inner class. However, that approach is not
// compatible with plain-old Java compilation. Now, Drill generates
// the nested classes as non-static inner classes. As a result, we
// do not want to copy the hidden fields; we'll end up with two if
// we do.
classToMerge.fields.stream().filter(field -> !field.name.startsWith("this$")).forEach(field -> field.accept(this));
// add all the methods that we to include.
for (MethodNode mn : classToMerge.methods) {
if (mn.name.equals("<init>")) {
continue;
}
String[] exceptions = new String[mn.exceptions.size()];
mn.exceptions.toArray(exceptions);
MethodVisitor mv = cv.visitMethod(mn.access | Modifier.FINAL, mn.name, mn.desc, mn.signature, exceptions);
if (verifyBytecode) {
mv = new CheckMethodVisitorFsm(api, mv);
}
mn.instructions.resetLabels();
// mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, new
// SimpleRemapper("org.apache.drill.exec.compile.ExampleTemplate", "Bunky")));
ClassSet top = set;
while (top.parent != null) {
top = top.parent;
}
mn.accept(new MethodRemapper(mv, new SimpleRemapper(top.precompiled.slash, top.generated.slash)));
}
super.visitEnd();
}
Aggregations