*
*/
public MethodInfo load(CapInputStream in, Short start, Short end) throws UnableToReadCapFileException {
try {
MethodInfo methodInfo = new MethodInfo();
byte bitfield = in.readByte();
byte flags = (byte) ((bitfield & 0xF0) >>> 4);
methodInfo.setBytecodes(new ArrayList<Byte>());
methodInfo.setMethodInfoOffset(start);
if ((flags == MethodInfo.ACC_EXTENDED)) {
// extended method header info
methodInfo.setMethodHeader(new ExtendedMethodHeaderInfoRead().load(in, bitfield));
for (int i = (start + MethodInfo.EXTENDED_METHOD_HEADER_INFO_SIZE);
i < end; i++) {
methodInfo.getBytecodes().add(in.readByte());
}
//we generate the opcodeMap
methodInfo.setFirstBytecodeOffset((short) (methodInfo.getMethodInfoOffset() +
MethodInfo.EXTENDED_METHOD_HEADER_INFO_SIZE));
makeOpcodeArray(methodInfo);
} else {
methodInfo.setMethodHeader(new MethodHeaderInfoRead().load(in, bitfield));
if (flags == MethodInfo.ACC) {
// method
for (int i = (start + MethodInfo.METHOD_HEADER_INFO_SIZE);
i < end; i++) {
methodInfo.getBytecodes().add(in.readByte());
}
//we generate the opcodeMap
methodInfo.setFirstBytecodeOffset((short) (methodInfo.getMethodInfoOffset() + MethodInfo.METHOD_HEADER_INFO_SIZE));
makeOpcodeArray(methodInfo);
} else if (flags != MethodInfo.ACC_ABSTRACT) {
// not abstract method
throw new UnknownFlagException("unknown flag value : " + flags);