コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
   }
 }
コード例 #4
0
 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);
   }
 }
コード例 #5
0
 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);
   }
 }
コード例 #6
0
 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);
   }
 }
コード例 #7
0
 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);
   }
 }
コード例 #8
0
 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);
   }
 }
コード例 #9
0
 @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));
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
   checkState();
   CheckMethodAdapter.checkDesc(desc, false);
   return new CheckAnnotationAdapter(cv.visitAnnotation(desc, visible));
 }
コード例 #13
0
 @Override
 public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
   checkEnd();
   CheckMethodAdapter.checkDesc(desc, false);
   return new CheckAnnotationAdapter(super.visitAnnotation(desc, visible));
 }
コード例 #14
0
 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));
 }