make evaluator generate multi jcg output
package eu.fasten.analyzer.javacgopal.version3;
import eu.fasten.analyzer.javacgopal.version3.merge.CallGraphUtils;
+import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import java.io.File;
@@ -41,7 +42,8 @@ public class Evaluator {
singleClass++;
}
}
- System.out.println("There was " + singleClass + " number of single class language features we couldn't merge!");
+ System.out.println(
+ "There was " + singleClass + " number of single class language features we couldn't merge!");
}
}
@@ -79,7 +81,8 @@ public class Evaluator {
}
- public static boolean generateMerge(final File langFeature, String main, String genAlg, String mergeAlg, final String output) {
+ public static boolean generateMerge(final File langFeature, String main, String genAlg, String mergeAlg,
+ final String output) {
final var files = langFeature.listFiles(file -> file.getPath().endsWith(".class"));
var deps = "";
@@ -89,15 +92,13 @@ public class Evaluator {
if (!main.isEmpty()) {
if (files[i].getName().equals(main.split("[.]")[1] + ".class")) {
art = files[i];
- }
- else{
+ } else {
deps = deps + files[i].getAbsolutePath() + ",";
}
} else {
if (files[i].getName().equals("Demo.class")) {
art = files[i];
- }
- else{
+ } else {
deps = deps + files[i].getAbsolutePath() + ",";
}
}
@@ -112,16 +113,31 @@ public class Evaluator {
}
}
- private static void compute(File langFeature, String main, String output, String deps, File art, String genAlg, String mergeAlg) {
- final var fileName = art.getName().replace(".class", "");
- final var resultGraphPath = langFeature.getAbsolutePath() + "/" + output+ "_"+fileName+"_merged";
+ private static void compute(File langFeature, String main, String output, String deps, File art, String genAlg,
+ String mergeAlg) {
final var mergeCommand =
- new String[]{"-s", "-a", art.getAbsolutePath(), "-d", deps.replaceAll(".$", ""), "-ma", mergeAlg, "-ga", genAlg, "-n", main, "-o",
+ new String[]{"-s", "-a", art.getAbsolutePath(), "-d", deps.replaceAll(".$", ""), "-ma", mergeAlg, "-ga",
+ genAlg, "-n", main, "-o",
langFeature.getAbsolutePath() + "/" + output};
System.out.println("mergeCommand :" + Arrays.toString(mergeCommand).replace(",", " "));
MainV3.main(mergeCommand);
- final var convertCommand = new String[]{"-c", "-i",resultGraphPath , "-f", "JCG", "-o",
+
+
+ String input = "";
+ final var files =
+ new File(langFeature.getAbsolutePath() + "/cg")
+ .listFiles(file -> (file.getName().startsWith("mergeV3") && !file.getName().endsWith("Demo")));
+ if (files.length > 1) {
+ for (int i = 0; i < files.length; i++) {
+ if (i == files.length - 1) {
+ input = input + files[i].getAbsolutePath();
+ }else {
+ input = input + files[i].getAbsolutePath() + ",";
+ }
+ }
+ }
+ final var convertCommand = new String[]{"-c", "-i", input, "-f", "JCG", "-o",
langFeature.getAbsolutePath() + "/" + output + "Jcg"};
System.out.println("mergeConvert: " + Arrays.toString(convertCommand).replace(",", " "));
