ClassParser (Apache Tomcat 9.0.111 API Documentation)
Description: declaration: package: org.apache.tomcat.util.bcel.classfile, class: ClassParser

# Class ClassParser

java.lang.Object
org.apache.tomcat.util.bcel.classfile.ClassParser

public final class ClassParser extends Object
Wrapper class that parses a given Java .class file. The method parse returns a JavaClass object on success. When an I/O error or an inconsistency occurs an appropriate exception is propagated back to the caller. The structure and the names comply, except for a few conveniences, exactly with the JVM specification 1.0. See this paper for further details about the structure of a bytecode file.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClassParser(InputStream inputStream)`
  Parses class from the given stream.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `JavaClass`
  `parse()`
  Parses the given Java class file and return an object that represents the contained data, i.e., constants, methods, fields and commands.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ClassParser

    public ClassParser(InputStream inputStream)
    Parses class from the given stream.
    Parameters:
      `inputStream` - Input stream

- ## Method Details

  - ### parse

    public JavaClass parse() throws IOException, ClassFormatException
    Parses the given Java class file and return an object that represents the contained data, i.e., constants, methods, fields and commands. A ClassFormatException is raised, if the file is not a valid .class file. (This does not include verification of the byte code as it is performed by the Java interpreter).
    Returns:
      Class object representing the parsed class file
    Throws:
      `IOException` - if an I/O error occurs.
      `ClassFormatException` - if a class is malformed or cannot be interpreted as a class file