misc bug fixes and cleanups for new AnalysisScopes
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2171 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
eb7599b7ac
commit
378427225c
|
@ -1,7 +1,6 @@
|
|||
bin.includes = lib/primordial.jar.model,\
|
||||
plugin.properties,\
|
||||
dat/J2SEClassHierarchyExclusions.xml,\
|
||||
dat/SyntheticJ2SEModel.xml,\
|
||||
dat/natives.xml,\
|
||||
META-INF/,\
|
||||
.
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Primordial,Java,jarFile,primordial_jar_model
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<com.ibm.wala.java.scope:EJavaAnalysisScope xmlns:com.ibm.wala.java.scope="http:///com/ibm/wala/wala.ecore.java.scope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<loaders loaderName="Primordial">
|
||||
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule" id="primordial_jar_model"/>
|
||||
</loaders>
|
||||
</com.ibm.wala.java.scope:EJavaAnalysisScope>
|
|
@ -97,14 +97,10 @@ public class AnalysisScope {
|
|||
protected AnalysisScope(Collection<Language> languages) {
|
||||
super();
|
||||
this.languages = languages;
|
||||
ClassLoaderReference primordial =
|
||||
new ClassLoaderReference(PRIMORDIAL, ClassLoaderReference.Java);
|
||||
ClassLoaderReference extension =
|
||||
new ClassLoaderReference(EXTENSION, ClassLoaderReference.Java);
|
||||
ClassLoaderReference application =
|
||||
new ClassLoaderReference(APPLICATION, ClassLoaderReference.Java);
|
||||
ClassLoaderReference synthetic =
|
||||
new ClassLoaderReference(SYNTHETIC, ClassLoaderReference.Java);
|
||||
ClassLoaderReference primordial = new ClassLoaderReference(PRIMORDIAL, ClassLoaderReference.Java);
|
||||
ClassLoaderReference extension = new ClassLoaderReference(EXTENSION, ClassLoaderReference.Java);
|
||||
ClassLoaderReference application = new ClassLoaderReference(APPLICATION, ClassLoaderReference.Java);
|
||||
ClassLoaderReference synthetic = new ClassLoaderReference(SYNTHETIC, ClassLoaderReference.Java);
|
||||
extension.setParent(primordial);
|
||||
application.setParent(extension);
|
||||
synthetic.setParent(application);
|
||||
|
@ -162,10 +158,11 @@ public class AnalysisScope {
|
|||
|
||||
/**
|
||||
* @return the set of "base languages," each of which defines a family of
|
||||
* compatible languages, and therefore induces a distinct ClassHierarchy
|
||||
* compatible languages, and therefore induces a distinct
|
||||
* ClassHierarchy
|
||||
*/
|
||||
public Set<Language> getBaseLanguages() {
|
||||
Set<Language> result= new HashSet<Language>();
|
||||
Set<Language> result = new HashSet<Language>();
|
||||
for (Language language : languages) {
|
||||
if (language.getBaseLanguage() == null) {
|
||||
result.add(language);
|
||||
|
@ -180,7 +177,7 @@ public class AnalysisScope {
|
|||
* @param loader
|
||||
* @param file
|
||||
*/
|
||||
public void addSourceFileToScope(ClassLoaderReference loader, File file, String fileName) throws IllegalArgumentException {
|
||||
public void addSourceFileToScope(ClassLoaderReference loader, File file, String fileName) throws IllegalArgumentException {
|
||||
Set<Module> s = MapUtil.findOrCreateSet(moduleMap, loader);
|
||||
s.add(new SourceFileModule(file, fileName));
|
||||
}
|
||||
|
@ -229,9 +226,10 @@ public class AnalysisScope {
|
|||
|
||||
/**
|
||||
* @return the ClassLoaderReference specified by <code>name</code>.
|
||||
* @throws IllegalArgumentException if name is null
|
||||
* @throws IllegalArgumentException
|
||||
* if name is null
|
||||
*/
|
||||
public ClassLoaderReference getLoader(Atom name) throws IllegalArgumentException {
|
||||
public ClassLoaderReference getLoader(Atom name) throws IllegalArgumentException {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("name is null");
|
||||
}
|
||||
|
@ -366,7 +364,7 @@ public class AnalysisScope {
|
|||
public boolean isJava16Libraries() throws IllegalStateException {
|
||||
return getJavaLibraryVersion().startsWith("1.6");
|
||||
}
|
||||
|
||||
|
||||
public boolean isJava15Libraries() throws IllegalStateException {
|
||||
return getJavaLibraryVersion().startsWith("1.5");
|
||||
}
|
||||
|
|
|
@ -1,39 +1,36 @@
|
|||
package com.ibm.wala.util.config;
|
||||
|
||||
import com.ibm.wala.classLoader.*;
|
||||
import com.ibm.wala.ipa.callgraph.*;
|
||||
import com.ibm.wala.properties.*;
|
||||
import com.ibm.wala.types.*;
|
||||
import com.ibm.wala.util.Atom;
|
||||
import com.ibm.wala.util.debug.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
import com.ibm.wala.classLoader.BinaryDirectoryTreeModule;
|
||||
import com.ibm.wala.classLoader.Language;
|
||||
import com.ibm.wala.classLoader.Module;
|
||||
import com.ibm.wala.classLoader.SourceDirectoryTreeModule;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.properties.WalaProperties;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.util.Atom;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
public class AnalysisScopeReader {
|
||||
|
||||
private static final ClassLoader MY_CLASSLOADER =
|
||||
AnalysisScopeReader.class.getClassLoader();
|
||||
private static final ClassLoader MY_CLASSLOADER = AnalysisScopeReader.class.getClassLoader();
|
||||
|
||||
private static final String BASIC_FILE =
|
||||
"J2SESyntheticModel.txt";
|
||||
private static final String BASIC_FILE = "primordial.txt";
|
||||
|
||||
public static AnalysisScope
|
||||
read(String scopeFileName, String exclusionsFile, ClassLoader javaLoader)
|
||||
{
|
||||
AnalysisScope scope =
|
||||
AnalysisScope.createAnalysisScope(Collections.singleton(Language.JAVA));
|
||||
public static AnalysisScope read(String scopeFileName, String exclusionsFile, ClassLoader javaLoader) {
|
||||
AnalysisScope scope = AnalysisScope.createAnalysisScope(Collections.singleton(Language.JAVA));
|
||||
|
||||
return read(scope, scopeFileName, exclusionsFile, javaLoader);
|
||||
}
|
||||
|
||||
public static AnalysisScope
|
||||
read(AnalysisScope scope,
|
||||
String scopeFileName,
|
||||
String exclusionsFile,
|
||||
ClassLoader javaLoader)
|
||||
{
|
||||
public static AnalysisScope read(AnalysisScope scope, String scopeFileName, String exclusionsFile, ClassLoader javaLoader) {
|
||||
try {
|
||||
File scopeFile = FileProvider.getFile(scopeFileName, javaLoader);
|
||||
assert scopeFile.exists();
|
||||
|
@ -41,50 +38,49 @@ public class AnalysisScopeReader {
|
|||
String line;
|
||||
BufferedReader r = new BufferedReader(new FileReader(scopeFile));
|
||||
while ((line = r.readLine()) != null) {
|
||||
StringTokenizer toks = new StringTokenizer(line, "\n,");
|
||||
StringTokenizer toks = new StringTokenizer(line, "\n,");
|
||||
|
||||
Atom loaderName = Atom.findOrCreateUnicodeAtom(toks.nextToken());
|
||||
Atom languageName = Atom.findOrCreateUnicodeAtom(toks.nextToken());
|
||||
ClassLoaderReference walaLoader =
|
||||
new ClassLoaderReference(loaderName, languageName);
|
||||
Atom loaderName = Atom.findOrCreateUnicodeAtom(toks.nextToken());
|
||||
Atom languageName = Atom.findOrCreateUnicodeAtom(toks.nextToken());
|
||||
ClassLoaderReference walaLoader = new ClassLoaderReference(loaderName, languageName);
|
||||
|
||||
String entryType = toks.nextToken();
|
||||
String entryPathname = toks.nextToken();
|
||||
if ("classFile".equals(entryType)) {
|
||||
File cf = FileProvider.getFile(entryPathname, javaLoader);
|
||||
scope.addClassFileToScope(walaLoader, cf);
|
||||
} else if ("sourceFile".equals(entryType)) {
|
||||
File sf = FileProvider.getFile(entryPathname, javaLoader);
|
||||
scope.addSourceFileToScope(walaLoader, sf, entryPathname);
|
||||
} else if ("binaryDir".equals(entryType)) {
|
||||
File bd = FileProvider.getFile(entryPathname, javaLoader);
|
||||
assert bd.isDirectory();
|
||||
scope.addToScope(walaLoader, new BinaryDirectoryTreeModule(bd));
|
||||
} else if ("sourceDir".equals(entryType)) {
|
||||
File sd = FileProvider.getFile(entryPathname, javaLoader);
|
||||
assert sd.isDirectory();
|
||||
scope.addToScope(walaLoader, new SourceDirectoryTreeModule(sd));
|
||||
} else if ("jarFile".equals(entryType)) {
|
||||
Module M = FileProvider.getJarFileModule(entryPathname, javaLoader);
|
||||
scope.addToScope(walaLoader, M);
|
||||
} else if ("loaderImpl".equals(entryType)) {
|
||||
scope.setLoaderImpl(walaLoader, entryPathname);
|
||||
} else if ("stdlib".equals(entryType)) {
|
||||
String[] stdlibs = WalaProperties.getJ2SEJarFiles();
|
||||
for(int i = 0; i < stdlibs.length; i++) {
|
||||
scope.addToScope(walaLoader, new JarFile(stdlibs[i]));
|
||||
}
|
||||
} else {
|
||||
Assertions.UNREACHABLE();
|
||||
}
|
||||
String entryType = toks.nextToken();
|
||||
String entryPathname = toks.nextToken();
|
||||
if ("classFile".equals(entryType)) {
|
||||
File cf = FileProvider.getFile(entryPathname, javaLoader);
|
||||
scope.addClassFileToScope(walaLoader, cf);
|
||||
} else if ("sourceFile".equals(entryType)) {
|
||||
File sf = FileProvider.getFile(entryPathname, javaLoader);
|
||||
scope.addSourceFileToScope(walaLoader, sf, entryPathname);
|
||||
} else if ("binaryDir".equals(entryType)) {
|
||||
File bd = FileProvider.getFile(entryPathname, javaLoader);
|
||||
assert bd.isDirectory();
|
||||
scope.addToScope(walaLoader, new BinaryDirectoryTreeModule(bd));
|
||||
} else if ("sourceDir".equals(entryType)) {
|
||||
File sd = FileProvider.getFile(entryPathname, javaLoader);
|
||||
assert sd.isDirectory();
|
||||
scope.addToScope(walaLoader, new SourceDirectoryTreeModule(sd));
|
||||
} else if ("jarFile".equals(entryType)) {
|
||||
Module M = FileProvider.getJarFileModule(entryPathname, javaLoader);
|
||||
scope.addToScope(walaLoader, M);
|
||||
} else if ("loaderImpl".equals(entryType)) {
|
||||
scope.setLoaderImpl(walaLoader, entryPathname);
|
||||
} else if ("stdlib".equals(entryType)) {
|
||||
String[] stdlibs = WalaProperties.getJ2SEJarFiles();
|
||||
for (int i = 0; i < stdlibs.length; i++) {
|
||||
scope.addToScope(walaLoader, new JarFile(stdlibs[i]));
|
||||
}
|
||||
} else {
|
||||
Assertions.UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (exclusionsFile != null) {
|
||||
scope.setExclusions(new FileOfClasses(exclusionsFile, javaLoader));
|
||||
scope.setExclusions(new FileOfClasses(exclusionsFile, javaLoader));
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Assertions.UNREACHABLE(e.toString());
|
||||
Assertions.UNREACHABLE(e.toString());
|
||||
}
|
||||
|
||||
return scope;
|
||||
|
@ -94,27 +90,24 @@ public class AnalysisScopeReader {
|
|||
return read(BASIC_FILE, exclusionsFile, MY_CLASSLOADER);
|
||||
}
|
||||
|
||||
public static AnalysisScope
|
||||
makeJavaBinaryAnalysisScope(String classPath, String exclusionsFile)
|
||||
{
|
||||
public static AnalysisScope makeJavaBinaryAnalysisScope(String classPath, String exclusionsFile) {
|
||||
AnalysisScope scope = makePrimordialScope(exclusionsFile);
|
||||
ClassLoaderReference loader = scope.getLoader(AnalysisScope.APPLICATION);
|
||||
|
||||
try {
|
||||
StringTokenizer paths =
|
||||
new StringTokenizer(classPath, File.pathSeparator);
|
||||
StringTokenizer paths = new StringTokenizer(classPath, File.pathSeparator);
|
||||
while (paths.hasMoreTokens()) {
|
||||
String path = paths.nextToken();
|
||||
if (path.endsWith(".jar")) {
|
||||
scope.addToScope(loader, new JarFile(path));
|
||||
} else {
|
||||
File f = new File(path);
|
||||
if (f.isDirectory()) {
|
||||
scope.addToScope(loader, new BinaryDirectoryTreeModule(f));
|
||||
} else {
|
||||
scope.addClassFileToScope(loader, f);
|
||||
}
|
||||
}
|
||||
String path = paths.nextToken();
|
||||
if (path.endsWith(".jar")) {
|
||||
scope.addToScope(loader, new JarFile(path));
|
||||
} else {
|
||||
File f = new File(path);
|
||||
if (f.isDirectory()) {
|
||||
scope.addToScope(loader, new BinaryDirectoryTreeModule(f));
|
||||
} else {
|
||||
scope.addClassFileToScope(loader, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Assertions.UNREACHABLE(e.toString());
|
||||
|
|
|
@ -10,14 +10,17 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.util.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.warnings.WalaException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue