/** * Constructs an instance from a sub-array of a {@link ByteArray}. * * @param name {@code non-null;} attribute name * @param data {@code non-null;} array containing the attribute data * @param offset offset in {@code data} to the attribute data * @param length length of the attribute data, in bytes * @param pool {@code null-ok;} constant pool to use for cpi resolution */ public RawAttribute(String name, ByteArray data, int offset, int length, ConstantPool pool) { this(name, data.slice(offset, offset + length), pool); }
/** * Constructs an instance from a sub-array of a {@link ByteArray}. * * @param name {@code non-null;} attribute name * @param data {@code non-null;} array containing the attribute data * @param offset offset in {@code data} to the attribute data * @param length length of the attribute data, in bytes * @param pool {@code null-ok;} constant pool to use for cpi resolution */ public RawAttribute(String name, ByteArray data, int offset, int length, ConstantPool pool) { this(name, data.slice(offset, offset + length), pool); }
/** * Constructs an instance from a sub-array of a {@link ByteArray}. * * @param name {@code non-null;} attribute name * @param data {@code non-null;} array containing the attribute data * @param offset offset in {@code data} to the attribute data * @param length length of the attribute data, in bytes * @param pool {@code null-ok;} constant pool to use for cpi resolution */ public RawAttribute(String name, ByteArray data, int offset, int length, ConstantPool pool) { this(name, data.slice(offset, offset + length), pool); }
/** * Constructs an instance from a sub-array of a {@link ByteArray}. * * @param name {@code non-null;} attribute name * @param data {@code non-null;} array containing the attribute data * @param offset offset in {@code data} to the attribute data * @param length length of the attribute data, in bytes * @param pool {@code null-ok;} constant pool to use for cpi resolution */ public RawAttribute(String name, ByteArray data, int offset, int length, ConstantPool pool) { this(name, data.slice(offset, offset + length), pool); }
/** * Constructs an instance from a sub-array of a {@link ByteArray}. * * @param name {@code non-null;} attribute name * @param data {@code non-null;} array containing the attribute data * @param offset offset in {@code data} to the attribute data * @param length length of the attribute data, in bytes * @param pool {@code null-ok;} constant pool to use for cpi resolution */ public RawAttribute(String name, ByteArray data, int offset, int length, ConstantPool pool) { this(name, data.slice(offset, offset + length), pool); }
/** * Constructs an instance from a sub-array of a {@link ByteArray}. * * @param name {@code non-null;} attribute name * @param data {@code non-null;} array containing the attribute data * @param offset offset in {@code data} to the attribute data * @param length length of the attribute data, in bytes * @param pool {@code null-ok;} constant pool to use for cpi resolution */ public RawAttribute(String name, ByteArray data, int offset, int length, ConstantPool pool) { this(name, data.slice(offset, offset + length), pool); }
/** * Parses a utf8 constant. * * @param at offset to the start of the constant (where the tag byte is) * @return {@code non-null;} the parsed value */ private CstString parseUtf8(int at) { int length = bytes.getUnsignedShort(at + 1); at += 3; // Skip to the data. ByteArray ubytes = bytes.slice(at, at + length); try { return new CstString(ubytes); } catch (IllegalArgumentException ex) { // Translate the exception throw new ParseException(ex); } }
/** * Parses a utf8 constant. * * @param at offset to the start of the constant (where the tag byte is) * @return {@code non-null;} the parsed value */ private CstString parseUtf8(int at) { int length = bytes.getUnsignedShort(at + 1); at += 3; // Skip to the data. ByteArray ubytes = bytes.slice(at, at + length); try { return new CstString(ubytes); } catch (IllegalArgumentException ex) { // Translate the exception throw new ParseException(ex); } } }
/** * Parses a utf8 constant. * * @param at offset to the start of the constant (where the tag byte is) * @return {@code non-null;} the parsed value */ private CstString parseUtf8(int at) { int length = bytes.getUnsignedShort(at + 1); at += 3; // Skip to the data. ByteArray ubytes = bytes.slice(at, at + length); try { return new CstString(ubytes); } catch (IllegalArgumentException ex) { // Translate the exception throw new ParseException(ex); } } }
/** * Parses a utf8 constant. * * @param at offset to the start of the constant (where the tag byte is) * @return {@code non-null;} the parsed value */ private CstString parseUtf8(int at) { int length = bytes.getUnsignedShort(at + 1); at += 3; // Skip to the data. ByteArray ubytes = bytes.slice(at, at + length); try { return new CstString(ubytes); } catch (IllegalArgumentException ex) { // Translate the exception throw new ParseException(ex); } } }
/** * Parses a utf8 constant. * * @param at offset to the start of the constant (where the tag byte is) * @return {@code non-null;} the parsed value */ private CstUtf8 parseUtf8(int at) { int length = bytes.getUnsignedShort(at + 1); at += 3; // Skip to the data. ByteArray ubytes = bytes.slice(at, at + length); try { return new CstUtf8(ubytes); } catch (IllegalArgumentException ex) { // Translate the exception throw new ParseException(ex); } } }
/** * Parses a {@code SourceDebugExtesion} attribute. */ private Attribute sourceDebugExtension(DirectClassFile cf, int offset, int length, ParseObserver observer) { ByteArray bytes = cf.getBytes().slice(offset, offset + length); CstString smapString = new CstString(bytes); Attribute result = new AttSourceDebugExtension(smapString); if (observer != null) { String decoded = smapString.getString(); observer.parsed(bytes, offset, length, "sourceDebugExtension: " + decoded); } return result; }
/** * Parses a {@code SourceDebugExtesion} attribute. */ private Attribute sourceDebugExtension(DirectClassFile cf, int offset, int length, ParseObserver observer) { ByteArray bytes = cf.getBytes().slice(offset, offset + length); CstString smapString = new CstString(bytes); Attribute result = new AttSourceDebugExtension(smapString); if (observer != null) { String decoded = smapString.getString(); observer.parsed(bytes, offset, length, "sourceDebugExtension: " + decoded); } return result; }
/** * Parses a {@code LocalVariableTable} attribute. */ private Attribute localVariableTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); if (observer != null) { observer.parsed(bytes, offset, 2, "local_variable_table_length: " + Hex.u2(count)); } LocalVariableList list = parseLocalVariables( bytes.slice(offset + 2, offset + length), cf.getConstantPool(), observer, count, false); return new AttLocalVariableTable(list); }
/** * Parses a {@code LocalVariableTypeTable} attribute. */ private Attribute localVariableTypeTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); if (observer != null) { observer.parsed(bytes, offset, 2, "local_variable_type_table_length: " + Hex.u2(count)); } LocalVariableList list = parseLocalVariables( bytes.slice(offset + 2, offset + length), cf.getConstantPool(), observer, count, true); return new AttLocalVariableTypeTable(list); }
/** * Parses a {@code LocalVariableTypeTable} attribute. */ private Attribute localVariableTypeTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); if (observer != null) { observer.parsed(bytes, offset, 2, "local_variable_type_table_length: " + Hex.u2(count)); } LocalVariableList list = parseLocalVariables( bytes.slice(offset + 2, offset + length), cf.getConstantPool(), observer, count, true); return new AttLocalVariableTypeTable(list); }
/** * Parses a {@code LocalVariableTypeTable} attribute. */ private Attribute localVariableTypeTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); if (observer != null) { observer.parsed(bytes, offset, 2, "local_variable_type_table_length: " + Hex.u2(count)); } LocalVariableList list = parseLocalVariables( bytes.slice(offset + 2, offset + length), cf.getConstantPool(), observer, count, true); return new AttLocalVariableTypeTable(list); }
/** * Parses a {@code LocalVariableTable} attribute. */ private Attribute localVariableTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); if (observer != null) { observer.parsed(bytes, offset, 2, "local_variable_table_length: " + Hex.u2(count)); } LocalVariableList list = parseLocalVariables( bytes.slice(offset + 2, offset + length), cf.getConstantPool(), observer, count, false); return new AttLocalVariableTable(list); }
/** * Parses a {@code LocalVariableTable} attribute. */ private Attribute localVariableTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); if (observer != null) { observer.parsed(bytes, offset, 2, "local_variable_table_length: " + Hex.u2(count)); } LocalVariableList list = parseLocalVariables( bytes.slice(offset + 2, offset + length), cf.getConstantPool(), observer, count, false); return new AttLocalVariableTable(list); }
/** * Parses a {@code LocalVariableTypeTable} attribute. */ private Attribute localVariableTypeTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); if (observer != null) { observer.parsed(bytes, offset, 2, "local_variable_type_table_length: " + Hex.u2(count)); } LocalVariableList list = parseLocalVariables( bytes.slice(offset + 2, offset + length), cf.getConstantPool(), observer, count, true); return new AttLocalVariableTypeTable(list); }