String signature, String[] exceptions) { if (cv != null) { return cv.visitMethod(access, name, desc, signature, exceptions);
/** * Visits the end of the class. This method, which is the last one to be * called, is used to inform the visitor that all the fields and methods of * the class have been visited. */ public void visitEnd() { if (cv != null) { cv.visitEnd(); } } }
/** * Makes the given class visitor visit this inner class. * * @param cv * a class visitor. */ public void accept(final ClassVisitor cv) { cv.visitInnerClass(name, outerName, innerName, access); } }
cv.visit(version, access, name, signature, superName, interfaces); cv.visitSource(sourceFile, sourceDebug); cv.visitOuterClass(outerClass, outerMethod, outerMethodDesc); for (i = 0; i < n; ++i) { AnnotationNode an = visibleAnnotations.get(i); an.accept(cv.visitAnnotation(an.desc, true)); an.accept(cv.visitAnnotation(an.desc, false)); an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, true)); for (i = 0; i < n; ++i) { TypeAnnotationNode an = invisibleTypeAnnotations.get(i); an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false)); cv.visitAttribute(attrs.get(i)); cv.visitEnd();
String signature, Object value) { if (cv != null) { return cv.visitField(access, name, desc, signature, value);
@Override public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { cv.visit(version, access, name, signature, superName, interfaces); this.name = name; }
/** * Visits an annotation of the class. * * @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 (cv != null) { return cv.visitAnnotation(desc, visible); } return null; }
/** * Visits the enclosing class of the class. This method must be called only * if the class has an enclosing class. * * @param owner * internal name of the enclosing class of the class. * @param name * the name of the method that contains the class, or * <tt>null</tt> if the class is not enclosed in a method of its * enclosing class. * @param desc * the descriptor of the method that contains the class, or * <tt>null</tt> if the class is not enclosed in a method of its * enclosing class. */ public void visitOuterClass(String owner, String name, String desc) { if (cv != null) { cv.visitOuterClass(owner, name, desc); } }
/** * Visits a non standard attribute of the class. * * @param attr * an attribute. */ public void visitAttribute(Attribute attr) { if (cv != null) { cv.visitAttribute(attr); } }
/** * Visits the source of the class. * * @param source * the name of the source file from which the class was compiled. * May be <tt>null</tt>. * @param debug * additional debug information to compute the correspondance * between source and compiled elements of the class. May be * <tt>null</tt>. */ public void visitSource(String source, String debug) { if (cv != null) { cv.visitSource(source, debug); } }
classVisitor.visit(readInt(items[1] - 7), access, name, signature, superClass, interfaces); classVisitor.visitSource(sourceFile, sourceDebug); classVisitor.visitOuterClass(enclosingOwner, enclosingName, enclosingDesc); for (int i = readUnsignedShort(anns), v = anns + 2; i > 0; --i) { v = readAnnotationValues(v + 2, c, true, classVisitor.visitAnnotation(readUTF8(v, c), true)); for (int i = readUnsignedShort(ianns), v = ianns + 2; i > 0; --i) { v = readAnnotationValues(v + 2, c, true, classVisitor.visitAnnotation(readUTF8(v, c), false)); v = readAnnotationTarget(context, v); v = readAnnotationValues(v + 2, c, true, classVisitor.visitTypeAnnotation(context.typeRef, context.typePath, readUTF8(v, c), true)); v = readAnnotationTarget(context, v); v = readAnnotationValues(v + 2, c, true, classVisitor.visitTypeAnnotation(context.typeRef, context.typePath, readUTF8(v, c), false)); Attribute attr = attributes.next; attributes.next = null; classVisitor.visitAttribute(attributes);
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 void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0; if (computeSVUID) { this.name = name; this.access = access; this.interfaces = new String[interfaces.length]; System.arraycopy(interfaces, 0, this.interfaces, 0, interfaces.length); } super.visit(version, access, name, signature, superName, interfaces); }
@Override public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { Printer p = this.p.visitClassAnnotation(desc, visible); AnnotationVisitor av = cv == null ? null : cv.visitAnnotation(desc, visible); return new TraceAnnotationVisitor(av, p); }
@Override public void visitOuterClass(final String owner, final String name, final String desc) { p.visitOuterClass(owner, name, desc); super.visitOuterClass(owner, name, desc); }
@Override public void visitAttribute(final Attribute attr) { p.visitClassAttribute(attr); super.visitAttribute(attr); }
@Override public void visitSource(final String file, final String debug) { p.visitSource(file, debug); super.visitSource(file, debug); }
@Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { MethodVisitor mv; if ("<clinit>".equals(name)) { int a = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC; String n = prefix + counter++; mv = cv.visitMethod(a, n, desc, signature, exceptions); if (clinit == null) { clinit = cv.visitMethod(a, name, desc, null, null); } clinit.visitMethodInsn(Opcodes.INVOKESTATIC, this.name, n, desc, false); } else { mv = cv.visitMethod(access, name, desc, signature, exceptions); } return mv; }
/** * Visits information about an inner class. This inner class is not * necessarily a member of the class being visited. * * @param name * the internal name of an inner class (see * {@link Type#getInternalName() getInternalName}). * @param outerName * the internal name of the class to which the inner class * belongs (see {@link Type#getInternalName() getInternalName}). * May be <tt>null</tt> for not member classes. * @param innerName * the (simple) name of the inner class inside its enclosing * class. May be <tt>null</tt> for anonymous inner classes. * @param access * the access flags of the inner class as originally declared in * the enclosing class. */ public void visitInnerClass(String name, String outerName, String innerName, int access) { if (cv != null) { cv.visitInnerClass(name, outerName, innerName, access); } }
@Override public void visitEnd() { p.visitClassEnd(); if (pw != null) { p.print(pw); pw.flush(); } super.visitEnd(); } }