예제 #1
0
 public void visitEnd() {
   if (clinit != null) {
     clinit.visitInsn(Opcodes.RETURN);
     clinit.visitMaxs(0, 0);
   }
   cv.visitEnd();
 }
예제 #2
0
  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);
    } else {
      mv = cv.visitMethod(access, name, desc, signature, exceptions);
    }
    return mv;
  }