Class ClassReader
🏭 Constructors
constructor public
ClassReader(buffer: Uint8Array, classFileOffset: number= 0, len: number= buffer.length): ClassReader
Constructs a new ClassReader object.
Parameters
- buffer:
Uint8Array
- classFileOffset:
number
- len:
number
the length of the class data.
Return Type
ClassReader
Defined in: packages/asm/libs/ClassReader.ts:165
🏷️ Properties
buf public
buf: Uint8Array
The class to be parsed. <i>The content of this array must not be modified. This field is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Defined in: packages/asm/libs/ClassReader.ts:128
header public
header: number
Start index of the class header information (access, name...) in [#b b].
Defined in: packages/asm/libs/ClassReader.ts:156
EXPAND_ASM_INSNS static
EXPAND_ASM_INSNS: number = 256
Flag to expand the ASM pseudo instructions into an equivalent sequence of standard bytecode instructions. When resolving a forward jump it may happen that the signed 2 bytes offset reserved for it is not sufficient to store the bytecode offset. In this case the jump instruction is replaced with a temporary ASM pseudo instruction using an unsigned 2 bytes offset (see Label#resolve). This internal flag is used to re-read classes containing such instructions, in order to replace them with standard instructions. In addition, when this flag is used, GOTO_W and JSR_W are <i>not</i> converted into GOTO and JSR, to make sure that infinite loops where a GOTO_W is replaced with a GOTO in ClassReader and converted back to a GOTO_W in ClassWriter cannot occur.
Defined in: packages/asm/libs/ClassReader.ts:121
EXPAND_FRAMES static public
EXPAND_FRAMES: number = 8
Flag to expand the stack map frames. By default stack map frames are visited in their original format (i.e. "expanded" for classes whose version is less than V1_6, and "compressed" for the other classes). If this flag is set, stack map frames are always visited in expanded format (this option adds a decompression/recompression step in ClassReader and ClassWriter which degrades performances quite a lot).
Defined in: packages/asm/libs/ClassReader.ts:106
RESIZE static
RESIZE: boolean = true
True to enable JSR_W and GOTO_W support.
Defined in: packages/asm/libs/ClassReader.ts:70
SKIP_CODE static public
SKIP_CODE: number = 1
Flag to skip method code. If this class is set <code>CODE</code> attribute won't be visited. This can be used, for example, to retrieve annotations for methods and method parameters.
Defined in: packages/asm/libs/ClassReader.ts:77
SKIP_DEBUG static public
SKIP_DEBUG: number = 2
Flag to skip the debug information in the class. If this flag is set the debug information of the class is not visited, i.e. the visitLocalVariable and visitLineNumber methods will not be called.
Defined in: packages/asm/libs/ClassReader.ts:86
SKIP_FRAMES static public
SKIP_FRAMES: number = 4
Flag to skip the stack map frames in the class. If this flag is set the stack map frames of the class is not visited, i.e. the visitFrame method will not be called. This flag is useful when the [ClassWriter#COMPUTE_FRAMES] option is used: it avoids visiting frames that will be ignored and recomputed from scratch in the class writer.
Defined in: packages/asm/libs/ClassReader.ts:96
WRITER static
WRITER: boolean = true
True to enable bytecode writing support.
Defined in: packages/asm/libs/ClassReader.ts:65
🔧 Methods
accept public
accept(classVisitor: ClassVisitor, attrs: Attribute[]= [], flags: number= 0): void
Makes the given visitor visit the Java class of this ClassReader. This class is the one specified in the constructor (see [#ClassReader(byte[]) ClassReader]).
Parameters
- classVisitor:
ClassVisitor
the visitor that must visit this class. - attrs:
Attribute[]
prototypes of the attributes that must be parsed during the visit of the class. Any attribute whose type is not equal to the type of one the prototypes will not be parsed: its byte array value will be passed unchanged to the ClassWriterConstant. <i>This may corrupt it if this value contains references to the constant pool, or has syntactic or semantic links with a class element that has been transformed by a class adapter between the reader and the writer</i>. - flags:
number
option flags that can be used to modify the default behavior of this class. See [#SKIP_DEBUG], [#EXPAND_FRAMES] , [#SKIP_FRAMES], [#SKIP_CODE].
Return Type
void
Defined in: packages/asm/libs/ClassReader.ts:288
getAccess public
getAccess(): number
Returns the class's access flags (see Opcodes). This value may not reflect Deprecated and Synthetic flags when bytecode is before 1.5 and those flags are represented by attributes.
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:220
getClassName public
getClassName(): string
Returns the internal name of the class (see [Type#getInternalName() getInternalName]).
Return Type
string
Defined in: packages/asm/libs/ClassReader.ts:231
getInterfaces public
getInterfaces(): string[]
Returns the internal names of the class's interfaces (see [Type#getInternalName() getInternalName]).
Return Type
string[]
Defined in: packages/asm/libs/ClassReader.ts:256
getItem public
getItem(item: number): number
Returns the start index of the constant pool item in [#b b], plus one. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- item:
number
the index a constant pool item.
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:1747
getItemCount public
getItemCount(): number
Returns the number of constant pool items in [#b b].
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:1734
getMaxStringLength public
getMaxStringLength(): number
Returns the maximum length of the strings contained in the constant pool of the class.
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:1758
getSuperName public
getSuperName(): string
Returns the internal of name of the super class (see [Type#getInternalName() getInternalName]). For interfaces, the super class is [Object].
Return Type
string
Defined in: packages/asm/libs/ClassReader.ts:244
readByte public
readByte(index: number): number
Reads a byte value in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- index:
number
the start index of the value to be read in [#b b].
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:1770
readClass public
readClass(index: number, buf: number[]): string
Reads a class constant pool item in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- index:
number
the start index of an unsigned short value in [#b b], whose value is the index of a class constant pool item. - buf:
number[]
buffer to be used to read the item. This buffer must be sufficiently large. It is not automatically resized.
Return Type
string
Defined in: packages/asm/libs/ClassReader.ts:1906
readConst public
readConst(item: number, buf: number[]): any
Reads a numeric or string constant pool item in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- item:
number
the index of a constant pool item. - buf:
number[]
buffer to be used to read the item. This buffer must be sufficiently large. It is not automatically resized.
Return Type
any
Defined in: packages/asm/libs/ClassReader.ts:1922
readInt public
readInt(index: number): number
Reads a signed int value in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- index:
number
the start index of the value to be read in [#b b].
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:1810
readLabel
readLabel(offset: number, labels: Label[]): Label
Returns the label corresponding to the given offset. The default implementation of this method creates a label for the given offset if it has not been already created.
Parameters
- offset:
number
a bytecode offset in a method. - labels:
Label[]
the already created labels, indexed by their offset. If a label already exists for offset this method must not create a new one. Otherwise it must store the new label in this array.
Return Type
Label
Defined in: packages/asm/libs/ClassReader.ts:1664
readLong public
readLong(index: number): bigint
Reads a signed long value in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- index:
number
the start index of the value to be read in [#b b].
Return Type
bigint
Defined in: packages/asm/libs/ClassReader.ts:1824
readShort public
readShort(index: number): number
Reads a signed short value in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- index:
number
the start index of the value to be read in [#b b].
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:1797
readUnsignedShort public
readUnsignedShort(index: number): number
Reads an unsigned short value in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- index:
number
the start index of the value to be read in [#b b].
Return Type
number
Defined in: packages/asm/libs/ClassReader.ts:1783
readUTF8 public
readUTF8(index: number, buf: number[]): string
Reads an UTF8 string constant pool item in [#b b]. <i>This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.</i>
Parameters
- index:
number
the start index of an unsigned short value in [#b b], whose value is the index of an UTF8 constant pool item. - buf:
number[]
buffer to be used to read the item. This buffer must be sufficiently large. It is not automatically resized.
Return Type
string
Defined in: packages/asm/libs/ClassReader.ts:1841