Slice reader that works as either a RandomAccessReader or a SequentialReader. The file
is buffered up to the point it has been read so far. Reads in big endian order, as required by the
classfile format.
| Modifier and Type | Field and Description |
|---|---|
| private byte[] | arr
Buffer. |
| private int | arrUsed
The number of bytes used in arr. |
| private static final int | BUF_CHUNK_SIZE
Read this many bytes each time there is a buffer underrun. |
| private int | classfileLengthHint
The length of the classfile if known (because it is not deflated), or -1 if unknown (because it is deflated). |
| private int | currIdx
The current read index within the slice. |
| private InputStream | inflaterInputStream
If slice is deflated, a wrapper for |
| private static final int | INITIAL_BUF_SIZE
Initial buffer size. |
| private RandomAccessReader | randomAccessReader
If slice is not deflated, a |
| private Resource | resourceToClose
The underlying resource to close when |
| Access | Constructor and Description |
|---|---|
| public | ClassfileReader(final Slice
the slice, final Resource Slice to read.the resource to close when resourceToClose)ClassfileReader#close() is called, or null.Constructor. |
| public | ClassfileReader(final InputStream
the inputStream, final Resource InputStream to read from.the underlying resource to close when resourceToClose)ClassfileReader#close() is called, or null.Constructor for reader of module |
| Modifier and Type | Method and Description |
|---|---|
| public byte[] | |
| public void | bufferTo(final int
the number of bytes to ensure have been buffered numBytes)Ensure that the given number of bytes have been read into the buffer from the beginning of the slice. |
| public void | close()
Implements java. Closes this stream and releases any system resources associated with it. |
| public int | |
| public int | read(final long
The offset to start reading from. srcOffset, final byte[] The byte array to write into. dstArr, final int The offset within the destination array to start writing at. dstArrStart, final int The number of bytes to read. numBytes)Implements nonapi. Read bytes into a byte array. |
| public int | read(final long
The offset to start reading from. srcOffset, final ByteBuffer The dstBuf, final int ByteBuffer to write into.The offset within the destination buffer to start writing at. dstBufStart, final int The number of bytes to read. numBytes)Implements nonapi. Read bytes into a |
| public byte | readByte(final long
The buffer offset to read from. offset)Implements nonapi. Read a byte at a specific offset (without changing the current cursor offset). |
| public byte | readByte()
Implements nonapi. Read a byte at the current cursor position. |
| public int | readInt(final long
The buffer offset to read from. offset)Implements nonapi. Read a int at a specific offset (without changing the current cursor offset). |
| public int | readInt()
Implements nonapi. Read a int at the current cursor position. |
| public long | readLong(final long
The buffer offset to read from. offset)Implements nonapi. Read a long at a specific offset (without changing the current cursor offset). |
| public long | readLong()
Implements nonapi. Read a long at the current cursor position. |
| public short | readShort(final long
The buffer offset to read from. offset)Implements nonapi. Read a short at a specific offset (without changing the current cursor offset). |
| public short | readShort()
Implements nonapi. Read a short at the current cursor position. |
| public String | readString(final long
The start offset of the string. offset, final int The number of bytes of the UTF8 encoding of the string. numBytes, final boolean If true, replace '/' with '.'. replaceSlashWithDot, final boolean If true, string final ';' character. stripLSemicolon)Implements nonapi. Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";". |
| public String | readString(final int
The number of bytes of the UTF8 encoding of the string. numBytes, final boolean If true, replace '/' with '.'. replaceSlashWithDot, final boolean If true, string final ';' character. stripLSemicolon)Implements nonapi. Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";". |
| public String | readString(final long
The start offset of the string. offset, final int The number of bytes of the UTF8 encoding of the string. numBytes)Implements nonapi. Reads the "modified UTF8" format defined in the Java classfile spec. |
| public String | readString(final int
The number of bytes of the UTF8 encoding of the string. numBytes)Implements nonapi. Reads the "modified UTF8" format defined in the Java classfile spec. |
| private void | |
| public int | readUnsignedByte(final long
The buffer offset to read from. offset)Implements nonapi. Read an unsigned byte at a specific offset (without changing the current cursor offset). |
| public int | readUnsignedByte()
Implements nonapi. Read an unsigned byte at the current cursor position. |
| public long | readUnsignedInt(final long
The buffer offset to read from. offset)Implements nonapi. Read a unsigned int at a specific offset (without changing the current cursor offset). |
| public long | readUnsignedInt()
Implements nonapi. Read a unsigned int at the current cursor position. |
| public int | readUnsignedShort(final long
The buffer offset to read from. offset)Implements nonapi. Read a unsigned short at a specific offset (without changing the current cursor offset). |
| public int | readUnsignedShort()
Implements nonapi. Read a unsigned short at the current cursor position. |
| public void | skip(final int
The number of bytes to skip. bytesToSkip)Implements nonapi. Skip the given number of bytes. |
| arr | back to summary |
|---|---|
| private byte[] arr Buffer. | |
| arrUsed | back to summary |
|---|---|
| private int arrUsed The number of bytes used in arr. | |
| BUF_CHUNK_SIZE | back to summary |
|---|---|
| private static final int BUF_CHUNK_SIZE Read this many bytes each time there is a buffer underrun. This is smaller than 8k by 8 bytes to prevent the doubling of the array size when the last chunk doesn't quite fit within the 16kb of INITIAL_BUF_SIZE, since the number of bytes that can be requested is up to 8 (for longs). Otherwise we could request to read to (8kb * 2 + 8), which would double the size of the buffer to 32kb, but if we only need to read between 8kb and 16kb, then we unnecessarily copied the buffer content one extra time. | |
| classfileLengthHint | back to summary |
|---|---|
| private int classfileLengthHint The length of the classfile if known (because it is not deflated), or -1 if unknown (because it is deflated). | |
| currIdx | back to summary |
|---|---|
| private int currIdx The current read index within the slice. | |
| inflaterInputStream | back to summary |
|---|---|
| private InputStream inflaterInputStream If slice is deflated, a wrapper for | |
| INITIAL_BUF_SIZE | back to summary |
|---|---|
| private static final int INITIAL_BUF_SIZE Initial buffer size. For most classfiles, only the first 16-64kb needs to be read (we don't read the bytecodes). | |
| randomAccessReader | back to summary |
|---|---|
| private RandomAccessReader randomAccessReader If slice is not deflated, a | |
| resourceToClose | back to summary |
|---|---|
| private Resource resourceToClose The underlying resource to close when | |
| ClassfileReader | back to summary |
|---|---|
| public ClassfileReader(final Slice slice, final Resource resourceToClose) throws IOException Constructor.
| |
| ClassfileReader | back to summary |
|---|---|
| public ClassfileReader(final InputStream inputStream, final Resource resourceToClose) throws IOException Constructor for reader of module
| |
| buf | back to summary |
|---|---|
| public byte[] buf() Buf.
| |
| bufferTo | back to summary |
|---|---|
| public void bufferTo(final int numBytes) throws IOException Ensure that the given number of bytes have been read into the buffer from the beginning of the slice.
| |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| currPos | back to summary |
|---|---|
| public int currPos() Curr pos.
| |
| read | back to summary |
|---|---|
| public int read(final long srcOffset, final byte[] dstArr, final int dstArrStart, final int numBytes) throws IOException Implements nonapi. Doc from nonapi. Read bytes into a byte array.
| |
| read | back to summary |
|---|---|
| public int read(final long srcOffset, final ByteBuffer dstBuf, final int dstBufStart, final int numBytes) throws IOException Implements nonapi. Doc from nonapi. Read bytes into a
| |
| readByte | back to summary |
|---|---|
| public byte readByte(final long offset) throws IOException Implements nonapi. Doc from nonapi. Read a byte at a specific offset (without changing the current cursor offset).
| |
| readByte | back to summary |
|---|---|
| public byte readByte() throws IOException Implements nonapi. Doc from nonapi. Read a byte at the current cursor position.
| |
| readInt | back to summary |
|---|---|
| public int readInt(final long offset) throws IOException Implements nonapi. Doc from nonapi. Read a int at a specific offset (without changing the current cursor offset).
| |
| readInt | back to summary |
|---|---|
| public int readInt() throws IOException Implements nonapi. Doc from nonapi. Read a int at the current cursor position.
| |
| readLong | back to summary |
|---|---|
| public long readLong(final long offset) throws IOException Implements nonapi. Doc from nonapi. Read a long at a specific offset (without changing the current cursor offset).
| |
| readLong | back to summary |
|---|---|
| public long readLong() throws IOException Implements nonapi. Doc from nonapi. Read a long at the current cursor position.
| |
| readShort | back to summary |
|---|---|
| public short readShort(final long offset) throws IOException Implements nonapi. Doc from nonapi. Read a short at a specific offset (without changing the current cursor offset).
| |
| readShort | back to summary |
|---|---|
| public short readShort() throws IOException Implements nonapi. Doc from nonapi. Read a short at the current cursor position.
| |
| readString | back to summary |
|---|---|
| public String readString(final long offset, final int numBytes, final boolean replaceSlashWithDot, final boolean stripLSemicolon) throws IOException Implements nonapi. Doc from nonapi. Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";".
| |
| readString | back to summary |
|---|---|
| public String readString(final int numBytes, final boolean replaceSlashWithDot, final boolean stripLSemicolon) throws IOException Implements nonapi. Doc from nonapi. Reads the "modified UTF8" format defined in the Java classfile spec, optionally replacing '/' with '.', and optionally removing the prefix "L" and the suffix ";".
| |
| readString | back to summary |
|---|---|
| public String readString(final long offset, final int numBytes) throws IOException Implements nonapi. Doc from nonapi. Reads the "modified UTF8" format defined in the Java classfile spec.
| |
| readString | back to summary |
|---|---|
| public String readString(final int numBytes) throws IOException Implements nonapi. Doc from nonapi. Reads the "modified UTF8" format defined in the Java classfile spec.
| |
| readTo | back to summary |
|---|---|
| private void readTo(final int targetArrUsed) throws IOException Called when there is a buffer underrun to ensure there are sufficient bytes available in the array to read the given number of bytes at the given start index.
| |
| readUnsignedByte | back to summary |
|---|---|
| public int readUnsignedByte(final long offset) throws IOException Implements nonapi. Doc from nonapi. Read an unsigned byte at a specific offset (without changing the current cursor offset).
| |
| readUnsignedByte | back to summary |
|---|---|
| public int readUnsignedByte() throws IOException Implements nonapi. Doc from nonapi. Read an unsigned byte at the current cursor position.
| |
| readUnsignedInt | back to summary |
|---|---|
| public long readUnsignedInt(final long offset) throws IOException Implements nonapi. Doc from nonapi. Read a unsigned int at a specific offset (without changing the current cursor offset).
| |
| readUnsignedInt | back to summary |
|---|---|
| public long readUnsignedInt() throws IOException Implements nonapi. Doc from nonapi. Read a unsigned int at the current cursor position.
| |
| readUnsignedShort | back to summary |
|---|---|
| public int readUnsignedShort(final long offset) throws IOException Implements nonapi. Doc from nonapi. Read a unsigned short at a specific offset (without changing the current cursor offset).
| |
| readUnsignedShort | back to summary |
|---|---|
| public int readUnsignedShort() throws IOException Implements nonapi. Doc from nonapi. Read a unsigned short at the current cursor position.
| |
| skip | back to summary |
|---|---|
| public void skip(final int bytesToSkip) throws IOException Implements nonapi. Doc from nonapi. Skip the given number of bytes.
| |