Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.ConstantPool


    }
  }

// TODO setting the constant value is a mess...
  public void setValue(int index) {
    ConstantPool cp = this.cp;
    Constant c = cp.getConstant(index);
    value = ((ConstantObject) c).getConstantValue(cp);
  }
View Full Code Here


  public World getIWorld() {
    return world;
  }

  private void deleteNewAndDup() {
    final ConstantPool cpg = getEnclosingClass().getConstantPool();
    int depth = 1;
    InstructionHandle ih = range.getStart();

    // Go back from where we are looking for 'NEW' that takes us to a stack depth of 0. INVOKESPECIAL <init>
    while (true) {
View Full Code Here

    if (!munger.getDeclaringType().isAnnotationStyleAspect()) {
      String proceedName = NameMangler.proceedMethodName(munger.getSignature().getName());

      InstructionHandle curr = localAdviceMethod.getBody().getStart();
      InstructionHandle end = localAdviceMethod.getBody().getEnd();
      ConstantPool cpg = localAdviceMethod.getEnclosingClass().getConstantPool();
      while (curr != end) {
        InstructionHandle next = curr.getNext();
        Instruction inst = curr.getInstruction();
        if ((inst.opcode == Constants.INVOKESTATIC) && proceedName.equals(((InvokeInstruction) inst).getMethodName(cpg))) {

          localAdviceMethod.getBody().append(curr,
              getRedoneProceedCall(fact, extractedShadowMethod, munger, localAdviceMethod, proceedVarList));
          Utility.deleteInstruction(curr, localAdviceMethod);
        }
        curr = next;
      }
      // and that's it.
    } else {
      // ATAJ inlining support for @AJ aspects
      // [TODO document @AJ code rule: don't manipulate 2 jps proceed at the same time.. in an advice body]
      InstructionHandle curr = localAdviceMethod.getBody().getStart();
      InstructionHandle end = localAdviceMethod.getBody().getEnd();
      ConstantPool cpg = localAdviceMethod.getEnclosingClass().getConstantPool();
      while (curr != end) {
        InstructionHandle next = curr.getNext();
        Instruction inst = curr.getInstruction();
        if ((inst instanceof INVOKEINTERFACE) && "proceed".equals(((INVOKEINTERFACE) inst).getMethodName(cpg))) {
          final boolean isProceedWithArgs;
View Full Code Here

      // is happening in an inner class so we don't inline it.
      // Note: for code style, this is done at Aspect compilation time.
      boolean canSeeProceedPassedToOther = false;
      InstructionHandle curr = adviceMethod.getBody().getStart();
      InstructionHandle end = adviceMethod.getBody().getEnd();
      ConstantPool cpg = adviceMethod.getEnclosingClass().getConstantPool();
      while (curr != end) {
        InstructionHandle next = curr.getNext();
        Instruction inst = curr.getInstruction();
        if ((inst instanceof InvokeInstruction)
            && ((InvokeInstruction) inst).getSignature(cpg).indexOf("Lorg/aspectj/lang/ProceedingJoinPoint;") > 0) {
View Full Code Here

      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()) {
View Full Code Here

  void deleteSourceObjectType(UnresolvedType ty) {
    typeMap.remove(ty.getSignature());
  }

  public static Member makeFieldJoinPointSignature(LazyClassGen cg, FieldInstruction fi) {
    ConstantPool cpg = cg.getConstantPool();
    return MemberImpl.field(fi.getClassName(cpg),
        (fi.opcode == Constants.GETSTATIC || fi.opcode == Constants.PUTSTATIC) ? Modifier.STATIC : 0, fi.getName(cpg),
        fi.getSignature(cpg));
  }
View Full Code Here

    return MemberImpl.monitorExit();
  }

  public Member makeJoinPointSignatureForArrayConstruction(LazyClassGen cg, InstructionHandle handle) {
    Instruction i = handle.getInstruction();
    ConstantPool cpg = cg.getConstantPool();
    Member retval = null;

    if (i.opcode == Constants.ANEWARRAY) {
      // ANEWARRAY arrayInstruction = (ANEWARRAY)i;
      Type ot = i.getType(cpg);
View Full Code Here

    }
    return retval;
  }

  public Member makeJoinPointSignatureForMethodInvocation(LazyClassGen cg, InvokeInstruction ii) {
    ConstantPool cpg = cg.getConstantPool();
    String name = ii.getName(cpg);
    String declaring = ii.getClassName(cpg);
    UnresolvedType declaringType = null;

    String signature = ii.getSignature(cpg);
View Full Code Here

      if (LazyMethodGen.isConstructor(aMethod)) {
        InstructionList insList = aMethod.getBody();
        InstructionHandle handle = insList.getStart();
        while (handle != null) {
          if (handle.getInstruction().opcode == Constants.INVOKESPECIAL) {
            ConstantPool cpg = newParentTarget.getConstantPool();
            InvokeInstruction invokeSpecial = (InvokeInstruction) handle.getInstruction();
            if (invokeSpecial.getClassName(cpg).equals(currentParent)
                && invokeSpecial.getMethodName(cpg).equals("<init>")) {
              // System.err.println("Transforming super call '<init>" + invokeSpecial.getSignature(cpg) + "'");

              // 1. Check there is a ctor in the new parent with
              // the same signature
              ResolvedMember newCtor = getConstructorWithSignature(newParent, invokeSpecial.getSignature(cpg));

              if (newCtor == null) {

                // 2. Check ITDCs to see if the necessary ctor is provided that way
                boolean satisfiedByITDC = false;
                for (Iterator<ConcreteTypeMunger> ii = newParentTarget.getType()
                    .getInterTypeMungersIncludingSupers().iterator(); ii.hasNext() && !satisfiedByITDC;) {
                  ConcreteTypeMunger m = ii.next();
                  if (m.getMunger() instanceof NewConstructorTypeMunger) {
                    if (m.getSignature().getSignature().equals(invokeSpecial.getSignature(cpg))) {
                      satisfiedByITDC = true;
                    }
                  }
                }

                if (!satisfiedByITDC) {
                  String csig = createReadableCtorSig(newParent, cpg, invokeSpecial);
                  weaver.getWorld()
                      .getMessageHandler()
                      .handleMessage(
                          MessageUtil.error(
                              "Unable to modify hierarchy for " + newParentTarget.getClassName()
                                  + " - the constructor " + csig + " is missing",
                              this.getSourceLocation()));
                  return false;
                }
              }

              int idx = cpg.addMethodref(newParent.getName(), invokeSpecial.getMethodName(cpg),
                  invokeSpecial.getSignature(cpg));
              invokeSpecial.setIndex(idx);
            }
          }
          handle = handle.getNext();
View Full Code Here

   * @param aroundAdvice
   */
  private void openAroundAdvice(LazyMethodGen aroundAdvice) {
    InstructionHandle curr = aroundAdvice.getBody().getStart();
    InstructionHandle end = aroundAdvice.getBody().getEnd();
    ConstantPool cpg = aroundAdvice.getEnclosingClass().getConstantPool();
    InstructionFactory factory = aroundAdvice.getEnclosingClass().getFactory();

    boolean realizedCannotInline = false;
    while (curr != end) {
      if (realizedCannotInline) {
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.ConstantPool

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.