Package jodd.asm5

Examples of jodd.asm5.Type


  /**
   * Creates init method that simply calls all advice constructor methods in correct order.
   * This created init method is called from each destination's constructor.
   */
  protected void makeProxyConstructor() {
    MethodVisitor mv = wd.dest.visitMethod(AsmUtil.ACC_PRIVATE | AsmUtil.ACC_FINAL, initMethodName, DESC_VOID, null, null);
    mv.visitCode();
    if (wd.adviceInits != null) {
      for (String name : wd.adviceInits) {
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, wd.thisReference, name, DESC_VOID);
      }
    }
    mv.visitInsn(RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
  }
View Full Code Here


  /**
   * Created empty default constructor.
   */
  protected void createEmptyCtor() {
    MethodVisitor mv = wd.dest.visitMethod(AsmUtil.ACC_PUBLIC, INIT, "()V", null, null);
    mv.visitCode();
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, AsmUtil.SIGNATURE_JAVA_LANG_OBJECT, INIT, "()V");
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(1, 1);
    mv.visitEnd();
  }
View Full Code Here

    int access = msign.getAccessFlags();

    access &= ~ACC_ABSTRACT;
    access &= ~ACC_NATIVE;

    MethodVisitor mv = wd.dest.visitMethod(
        access, msign.getMethodName(), msign.getDescription(), msign.getRawSignature(), msign.getExceptionsArray());
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, wd.thisReference, wd.wrapperRef, wd.wrapperType);
    loadVirtualMethodArguments(mv, msign);
    if (wd.wrapInterface) {
      mv.visitMethodInsn(INVOKEINTERFACE, wd.wrapperType.substring(1, wd.wrapperType.length() - 1), msign.getMethodName(), msign.getDescription());
    } else {
      mv.visitMethodInsn(INVOKEVIRTUAL, wd.wrapperType.substring(1, wd.wrapperType.length() - 1), msign.getMethodName(), msign.getDescription());
    }
    ProxettaAsmUtil.prepareReturnValue(mv, msign, 0);
    visitReturn(mv, msign, true);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
  }
View Full Code Here

   * Creates method signature from method name.
   */
  protected MethodSignatureVisitor createMethodSignature(int access, String methodName, String description, String signature, String classname) {
    MethodSignatureVisitor v = new MethodSignatureVisitor(methodName, access, classname, description, signature, this);
    v.hierarchyLevel = this.hierarchyLevel;
    new SignatureReader(signature != null ? signature : description).accept(v);
    return v;
  }
View Full Code Here

   * Creates method signature from method name.
   */
  protected MethodSignatureVisitor createMethodSignature(int access, String methodName, String description, String signature, String classname) {
    MethodSignatureVisitor v = new MethodSignatureVisitor(methodName, access, classname, description, signature, this);
    v.hierarchyLevel = this.hierarchyLevel;
    new SignatureReader(signature != null ? signature : description).accept(v);
    return v;
  }
View Full Code Here

    assertEquals("(java.util.List<? super java.lang.Integer>)", resolveSignature(mps[2].getSignature()));
  }


  private String resolveSignature(String signature) {
    SignatureReader signatureReader = new SignatureReader("(" + signature + ")V");
    StringBuilder sb = new StringBuilder();
    signatureReader.accept(new TraceSignatureVisitor(sb, true));
    return sb.toString();
  }
View Full Code Here

            // now calculate the parameters
            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            // and finally invoke the target method on the provided Contextual Instance
            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            boolean interfaceMethod = Modifier.isInterface(delegatedMethod.getDeclaringClass().getModifiers());
            mv.visitMethodInsn(interfaceMethod ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL,
                               declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor);

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy));

            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor);

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            // now calculate the parameters
            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            // and finally invoke the target method on the provided Contextual Instance
            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            if (abstractMethod)
            {
                // generate an empty return block
            }
            else
            {
                // invoke the method on the super class;
                mv.visitMethodInsn(Opcodes.INVOKESPECIAL, declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor);
            }

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

    @Override
    public void visit(final String name, final Object value) {
        if ("value".equals(name)) {
            if (value instanceof Type) {
                final Type type = (Type) value;
                final int sort = type.getSort();
                switch (sort) {
                    case Type.OBJECT:
                        if (type.getClassName().equals(ValidationRunner.class.getName())) {
                            classInfos.add(current);
                        }
                        break;
                }
            } else {
View Full Code Here

TOP

Related Classes of jodd.asm5.Type

Copyright © 2018 www.massapicom. 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.