/** * @return an array of instructions without target information for branch instructions. */ public Instruction[] getInstructions() { final List<Instruction> instructions = new ArrayList<>(); try (ByteSequence bytes = new ByteSequence(getByteCode())) { while (bytes.available() > 0) { instructions.add(Instruction.readInstruction(bytes)); } } catch (final IOException e) { throw new ClassGenException(e.toString(), e); } return instructions.toArray(new Instruction[instructions.size()]); }
/** * @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()]; instructions.toArray(result); return result; }
private void compare(final String name, final Method m) { // System.out.println("Method: " + m); final Code c = m.getCode(); if (c == null) { return; // e.g. abstract method } final byte[] src = c.getCode(); final InstructionList il = new InstructionList(src); final byte[] out = il.getByteCode(); if (src.length == out.length) { assertArrayEquals(name + ": " + m.toString(), src, out); } else { System.out.println(name + ": " + m.toString() + " " + src.length + " " + out.length); System.out.println(bytesToHex(src)); System.out.println(bytesToHex(out)); for (final InstructionHandle ih : il) { System.out.println(ih.toString(false)); } fail("Array comparison failure"); } }
byte_code = il.getByteCode();
byte_code = il.getByteCode();