/** * Visits an annotation of the field. * * @param desc * the class descriptor of the annotation class. * @param visible * <tt>true</tt> if the annotation is visible at runtime. * @return a visitor to visit the annotation values, or <tt>null</tt> if * this visitor is not interested in visiting this annotation. */ public AnnotationVisitor visitAnnotation(String desc, boolean visible) { if (fv != null) { return fv.visitAnnotation(desc, visible); } return null; }
/** * Visits the end of the field. This method, which is the last one to be * called, is used to inform the visitor that all the annotations and * attributes of the field have been visited. */ public void visitEnd() { if (fv != null) { fv.visitEnd(); } } }
/** * Visits a non standard attribute of the field. * * @param attr * an attribute. */ public void visitAttribute(Attribute attr) { if (fv != null) { fv.visitAttribute(attr); } }
for (i = 0; i < n; ++i) { AnnotationNode an = visibleAnnotations.get(i); an.accept(fv.visitAnnotation(an.desc, true)); an.accept(fv.visitAnnotation(an.desc, false)); an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, true)); for (i = 0; i < n; ++i) { TypeAnnotationNode an = invisibleTypeAnnotations.get(i); an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false)); fv.visitAttribute(attrs.get(i)); fv.visitEnd();
@Override public void visitEnd() { if(!methodBodyOnly) { FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE, MANAGER_FIELD, MANAGER_TYPE.getDescriptor(), null, null); { AnnotationVisitor av = fv.visitAnnotation(INJECT_TYPE.getDescriptor(), true); av.visitEnd(); } fv.visitEnd(); } super.visitEnd(); }
/** * Visits an annotation on the type of the field. * * @param typeRef * a reference to the annotated type. The sort of this type * reference must be {@link TypeReference#FIELD FIELD}. See * {@link TypeReference}. * @param typePath * the path to the annotated type argument, wildcard bound, array * element type, or static inner type within 'typeRef'. May be * <tt>null</tt> if the annotation targets 'typeRef' as a whole. * @param desc * the class descriptor of the annotation class. * @param visible * <tt>true</tt> if the annotation is visible at runtime. * @return a visitor to visit the annotation values, or <tt>null</tt> if * this visitor is not interested in visiting this annotation. */ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { if (api < Opcodes.ASM5) { throw new RuntimeException(); } if (fv != null) { return fv.visitTypeAnnotation(typeRef, typePath, desc, visible); } return null; }
for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) { v = readAnnotationValues(v + 2, c, true, fv.visitAnnotation(readUTF8(v, c), true)); for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) { v = readAnnotationValues(v + 2, c, true, fv.visitAnnotation(readUTF8(v, c), false)); v = readAnnotationTarget(context, v); v = readAnnotationValues(v + 2, c, true, fv.visitTypeAnnotation(context.typeRef, context.typePath, readUTF8(v, c), true)); v = readAnnotationTarget(context, v); v = readAnnotationValues(v + 2, c, true, fv.visitTypeAnnotation(context.typeRef, context.typePath, readUTF8(v, c), false)); Attribute attr = attributes.next; attributes.next = null; fv.visitAttribute(attributes); attributes = attr; fv.visitEnd();
PROVIDER_FIELD, PROVIDER_TYPE.getDescriptor(), null, null); fv.visitEnd(); AnnotationVisitor av = fv.visitAnnotation(INJECT_TYPE.getDescriptor(), true); av.visit("create", Boolean.TRUE); av.visitEnd(); AnnotationVisitor av = fv.visitAnnotation(MANDATORY_TYPE.getDescriptor(), true); av.visitEnd(); fv.visitEnd(); AnnotationVisitor av = fv.visitAnnotation(INJECT_TYPE.getDescriptor(), true); av.visit("name", field.getKey()); av.visit("create", Boolean.TRUE); AnnotationVisitor av = fv.visitAnnotation(MANDATORY_TYPE.getDescriptor(), true); av.visitEnd(); fv.visitEnd(); fv.visitEnd();
@Override public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath, remapper.mapDesc(desc), visible); return av == null ? null : new RemappingAnnotationAdapter(av, remapper); } }
protected void addSVUID(long svuid) { FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, new Long( svuid)); if (fv != null) { fv.visitEnd(); } }
@Override public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { Printer p = this.p.visitFieldAnnotation(desc, visible); AnnotationVisitor av = fv == null ? null : fv.visitAnnotation(desc, visible); return new TraceAnnotationVisitor(av, p); }
@Override public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { Printer p = this.p.visitFieldTypeAnnotation(typeRef, typePath, desc, visible); AnnotationVisitor av = fv == null ? null : fv.visitTypeAnnotation( typeRef, typePath, desc, visible); return new TraceAnnotationVisitor(av, p); }
@Override public void visitAttribute(final Attribute attr) { p.visitFieldAttribute(attr); super.visitAttribute(attr); }
@Override public void visitEnd() { p.visitFieldEnd(); super.visitEnd(); } }
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { AnnotationVisitor av = fv.visitAnnotation(remapper.mapDesc(desc), visible); return av == null ? null : new RemappingAnnotationAdapter(av, remapper); }
@Override public void visitEnd() { if(!methodBodyOnly) { FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC, PROVIDER_FIELD, PROVIDER_TYPE.getDescriptor(), null, null); fv.visitEnd(); if (!visitStaticInit) { int access = Opcodes.ACC_STATIC; MethodVisitor real = cw.visitMethod(access, "<clinit>", "()V", null, null); ClinitMethodVisitor mv = new ClinitMethodVisitor(real, access, "<clinit>", "()V"); mv.visitCode(); mv.returnValue(); mv.visitMaxs(0, 0); mv.visitEnd(); } } super.visitEnd(); }