Class Diff
- Object
-
- Diff
-
public final class Diff extends Object
Diff is the main class for the invariant diff program. The invariant diff program outputs the differences between two sets of invariants.The following is a high-level description of the program. Each input file contains a serialized PptMap or InvMap. PptMap and InvMap are similar structures, in that they both map program points to invariants. However, PptMaps are much more complicated than InvMaps. PptMaps are output by Daikon, and InvMaps are output by this program.
First, if either input is a PptMap, it is converted to an InvMap. Next, the two InvMaps are combined to form a tree. The tree is exactly three levels deep. The first level contains the root, which holds no data. Each node in the second level is a pair of Ppts, and each node in the third level is a pair of Invariants. The tree is constructed by pairing the corresponding Ppts and Invariants in the two PptMaps. Finally, the tree is traversed via the Visitor pattern to produce output. The Visitor pattern makes it easy to extend the program, simply by writing a new Visitor.
-
-
Constructor Summary
Constructors Constructor Description Diff()
Diff(boolean examineAllPpts)
Diff(boolean examineAllPpts, boolean ignoreNumberedExits)
Diff(boolean examineAllPpts, boolean ignoreNumberedExits, @Nullable @ClassGetName String invSortComparator1Classname, @Nullable @ClassGetName String invSortComparator2Classname, @Nullable @ClassGetName String invPairComparatorClassname, Comparator<Invariant> defaultComparator)
Diff(boolean examineAllPpts, Comparator<Invariant> c)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InvMap
convertToInvMap(PptMap pptMap)
Extracts the PptTopLevel and Invariants out of a pptMap, and places them into an InvMap.RootNode
diffInvMap(InvMap map1, InvMap map2)
Returns a pair tree of corresponding program points, and corresponding invariants at each program point.RootNode
diffInvMap(InvMap map1, InvMap map2, boolean includeUnjustified)
Returns a pair tree of corresponding program points, and corresponding invariants at each program point.RootNode
diffPptMap(PptMap pptMap1, PptMap pptMap2)
Diffs two PptMaps by converting them to InvMaps.RootNode
diffPptMap(PptMap pptMap1, PptMap pptMap2, boolean includeUnjustified)
Diffs two PptMaps by converting them to InvMaps.static void
main(String[] args)
Read two PptMap or InvMap objects from their respective files.static void
mainHelper(String[] args)
This does the work ofmain(String[])
, but it never calls System.exit, so it is appropriate to be called progrmmatically.void
setAllInvComparators(Comparator<Invariant> c)
Use the comparator for sorting both sets and creating the pair tree.void
setInvPairComparator(Comparator<Invariant> c)
Use the comparator for creating the pair tree.void
setInvSortComparator1(Comparator<Invariant> c)
Use the comparator for sorting the first set.void
setInvSortComparator2(Comparator<Invariant> c)
Use the comparator for sorting the second set.
-
-
-
Constructor Detail
-
Diff
public Diff()
-
Diff
public Diff(boolean examineAllPpts)
-
Diff
public Diff(boolean examineAllPpts, Comparator<Invariant> c)
-
Diff
public Diff(boolean examineAllPpts, boolean ignoreNumberedExits)
-
Diff
public Diff(boolean examineAllPpts, boolean ignoreNumberedExits, @Nullable @ClassGetName String invSortComparator1Classname, @Nullable @ClassGetName String invSortComparator2Classname, @Nullable @ClassGetName String invPairComparatorClassname, Comparator<Invariant> defaultComparator) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException
-
-
Method Detail
-
main
public static void main(String[] args) throws FileNotFoundException, StreamCorruptedException, OptionalDataException, IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException
Read two PptMap or InvMap objects from their respective files. Convert the PptMaps to InvMaps as necessary, and diff the InvMaps.
-
mainHelper
public static void mainHelper(String[] args) throws FileNotFoundException, StreamCorruptedException, OptionalDataException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
This does the work ofmain(String[])
, but it never calls System.exit, so it is appropriate to be called progrmmatically.
-
convertToInvMap
public InvMap convertToInvMap(PptMap pptMap)
Extracts the PptTopLevel and Invariants out of a pptMap, and places them into an InvMap. Maps PptTopLevel to a List of Invariants. The InvMap is a cleaner representation than the PptMap, and it allows us to more easily manipulate the contents. The InvMap contains exactly the elements contained in the PptMap. Conditional program points are also added as keys. Filtering is done when creating the pair tree. The ppts in the InvMap must be sorted, but the invariants need not be sorted.
-
diffInvMap
public RootNode diffInvMap(InvMap map1, InvMap map2)
Returns a pair tree of corresponding program points, and corresponding invariants at each program point. This tree can be walked to determine differences between the sets of invariants. Calls diffInvMap and asks to include all justified invariants.
-
diffInvMap
public RootNode diffInvMap(InvMap map1, InvMap map2, boolean includeUnjustified)
Returns a pair tree of corresponding program points, and corresponding invariants at each program point. This tree can be walked to determine differences between the sets of invariants. The tree consists of the invariants in map1 and map2. If includeUnjustified is true, the unjustified invariants are included.
-
diffPptMap
public RootNode diffPptMap(PptMap pptMap1, PptMap pptMap2)
Diffs two PptMaps by converting them to InvMaps. Provided for compatibiliy with legacy code. Calls diffPptMap and asks to include all invariants.
-
diffPptMap
public RootNode diffPptMap(PptMap pptMap1, PptMap pptMap2, boolean includeUnjustified)
Diffs two PptMaps by converting them to InvMaps. Provided for compatibiliy with legacy code. If includeUnjustified is true, the unjustified invariants are included.
-
setAllInvComparators
@EnsuresNonNull({"invSortComparator1","invSortComparator2","invPairComparator"}) public void setAllInvComparators(@UnknownInitialization Diff this, Comparator<Invariant> c)
Use the comparator for sorting both sets and creating the pair tree.
-
setInvSortComparator1
@EnsuresNonNull("invSortComparator1") public void setInvSortComparator1(@UnknownInitialization Diff this, Comparator<Invariant> c)
Use the comparator for sorting the first set.
-
setInvSortComparator2
@EnsuresNonNull("invSortComparator2") public void setInvSortComparator2(@UnknownInitialization Diff this, Comparator<Invariant> c)
Use the comparator for sorting the second set.
-
setInvPairComparator
@EnsuresNonNull("invPairComparator") public void setInvPairComparator(@UnknownInitialization Diff this, Comparator<Invariant> c)
Use the comparator for creating the pair tree.
-
-