Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Constant


                if (type.equals(Utility.signatureToString(sig, false))) {
                    ConstantValue cval = field.getConstantValue();
                    if (cval != null) {
                        int index = cval.getConstantValueIndex();
                        ConstantPool cp = m_curClass.getConstantPool();
                        Constant cnst = cp.getConstant(index);
                        if (cnst instanceof ConstantString) {
                            Object value = ((ConstantString)cnst).
                                getConstantValue(cp);
                            if (init.equals(value)) {
                                return new ClassItem(name,this, field);
View Full Code Here


        }
       
        // finish with constant table simple values (except name and signature)
        Constant[] cnsts = m_curClass.getConstantPool().getConstantPool();
        for (int i = m_curClass.getClassNameIndex()+1; i < cnsts.length; i++) {
            Constant cnst = cnsts[i];
            if (cnst != null) {
                int value = 0;
                switch (cnst.getTag()) {
                    case Constants.CONSTANT_Double:
                        value = (int)Double.doubleToRawLongBits
                            (((ConstantDouble)cnst).getBytes());
                        break;
                    case Constants.CONSTANT_Float:
View Full Code Here

            Constant[] ccnsts = cjc.getConstantPool().getConstantPool();
            if (tcnsts.length != ccnsts.length) {
                return false;
            }
            for (int i = tjc.getClassNameIndex()+1; i < tcnsts.length; i++) {
                Constant tcnst = tcnsts[i];
                Constant ccnst = ccnsts[i];
                if (tcnst != null && ccnst != null) {
                    int tag = tcnst.getTag();
                    if (tag != ccnst.getTag()) {
                        return false;
                    }
                    boolean equal = true;
                    switch (tag) {
                        case Constants.CONSTANT_Double:
View Full Code Here

    // Remember the class, so it doesn't get scanned again.
    scannedConstantPools.put( cls, dummyValue );

    // 1. Iterate through all constant pool entries
    for( int i = 0; i < constants.length; i++ ) {
      Constant con = constants[i];

      // 2. Get field and method references
      if( con instanceof ConstantCP ) {
        ConstantCP cp = (ConstantCP) con;
        ConstantNameAndType nt = (ConstantNameAndType) constants[cp.getNameAndTypeIndex()];
View Full Code Here

  public void visitLCONST(LCONST o){
    stack().push(Type.LONG);
  }
  /** Symbolically executes the corresponding Java Virtual Machine instruction. */
  public void visitLDC(LDC o){
    Constant c = cpg.getConstant(o.getIndex());
    if (c instanceof ConstantInteger){
      stack().push(Type.INT);
    }
    if (c instanceof ConstantFloat){
      stack().push(Type.FLOAT);
View Full Code Here

      stack().push(Type.STRING);
    }
  }
  /** Symbolically executes the corresponding Java Virtual Machine instruction. */
  public void visitLDC_W(LDC_W o){
    Constant c = cpg.getConstant(o.getIndex());
    if (c instanceof ConstantInteger){
      stack().push(Type.INT);
    }
    if (c instanceof ConstantFloat){
      stack().push(Type.FLOAT);
View Full Code Here

      stack().push(Type.STRING);
    }
  }
  /** Symbolically executes the corresponding Java Virtual Machine instruction. */
  public void visitLDC2_W(LDC2_W o){
    Constant c = cpg.getConstant(o.getIndex());
    if (c instanceof ConstantLong){
      stack().push(Type.LONG);
    }
    if (c instanceof ConstantDouble){
      stack().push(Type.DOUBLE);
View Full Code Here

   public void visitFieldInstruction(FieldInstruction o){
     // visitLoadClass(o) has been called before: Every FieldOrMethod
     // implements LoadClass.
     // visitCPInstruction(o) has been called before.
    // A FieldInstruction may be: GETFIELD, GETSTATIC, PUTFIELD, PUTSTATIC
      Constant c = cpg.getConstant(o.getIndex());
      if (!(c instanceof ConstantFieldref)){
        constraintViolated(o, "Index '"+o.getIndex()+"' should refer to a CONSTANT_Fieldref_info structure, but refers to '"+c+"'.");
      }
      // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o).
      Type t = o.getType(cpg);
View Full Code Here

      referenceTypeIsInitialized(o, (ReferenceType) objectref);
    }
    // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the
    // current class (�3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant
    // pool item at the index must be a symbolic reference to a class, array, or interface type.
    Constant c = cpg.getConstant(o.getIndex());
    if (! (c instanceof ConstantClass)){
      constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'.");
    }
  }
View Full Code Here

      referenceTypeIsInitialized(o, (ReferenceType) objectref);
    }
    // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the
    // current class (�3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant
    // pool item at the index must be a symbolic reference to a class, array, or interface type.
    Constant c = cpg.getConstant(o.getIndex());
    if (! (c instanceof ConstantClass)){
      constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'.");
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.Constant

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.