Commit c6079dff authored by ebruneton's avatar ebruneton

fixed bug (correct handling of cases where delegate annotation visitor is null)

parent 2933ae37
......@@ -38,7 +38,9 @@ import org.objectweb.asm.AnnotationVisitor;
* @author Eugene Kuleshov
*/
public class RemappingAnnotationAdapter implements AnnotationVisitor {
private final AnnotationVisitor av;
private final Remapper renamer;
public RemappingAnnotationAdapter(AnnotationVisitor av, Remapper renamer) {
......@@ -56,16 +58,19 @@ public class RemappingAnnotationAdapter implements AnnotationVisitor {
public AnnotationVisitor visitAnnotation(String name, String desc) {
AnnotationVisitor v = av.visitAnnotation(name, renamer.mapType(desc));
return v == av ? this : new RemappingAnnotationAdapter(v, renamer);
return v == null ? null : (v == av
? this
: new RemappingAnnotationAdapter(v, renamer));
}
public AnnotationVisitor visitArray(String name) {
AnnotationVisitor v = av.visitArray(name);
return v == av ? this : new RemappingAnnotationAdapter(v, renamer);
return v == null ? null : (v == av
? this
: new RemappingAnnotationAdapter(v, renamer));
}
public void visitEnd() {
av.visitEnd();
}
}
......@@ -71,8 +71,8 @@ public class RemappingClassAdapter extends ClassAdapter {
}
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationVisitor av = super.visitAnnotation(remapper.mapType(desc),
visible);
AnnotationVisitor av;
av = super.visitAnnotation(remapper.mapType(desc), visible);
return av == null ? null : createRemappingAnnotationAdapter(av);
}
......@@ -88,8 +88,7 @@ public class RemappingClassAdapter extends ClassAdapter {
remapper.mapDesc(desc),
remapper.mapSignature(signature, true),
remapper.mapValue(value));
return fv == null ? null
: createRemappingFieldAdapter(fv);
return fv == null ? null : createRemappingFieldAdapter(fv);
}
public MethodVisitor visitMethod(
......@@ -105,8 +104,7 @@ public class RemappingClassAdapter extends ClassAdapter {
newDesc,
remapper.mapSignature(signature, false),
exceptions == null ? null : remapper.mapTypes(exceptions));
return mv == null ? null
: createRemappingMethodAdapter(access, newDesc, mv);
return mv == null ? null : createRemappingMethodAdapter(access, newDesc, mv);
}
public void visitInnerClass(
......
......@@ -42,6 +42,7 @@ import org.objectweb.asm.FieldVisitor;
public class RemappingFieldAdapter implements FieldVisitor {
private final FieldVisitor fv;
private final Remapper remapper;
public RemappingFieldAdapter(FieldVisitor fv, Remapper remapper) {
......@@ -50,8 +51,8 @@ public class RemappingFieldAdapter implements FieldVisitor {
}
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
return new RemappingAnnotationAdapter(fv.visitAnnotation(desc, visible),
remapper);
AnnotationVisitor av = fv.visitAnnotation(desc, visible);
return av == null ? null : new RemappingAnnotationAdapter(av, remapper);
}
public void visitAttribute(Attribute attr) {
......@@ -61,5 +62,4 @@ public class RemappingFieldAdapter implements FieldVisitor {
public void visitEnd() {
fv.visitEnd();
}
}
......@@ -116,13 +116,13 @@ public class RemappingMethodAdapter extends LocalVariablesSorter {
}
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
return new RemappingAnnotationAdapter(mv.visitAnnotation(desc, visible),
remapper);
AnnotationVisitor av = mv.visitAnnotation(desc, visible);
return av == null ? av : new RemappingAnnotationAdapter(av, remapper);
}
public AnnotationVisitor visitAnnotationDefault() {
return new RemappingAnnotationAdapter(mv.visitAnnotationDefault(),
remapper);
AnnotationVisitor av = mv.visitAnnotationDefault();
return av == null ? av : new RemappingAnnotationAdapter(av, remapper);
}
public AnnotationVisitor visitParameterAnnotation(
......@@ -130,10 +130,10 @@ public class RemappingMethodAdapter extends LocalVariablesSorter {
String desc,
boolean visible)
{
return new RemappingAnnotationAdapter(mv.visitParameterAnnotation(parameter,
AnnotationVisitor av = mv.visitParameterAnnotation(parameter,
desc,
visible),
remapper);
visible);
return av == null ? av : new RemappingAnnotationAdapter(av, remapper);
}
public void visitFrame(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment