binaryeq / jcompile

scripts to compile Java projects with different compilers to create a data set of comparable binaries
Apache License 2.0
0 stars 0 forks source link

Combine anonymous inner classes in oracles #66

Closed wtwhite closed 11 months ago

wtwhite commented 11 months ago

Tested on a small example that finds 58 more rows:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ time java -cp target/jcompile.jar nz.ac.wgtn.shadedetector.jcompile.oracles.SameArtifactDifferentCompilerClassOracle fixed_small_jars_with_tests > fixed_small_jars_with_tests_withAIC.txt 
--snip--
real    0m43.521s
user    0m50.997s
sys 0m5.177s
wtwhite commented 11 months ago

Tested the new machinery for combining anonymous inner classes by first leaving includeAnonymousInnerClasses at false and checking that the same number of final rows was produced as before, and that all rows have 0 for their two n_anon_inner_classes columns:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ time java -cp target/jcompile.jar nz.ac.wgtn.shadedetector.jcompile.oracles.SameArtifactDifferentCompilerClassOracle fixed_small_jars_with_tests > fixed_small_jars_with_tests_noAIC.txt
--snip--
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ wc -l small_jars_with_tests.txt fixed_small_jars_with_tests_noAIC.txt 
   35584 small_jars_with_tests.txt
   35584 fixed_small_jars_with_tests_noAIC.txt
   71168 total
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ grep -c '[^0-9]0[^0-9]0$' fixed_small_jars_with_tests_noAIC.txt
35583

