Skip to content

Commit

Permalink
Fix bug in missing call edge
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Krishna <[email protected]>
  • Loading branch information
rahlk committed May 24, 2024
1 parent 78d704e commit 3555fa4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
12 changes: 4 additions & 8 deletions src/main/java/com/ibm/northstar/CodeAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPOutputStream;

/**
* The type Code analyzer.
Expand All @@ -61,9 +59,6 @@ public class CodeAnalyzer implements Runnable {
@Option(names = {"-a", "--analysis-level"}, description = "Level of analysis to perform. Options: 1 (for just symbol table) or 2 (for call graph). Default: 1")
private static int analysisLevel = 1;

@Option(names = {"-d", "--dependencies"}, description = "Path to the application 3rd party dependencies that may be helpful in analyzing the application.")
private static String dependencies;

@Option(names = {"-v", "--verbose"}, description = "Print logs to console.")
private static boolean verbose = false;

Expand Down Expand Up @@ -107,9 +102,10 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
}

else {

String dependencies = null;
// download library dependencies of project for type resolution
if (!BuildProject.downloadLibraryDependencies(input)) {
dependencies = String.valueOf(BuildProject.libDownloadPath);
Log.warn("Failed to download library dependencies of project");
}
// construct symbol table for project, write parse problems to file in output directory if specified
Expand All @@ -123,8 +119,8 @@ private static void analyze() throws IOException, ClassHierarchyException, CallG
if (!Files.exists(outputPath)) {
Files.createDirectories(outputPath);
}
String parseError = gson.toJson(symbolTableExtractionResult.getRight());
emit(parseError, "parse_errors.json");
// String parseError = gson.toJson(symbolTableExtractionResult.getRight());
// emit(parseError, "parse_errors.json");
/* gson.toJson(symbolTableExtractionResult.getRight(), new FileWriter(new File(outputPath.toString(), "parse_errors.json")));
* }
**/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ibm/northstar/SystemDependencyGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public static String construct(

// Initialize scope
AnalysisScope scope = ScopeUtils.createScope(input, dependencies, build);
IClassHierarchy cha = ClassHierarchyFactory.makeWithRoot(scope,
IClassHierarchy cha = ClassHierarchyFactory.make(scope,
new ECJClassLoaderFactory(scope.getExclusions()));
Log.done("There were a total of " + cha.getNumberOfClasses() + " classes of which "
+ AnalysisUtils.getNumberOfApplicationClasses(cha) + " are application classes.");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/ibm/northstar/utils/BuildProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

public class BuildProject {

private static final String LIB_DEPS_DOWNLOAD_DIR = "_libdeps";

public static Path libDownloadPath = null;
private static final String LIB_DEPS_DOWNLOAD_DIR = ".library-dependencies";
private static final String MAVEN_CMD = System.getProperty("os.name").contains("win") ? "mvn.cmd" : "mvn";
private static final String GRADLE_CMD = System.getProperty("os.name").contains("win") ? "gradlew.bat" : "gradlew";

Expand Down Expand Up @@ -129,7 +129,7 @@ public static List<Path> buildProjectAndStreamClassFiles(String projectPath, Str
*/
public static boolean downloadLibraryDependencies(String projectPath) {
// created download dir if it does not exist
Path libDownloadPath = Paths.get(projectPath, LIB_DEPS_DOWNLOAD_DIR);
libDownloadPath = Paths.get(projectPath, LIB_DEPS_DOWNLOAD_DIR);
if (!Files.exists(libDownloadPath)) {
try {
Files.createDirectory(libDownloadPath);
Expand Down

0 comments on commit 3555fa4

Please sign in to comment.