From cd28a3908c01950668fca6fc626953695d9f5664 Mon Sep 17 00:00:00 2001 From: jerryxu158 <57112858+jerryxu158@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:37:43 -0600 Subject: [PATCH] AnalysisScope example (#11) * initial commit * initial commit * JavaDoc creation & removal of static keyword on import * hopefully finished the scope file example implementation * fixed scope file input * changed param names, renamed class * changed exception to exlcusion * tweaks --------- Co-authored-by: Manu Sridharan --- .../analysisscope/AnalysisScopeExample.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/ibm/wala/examples/analysisscope/AnalysisScopeExample.java diff --git a/src/main/java/com/ibm/wala/examples/analysisscope/AnalysisScopeExample.java b/src/main/java/com/ibm/wala/examples/analysisscope/AnalysisScopeExample.java new file mode 100644 index 0000000..d4ffa07 --- /dev/null +++ b/src/main/java/com/ibm/wala/examples/analysisscope/AnalysisScopeExample.java @@ -0,0 +1,34 @@ +package com.ibm.wala.examples.analysisscope; + +import com.ibm.wala.core.util.config.AnalysisScopeReader; +import com.ibm.wala.ipa.callgraph.AnalysisScope; +import java.io.File; +import java.io.IOException; + +/** + * This class shows two ways to create an {@link AnalysisScope}. for more information, check out + * https://github.com/wala/WALA/wiki/Analysis-Scope + */ +public class AnalysisScopeExample { + /** + * @param classPath paths of jars to include in analysis scope, formatted as a Java classpath + * @return AnaylsisScope object created by makeJavaBinaryAnalysisScope + * @throws IOException + */ + AnalysisScope makeAnalysisScope(String classPath) throws IOException { + return AnalysisScopeReader.instance.makeJavaBinaryAnalysisScope(classPath, null); + } + + /** + * @param scopeFilePath Location of a scope file in string form + * @param exclusionFilePath location of an exception file + * @return return an analysis scope object + * @throws IOException + */ + AnalysisScope makeAnalysisScope(String scopeFilePath, String exclusionFilePath) + throws IOException { + File exclusionsFile = new File(exclusionFilePath); + return AnalysisScopeReader.instance.readJavaScope( + scopeFilePath, exclusionsFile, AnalysisScopeExample.class.getClassLoader()); + } +}