I then (in https://github.com/binaryeq/jcompile/pull/66/commits/8dfa6fa471f8d1e611d581d0c8b7457af103ab2a) included anonymous inner classes and reran. This resulted in 35642-35584 = 58 more rows:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ time java -cp target/jcompile.jar nz.ac.wgtn.shadedetector.jcompile.oracles.SameArtifactDifferentCompilerClassOracle fixed_small_jars_with_tests > fixed_small_jars_with_tests_withAIC.txt
--snip--
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ wc -l fixed_small_jars_with_tests*AIC.txt
   35584 fixed_small_jars_with_tests_noAIC.txt
   35642 fixed_small_jars_with_tests_withAIC.txt
   71226 total

2425 of all rows have one or more associated anonymous inner classes (ignore the header row), with some classes having up to 76 AICs:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ grep -cv '[^0-9]0[^0-9]0$' fixed_small_jars_with_tests_withAIC.txt
2426
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ sort -k 24n < fixed_small_jars_with_tests_withAIC.txt | tail
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.9-tests.jar fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.9-tests.jar /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.classopenjdk   openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   test    test    25  25
fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.11-tests.jar    fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.11-tests.jar /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   test    test    27  27
fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.12.0-tests.jar  fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.12.0-tests.jar   /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   test    test    27  27
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.10-tests.jar    fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.10-tests.jar    /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   test    test    27  27
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.11-tests.jar    fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.11-tests.jar    /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   test    test    27  27
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.12.0-tests.jar  fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.12.0-tests.jar  /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   test    test    27  27
fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.11-tests.jar    fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.11-tests.jar /org/apache/commons/lang3/function/FailableFunctionsTest.class  /org/apache/commons/lang3/function/FailableFunctionsTest.class  openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   test    test    74  74
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.11-tests.jar    fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.11-tests.jar    /org/apache/commons/lang3/function/FailableFunctionsTest.class  /org/apache/commons/lang3/function/FailableFunctionsTest.class  openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   test    test    74  74
fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.12.0-tests.jar  fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.12.0-tests.jar   /org/apache/commons/lang3/function/FailableFunctionsTest.class  /org/apache/commons/lang3/function/FailableFunctionsTest.class  openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   test    test    76  76
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.12.0-tests.jar  fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.12.0-tests.jar  /org/apache/commons/lang3/function/FailableFunctionsTest.class  /org/apache/commons/lang3/function/FailableFunctionsTest.class  openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   test    test    76  76

There are 8 rows where the class is the same as it was without grouped AICs but the metadata has changed:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ cut -f1-22 fixed_small_jars_with_tests_noAIC.txt |sort> fixed_small_jars_with_tests_noAIC_f1-22.txt
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ cut -f1-22 fixed_small_jars_with_tests_withAIC.txt |sort> fixed_small_jars_with_tests_withAIC_f1-22.txt
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ comm -1 -2 fixed*_f1-22.txt|wc -l
35576
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ comm -1 -3 fixed*_f1-22.txt|wc -l
66
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ comm -2 -3 fixed*_f1-22.txt|wc -l
8

The specific differences in each case were that either one or both of the JEP280 columns changed from false to true after including AICs:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ comm -2 -3 fixed*_f1-22.txt
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.20.jar    /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   main    main
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.20.jar    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   main    main
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.21.jar    /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   main    main
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.21.jar    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   false   false   main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   false   main    main
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ comm -2 -3 fixed*_f1-22.txt|cut -f1-12 | grep -f - -F fixed_small_jars_with_tests_withAIC_f1-22.txt
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.20.jar    /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   true    true    main    main
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.20.jar    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   true    true    main    main
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.21.jar    /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   true    true    main    main
fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-compress-1.21.jar    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 11  17  0   0   19  7   -   -   -   -   false   false   true    true    main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   true    main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.20.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.20.jar   /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   true    main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class /org/apache/commons/compress/archivers/sevenz/AES256SHA256Decoder.class openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   true    main    main
fixed_small_jars_with_tests/openjdk-8.0.372/commons-compress-1.21.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-compress-1.21.jar   /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    /org/apache/commons/compress/archivers/sevenz/CLI$Mode.class    openjdk openjdk 8   11  0   0   372 19  -   -   -   -   false   false   false   true    main    main

I'm confident this works for SameArtifactDifferentCompilerClassOracle.

wtwhite commented 11 months ago

Testing AdjacentVersionSameArtifactAndCompilerClassOracle:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ time java -cp target/jcompile.jar nz.ac.wgtn.shadedetector.jcompile.oracles.AdjacentVersionSameArtifactAndCompilerClassOracle fixed_small_jars_with_tests > fixed_small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler_withAIC.txt 
--snip--
real    0m54.461s
user    1m2.598s
sys 0m6.351s

This shrinks the results a little, since for this oracle (and unlike the other oracle), we had already been setting includeAnonymousInnerClasses to true, so we had been previously getting a row per AIC:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ wc -l small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler3.txt fixed_small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler_withAIC.txt 
   24341 small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler3.txt
   21992 fixed_small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler_withAIC.txt
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ grep '\$[0-9]' fixed_small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler_withAIC.txt |wc -l
0
wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ grep '\$[0-9]' small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler3.txt |wc -l
2369

As before, the largest number of AICs we see is 76. The number can change between versions of a project:

wtwhite@wtwhite-vuw-vm:~/code/jcompile/oracle-construction$ sort -k 19n < fixed_small_jars_with_tests_AdjacentVersionSameArtifactAndCompiler_withAIC.txt | tail
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.8.jar   fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.9.jar   /org/apache/commons/lang3/builder/DiffBuilder.class /org/apache/commons/lang3/builder/DiffBuilder.class openjdk 8   0   372 -   -   -   false   false   false   false   main    main    18  18
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.9.jar   fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.10.jar  /org/apache/commons/lang3/builder/DiffBuilder.class /org/apache/commons/lang3/builder/DiffBuilder.class openjdk 8   0   372 -   -   -   false   false   false   false   main    main    18  18
fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.12.0-tests.jar  fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.8-tests.jar /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk 11  0   19  -   -   -   false   false   false   false   test    test    27  25
fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.8.1-tests.jar   fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.9-tests.jar /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk 11  0   19  -   -   -   false   false   false   false   test    test    25  25
fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.12.0-tests.jar   fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.8-tests.jar  /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk 17  0   7   -   -   -   false   false   false   false   test    test    27  25
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.12.0-tests.jar  fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.8-tests.jar /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk 8   0   372 -   -   -   false   false   false   false   test    test    27  25
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.8.1-tests.jar   fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.9-tests.jar /org/apache/commons/lang3/ClassUtilsTest.class  /org/apache/commons/lang3/ClassUtilsTest.class  openjdk 8   0   372 -   -   -   false   false   false   false   test    test    25  25
fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.11-tests.jar    fixed_small_jars_with_tests/openjdk-11.0.19/commons-lang3-3.12.0-tests.jar  /org/apache/commons/lang3/function/FailableFunctionsTest.class  /org/apache/commons/lang3/function/FailableFunctionsTest.class  openjdk 11  0   19  -   -   -   false   false   false   false   test    test    74  76
fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.11-tests.jar fixed_small_jars_with_tests/openjdk-17.0.7/commons-lang3-3.12.0-tests.jar   /org/apache/commons/lang3/function/FailableFunctionsTest.class  /org/apache/commons/lang3/function/FailableFunctionsTest.class  openjdk 17  0   7   -   -   -   false   false   false   false   test    test    74  76
fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.11-tests.jar    fixed_small_jars_with_tests/openjdk-8.0.372/commons-lang3-3.12.0-tests.jar  /org/apache/commons/lang3/function/FailableFunctionsTest.class  /org/apache/commons/lang3/function/FailableFunctionsTest.class  openjdk 8   0   372 -   -   -   false   false   false   false   test    test    74  76