From 00bb5a9d848bd00db6b2a6d028e3c976ea951cf4 Mon Sep 17 00:00:00 2001 From: Martin Kellogg Date: Thu, 1 Aug 2024 11:05:57 -0400 Subject: [PATCH] analysis of CF-4614 --- differences-between-specimin-and-perses.md | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 differences-between-specimin-and-perses.md diff --git a/differences-between-specimin-and-perses.md b/differences-between-specimin-and-perses.md new file mode 100644 index 0000000..89ff481 --- /dev/null +++ b/differences-between-specimin-and-perses.md @@ -0,0 +1,62 @@ +This file lists each bug for which we managed to run both Specimin and Perses, +and discusses the specific differences in the output. Note that the line counts +in this analysis and in Table 1 of the paper might be different: in Table 1, the formatting +used is the JavaParser pretty-printer (Specimin's output format), but in this document both programs have been +reformatted using GJF-like rules, for fairness of comparison. + +## CF-4614 + +Specimin output: +``` +package net.mtu.eggplant.checker.parser_error; + +import java.util.Map; +import java.util.stream.Collectors; + +public final class Version { + + public static Map getAllVersionInformation() { + throw new Error(); + } + + public void method() { + final String versionInfo = + Version.getAllVersionInformation().entrySet().stream() + .map(e -> String.format("%s:%s", e.getKey(), e.getValue())) + .collect(Collectors.joining("\n")); + } +} +``` + +Perses output: +``` +import java.util.Map; +import java.util.stream.Collectors; + +class Version { + static Map VERSION_INFORMATION; + + static Map getAllVersionInformation() { + return VERSION_INFORMATION; + } + + { + String versionInfo = + Version.getAllVersionInformation().entrySet().stream() + .map(e -> String.format("%s:%s", e.getKey(), e.getValue())) + .collect(Collectors.joining()); + } +} +``` + +Line counts using same formatting: +* Specimin: 14 +* Perses: 14 + +Differences: +* Perses removes the package declaration +* Perses removes "public final" before "class" in the class declaration +* Specimin removes the `VERSION_INFORMATION` field, which apparently doesn't contribute to the error (why does Perses keep it?) +* Specimin replaces the body of `getAllVersionInformation()` with `throw new Error();`, but Perses leaves it as-is +* Perses moves the contents of the target method `method()` to an initializer block +* Perses removes the `final` from the declaration of the `versionInfo` local \ No newline at end of file