Trait/Object

org.opalj.bi.reader

ClassFileReader

Related Docs: object ClassFileReader | package reader

Permalink

trait ClassFileReader extends ClassFileReaderConfiguration with Constant_PoolAbstractions

Implements the template method to read in a Java class file. Additionally, several convenience methods are defined to read in class files from various sources (Streams, Files, JAR archives).

This library supports class files from version 45 (Java 1.1) up to version 53 (Java 9).

Notes for Implementors

Reading of the class file's major structures: the constant pool, fields, methods and the attributes is delegated to corresponding readers. This enables a very high-level of adaptability.

For further details see the JVM Specification: The ClassFile Structure.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ClassFileReader
  2. Constant_PoolAbstractions
  3. ClassFileReaderConfiguration
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract type Attributes

    Permalink

    The type of the object that represents a class declaration's attributes (e.g., the source file attribute.)

  2. abstract type ClassFile

    Permalink

    The type of the object that represents a Java class file.

    The type of the object that represents a Java class file.

    Definition Classes
    ClassFileReaderConstant_PoolAbstractions
  3. abstract type Constant_Pool

    Permalink
    Definition Classes
    Constant_PoolAbstractions
  4. abstract type Constant_Pool_Entry

    Permalink
    Definition Classes
    Constant_PoolAbstractions
  5. type Constant_Pool_Index = Int

    Permalink
    Definition Classes
    Constant_PoolAbstractions
  6. type DeferredActionsStore = Buffer[(ClassFile) ⇒ ClassFile] with Constant_Pool_Entry

    Permalink

    A DeferredActionsStore stores all functions that need to perform post load actions.

    A DeferredActionsStore stores all functions that need to perform post load actions.

    One example is the resolution of references to attributes. (The constant pool is the only structure that is passed around and hence it is the only place where to store information/functions related to a specific class file).

    Definition Classes
    Constant_PoolAbstractions
  7. abstract type Fields

    Permalink

    The type of the object that represents the fields of a class.

  8. abstract type Methods

    Permalink

    The type of the object that represents all methods of a class.

