Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.ConstantPoolGen$Index


    return String.valueOf(characters, index++, len);
  }

  @Override
  public Index getIndex(int bookmark) {
    return new Index(bookmark, index);
  }
View Full Code Here


     *
     * @see org.apache.bcel.verifier.statics.LocalVariablesInfo
     * @see org.apache.bcel.verifier.statics.Pass2Verifier#getLocalVariablesInfo(int)
     */
    public VerificationResult do_verify() {
        ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool());
        // Init Visitors
        InstConstraintVisitor icv = new InstConstraintVisitor();
        icv.setConstantPoolGen(constantPoolGen);

        ExecutionVisitor ev = new ExecutionVisitor();
View Full Code Here

     *
     * @see org.apache.bcel.verifier.statics.LocalVariablesInfo
     * @see org.apache.bcel.verifier.statics.Pass2Verifier#getLocalVariablesInfo(int)
     */
    public VerificationResult do_verify() {
        ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool());
        // Init Visitors
        InstConstraintVisitor icv = new InstConstraintVisitor();
        icv.setConstantPoolGen(constantPoolGen);

        ExecutionVisitor ev = new ExecutionVisitor();
View Full Code Here

          new SourceLocation(new File(myGen.getFileName()),0), null
          );
  }

  private static boolean hasSourceDebugExtensionAttribute(ClassGen gen) {
    ConstantPoolGen pool = gen.getConstantPool();
    Attribute[] attrs = gen.getAttributes();
    for (int i = 0; i < attrs.length; i++) {
      if ("SourceDebugExtension"
        .equals(((ConstantUtf8) pool.getConstant(attrs[i].getNameIndex())).getBytes())) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

    InstructionList ret = new InstructionList();
    InstructionList sourceList = donor.getBody();

    Map srcToDest  = new HashMap();
    ConstantPoolGen donorCpg = donor.getEnclosingClass().getConstantPoolGen();
    ConstantPoolGen recipientCpg = recipient.getEnclosingClass().getConstantPoolGen();
   
    boolean isAcrossClass = donorCpg != recipientCpg;
   
    // first pass: copy the instructions directly, populate the srcToDest map,
    // fix frame instructions
    for (InstructionHandle src = sourceList.getStart();
      src != null;
      src = src.getNext())
    {
      Instruction fresh = Utility.copyInstruction(src.getInstruction());
      InstructionHandle dest;
      if (fresh instanceof CPInstruction) {
        // need to reset index to go to new constant pool.  This is totally
        // a computation leak... we're testing this LOTS of times.  Sigh.
        if (isAcrossClass) {
          CPInstruction cpi = (CPInstruction) fresh;
          cpi.setIndex(
            recipientCpg.addConstant(
              donorCpg.getConstant(cpi.getIndex()),
              donorCpg));
        }
      }
      if (src.getInstruction() == Range.RANGEINSTRUCTION) {
View Full Code Here

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

    public static Member makeFieldJoinPointSignature(LazyClassGen cg, FieldInstruction fi) {
      ConstantPoolGen cpg = cg.getConstantPoolGen();
        return           
                MemberImpl.field(
                  fi.getClassName(cpg),
                  (fi instanceof GETSTATIC || fi instanceof PUTSTATIC)
                  ? Modifier.STATIC: 0,
View Full Code Here

    }
       
    }

    public Member makeJoinPointSignatureForMethodInvocation(LazyClassGen cg, InvokeInstruction ii) {
      ConstantPoolGen cpg = cg.getConstantPoolGen();
      String name = ii.getName(cpg);
        String declaring = ii.getClassName(cpg);
        UnresolvedType declaringType = null;
       
        String signature = ii.getSignature(cpg);
View Full Code Here

          if (aMethod.getName().equals("<init>")) {
            InstructionList insList = aMethod.getBody();
            InstructionHandle handle = insList.getStart();
            while (handle!= null) {
              if (handle.getInstruction() instanceof INVOKESPECIAL) {
                ConstantPoolGen cpg = newParentTarget.getConstantPoolGen();
                INVOKESPECIAL invokeSpecial = (INVOKESPECIAL)handle.getInstruction();
                if (invokeSpecial.getClassName(cpg).equals(currentParent) && invokeSpecial.getMethodName(cpg).equals("<init>")) {
                  // System.err.println("Transforming super call '<init>"+sp.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 ii = newParentTarget.getType().getInterTypeMungersIncludingSupers().iterator(); ii.hasNext() && !satisfiedByITDC; ) {
                                    ConcreteTypeMunger m = (ConcreteTypeMunger)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 out where to output Java program
   */
  public BCELifier(JavaClass clazz, OutputStream out) {
    _clazz = clazz;
    _out = new PrintWriter(out);
    _cp = new ConstantPoolGen(_clazz.getConstantPool());
  }
View Full Code Here

    //       when we're ready to insulate the offending instruction by doing the
    //       above thing.

    // TODO: Implement as much as possible here. BCEL does _not_ check everything.

    ConstantPoolGen cpg = new ConstantPoolGen(Repository.lookupClass(myOwner.getClassName()).getConstantPool());
    InstOperandConstraintVisitor v = new InstOperandConstraintVisitor(cpg);
 
    // Checks for the things BCEL does _not_ handle itself.
    InstructionHandle ih = instructionList.getStart();
    while (ih != null){
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.ConstantPoolGen$Index

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.