daikon.diff
Class Diff

Object
  extended by 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.


Field Summary
static Logger debug
           
 
Constructor Summary
Diff()
           
Diff(boolean examineAllPpts)
           
Diff(boolean examineAllPpts, boolean ignoreNumberedExits)
           
 
Method Summary
 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 of main, 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.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static final Logger debug
Constructor Detail

Diff

public Diff()

Diff

public Diff(boolean examineAllPpts)

Diff

public Diff(boolean examineAllPpts,
            boolean ignoreNumberedExits)
Method Detail

main

public static void main(String[] args)
                 throws FileNotFoundException,
                        StreamCorruptedException,
                        OptionalDataException,
                        IOException,
                        ClassNotFoundException,
                        InstantiationException,
                        IllegalAccessException
Read two PptMap or InvMap objects from their respective files. Convert the PptMaps to InvMaps as necessary, and diff the InvMaps.

Throws:
FileNotFoundException
StreamCorruptedException
OptionalDataException
IOException
ClassNotFoundException
InstantiationException
IllegalAccessException

mainHelper

public static void mainHelper(String[] args)
                       throws FileNotFoundException,
                              StreamCorruptedException,
                              OptionalDataException,
                              IOException,
                              ClassNotFoundException,
                              InstantiationException,
                              IllegalAccessException
This does the work of main, but it never calls System.exit, so it is appropriate to be called progrmmatically. Termination of the program with a message to the user is indicated by throwing Daikon.TerminationMessage.

Throws:
FileNotFoundException
StreamCorruptedException
OptionalDataException
IOException
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
main(String[]), Daikon.TerminationMessage

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

public void setAllInvComparators(Comparator<Invariant> c)
Use the comparator for sorting both sets and creating the pair tree.


setInvSortComparator1

public void setInvSortComparator1(Comparator<Invariant> c)
Use the comparator for sorting the first set.


setInvSortComparator2

public void setInvSortComparator2(Comparator<Invariant> c)
Use the comparator for sorting the second set.


setInvPairComparator

public void setInvPairComparator(Comparator<Invariant> c)
Use the comparator for creating the pair tree.