Abstract Value Members

  1. abstract def Attributes(ap: AttributeParent, cp: Constant_Pool, in: DataInputStream): Attributes

    Permalink

    Reads all attributes using the given stream and constant pool.

    Reads all attributes using the given stream and constant pool.

    The given stream is positioned directly before a class file's "attributes_count" field. This method is called by the template method that reads in a class file to delegate the reading of the attributes.

    From the Specification

    The attributes [...] appearing in the attributes table of a ClassFile structure are the InnerClasses, EnclosingMethod, Synthetic, Signature, SourceFile, SourceDebugExtension, Deprecated, RuntimeVisibleAnnotations, RuntimeInvisibleAnnotations, BootstrapMethods, RuntimeVisibleTypeAnnotations, and RuntimeInvisibleTypeAnnotations attributes.

    Attributes
    protected
  2. abstract def ClassFile(cp: Constant_Pool, minor_version: Int, major_version: Int, access_flags: Int, this_class: Constant_Pool_Index, super_class: Constant_Pool_Index, interfaces: IndexedSeq[Constant_Pool_Index], fields: Fields, methods: Methods, attributes: Attributes): ClassFile

    Permalink

    Factory method to create the ClassFile object that represents the class file as a whole, plus any ClassFiles that have been synthesized in the process of parsing it.

    Factory method to create the ClassFile object that represents the class file as a whole, plus any ClassFiles that have been synthesized in the process of parsing it.

    The result will always contain at least one ClassFile object, namely the one that is created from this method's parameters. Regardless of how many ClassFiles the result contains, the ClassFile created from this method's parameters will always be the result's first element.

    Attributes
    protected
  3. abstract def Constant_Pool(in: DataInputStream): Constant_Pool

    Permalink

    Reads the constant pool using the given stream.

    Reads the constant pool using the given stream.

    When this method is called the given stream has to be positioned at the very beginning of the constant pool. This method is called by the template method that reads in a class file to delegate the reading of the constant pool. Only information belonging to the constant pool are allowed to be read.

    The stream must not be closed after reading the constant pool.

    Attributes
    protected
  4. abstract def Fields(cp: Constant_Pool, in: DataInputStream): Fields

    Permalink

    Reads all field declarations using the given stream and constant pool.

    Reads all field declarations using the given stream and constant pool.

    The given stream is positioned directly before a class file's "fields_count" field. This method is called by the template method that reads in a class file to delegate the reading of the declared fields.

    Attributes
    protected
  5. abstract def Methods(cp: Constant_Pool, in: DataInputStream): Methods

    Permalink

    Reads all method declarations using the given stream and constant pool.

    Reads all method declarations using the given stream and constant pool.

    The given stream is positioned directly before a class file's "methods_count" field. This method is called by the template method that reads in a class file to delegate the reading of the declared method.

    Attributes
    protected
  6. abstract def applyDeferredActions(cp: Constant_Pool, classFile: ClassFile): ClassFile

    Permalink

    This method is called/needs to be called after the class file was completely loaded to perform class file specific transformations.

    This method is called/needs to be called after the class file was completely loaded to perform class file specific transformations.

    Definition Classes
    Constant_PoolAbstractions
  7. abstract def loadsInterfacesOnly: Boolean

    Permalink

    If true method bodies are never loaded.

    If true method bodies are never loaded.

    Definition Classes
    ClassFileReaderConfiguration

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def AllClassFiles(files: Traversable[File], exceptionHandler: ExceptionHandler = defaultExceptionHandler): Traversable[(ClassFile, URL)]

    Permalink
  5. def ClassFile(jarFileName: String, jarFileEntryName: String): List[ClassFile]

    Permalink

    Reads in a single class file from a Jar file.

    Reads in a single class file from a Jar file.

    jarFileName

    the name of an existing ZIP/JAR file that contains class files.

    jarFileEntryName

    the name of a class file stored in the specified ZIP/JAR file.

    Annotations
    @throws( ... )
  6. def ClassFile(jarFile: File, jarFileEntryName: String): List[ClassFile]

    Permalink

    Reads in a single class file from a Jar file.

    Reads in a single class file from a Jar file.

    jarFile

    An existing ZIP/JAR file that contains class files.

    jarFileEntryName

    The name of a class file stored in the specified ZIP/JAR file.

    Annotations
    @throws( ... )
  7. def ClassFile(jarFile: ZipFile, jarEntry: ZipEntry): List[ClassFile]

    Permalink
    Attributes
    protected[this]
  8. def ClassFile(create: () ⇒ InputStream): List[ClassFile]

    Permalink

    Reads in a class file.

    Reads in a class file.

    create

    A function that creates a new InputStream and which must not return null. If you already do have an open input stream which should not be closed after reading the class file use ...ClassFileReader.ClassFile(java.io.DataInputStream) : ClassFile instead. The (newly created) InputStream returned by calling create is closed by this method. The created input stream will automatically be wrapped by OPAL to enable efficient reading of the class file.

  9. def ClassFile(in: DataInputStream): List[ClassFile]

    Permalink

    Template method that reads a Java class file from the given input stream.

    Template method that reads a Java class file from the given input stream.

    All other methods to read a class file use this method to eventually parse a class file.

    Class File Structure

    Parses a class file according to the specification:

    ClassFile {
       u4 magic;
       u2 minor_version;
       u2 major_version;
       u2 constant_pool_count;
       cp_info constant_pool[constant_pool_count-1];
       u2 access_flags;
       u2 this_class;
       u2 super_class;
       u2 interfaces_count;
       u2 interfaces[interfaces_count];
       u2 fields_count;
       field_info fields[fields_count];
       u2 methods_count;
       method_info methods[methods_count];
       u2 attributes_count;
       attribute_info attributes[attributes_count];
    }
    

    in

    The DataInputStream from which the class file will be read. The stream is not closed by this method. It is highly recommended that the stream is buffered; otherwise the performance will be terrible!

  10. def ClassFiles(file: File, exceptionHandler: ExceptionHandler = defaultExceptionHandler): List[(ClassFile, URL)]

    Permalink

    Loads class files from the given file location.

    Loads class files from the given file location. If the file denotes a single ".class" file this class file is loaded. If the file object denotes a ".jar|.war|.ear|.zip" file, all class files in the jar file will be loaded. If the file object specifies a directory object, all ".class" files in the directory and in all subdirectories are loaded as well as all class files stored in ".jar" files in one of the directories. This class loads all class files in parallel. However, this does not effect analyses working on the resulting List.

  11. def ClassFiles(jarFile: ZipFile, classFileHandler: (ClassFile, URL) ⇒ Unit, exceptionHandler: ExceptionHandler): Unit

    Permalink

    Reads in parallel all class files stored in the given jar file.

    Reads in parallel all class files stored in the given jar file. For each successfully read class file the function classFileHandler is called.

    jarFile

    A valid jar file that contains .class files and other .jar files; other files are ignored. Inner jar files are also unzipped.

    classFileHandler

    A function that is called for each class file in the given jar file. Given that the jarFile is read in parallel this function has to be thread safe.

    exceptionHandler

    The exception handler that is called when the reading of a class file fails. This function has to be thread safe.

  12. def ClassFiles(jarFile: ZipFile, exceptionHandler: ExceptionHandler): List[(ClassFile, URL)]

    Permalink

    Reads in parallel all class files stored in the given jar/zip file.

    Reads in parallel all class files stored in the given jar/zip file.

    jarFile

    Some valid (non-empty) jar File.

    returns

    The loaded class files.

  13. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  14. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. implicit val config: Config

    Permalink

    The Config object that will be used to read the configuration settings for reading in class files.

    The Config object that will be used to read the configuration settings for reading in class files.

    Definition Classes
    ClassFileReaderConfiguration
  16. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  20. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  21. def isClassFileRepository(filename: String): Boolean

    Permalink
  22. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  23. implicit val logContext: LogContext

    Permalink

    The org.opalj.log.LogContext that should be used to log rewritings.

    The org.opalj.log.LogContext that should be used to log rewritings.

    Definition Classes
    ClassFileReaderConfiguration
    Note

    The org.opalj.log.LogContext is typically either the org.opalj.log.GlobalLogContext or a project specific log context.

  24. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  25. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  26. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  27. def registerClassFilePostProcessor(p: (List[ClassFile]) ⇒ List[ClassFile]): Unit

    Permalink

    Register a class file post processor.

    Register a class file post processor. A class file post processor can transform the completely read and reified class file. Post processors can only be registered before the usage of a class file reader. Registering new ClassFilePostProcessors while processing class files is not supported and the behavior is undefined.

    Note

    PostProcessors will be executed in last-in-first-out order.

  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  29. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  30. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Constant_PoolAbstractions

Inherited from AnyRef

Inherited from Any

Ungrouped