Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Constant


    }

    /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
    public void visitNEW(NEW o){
      indexValid(o, o.getIndex());
      Constant c = cpg.getConstant(o.getIndex());
      if ((c instanceof ConstantClass)){
        constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
      }
      else{
        ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() ));
View Full Code Here


    }

    /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
    public void visitMULTIANEWARRAY(MULTIANEWARRAY o){
      indexValid(o, o.getIndex());
      Constant c = cpg.getConstant(o.getIndex());
      if ((c instanceof ConstantClass)){
        constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
      }
      int dimensions2create = o.getDimensions();
      if (dimensions2create < 1){
View Full Code Here

    }

    /** Checks if the constraints of operands of the said instruction(s) are satisfied. */
    public void visitANEWARRAY(ANEWARRAY o){
      indexValid(o, o.getIndex());
      Constant c = cpg.getConstant(o.getIndex());
      if ((c instanceof ConstantClass)){
        constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
      }
      Type t = o.getType(cpg);
      if (t instanceof ArrayType){
View Full Code Here

        System.arraycopy(cs, 0, constants, 0, cs.length);
        if (cs.length > 0) {
            index = cs.length;
        }
        for (int i = 1; i < index; i++) {
            Constant c = constants[i];
            if (c instanceof ConstantString) {
                ConstantString s = (ConstantString) c;
                ConstantUtf8 u8 = (ConstantUtf8) constants[s.getStringIndex()];
                String key = u8.getBytes();
                if (!string_table.containsKey(key)) {
View Full Code Here

    /**
     * @return mnemonic for instruction with symbolic references resolved
     */
    public String toString( ConstantPool cp ) {
        Constant c = cp.getConstant(index);
        StringTokenizer tok = new StringTokenizer(cp.constantToString(c));
        return Constants.OPCODE_NAMES[opcode] + " " + tok.nextToken().replace('.', '/')
                + tok.nextToken();
    }
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

   * Ensures the specific preconditions of the said instruction.
   */
  public void visitLDC(LDC o){
    // visitCPInstruction is called first.
   
    Constant c = cpg.getConstant(o.getIndex());
    if   ((  ( c instanceof ConstantInteger) ||
              ( c instanceof ConstantFloat  ||
              ( c instanceof ConstantString )  )  ){
      constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+c+"'.");
    }
View Full Code Here

   * Ensures the specific preconditions of the said instruction.
   */
  public void visitLDC_W(LDC_W o){
    // visitCPInstruction is called first.
   
    Constant c = cpg.getConstant(o.getIndex());
    if   ((  ( c instanceof ConstantInteger) ||
              ( c instanceof ConstantFloat  ||
              ( c instanceof ConstantString )  )  ){
      constraintViolated(o, "Referenced constant should be a CONSTANT_Integer, a CONSTANT_Float or a CONSTANT_String, but is '"+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.