Package jodd.proxetta

Examples of jodd.proxetta.ProxettaException


        Method m;
        try {
          m = type.getMethod(methodName, methodArgTypes);
        } catch (NoSuchMethodException nsmex) {
          throw new ProxettaException(nsmex);
        }

        TransactionAnnotationData txAnn = getTransactionAnnotation(m);
        if (txAnn != null) {
          txMode = new JtxTransactionMode();
View Full Code Here


  /**
   * Validates argument index.
   */
  public static void checkArgumentIndex(MethodInfo methodInfo, int argIndex) {
    if ((argIndex < 1) || (argIndex > methodInfo.getArgumentsCount())) {
      throw new ProxettaException("Invalid argument index: " + argIndex);
    }
  }
View Full Code Here

      if (isArray() == true) {
        type = '[';
        typeName = getArrayDepthString() + typeName;
      }
      if (type == 'V') {
        throw new ProxettaException("Method argument can't be void");
      }
      argumentsCount++;
      argumentsOpcodeType.add(type);
      argumentsOffset.add(argumentsWords + 1);
      argumentsTypeNames.add(typeName);
View Full Code Here

    InputStream inputStream = null;
    try {
      inputStream = ClassLoaderUtil.getClassAsStream(advice);
      return new ClassReader(inputStream);
    } catch (IOException ioex) {
      throw new ProxettaException(ioex);
    } finally {
      StreamUtil.close(inputStream);
    }
  }
View Full Code Here

      /**
       * Prevents advice to have inner classes.
       */
      @Override
      public void visitInnerClass(String name, String outerName, String innerName, int access) {
        throw new ProxettaException("Proxetta doesn't allow inner classes in/for advice: " + advice.getName());
      }

      /**
       * Clones advices fields to destination.
       */
      @Override
      public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
        wd.dest.visitField(access, adviceFieldName(name, aspectIndex), desc, signature, value);     // [A5]
        return super.visitField(access, name, desc, signature, value);
      }

      /**
       * Copies advices methods to destination.
       */
      @Override
      public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        if (name.equals(CLINIT) == true) {              // [A6]
          if (desc.equals(DESC_VOID) == false) {
            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);
View Full Code Here

      return null;
    }

    int access = msign.getAccessFlags();
    if ((access & ACC_ABSTRACT) != 0) {
      throw new ProxettaException("Unable to process abstract method: " + msign);
    }

    wd.proxyApplied = true;
    return new ProxettaMethodBuilder(msign, wd, aspectList);
  }
