Java Code Examples for com.sun.org.apache.bcel.internal.classfile.Constant

The following examples show how to use com.sun.org.apache.bcel.internal.classfile.Constant. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk1.8-source-analysis   Source File: InstructionList.java    License: Apache License 2.0 5 votes vote down vote up
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 2
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 3
Source Project: jdk8u60   Source File: InstructionList.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 4
Source Project: JDKSourceCode1.8   Source File: InstructionList.java    License: MIT License 5 votes vote down vote up
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 5
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 6
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 7
Source Project: Bytecoder   Source File: ConstantPoolGen.java    License: Apache License 2.0 5 votes vote down vote up
/** Resize internal array of constants.
 */
protected void adjustSize() {
    if (index + 3 >= size) {
        final Constant[] cs = constants;
        size *= 2;
        constants = new Constant[size];
        System.arraycopy(cs, 0, constants, 0, index);
    }
}
 
Example 8
Source Project: Bytecoder   Source File: InvokeInstruction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return mnemonic for instruction with symbolic references resolved
 */
@Override
public String toString( final ConstantPool cp ) {
    final Constant c = cp.getConstant(super.getIndex());
    final StringTokenizer tok = new StringTokenizer(cp.constantToString(c));
    return Const.getOpcodeName(super.getOpcode()) + " " + tok.nextToken().replace('.', '/')
            + tok.nextToken();
}
 
Example 9
Source Project: Bytecoder   Source File: InstructionList.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Replace all references to the old constant pool with references to the
 * new constant pool
 */
public void replaceConstantPool(final ConstantPoolGen old_cp, final ConstantPoolGen new_cp) {
    for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
        final Instruction i = ih.getInstruction();
        if (i instanceof CPInstruction) {
            final CPInstruction ci = (CPInstruction) i;
            final Constant c = old_cp.getConstant(ci.getIndex());
            ci.setIndex(new_cp.addConstant(c, old_cp));
        }
    }
}
 
Example 10
Source Project: Bytecoder   Source File: CPInstruction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return mnemonic for instruction with symbolic references resolved
 */
@Override
public String toString( final ConstantPool cp ) {
    final Constant c = cp.getConstant(index);
    String str = cp.constantToString(c);
    if (c instanceof ConstantClass) {
        str = str.replace('.', '/');
    }
    return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " + str;
}
 
Example 11
Source Project: openjdk-jdk9   Source File: InstructionList.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 12
Source Project: hottub   Source File: InstructionList.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 13
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 14
Source Project: openjdk-8   Source File: InstructionList.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** Replace all references to the old constant pool with references to the new
 *  constant pool
 */
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) {
  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));
    }
  }
}
 
Example 15
Source Project: Bytecoder   Source File: FieldGen.java    License: Apache License 2.0 4 votes vote down vote up
private void setValue( final int index ) {
    final ConstantPool cp = super.getConstantPool().getConstantPool();
    final Constant c = cp.getConstant(index);
    value = ((ConstantObject) c).getConstantValue(cp);
}
 
Example 16
Source Project: Bytecoder   Source File: ConstantPoolGen.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create empty constant pool.
 */
public ConstantPoolGen() {
    size = DEFAULT_BUFFER_SIZE;
    constants = new Constant[size];
}
 
Example 17
Source Project: Bytecoder   Source File: ConstantPoolGen.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @return constant pool with proper length
 */
public ConstantPool getFinalConstantPool() {
    final Constant[] cs = new Constant[index];
    System.arraycopy(constants, 0, cs, 0, index);
    return new ConstantPool(cs);
}
 
Example 18
Source Project: Bytecoder   Source File: ConstantPoolGen.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * @param i index in constant pool
 * @return constant pool entry at index i
 */
public Constant getConstant( final int i ) {
    return constants[i];
}
 
Example 19
Source Project: Bytecoder   Source File: ConstantPoolGen.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Use with care!
 *
 * @param i index in constant pool
 * @param c new constant pool entry at index i
 */
public void setConstant( final int i, final Constant c ) {
    constants[i] = c;
}