FilterClassAdapterpublic class FilterClassAdapter extends org.objectweb.asm.ClassAdapter A class visitor that filters out all members (fields, methods and inner classes) that are
either private or rejected by the {@link Filter}. |
Fields Summary |
---|
private final Filter | mFilter | private String | mClassName |
Methods Summary |
---|
public void | visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
mClassName = name;
super.visit(version, access, name, signature, superName, interfaces);
| public org.objectweb.asm.AnnotationVisitor | visitAnnotation(java.lang.String desc, boolean visible)
// TODO produce an error if a filtered annotation type is being used
return super.visitAnnotation(desc, visible);
| public void | visitAttribute(org.objectweb.asm.Attribute attr)
// pass
| public void | visitEnd()
super.visitEnd();
| public org.objectweb.asm.FieldVisitor | visitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)Visits a field.
{@inheritDoc}
Examples:
name = mArg
desc = Ljava/Lang/String;
signature = null (not a template) or template type
// exclude private fields
if ((access & Opcodes.ACC_PRIVATE) != 0) {
return null;
}
// filter on field name
String filterName = String.format("%s#%s", mClassName, name);
if (!mFilter.accept(filterName)) {
System.out.println("- Remove field " + filterName);
return null;
}
// TODO we should produce an error if a filtered desc/signature is being used.
return super.visitField(access, name, desc, signature, value);
| public void | visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
// exclude private methods
if ((access & Opcodes.ACC_PRIVATE) != 0) {
return;
}
// filter on name
if (!mFilter.accept(name)) {
return;
}
super.visitInnerClass(name, outerName, innerName, access);
| public org.objectweb.asm.MethodVisitor | visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)Visits a method.
{@inheritDoc}
Examples:
name =
desc = ()V
signature = null (not a template) or template type
// exclude private methods
if ((access & Opcodes.ACC_PRIVATE) != 0) {
return null;
}
// filter on method name using the non-generic descriptor
String filterName = String.format("%s#%s%s", mClassName, name, desc);
if (!mFilter.accept(filterName)) {
System.out.println("- Remove method " + filterName);
return null;
}
// filter on method name using the generic signature
if (signature != null) {
filterName = String.format("%s#%s%s", mClassName, name, signature);
if (!mFilter.accept(filterName)) {
System.out.println("- Remove method " + filterName);
return null;
}
}
// TODO we should produce an error if a filtered desc/signature/exception is being used.
return super.visitMethod(access, name, desc, signature, exceptions);
| public void | visitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)
// pass
| public void | visitSource(java.lang.String source, java.lang.String debug)
// pass
|
|