Package mockit.asm.classes
Class ClassReader
java.lang.Object
mockit.asm.util.BytecodeReader
mockit.asm.AnnotatedReader
mockit.asm.classes.ClassReader
A Java class parser to make a
ClassVisitor
visit an existing class.
The Java type to be parsed is given in the form of a byte array conforming to the Java class file format. For each field and method encountered, the appropriate visit method of a given class visitor is called.
-
Field Summary
Fields inherited from class mockit.asm.AnnotatedReader
access, signature
Fields inherited from class mockit.asm.util.BytecodeReader
code, codeIndex, items
-
Constructor Summary
ConstructorsConstructorDescriptionClassReader
(byte[] code) Initializes a new class reader with the given bytecode array for a classfile. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ClassVisitor visitor) Makes the given visitor visit the Java class of this Class Reader.int
Returns the class's access flags.@org.checkerframework.checker.index.qual.NonNegative int
getBSMCodeIndex
(@org.checkerframework.checker.index.qual.NonNegative int bsmStartIndex) byte[]
Returns the bytecode array of the Java classfile that was read.Returns the internal of name of the super class.int
Returns the classfile version of the class being read.protected Boolean
readAttribute
(String attributeName) Attempts to read the next attribute, provided it's one recognizable by the implementing subclass.Methods inherited from class mockit.asm.AnnotatedReader
readAnnotations, readAnnotationValues, readAttributes
Methods inherited from class mockit.asm.util.BytecodeReader
readBoolean, readChar, readClass, readConst, readConstItem, readConstItem, readDouble, readDouble, readFloat, readFloat, readInt, readInt, readItem, readItem, readLong, readLong, readMethodHandle, readMethodHandleItem, readNonnullClass, readNonnullClass, readNonnullUTF8, readNonnullUTF8, readShort, readShort, readSignedByte, readString, readUnsignedByte, readUnsignedByte, readUnsignedShort, readUnsignedShort, readUTF8, readUTF8
-
Constructor Details
-
ClassReader
public ClassReader(@NonNull byte[] code) Initializes a new class reader with the given bytecode array for a classfile.
-
-
Method Details
-
getVersion
public int getVersion()Returns the classfile version of the class being read. -
getAccess
public int getAccess()Returns the class's access flags. -
getSuperName
Returns the internal of name of the super class. For interfaces, the super class isObject
. -
getBytecode
@NonNull public byte[] getBytecode()Returns the bytecode array of the Java classfile that was read. -
accept
Makes the given visitor visit the Java class of this Class Reader. -
readAttribute
Description copied from class:AnnotatedReader
Attempts to read the next attribute, provided it's one recognizable by the implementing subclass.- Specified by:
readAttribute
in classAnnotatedReader
- Parameters:
attributeName
- the attribute name- Returns:
true
ifBytecodeReader.codeIndex
is already pointing to the next attribute in the classfile,false
ornull
otherwise; in the case ofnull
, the current attribute was not yet identified, but is one of the more general ones ("RuntimeVisibleAnnotations", "Deprecated", or "Synthetic")
-
getBSMCodeIndex
public @org.checkerframework.checker.index.qual.NonNegative int getBSMCodeIndex(@org.checkerframework.checker.index.qual.NonNegative int bsmStartIndex)
-