Class ClassReader


public final class ClassReader extends AnnotatedReader
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.

  • 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

      @NonNull public String getSuperName()
      Returns the internal of name of the super class. For interfaces, the super class is Object.
    • getBytecode

      @NonNull public byte[] getBytecode()
      Returns the bytecode array of the Java classfile that was read.
    • accept

      public void accept(ClassVisitor visitor)
      Makes the given visitor visit the Java class of this Class Reader.
    • readAttribute

      @Nullable protected Boolean readAttribute(@NonNull String attributeName)
      Description copied from class: AnnotatedReader
      Attempts to read the next attribute, provided it's one recognizable by the implementing subclass.
      Specified by:
      readAttribute in class AnnotatedReader
      Parameters:
      attributeName - the attribute name
      Returns:
      true if BytecodeReader.codeIndex is already pointing to the next attribute in the classfile, false or null otherwise; in the case of null, 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)