The type of the object that represents a class declaration's attributes (e.g., the source file attribute.)
The type of the object that represents a Java class file.
The type of the object that represents a Java class file.
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).
The type of the object that represents the fields of a class.
The type of the object that represents all methods of a class.
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.
Factory method to create the ClassFile
object that represents the class
file as a whole, plus any ClassFile
s 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 ClassFile
s 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 ClassFile
s the
result contains, the ClassFile
created from this method's parameters will always
be the result's first element.
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.
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.
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.
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.
If true
method bodies are never loaded.
If true
method bodies are never loaded.
Reads in a single class file from a Jar file.
Reads in a single class file from a Jar file.
the name of an existing ZIP/JAR file that contains class files.
the name of a class file stored in the specified ZIP/JAR file.
Reads in a single class file from a Jar file.
Reads in a single class file from a Jar file.
An existing ZIP/JAR file that contains class files.
The name of a class file stored in the specified ZIP/JAR file.
Reads in a class file.
Reads in a class file.
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.
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.
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]; }
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!
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
.
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.
A valid jar file that contains .class
files and other
.jar
files; other files are ignored. Inner jar files are also unzipped.
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.
The exception handler that is called when the reading of a class file fails. This function has to be thread safe.
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.
Some valid (non-empty) jar File.
The loaded class files.
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.
The org.opalj.log.LogContext that should be used to log rewritings.
The org.opalj.log.LogContext that should be used to log rewritings.
The org.opalj.log.LogContext is typically either the org.opalj.log.GlobalLogContext or a project specific log context.
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.
PostProcessors
will be executed in last-in-first-out order.
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.