use of jdk.internal.org.objectweb.asm.FieldVisitor in project jdk8u_jdk by JetBrains.
the class FieldNode method accept.
/**
* Makes the given class visitor visit this field.
*
* @param cv
* a class visitor.
*/
public void accept(final ClassVisitor cv) {
FieldVisitor fv = cv.visitField(access, name, desc, signature, value);
if (fv == null) {
return;
}
int i, n;
n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = visibleAnnotations.get(i);
an.accept(fv.visitAnnotation(an.desc, true));
}
n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = invisibleAnnotations.get(i);
an.accept(fv.visitAnnotation(an.desc, false));
}
n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
for (i = 0; i < n; ++i) {
TypeAnnotationNode an = visibleTypeAnnotations.get(i);
an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, true));
}
n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations.size();
for (i = 0; i < n; ++i) {
TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false));
}
n = attrs == null ? 0 : attrs.size();
for (i = 0; i < n; ++i) {
fv.visitAttribute(attrs.get(i));
}
fv.visitEnd();
}
use of jdk.internal.org.objectweb.asm.FieldVisitor in project openj9 by eclipse.
the class Cmvc196982 method addAnnotation.
/*
* Transform classToTransform by adding the given annotation to all already-annotated methods, fields and constructors in the class.
* Return the modified class file bytes.
*/
private byte[] addAnnotation(Class<?> classToTransform, final Class<?> annotation) throws IOException {
ClassWriter writer = new ClassWriter(0);
new ClassReader(Type.getInternalName(classToTransform)).accept(new ClassVisitor(ASM4, writer) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
return new MethodVisitor(ASM4, cv.visitMethod(access, name, desc, signature, exceptions)) {
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
mv.visitAnnotation(Type.getDescriptor(annotation), true).visitEnd();
return mv.visitAnnotation(desc, visible);
}
};
}
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
return new FieldVisitor(ASM4, cv.visitField(access, name, desc, signature, value)) {
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
fv.visitAnnotation(Type.getDescriptor(annotation), true).visitEnd();
return fv.visitAnnotation(desc, visible);
}
};
}
}, 0);
return writer.toByteArray();
}
use of jdk.internal.org.objectweb.asm.FieldVisitor in project Bytecoder by mirkosertic.
the class TraceClassVisitor method visitField.
@Override
public FieldVisitor visitField(final int access, final String name, final String desc, final String signature, final Object value) {
Printer p = this.p.visitField(access, name, desc, signature, value);
FieldVisitor fv = cv == null ? null : cv.visitField(access, name, desc, signature, value);
return new TraceFieldVisitor(fv, p);
}
Aggregations