Examples of MethodGen


Examples of org.aspectj.apache.bcel.generic.MethodGen

      return savedMethod; // ??? this relies on gentle treatment of
      // constant pool
    }

    try {
      MethodGen gen = pack();
      savedMethod = gen.getMethod();
      return savedMethod;
    } catch (ClassGenException e) {
      enclosingClass
          .getBcelObjectType()
          .getResolvedTypeX()
          .getWorld()
          .showMessage(
              IMessage.ERROR,
              WeaverMessages.format(WeaverMessages.PROBLEM_GENERATING_METHOD, this.getClassName(), this.getName(),
                  e.getMessage()),
              this.getMemberView() == null ? null : this.getMemberView().getSourceLocation(), null);
      // throw e; PR 70201.... let the normal problem reporting
      // infrastructure deal with this rather than crashing.
      body = null;
      MethodGen gen = pack();
      return gen.getMethod();
    }
  }
View Full Code Here

Examples of org.aspectj.apache.bcel.generic.MethodGen

    int flags = getAccessFlags();
    if (enclosingClass.getWorld().isJoinpointSynchronizationEnabled()
        && enclosingClass.getWorld().areSynchronizationPointcutsInUse()) {
      flags = getAccessFlagsWithoutSynchronized();
    }
    MethodGen gen = new MethodGen(flags, getReturnType(), getArgumentTypes(), null, // getArgumentNames(),
        getName(), getEnclosingClass().getName(), new InstructionList(), getEnclosingClass().getConstantPool());
    for (int i = 0, len = declaredExceptions.length; i < len; i++) {
      gen.addException(declaredExceptions[i]);
    }

    for (Attribute attr : attributes) {
      gen.addAttribute(attr);
    }

    if (newAnnotations != null) {
      for (AnnotationAJ element : newAnnotations) {
        gen.addAnnotation(new AnnotationGen(((BcelAnnotation) element).getBcelAnnotation(), gen.getConstantPool(), true));
      }
    }

    if (newParameterAnnotations != null) {
      for (int i = 0; i < newParameterAnnotations.length; i++) {
        AnnotationAJ[] annos = newParameterAnnotations[i];
        for (int j = 0; j < annos.length; j++) {
          gen.addParameterAnnotation(i,
              new AnnotationGen(((BcelAnnotation) annos[j]).getBcelAnnotation(), gen.getConstantPool(), true));
        }
      }
    }

    if (memberView != null && memberView.getAnnotations() != null && memberView.getAnnotations().length != 0) {
      AnnotationAJ[] ans = memberView.getAnnotations();
      for (int i = 0, len = ans.length; i < len; i++) {
        AnnotationGen a = ((BcelAnnotation) ans[i]).getBcelAnnotation();
        gen.addAnnotation(new AnnotationGen(a, gen.getConstantPool(), true));
      }
    }

    if (isSynthetic) {
      if (enclosingClass.getWorld().isInJava5Mode()) {
        gen.setModifiers(gen.getModifiers() | ACC_SYNTHETIC);
      }
      // belt and braces, do the attribute even on Java 5 in addition to
      // the modifier flag
      ConstantPool cpg = gen.getConstantPool();
      int index = cpg.addUtf8("Synthetic");
      gen.addAttribute(new Synthetic(index, 0, new byte[0], cpg));
    }

    if (hasBody()) {
      if (this.enclosingClass.getWorld().shouldFastPackMethods()) {
        if (isAdviceMethod() || getName().equals("<clinit>")) {
          packBody(gen);
        } else {
          optimizedPackBody(gen);
        }
      } else {
        packBody(gen);
      }
      gen.setMaxLocals();
      gen.setMaxStack();
    } else {
      gen.setInstructionList(null);
    }
    return gen;
  }
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.