Package org.jacoco.core.analysis
Class Analyzer
java.lang.Object
org.jacoco.core.analysis.Analyzer
An
Analyzer
instance processes a set of Java class files and
calculates coverage data for them. For each class file the result is reported
to a given ICoverageVisitor
instance. In addition the
Analyzer
requires a ExecutionDataStore
instance that holds
the execution data for the classes to analyze. The Analyzer
offers
several methods to analyze classes from a variety of sources.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ICoverageVisitor
private final ExecutionDataStore
private final StringPool
-
Constructor Summary
ConstructorsConstructorDescriptionAnalyzer
(ExecutionDataStore executionData, ICoverageVisitor coverageVisitor) Creates a new analyzer reporting to the given output. -
Method Summary
Modifier and TypeMethodDescriptionint
analyzeAll
(File file) Analyzes all class files contained in the given file or folder.int
analyzeAll
(InputStream input, String location) Analyzes all classes found in the given input stream.int
analyzeAll
(String path, File basedir) Analyzes all classes from the given class path.private void
analyzeClass
(byte[] source) void
analyzeClass
(byte[] buffer, String location) Analyzes the class definition from a given in-memory buffer.void
analyzeClass
(InputStream input, String location) Analyzes the class definition from a given input stream.private int
analyzeGzip
(InputStream input, String location) private int
analyzePack200
(InputStream input, String location) private IOException
analyzerError
(String location, Exception cause) private int
analyzeZip
(InputStream input, String location) private org.objectweb.asm.ClassVisitor
createAnalyzingVisitor
(long classid, String className) Creates an ASM class visitor for analysis.private ZipEntry
nextEntry
(ZipInputStream input, String location)
-
Field Details
-
executionData
-
coverageVisitor
-
stringPool
-
-
Constructor Details
-
Analyzer
Creates a new analyzer reporting to the given output.- Parameters:
executionData
- execution datacoverageVisitor
- the output instance that will coverage data for every analyzed class
-
-
Method Details
-
createAnalyzingVisitor
Creates an ASM class visitor for analysis.- Parameters:
classid
- id of the class calculated withCRC64
className
- VM name of the class- Returns:
- ASM visitor to write class definition to
-
analyzeClass
private void analyzeClass(byte[] source) -
analyzeClass
Analyzes the class definition from a given in-memory buffer.- Parameters:
buffer
- class definitionslocation
- a location description used for exception messages- Throws:
IOException
- if the class can't be analyzed
-
analyzeClass
Analyzes the class definition from a given input stream. The providedInputStream
is not closed by this method.- Parameters:
input
- stream to read class definition fromlocation
- a location description used for exception messages- Throws:
IOException
- if the stream can't be read or the class can't be analyzed
-
analyzerError
-
analyzeAll
Analyzes all classes found in the given input stream. The input stream may either represent a single class file, a ZIP archive, a Pack200 archive or a gzip stream that is searched recursively for class files. All other content types are ignored. The providedInputStream
is not closed by this method.- Parameters:
input
- input datalocation
- a location description used for exception messages- Returns:
- number of class files found
- Throws:
IOException
- if the stream can't be read or a class can't be analyzed
-
analyzeAll
Analyzes all class files contained in the given file or folder. Class files as well as ZIP files are considered. Folders are searched recursively.- Parameters:
file
- file or folder to look for class files- Returns:
- number of class files found
- Throws:
IOException
- if the file can't be read or a class can't be analyzed
-
analyzeAll
Analyzes all classes from the given class path. Directories containing class files as well as archive files are considered.- Parameters:
path
- path definitionbasedir
- optional base directory, ifnull
the current working directory is used as the base for relative path entries- Returns:
- number of class files found
- Throws:
IOException
- if a file can't be read or a class can't be analyzed
-
analyzeZip
- Throws:
IOException
-
nextEntry
- Throws:
IOException
-
analyzeGzip
- Throws:
IOException
-
analyzePack200
- Throws:
IOException
-