Package org.apache.bcel.util

Examples of org.apache.bcel.util.ByteSequence


        byte[] code = m.getCode().getCode();
        byte[] bytes = new byte[end - start];
        System.arraycopy(code, start, bytes, 0, end - start);

        try {
            ByteSequence sequence = new ByteSequence(code);
            while ((sequence.available() > 0) && (sequence.getIndex() < start)) {
                Instruction.readInstruction(sequence);
            }

            int pos;
            while (sequence.available() > 0 && ((pos = sequence.getIndex()) < end)) {
                Instruction ins = Instruction.readInstruction(sequence);
                if ((ins instanceof BranchInstruction) && !(ins instanceof TABLESWITCH) && !(ins instanceof LOOKUPSWITCH)) {
                    BranchInstruction bi = (BranchInstruction) ins;
                    int offset = bi.getIndex();
                    int target = offset + pos;
View Full Code Here


     * @return String representation of byte codes
     */
    public static final String codeToString( byte[] code, ConstantPool constant_pool, int index,
            int length, boolean verbose ) {
        StringBuffer buf = new StringBuffer(code.length * 20); // Should be sufficient
        ByteSequence stream = new ByteSequence(code);
        try {
            for (int i = 0; i < index; i++) {
                codeToString(stream, constant_pool, verbose);
            }
            for (int i = 0; stream.available() > 0; i++) {
                if ((length < 0) || (i < length)) {
                    String indices = fillup(stream.getIndex() + ":", 6, true, ' ');
                    buf.append(indices).append(codeToString(stream, constant_pool, verbose))
                            .append('\n');
                }
            }
        } catch (IOException e) {
View Full Code Here

     * Initialize instruction list from byte array.
     *
     * @param code byte array containing the instructions
     */
    public InstructionList(byte[] code) {
        ByteSequence bytes = new ByteSequence(code);
        InstructionHandle[] ihs = new InstructionHandle[code.length];
        int[] pos = new int[code.length]; // Can't be more than that
        int count = 0; // Contains actual length
        /* Pass 1: Create an object for each byte code and append them
         * to the list.
         */
        try {
            while (bytes.available() > 0) {
                // Remember byte offset and associate it with the instruction
                int off = bytes.getIndex();
                pos[count] = off;
                /* Read one instruction from the byte stream, the byte position is set
                 * accordingly.
                 */
                Instruction i = Instruction.readInstruction(bytes);
View Full Code Here

    /**
     * @return an array of instructions without target information for branch instructions.
     */
    public Instruction[] getInstructions() {
        ByteSequence bytes = new ByteSequence(getByteCode());
        List instructions = new ArrayList();
        try {
            while (bytes.available() > 0) {
                instructions.add(Instruction.readInstruction(bytes));
            }
        } catch (IOException e) {
            throw new ClassGenException(e.toString());
        }
View Full Code Here

  public static final String codeToString(byte[] code,
            ConstantPool constant_pool,
            int index, int length, boolean verbose)
  {
    StringBuffer buf    = new StringBuffer(code.length * 20); // Should be sufficient
    ByteSequence stream = new ByteSequence(code);

    try {
      for(int i=0; i < index; i++) // Skip `index' lines of code
  codeToString(stream, constant_pool, verbose);

      for(int i=0; stream.available() > 0; i++) {
  if((length < 0) || (i < length)) {
    String indices = fillup(stream.getIndex() + ":", 6, true, ' ');
    buf.append(indices + codeToString(stream, constant_pool, verbose) + '\n');
  }
      }
    } catch(IOException e) {
      System.out.println(buf.toString());
View Full Code Here

   * Initialize instruction list from byte array.
   *
   * @param code byte array containing the instructions
   */
  public InstructionList(byte[] code) {
    ByteSequence        bytes = new ByteSequence(code);
    InstructionHandle[] ihs   = new InstructionHandle[code.length];
    int[]               pos   = new int[code.length]; // Can't be more than that
    int                 count = 0; // Contains actual length

    /* Pass 1: Create an object for each byte code and append them
     * to the list.
     */
    try {
      while(bytes.available() > 0) {
  // Remember byte offset and associate it with the instruction
  int off =  bytes.getIndex();
  pos[count] = off;
 
  /* Read one instruction from the byte stream, the byte position is set
   * accordingly.
   */
 
View Full Code Here

  /**
   * @return an array of instructions without target information for branch instructions.
   */
  public Instruction[] getInstructions() {
    ByteSequence  bytes        = new ByteSequence(getByteCode());
    ArrayList     instructions = new ArrayList();

    try {
      while(bytes.available() > 0) {
  instructions.add(Instruction.readInstruction(bytes));
      }
    } catch(IOException e) { throw new ClassGenException(e.toString()); }

    Instruction[] result = new Instruction[instructions.size()];
View Full Code Here

  public static final String codeToString(byte[] code,
            ConstantPool constant_pool,
            int index, int length, boolean verbose)
  {
    StringBuffer buf    = new StringBuffer(code.length * 20); // Should be sufficient
    ByteSequence stream = new ByteSequence(code);

    try {
      for(int i=0; i < index; i++) // Skip `index' lines of code
  codeToString(stream, constant_pool, verbose);

      for(int i=0; stream.available() > 0; i++) {
  if((length < 0) || (i < length)) {
    String indices = fillup(stream.getIndex() + ":", 6, true, ' ');
    buf.append(indices + codeToString(stream, constant_pool, verbose) + '\n');
  }
      }
    } catch(IOException e) {
      System.out.println(buf.toString());
View Full Code Here

   * Initialize instruction list from byte array.
   *
   * @param code byte array containing the instructions
   */
  public InstructionList(byte[] code) {
    ByteSequence        bytes = new ByteSequence(code);
    InstructionHandle[] ihs   = new InstructionHandle[code.length];
    int[]               pos   = new int[code.length]; // Can't be more than that
    int                 count = 0; // Contains actual length

    /* Pass 1: Create an object for each byte code and append them
     * to the list.
     */
    try {
      while(bytes.available() > 0) {
  // Remember byte offset and associate it with the instruction
  int off =  bytes.getIndex();
  pos[count] = off;
 
  /* Read one instruction from the byte stream, the byte position is set
   * accordingly.
   */
 
View Full Code Here

  /**
   * @return an array of instructions without target information for branch instructions.
   */
  public Instruction[] getInstructions() {
    ByteSequence  bytes        = new ByteSequence(getByteCode());
    ArrayList     instructions = new ArrayList();

    try {
      while(bytes.available() > 0) {
  instructions.add(Instruction.readInstruction(bytes));
      }
    } catch(IOException e) { throw new ClassGenException(e.toString()); }

    Instruction[] result = new Instruction[instructions.size()];
View Full Code Here

TOP

Related Classes of org.apache.bcel.util.ByteSequence

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.