Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Constant


    public static String getExceptionSig(DismantleBytecode dbc, CodeException e) {
        if (e.getCatchType() == 0) {
            return "Ljava/lang/Throwable;";
        }
        Constant c = dbc.getConstantPool().getConstant(e.getCatchType());
        if (c instanceof ConstantClass) {
            return "L" + ((ConstantClass) c).getBytes(dbc.getConstantPool()) + ";";
        }
        return "Ljava/lang/Throwable;";
    }
View Full Code Here


    public void sawOpcode(DismantleBytecode dbc, int seen) {
        int register;
        String signature;
        Item it, it2;
        Constant cons;

        // System.out.printf("%3d %12s%s%n", dbc.getPC(), OPCODE_NAMES[seen],
        // this);
        if (dbc.isRegisterStore()) {
            setLastUpdate(dbc.getRegisterOperand(), dbc.getPC());
View Full Code Here

            if (pc >= startPC && pc <= endPC) {
                int thisSize = endPC - startPC;
                if (size > thisSize) {
                    result.clear();
                    size = thisSize;
                    Constant kind = constantPool.getConstant(catchBlock.getCatchType());
                    result.add("C" + catchBlock.getCatchType());
                } else if (size == thisSize) {
                    result.add("C" + catchBlock.getCatchType());
                }
            }
View Full Code Here

            return null;
        }
        CodeException result = null;
        for (CodeException catchBlock : code.getExceptionTable()) {
            if (vmNameOfExceptionClass != null) {
                Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
                if (catchType == null && !vmNameOfExceptionClass.isEmpty() ||  catchType instanceof ConstantClass
                        && !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass)) {
                    continue;
                }
            }
View Full Code Here

        if (code.getExceptionTable() == null) {
            return size;
        }
        for (CodeException catchBlock : code.getExceptionTable()) {
            if (vmNameOfExceptionClass != null) {
                Constant catchType = constantPool.getConstant(catchBlock.getCatchType());
                if (catchType == null && !vmNameOfExceptionClass.isEmpty() ||  catchType instanceof ConstantClass
                        && !((ConstantClass) catchType).getBytes(constantPool).equals(vmNameOfExceptionClass)) {
                    continue;
                }
            }
View Full Code Here

    public void printOpCode(int seen) {
        System.out.print("  " + this.getClass().getSimpleName() + ": [" + formatter.format(getPC()) + "]  " + OPCODE_NAMES[seen]);
        if ((seen == INVOKEVIRTUAL) || (seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) {
            System.out.print("   " + getClassConstantOperand() + "." + getNameConstantOperand() + " " + getSigConstantOperand());
        } else if (seen == LDC || seen == LDC_W || seen == LDC2_W) {
            Constant c = getConstantRefOperand();
            if (c instanceof ConstantString) {
                System.out.print("   \"" + getStringConstantOperand() + "\"");
            } else if (c instanceof ConstantClass) {
                System.out.print("   " + getClassConstantOperand());
            } else {
View Full Code Here

  void addDependents( JavaClass clazz ) throws IOException {
    String name = clazz.getClassName().replace('.', '/');
    allClasses.put( name , clazz );
    ConstantPool pool = clazz.getConstantPool();
    for( int i = 1 ; i < pool.getLength() ; i++){
      Constant cons =  pool.getConstant(i);
      //System.out.println("("+i+") " + cons );
      if( cons!=null && cons.getTag() == Constants.CONSTANT_Class ){
  int idx = ((ConstantClass)pool.getConstant(i)).getNameIndex();
  String clas = ((ConstantUtf8)pool.getConstant(idx)).getBytes();
  addClassString(clas,name);
      }
    }
View Full Code Here

    String[] tempArray = new String[pool.getLength()];
    int size = 0;
    StringBuffer buf = new StringBuffer();

    for(int idx = 0; idx < pool.getLength(); idx++) {
      Constant c = pool.getConstant(idx);
      if(c != null && c.getTag() == Constants.CONSTANT_Class) {
        ConstantUtf8 c1 = (ConstantUtf8) pool.getConstant(((ConstantClass)c).getNameIndex());
        buf.setLength(0);
        buf.append(c1.getBytes());
        for(int n = 0; n < buf.length(); n++) {
          if(buf.charAt(n) == '/') {
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

  /**
   * @return mnemonic for instruction with symbolic references resolved
   */
  public String toString(ConstantPool cp) {
    Constant c   = cp.getConstant(index);
    String   str = cp.constantToString(c);

    if(c instanceof ConstantClass)
      str = str.replace('.', '/');

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.