ASPL Manual v 1.00
© 2024 by SetSphere.COM
12-12
Comparing the similarity between two Jar files can be effectively done by representing each Jar file by its dataset then by calculating the similarity between the two datasets. Since comparing datasets is not restricted to only two datasets, one can compare two or many Jar archives all at once. The following Perl program build the ASPL script to compare two or more Jar archives, then invoke the ASPL interpreter to display the similarity and and differences of the Jar archives.
You can also compare these Jar files by displaying an extended comparison using the ASPL script jarcomparelong.aspl see SECTION 12.11.1 [Script jarcomparelong.aspl]
The following script compare two or many Jar files. In a loop, lines 24 to 29, we assign each Jar file to a set variable. Line 34 generates the ASPL code to display the groups union of all set variables. Line 36 generates the ASPL code to display the similarity between the datasets. Line 44 we call the ASPL interpreter to excute the code that is piped through the STDIN.
[Top Text]
1. #!/usr/bin/perl 2. 3. use strict; 4. use warnings; 5. 6. usage() unless @ARGV > 1; 7. sub usage { print join "",<DATA>; exit; } 8. 9. my $interpreter = "aspl -groupingclass POSIX -wsname TRANSIENT -dm 3 -singlepass"; 10. 11. # make sure the Jar files are readable 12. for (my $i=0; $i<@ARGV; $i++) { 13. die " PROGRAM EXITING BECAUSE CANNOT READ FILE $ARGV[$i]\n" unless -r $ARGV[$i]; 14. } 15. 16. # build the ASPL script 17. my $s = qq~ 18. timeout 120 19. ks chksum size ppdd ffl 20. displayoff 21. ~; 22. 23. my @v; 24. for (my $i=0; $i<@ARGV; $i++) { 25. # adding aspl variables jar0 jar1 jar2 .. assigned to ggjar() 26. $s .= "jar$i = ggjar(jarfile,$ARGV[$i],calchksum,1,calentropy,1)\n"; 27. # save the ASPL variables on the Perl stack (jar1 jar2 ..) in @v 28. push(@v,"jar$i"); 29. } 30. 31. $s .= qq~ 32. displayon 33. print ##### SHOWING THE GROUP UNION ##### 34. ,gU @v 35. print ##### SHOWING SET SIMILARITY ##### 36. sim @v 37. print ##### SHOWING SET SIMILARITY w. FILE CHECKSUMS ##### 38. sim`fflc @v 39. print ##### SHOWING ASPL SYMBOL TABLE ##### 40. v 41. 42. ~; 43. 44. open(ASPL, "| $interpreter -STDIN") or die "ERROR OPENING A PIPE TO aspl: $! \n"; 45. print ASPL $s; 46. close ASPL; 47. exit 0; 48. 49. __END__ 50. 51. jarsimilarity.pl compares a list of JAR archives via the ASPL interpreter. 52. 53. jarsimilarity.pl jarfile1 jarfile2 jarfile3 ... 54. 55. 56. Examples: 57. 58. jarsimilarity.pl /tmp/TX/27238-tx.jar /tmp/TX/38141-tx.jar /tmp/TX/38478-tx.jar 59. jarsimilarity.pl /tmp/JMX/2141611-wasjmx.jar /tmp/JMX/2151754-wasjmx.jar /tmp/JMX/2281258-wasjmx.jar /tmp/JMX/2376115-wasjmx.jar 60. jarsimilarity.pl /tmp/JMX/2151754-wasjmx.jar /tmp/JMX/2281258-wasjmx.jar /tmp/JMX/2376115-wasjmx.jar 61. 62.
This example is shown in the following terminal. display or terminal for Example: Script jarsimilarity.pl