Examples of MethodAdapter


Examples of jodd.asm.MethodAdapter

            throw new ProxettaException("Invalid static initialization block description for advice: " + advice.getName());
          }
          name = clinitMethodName + methodDivider + aspectIndex;
          access |= AsmUtil.ACC_PRIVATE | AsmUtil.ACC_FINAL;
          wd.addAdviceClinitMethod(name);
          return new MethodAdapter(wd.dest.visitMethod(access, name, desc, signature, exceptions)) {

            @Override
            public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
            }

            @Override
            public void visitLineNumber(int line, Label start) {
            }

            @Override
            public void visitMethodInsn(int opcode, String owner, String name, String desc) {
              if (opcode == INVOKESTATIC) {
                if (owner.equals(adviceReference)) {
                  owner = wd.thisReference;
                  name = adviceMethodName(name, aspectIndex);
                }
              }
              super.visitMethodInsn(opcode, owner, name, desc);
            }

            @Override
            public void visitFieldInsn(int opcode, String owner, String name, String desc) { // [F6]
              if (owner.equals(adviceReference)) {
                owner = wd.thisReference;              // [F5]
                name = adviceFieldName(name, aspectIndex);
              }
              super.visitFieldInsn(opcode, owner, name, desc);
            }
          };
        } else

        if (name.equals(INIT) == true) { // [A7]
          if (desc.equals(DESC_VOID) == false) {
            throw new ProxettaException("Advices can have only default constructors. Invalid advice: " + advice.getName());
          }

          name = initMethodName + methodDivider + aspectIndex;
          access = ProxettaAsmUtil.makePrivateFinalAccess(access);
          wd.addAdviceInitMethod(name);
          return new MethodAdapter(wd.dest.visitMethod(access, name, desc, signature, exceptions)) {
            @Override
            public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
            }

            @Override
            public void visitLineNumber(int line, Label start) {
            }

            int state; // used to detect and to ignore the first super call()

            @Override
            public void visitVarInsn(int opcode, int var) {                      // [F7]
              if ((state == 0) && (opcode == ALOAD) && (var == 0)) {
                state++;
                return;
              }
              super.visitVarInsn(opcode, var);
            }

            @Override
            public void visitMethodInsn(int opcode, String owner, String name, String desc) {
              if ((state == 1) && (opcode == INVOKESPECIAL)) {
                  state++;
                return;
              }
              if ((opcode == INVOKEVIRTUAL) || (opcode == INVOKEINTERFACE)) {
                if (owner.equals(adviceReference)) {
                  owner = wd.thisReference;
                  name = adviceMethodName(name, aspectIndex);
                }
              } else

              if (opcode == INVOKESTATIC) {
                if (owner.equals(adviceReference)) {
                  owner = wd.thisReference;
                  name = adviceMethodName(name, aspectIndex);
                }
              }
              super.visitMethodInsn(opcode, owner, name, desc);
            }

            @Override
            public void visitFieldInsn(int opcode, String owner, String name, String desc) { // [F7]
              if (owner.equals(adviceReference)) {
                owner = wd.thisReference;              // [F5]
                name = adviceFieldName(name, aspectIndex);
              }
              super.visitFieldInsn(opcode, owner, name, desc);
            }
          };

        } else

        // other methods
        if (name.equals(executeMethodName) == false) {
          name = adviceMethodName(name, aspectIndex);
          return new MethodAdapter(wd.dest.visitMethod(access, name, desc, signature, exceptions)) {

            @Override
            public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
            }
View Full Code Here

Examples of jodd.asm.MethodAdapter

            throw new ProxettaException("Invalid static initialization block description for advice: " + advice.getName());
          }
          name = clinitMethodName + methodDivider + aspectIndex;
          access |= AsmUtil.ACC_PRIVATE | AsmUtil.ACC_FINAL;
          wd.addAdviceClinitMethod(name);
          return new MethodAdapter(wd.dest.visitMethod(access, name, desc, signature, exceptions)) {

            @Override
            public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
            }

            @Override
            public void visitLineNumber(int line, Label start) {
            }

            @Override
            public void visitMethodInsn(int opcode, String owner, String name, String desc) {
              if (opcode == INVOKESTATIC) {
                if (owner.equals(adviceReference)) {
                  owner = wd.thisReference;
                  name = adviceMethodName(name, aspectIndex);
                }
              }
              super.visitMethodInsn(opcode, owner, name, desc);
            }

            @Override
            public void visitFieldInsn(int opcode, String owner, String name, String desc) { // [F6]
              if (owner.equals(adviceReference)) {
                owner = wd.thisReference;              // [F5]
                name = adviceFieldName(name, aspectIndex);
              }
              super.visitFieldInsn(opcode, owner, name, desc);
            }
          };
        } else

        if (name.equals(INIT) == true) { // [A7]
          if (desc.equals(DESC_VOID) == false) {
            throw new ProxettaException("Advices can have only default constructors. Invalid advice: " + advice.getName());
          }

          name = initMethodName + methodDivider + aspectIndex;
          access = ProxettaAsmUtil.makePrivateFinalAccess(access);
          wd.addAdviceInitMethod(name);
          return new MethodAdapter(wd.dest.visitMethod(access, name, desc, signature, exceptions)) {
            @Override
            public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
            }

            @Override
            public void visitLineNumber(int line, Label start) {
            }

            int state; // used to detect and to ignore the first super call()

            @Override
            public void visitVarInsn(int opcode, int var) {                      // [F7]
              if ((state == 0) && (opcode == ALOAD) && (var == 0)) {
                state++;
                return;
              }
              super.visitVarInsn(opcode, var);
            }

            @Override
            public void visitMethodInsn(int opcode, String owner, String name, String desc) {
              if ((state == 1) && (opcode == INVOKESPECIAL)) {
                  state++;
                return;
              }
              if ((opcode == INVOKEVIRTUAL) || (opcode == INVOKEINTERFACE)) {
                if (owner.equals(adviceReference)) {
                  owner = wd.thisReference;
                  name = adviceMethodName(name, aspectIndex);
                }
              } else

              if (opcode == INVOKESTATIC) {
                if (owner.equals(adviceReference)) {
                  owner = wd.thisReference;
                  name = adviceMethodName(name, aspectIndex);
                }
              }
              super.visitMethodInsn(opcode, owner, name, desc);
            }

            @Override
            public void visitFieldInsn(int opcode, String owner, String name, String desc) { // [F7]
              if (owner.equals(adviceReference)) {
                owner = wd.thisReference;              // [F5]
                name = adviceFieldName(name, aspectIndex);
              }
              super.visitFieldInsn(opcode, owner, name, desc);
            }
          };

        } else

        // other methods
        if (name.equals(executeMethodName) == false) {
          name = adviceMethodName(name, aspectIndex);
          return new MethodAdapter(wd.dest.visitMethod(access, name, desc, signature, exceptions)) {

            @Override
            public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
            }
View Full Code Here

Examples of org.deuce.objectweb.asm.MethodAdapter

   
    Type[] args = Type.getArgumentTypes(desc);
    if(args.length>0 && args[args.length-1].equals(ITypeInternalName.CONTEXT))
      return  new RemoteMethodTransformer(originalMethod, className, name, desc);
    else
      return new MethodAdapter(originalMethod){
        @Override
        public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
          if(desc.equals(ITypeInternalName.REMOTE))
            return null;
          return super.visitAnnotation(desc, visible);
View Full Code Here

Examples of org.objectweb.asm.MethodAdapter

    };
  }

  public MethodVisitor visitMethod(final int access, final String methodName,
      final String desc, final String signature, final String[] exceptions) {
    return new MethodAdapter(EMPTY_VISITOR) {

      Map<String,Annotation> ma = new HashMap<String,Annotation>();
      ArrayList<Map<String, Annotation>> pa = new ArrayList<Map<String, Annotation>>();

      public AnnotationVisitor visitAnnotationDefault() {
View Full Code Here

Examples of org.objectweb.asm.MethodAdapter

      return EMPTY_VISITOR;
    }

    public MethodVisitor visitMethod(final int access, final String methodName,
        final String desc, final String signature, final String[] exceptions) {
      return new MethodAdapter(EMPTY_VISITOR) {

        public AnnotationVisitor visitAnnotationDefault() {
          // remove leading ()
          String type = desc.substring(2);
View Full Code Here

Examples of org.objectweb.asm.MethodAdapter

            ClassReader cr = new ClassReader(bytes);
            ClassWriter cw = new ClassWriter(false, true);
            cr.accept(
                    new ClassAdapter(cw) {
                        public MethodVisitor visitMethod(int access, final String name, String desc, String signature, String[] exceptions) {
                            return new MethodAdapter(super.visitMethod(access, name, desc, signature, exceptions)) {
                                public AnnotationVisitor visitAnnotationDefault() {
                                    return new DefaultAnnotationBuilderVisitor(newDefaults, name);
                                }
                            };
                        }
View Full Code Here

Examples of org.objectweb.asm.MethodAdapter

    @Override
    public MethodVisitor visitMethod(int access, String name, String desc,
        String signature, String[] exceptions) {
      final MethodVisitor mv = super.visitMethod(access, name, desc,
          signature, exceptions);
      return new MethodAdapter(mv) {
        @Override
        public void visitMaxs(int maxStack, int maxLocals) {
          super.visitMaxs(-1, maxLocals);
        }
      };
View Full Code Here

Examples of org.objectweb.asm.MethodAdapter

    @Override
    public MethodVisitor visitMethod(int access, String name, String desc,
        String signature, String[] exceptions) {
      final MethodVisitor mv = super.visitMethod(access, name, desc,
          signature, exceptions);
      return new MethodAdapter(mv) {
        @Override
        public void visitMaxs(int maxStack, int maxLocals) {
          super.visitMaxs(-1, maxLocals);
        }
      };
View Full Code Here

Examples of org.objectweb.asm.MethodAdapter

        TODO(mmirabelli): find how to change the access of the default
        constructor, since that it seems to be private by default in a private
        class. It cause this assembly to break in private inner classes, unless
        an explicit public constructor will be defined.
       */
      mv = new MethodAdapter(mv) {
        private boolean alreadySet = false;

        @Override
        public void visitMethodInsn(final int opcode, final String klass, final String method,
            final String desc) {
View Full Code Here

Examples of org.objectweb.asm.MethodAdapter

                MethodVisitor v = cv.visitMethod(access,
                        name,
                        desc,
                        signature,
                        exceptions);
                return new MethodAdapter(v) {

                    private final List params = new ArrayList();

                    public AnnotationVisitor visitParameterAnnotation(
                        final int parameter,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.