public FieldVisitor visitField( final int access, final String name, final String desc, final String signature, final Object value) { checkState(); checkAccess( access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED + 0x40000); // ClassWriter.ACC_SYNTHETIC_ATTRIBUTE CheckMethodAdapter.checkIdentifier(name, "field name"); CheckMethodAdapter.checkDesc(desc, false); if (signature != null) { CheckMethodAdapter.checkFieldSignature(signature); } if (value != null) { CheckMethodAdapter.checkConstant(value); } FieldVisitor av = cv.visitField(access, name, desc, signature, value); return new CheckFieldAdapter(av); }
public void visit( final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { if (start) { throw new IllegalStateException("visit must be called only once"); } start = true; checkState(); checkAccess( access, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER + Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED + 0x40000); // ClassWriter.ACC_SYNTHETIC_ATTRIBUTE if (name == null || !name.endsWith("package-info")) { CheckMethodAdapter.checkInternalName(name, "class name"); } if ("java/lang/Object".equals(name)) { if (superName != null) { throw new IllegalArgumentException( "The super class name of the Object class must be 'null'"); } } else { CheckMethodAdapter.checkInternalName(superName, "super class name"); } if (signature != null) { CheckMethodAdapter.checkClassSignature(signature); } if ((access & Opcodes.ACC_INTERFACE) != 0) { if (!"java/lang/Object".equals(superName)) { throw new IllegalArgumentException( "The super class name of interfaces must be 'java/lang/Object'"); } } if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { CheckMethodAdapter.checkInternalName(interfaces[i], "interface name at index " + i); } } cv.visit(version, access, name, signature, superName, interfaces); }
public void visitInnerClassType(final String name) { if (state != CLASS_TYPE) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "inner class name"); if (sv != null) { sv.visitInnerClassType(name); } }
public void visitFormalTypeParameter(final String name) { if (type == TYPE_SIGNATURE || (state != EMPTY && state != FORMAL && state != BOUND)) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "formal type parameter"); state = FORMAL; if (sv != null) { sv.visitFormalTypeParameter(name); } }
public void visitClassType(final String name) { if (type != TYPE_SIGNATURE || state != EMPTY) { throw new IllegalStateException(); } CheckMethodAdapter.checkInternalName(name, "class name"); state = CLASS_TYPE; if (sv != null) { sv.visitClassType(name); } }
public void visitTypeVariable(final String name) { if (type != TYPE_SIGNATURE || state != EMPTY) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "type variable"); state = SIMPLE_TYPE; if (sv != null) { sv.visitTypeVariable(name); } }
public void visitEnum(final String name, final String desc, final String value) { checkEnd(); checkName(name); CheckMethodAdapter.checkDesc(desc, false); if (value == null) { throw new IllegalArgumentException("Invalid enum value"); } if (av != null) { av.visitEnum(name, desc, value); } }
public MethodVisitor visitMethod( final int access, final String name, final String desc, final String signature, final String[] exceptions) { checkState(); checkAccess( access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL + Opcodes.ACC_SYNCHRONIZED + Opcodes.ACC_BRIDGE + Opcodes.ACC_VARARGS + Opcodes.ACC_NATIVE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_STRICT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_DEPRECATED + 0x40000); // ClassWriter.ACC_SYNTHETIC_ATTRIBUTE CheckMethodAdapter.checkMethodIdentifier(name, "method name"); CheckMethodAdapter.checkMethodDesc(desc); if (signature != null) { CheckMethodAdapter.checkMethodSignature(signature); } if (exceptions != null) { for (int i = 0; i < exceptions.length; ++i) { CheckMethodAdapter.checkInternalName(exceptions[i], "exception name at index " + i); } } if (checkDataFlow) { return new CheckMethodAdapter( access, name, desc, cv.visitMethod(access, name, desc, signature, exceptions), labels); } else { return new CheckMethodAdapter( cv.visitMethod(access, name, desc, signature, exceptions), labels); } }
@Override public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String desc, final boolean visible) { checkEnd(); int sort = typeRef >>> 24; if (sort != TypeReference.FIELD) { throw new IllegalArgumentException( "Invalid type reference sort 0x" + Integer.toHexString(sort)); } CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(super.visitTypeAnnotation(typeRef, typePath, desc, visible)); }
public void visitOuterClass(final String owner, final String name, final String desc) { checkState(); if (outer) { throw new IllegalStateException("visitOuterClass can be called only once."); } outer = true; if (owner == null) { throw new IllegalArgumentException("Illegal outer class owner"); } if (desc != null) { CheckMethodAdapter.checkMethodDesc(desc); } cv.visitOuterClass(owner, name, desc); }
public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { checkState(); CheckMethodAdapter.checkInternalName(name, "class name"); if (outerName != null) { CheckMethodAdapter.checkInternalName(outerName, "outer class name"); } if (innerName != null) { CheckMethodAdapter.checkIdentifier(innerName, "inner class name"); } checkAccess( access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL + Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM); cv.visitInnerClass(name, outerName, innerName, access); }
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { checkState(); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(cv.visitAnnotation(desc, visible)); }
@Override public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { checkEnd(); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(super.visitAnnotation(desc, visible)); }
public AnnotationVisitor visitAnnotation(final String name, final String desc) { checkEnd(); checkName(name); CheckMethodAdapter.checkDesc(desc, false); return new CheckAnnotationAdapter(av == null ? null : av.visitAnnotation(name, desc)); }