Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Constant


   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

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

    for(InstructionHandle ih=start; ih != null; ih = ih.next) {
      Instruction i = ih.instruction;

      if(i instanceof CPInstruction) {
  CPInstruction ci = (CPInstruction)i;
  Constant      c  = old_cp.getConstant(ci.getIndex());
  ci.setIndex(new_cp.addConstant(c, old_cp));
      }
    }   
  }
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.