View Full Code Here

      }
    }

    // detection of super calls
    if ((opcode == INVOKESPECIAL) && (owner.equals(wd.nextSupername) && (name.equals(INIT) == false))) {
      throw new ProxettaException("Super call detected in class " + methodInfo.getClassname() + " method: " + methodInfo.getSignature() +
        "\nProxetta can't handle super calls due to VM limitations.");
    }


    InvokeReplacer ir = null;

    // find first matching aspect
    for (InvokeAspect aspect : aspects) {
      ir = aspect.pointcut(invokeInfo);
      if (ir != null) {
        break;
      }
    }

    if (ir == null || ir.isNone()) {

      if (ProxettaAsmUtil.isCreateArgumentsArrayMethod(name, desc)) {
        ProxyTargetReplacement.createArgumentsArray(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (ProxettaAsmUtil.isCreateArgumentsClassArrayMethod(name, desc)) {
        ProxyTargetReplacement.createArgumentsClassArray(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (ProxettaAsmUtil.isArgumentsCountMethod(name, desc)) {
        ProxyTargetReplacement.argumentsCount(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (ProxettaAsmUtil.isTargetMethodNameMethod(name, desc)) {
        ProxyTargetReplacement.targetMethodName(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (ProxettaAsmUtil.isTargetMethodDescriptionMethod(name, desc)) {
        ProxyTargetReplacement.targetMethodDescription(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (ProxettaAsmUtil.isTargetMethodSignatureMethod(name, desc)) {
        ProxyTargetReplacement.targetMethodSignature(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (ProxettaAsmUtil.isReturnTypeMethod(name, desc)) {
        ProxyTargetReplacement.returnType(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (ProxettaAsmUtil.isTargetClassMethod(name, desc)) {
        ProxyTargetReplacement.targetClass(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      if (isArgumentTypeMethod(name, desc)) {
        int argIndex = this.getArgumentIndex();
        ProxyTargetReplacement.argumentType(mv, methodInfo, argIndex);
        wd.proxyApplied = true;
        return;
      }

      if (isArgumentMethod(name, desc)) {
        int argIndex = this.getArgumentIndex();
        ProxyTargetReplacement.argument(mv, methodInfo, argIndex);
        wd.proxyApplied = true;
        return;
      }

      if (isInfoMethod(name, desc)) {
        ProxyTargetReplacement.info(mv, methodInfo);
        wd.proxyApplied = true;
        return;
      }

      super.visitMethodInsn(opcode, owner, name, desc);
      return;
    }

    wd.proxyApplied = true;

    String exOwner = owner;
    owner = ir.getOwner();
    name = ir.getMethodName();

    switch (opcode) {
      case INVOKEINTERFACE:
        desc = prependArgument(desc, AsmUtil.L_SIGNATURE_JAVA_LANG_OBJECT);
        break;
      case INVOKEVIRTUAL:
        desc = prependArgument(desc, AsmUtil.L_SIGNATURE_JAVA_LANG_OBJECT);
        break;
      case INVOKESTATIC:
        break;
      default:
        throw new ProxettaException("Unsupported opcode: " + opcode);
    }

    // additional arguments
    if (ir.isPassOwnerName()) {
      desc = appendArgument(desc, AsmUtil.L_SIGNATURE_JAVA_LANG_STRING);
View Full Code Here

   * Returns argument index from the history.
   * <b>Must</b> POP value from the stack after the execution.
   */
  protected int getArgumentIndex() {
    if (isPrevious == false) {
      throw new ProxettaException("Unexpected previous instruction type used for setting argument index");
    }
    int argIndex;
    switch (opcode) {
      case ICONST_0: argIndex = 0; break;
      case ICONST_1: argIndex = 1; break;
      case ICONST_2: argIndex = 2; break;
      case ICONST_3: argIndex = 3; break;
      case ICONST_4: argIndex = 4; break;
      case ICONST_5: argIndex = 5; break;
      case BIPUSH:
      case SIPUSH:
        argIndex = operand; break;
      default:
        throw new ProxettaException("Unexpected previous instruction used for setting argument index");
    }
    return argIndex;
  }
View Full Code Here

      ClassReader cr = null;
      try {
        inputStream = ClassLoaderUtil.getClassAsStream(nextSupername);
        cr = new ClassReader(inputStream);
      } catch (IOException ioex) {
        throw new ProxettaException("Unable to inspect super class: " + nextSupername, ioex);
      } finally {
        StreamUtil.close(inputStream);
      }
      hierarchyLevel++;
      superList.add(nextSupername);
      superClassReaders.add(cr)// remember the super class reader
      cr.accept(new SuperClassVisitor(), 0);
    }
    superClasses = superList.toArray(new String[superList.size()]);

    // check all interface methods that are not overridden in super-interface
    if (nextInterfaces != null) {
      while (!nextInterfaces.isEmpty()) {
        Iterator<String> iterator = nextInterfaces.iterator();
        String next = iterator.next();
        iterator.remove();

        InputStream inputStream = null;
        ClassReader cr = null;
        try {
          inputStream = ClassLoaderUtil.getClassAsStream(next);
          cr = new ClassReader(inputStream);
        } catch (IOException ioex) {
          throw new ProxettaException("Unable to inspect super interface: " + next, ioex);
        } finally {
          StreamUtil.close(inputStream);
        }
        hierarchyLevel++;
        superClassReaders.add(cr);        // remember the super class reader
View Full Code Here

   */
  protected void createFirstChainDelegate_Start() {
    // check invalid access flags
    int access = msign.getAccessFlags();
    if ((access & AsmUtil.ACC_FINAL) != 0) {   // detect final
      throw new ProxettaException("Unable to create proxy for final method: " + msign +". Remove final modifier or change the pointcut definition.");
    }

    // create proxy methods
    tmd = new TargetMethodData(msign, aspectList);

View Full Code Here

TOP

Related Classes of jodd.proxetta.ProxettaException

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.