Package japicmp.cmp
Class JarArchiveComparator
java.lang.Object
japicmp.cmp.JarArchiveComparator
This class provides the basic methods to compare the classes within to jar archives.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private javassist.ClassPool
private static final Logger
private String
private javassist.ClassPool
private String
private javassist.ClassPool
private final JarArchiveComparatorOptions
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an instance of this class and performs a setup of the classpath -
Method Summary
Modifier and TypeMethodDescriptionprivate String
appendSystemClassPath
(javassist.ClassPool classPool, String classPathAsString) private String
appendUserDefinedClassPathEntries
(javassist.ClassPool classPool, List<String> classPathEntries) private List
<javassist.CtClass> applyFilter
(JarArchiveComparatorOptions options, List<javassist.CtClass> ctClasses) private void
checkBinaryCompatibility
(List<JApiClass> classList) private void
checkJavaObjectSerializationCompatibility
(List<JApiClass> jApiClasses) compare
(JApiCmpArchive oldArchive, JApiCmpArchive newArchive) Compares the two given archives.compare
(List<JApiCmpArchive> oldArchives, List<JApiCmpArchive> newArchives) Compares the two given lists of archives.compareClassLists
(JarArchiveComparatorOptions options, List<javassist.CtClass> oldClasses, List<javassist.CtClass> newClasses) Compares the two lists with CtClass objects using the provided options instance.createAndCompareClassLists
(List<File> oldArchives, List<File> newArchives) private List
<javassist.CtClass> createListOfCtClasses
(List<File> archives, javassist.ClassPool classPool) Returns the common classpath used byJarArchiveComparator
javassist.ClassPool
Returns the javassist ClassPool instance that is used by this instance.Returns the instance ofJarArchiveComparatorOptions
that is used.Returns the classpath for the new version as String.javassist.ClassPool
Returns the javassist ClassPool that is used for the new version.Returns the classpath for the old version as String.javassist.ClassPool
Returns the javassist ClassPool that is used for the old version.Optional
<javassist.CtClass> loadClass
(JarArchiveComparator.ArchiveType archiveType, String name) Loads a class either from the old, new or common classpath.private String
setupClasspath
(javassist.ClassPool classPool, List<String> classPathEntries) private void
private void
private void
updatePackageFilter
(javassist.CtClass ctClass)
-
Field Details
-
LOGGER
-
commonClassPool
private javassist.ClassPool commonClassPool -
oldClassPool
private javassist.ClassPool oldClassPool -
newClassPool
private javassist.ClassPool newClassPool -
commonClassPathAsString
-
oldClassPathAsString
-
newClassPathAsString
-
options
-
-
Constructor Details
-
JarArchiveComparator
Constructs an instance of this class and performs a setup of the classpath- Parameters:
options
- the options used in the further processing
-
-
Method Details
-
setupCompatibilityChanges
-
compare
Compares the two given archives.- Parameters:
oldArchive
- the old version of the archivenewArchive
- the new version of the archive- Returns:
- a list which contains one instance of
JApiClass
for each class found in one of the two archives - Throws:
JApiCmpException
- if the comparison fails
-
compare
Compares the two given lists of archives.- Parameters:
oldArchives
- the old versions of the archivesnewArchives
- the new versions of the archives- Returns:
- a list which contains one instance of
JApiClass
for each class found in one of the archives - Throws:
JApiCmpException
- if the comparison fails
-
checkJavaObjectSerializationCompatibility
-
setupClasspaths
private void setupClasspaths() -
setupClasspath
-
appendSystemClassPath
-
appendUserDefinedClassPathEntries
-
getCommonClasspathAsString
Returns the common classpath used byJarArchiveComparator
- Returns:
- the common classpath as String
-
getOldClassPathAsString
Returns the classpath for the old version as String.- Returns:
- the classpath for the old version
-
getNewClassPathAsString
Returns the classpath for the new version as String.- Returns:
- the classpath for the new version
-
checkBinaryCompatibility
-
createAndCompareClassLists
-
compareClassLists
List<JApiClass> compareClassLists(JarArchiveComparatorOptions options, List<javassist.CtClass> oldClasses, List<javassist.CtClass> newClasses) Compares the two lists with CtClass objects using the provided options instance.- Parameters:
options
- the options to useoldClasses
- a list of CtClasses that represent the old versionnewClasses
- a list of CtClasses that represent the new version- Returns:
- a list of
JApiClass
that represent the changes
-
applyFilter
private List<javassist.CtClass> applyFilter(JarArchiveComparatorOptions options, List<javassist.CtClass> ctClasses) -
createListOfCtClasses
-
updatePackageFilter
private void updatePackageFilter(javassist.CtClass ctClass) -
getJarArchiveComparatorOptions
Returns the instance ofJarArchiveComparatorOptions
that is used.- Returns:
- an instance of
JarArchiveComparatorOptions
-
getCommonClassPool
public javassist.ClassPool getCommonClassPool()Returns the javassist ClassPool instance that is used by this instance. This can be used in unit tests to define artificial CtClass instances for the same ClassPool.- Returns:
- an instance of ClassPool
-
getOldClassPool
public javassist.ClassPool getOldClassPool()Returns the javassist ClassPool that is used for the old version.- Returns:
- an instance of ClassPool
-
getNewClassPool
public javassist.ClassPool getNewClassPool()Returns the javassist ClassPool that is used for the new version.- Returns:
- an instance of ClassPool
-
loadClass
public Optional<javassist.CtClass> loadClass(JarArchiveComparator.ArchiveType archiveType, String name) Loads a class either from the old, new or common classpath.- Parameters:
archiveType
- specify if this class should be loaded from the old or new class pathname
- the name of the class (FQN)- Returns:
- the loaded class (if options are not set to ignore missing classes)
- Throws:
JApiCmpException
- if loading the class fails
-