diff --git a/java/common/pom.xml b/java/common/pom.xml index 915ec3a..75f191a 100644 --- a/java/common/pom.xml +++ b/java/common/pom.xml @@ -6,7 +6,7 @@ com.debricked SootWrapper - 5.0 + 5.1 11 @@ -23,7 +23,7 @@ org.soot-oss soot - 4.2.1 + 4.4.1 info.picocli diff --git a/java/common/src/main/java/SootWrapper/Cli.java b/java/common/src/main/java/SootWrapper/Cli.java index d7804f1..253c373 100644 --- a/java/common/src/main/java/SootWrapper/Cli.java +++ b/java/common/src/main/java/SootWrapper/Cli.java @@ -34,8 +34,8 @@ public static void main(String[] args) { @Override public Integer call() throws Exception { - checkExistsAndIsDir(userCodePaths); - checkExistsAndIsDir(libraryCodePaths); + checkExistsAndIsDir(userCodePaths, true); + checkExistsAndIsDir(libraryCodePaths, false); BufferedWriter writer; if (outputFile != null) { if (outputFile.isDirectory()) { @@ -85,13 +85,25 @@ public Integer call() throws Exception { return exitCode; } - private static void checkExistsAndIsDir(Iterable paths) throws FileNotFoundException { + private static void checkExistsAndIsDir(Iterable paths, boolean checkJar) throws FileNotFoundException { for (Path p : paths) { File f = p.toFile(); if (!f.exists()) { throw new FileNotFoundException(String.format("Error: %s can't be found", p)); } if (!f.isDirectory()) { + // Check for .jar file + if (checkJar) { + String fileName = f.getName(); + int index = fileName.lastIndexOf('.'); + if (index > 0) { + String extension = fileName.substring(index+1); + if (extension.equals("jar")) { + return; + } + } + } + throw new IllegalArgumentException(String.format("Error: %s is not a directory", p)); } } diff --git a/java/common/src/test/java/SootWrapper/SootWrapperTest.java b/java/common/src/test/java/SootWrapper/SootWrapperTest.java index ed5bbb3..5d65d3e 100644 --- a/java/common/src/test/java/SootWrapper/SootWrapperTest.java +++ b/java/common/src/test/java/SootWrapper/SootWrapperTest.java @@ -256,7 +256,7 @@ public void testGetCallGraphSelf() { "SootWrapper.Cli.main(String[])" }); assertMethodIsCalledByMethods(calls, "java.io.File.exists()", new String[]{ - "SootWrapper.Cli.checkExistsAndIsDir(Iterable)" + "SootWrapper.Cli.checkExistsAndIsDir(Iterable, boolean)" }); assertMethodIsCalledByMethods(calls, "soot.G.reset()", new String[]{ "SootWrapper.SootWrapper.writeAnalysis(JSONWriter, Iterable, Iterable)"