bug fix 2666538: make ClassLoaderReference immutable, and related API fixes

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3302 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2009-03-13 14:20:35 +00:00
parent 264448239a
commit ed13ddbb17
19 changed files with 99 additions and 195 deletions

View File

@ -8,6 +8,7 @@ import junit.framework.Assert;
import org.eclipse.core.runtime.NullProgressMonitor;
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.cast.java.translator.jdt.JDTJavaSourceAnalysisEngine;
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
import com.ibm.wala.core.tests.plugin.CoreTestsPlugin;
@ -39,7 +40,7 @@ public class JDTJava15IRTests extends IRTests {
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) {
JavaSourceAnalysisEngine engine = new JDTJavaSourceAnalysisEngine() {
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(EclipseProjectPath.SOURCE_REF, cha, mainClassDescriptors);
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
}
};

View File

@ -44,11 +44,11 @@ import junit.framework.Assert;
import org.eclipse.core.runtime.NullProgressMonitor;
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.cast.java.translator.jdt.JDTJavaSourceAnalysisEngine;
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
import com.ibm.wala.core.tests.plugin.CoreTestsPlugin;
import com.ibm.wala.core.tests.util.EclipseTestUtil;
import com.ibm.wala.eclipse.util.EclipseProjectPath;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.Entrypoint;
import com.ibm.wala.ipa.callgraph.impl.Util;
@ -75,7 +75,7 @@ public class JDTJavaIRTests extends JavaIRTests {
protected JavaSourceAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors) {
JavaSourceAnalysisEngine engine = new JDTJavaSourceAnalysisEngine() {
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(EclipseProjectPath.SOURCE_REF, cha, mainClassDescriptors);
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
}
};

View File

@ -39,10 +39,10 @@ package com.ibm.wala.cast.java.translator.jdt;
import java.io.IOException;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.classLoader.ClassLoaderFactoryImpl;
import com.ibm.wala.classLoader.ClassLoaderImpl;
import com.ibm.wala.classLoader.IClassLoader;
import com.ibm.wala.eclipse.util.EclipseProjectPath;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
import com.ibm.wala.ipa.cha.IClassHierarchy;
@ -62,7 +62,7 @@ public class JDTClassLoaderFactory extends ClassLoaderFactoryImpl {
protected IClassLoader makeNewClassLoader(ClassLoaderReference classLoaderReference, IClassHierarchy cha, IClassLoader parent,
AnalysisScope scope) throws IOException {
if (classLoaderReference.equals(EclipseProjectPath.SOURCE_REF)) {
if (classLoaderReference.equals(JavaSourceAnalysisScope.SOURCE)) {
ClassLoaderImpl cl = new JDTSourceLoaderImpl(classLoaderReference, parent, getExclusions(), cha);
cl.init(scope.getModules(classLoaderReference));
return cl;

View File

@ -33,6 +33,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jdt.core.IJavaProject;
import com.ibm.wala.cast.java.client.JavaSourceAnalysisEngine;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.classLoader.EclipseSourceFileModule;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IClassLoader;
@ -42,7 +43,6 @@ import com.ibm.wala.classLoader.SourceDirectoryTreeModule;
import com.ibm.wala.classLoader.SourceFileModule;
import com.ibm.wala.core.tests.util.EclipseTestUtil;
import com.ibm.wala.core.tests.util.WalaTestCase;
import com.ibm.wala.eclipse.util.EclipseProjectPath;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.cha.IClassHierarchy;
@ -309,7 +309,7 @@ public abstract class IRTests extends WalaTestCase {
protected static void dumpIR(CallGraph cg, boolean assertReachable) throws IOException {
Set<IMethod> unreachable = HashSetFactory.make();
IClassHierarchy cha = cg.getClassHierarchy();
IClassLoader sourceLoader = cha.getLoader(EclipseProjectPath.SOURCE_REF);
IClassLoader sourceLoader = cha.getLoader(JavaSourceAnalysisScope.SOURCE);
for (Iterator iter = sourceLoader.iterateAllClasses(); iter.hasNext();) {
IClass clazz = (IClass) iter.next();

View File

@ -22,13 +22,13 @@ import java.util.Set;
import junit.framework.Assert;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.cast.java.ipa.slicer.AstJavaSlicer;
import com.ibm.wala.cast.java.loader.JavaSourceLoaderImpl;
import com.ibm.wala.cast.java.ssa.EnclosingObjectReference;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.core.tests.slicer.SlicerTest;
import com.ibm.wala.eclipse.util.CancelException;
import com.ibm.wala.eclipse.util.EclipseProjectPath;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
@ -568,7 +568,7 @@ public abstract class JavaIRTests extends IRTests {
private MethodReference getSliceRootReference(String className, String methodName, String methodDescriptor) {
TypeName clsName = TypeName.string2TypeName("L" + className.replace('.', '/'));
TypeReference clsRef = TypeReference.findOrCreate(EclipseProjectPath.SOURCE_REF, clsName);
TypeReference clsRef = TypeReference.findOrCreate(JavaSourceAnalysisScope.SOURCE, clsName);
Atom nameAtom = Atom.findOrCreateUnicodeAtom(methodName);
Descriptor descr = Descriptor.findOrCreateUTF8(methodDescriptor);

View File

@ -10,8 +10,8 @@
*****************************************************************************/
package com.ibm.wala.cast.java.test;
import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.eclipse.util.EclipseProjectPath;
import com.ibm.wala.shrikeBT.IInvokeInstruction;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
@ -26,7 +26,7 @@ public abstract class SyncDuplicatorTest extends IRTests {
}
protected final static CallSiteReference testMethod = CallSiteReference.make(0, MethodReference.findOrCreate(TypeReference
.findOrCreate(EclipseProjectPath.SOURCE_REF, TypeName.string2TypeName("LMonitor2")), Atom.findOrCreateUnicodeAtom("test"),
.findOrCreate(JavaSourceAnalysisScope.SOURCE, TypeName.string2TypeName("LMonitor2")), Atom.findOrCreateUnicodeAtom("test"),
Descriptor.findOrCreateUTF8("(Ljava/lang/Object;)Z")), IInvokeInstruction.Dispatch.STATIC);
public void testMonitor2() {

View File

@ -20,7 +20,6 @@ import com.ibm.wala.cast.java.ipa.callgraph.JavaSourceAnalysisScope;
import com.ibm.wala.classLoader.ClassLoaderFactory;
import com.ibm.wala.classLoader.Module;
import com.ibm.wala.client.AbstractAnalysisEngine;
import com.ibm.wala.eclipse.util.EclipseProjectPath;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
@ -142,7 +141,7 @@ public abstract class JavaSourceAnalysisEngine extends AbstractAnalysisEngine {
}
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(EclipseProjectPath.SOURCE_REF, cha);
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha);
}
@Override

View File

@ -17,12 +17,17 @@ import java.util.Collection;
import java.util.Collections;
import com.ibm.wala.classLoader.Language;
import com.ibm.wala.eclipse.util.EclipseProjectPath;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.strings.Atom;
public class JavaSourceAnalysisScope extends AnalysisScope {
public final static ClassLoaderReference SOURCE = new ClassLoaderReference(Atom.findOrCreateAsciiAtom("Source"), Atom
.findOrCreateAsciiAtom("Java"), ClassLoaderReference.Application);
private final static ClassLoaderReference SYNTH_SOURCE = new ClassLoaderReference(Atom.findOrCreateAsciiAtom("Synthetic_Source"), Atom
.findOrCreateAsciiAtom("Java"), SOURCE);
public JavaSourceAnalysisScope() {
this(Collections.singleton(Language.JAVA));
}
@ -30,16 +35,14 @@ public class JavaSourceAnalysisScope extends AnalysisScope {
public JavaSourceAnalysisScope(Collection<Language> languages) {
super(languages);
initForJava();
EclipseProjectPath.SOURCE_REF.setParent(getLoader(APPLICATION));
getLoader(SYNTHETIC).setParent(EclipseProjectPath.SOURCE_REF);
loadersByName.put(EclipseProjectPath.SOURCE, EclipseProjectPath.SOURCE_REF);
loadersByName.put(SOURCE.getName(),SOURCE);
setLoaderImpl(getLoader(SYNTHETIC), "com.ibm.wala.ipa.summaries.BypassSyntheticClassLoader");
setLoaderImpl(EclipseProjectPath.SOURCE_REF, "com.ibm.wala.cast.java.translator.polyglot.PolyglotSourceLoaderImpl");
setLoaderImpl(getLoader(SYNTH_SOURCE.getName()), "com.ibm.wala.ipa.summaries.BypassSyntheticClassLoader");
setLoaderImpl(SOURCE, "com.ibm.wala.cast.java.translator.polyglot.PolyglotSourceLoaderImpl");
}
public ClassLoaderReference getSourceLoader() {
return getLoader(EclipseProjectPath.SOURCE);
return SOURCE;
}
}

View File

@ -21,79 +21,54 @@ public class JavaScriptTypes extends AstTypeReference {
public static final String jsLoaderNameStr = "JavaScriptLoader";
public static final Atom jsName =
Atom.findOrCreateUnicodeAtom(jsNameStr);
public static final Atom jsName = Atom.findOrCreateUnicodeAtom(jsNameStr);
public static final Atom jsLoaderName =
Atom.findOrCreateUnicodeAtom(jsLoaderNameStr);
public static final Atom jsLoaderName = Atom.findOrCreateUnicodeAtom(jsLoaderNameStr);
public static final ClassLoaderReference jsLoader =
new ClassLoaderReference( jsLoaderName, jsName );
public static final ClassLoaderReference jsLoader = new ClassLoaderReference(jsLoaderName, jsName, null);
public static final TypeReference Root =
TypeReference.findOrCreate(jsLoader, rootTypeName);
public static final TypeReference Root = TypeReference.findOrCreate(jsLoader, rootTypeName);
public static final TypeReference Undefined =
TypeReference.findOrCreate(jsLoader, "LUndefined");
public static final TypeReference Undefined = TypeReference.findOrCreate(jsLoader, "LUndefined");
public static final TypeReference Null =
TypeReference.findOrCreate(jsLoader, "LNull");
public static final TypeReference Null = TypeReference.findOrCreate(jsLoader, "LNull");
public static final TypeReference Array =
TypeReference.findOrCreate(jsLoader, "LArray");
public static final TypeReference Array = TypeReference.findOrCreate(jsLoader, "LArray");
public static final TypeReference Object =
TypeReference.findOrCreate(jsLoader, "LObject");
public static final TypeReference Object = TypeReference.findOrCreate(jsLoader, "LObject");
public static final TypeReference CodeBody =
TypeReference.findOrCreate(jsLoader, functionTypeName);
public static final TypeReference CodeBody = TypeReference.findOrCreate(jsLoader, functionTypeName);
public static final TypeReference Function =
TypeReference.findOrCreate(jsLoader, "LFunction");
public static final TypeReference Function = TypeReference.findOrCreate(jsLoader, "LFunction");
public static final TypeReference Script =
TypeReference.findOrCreate(jsLoader, "LScript");
public static final TypeReference Script = TypeReference.findOrCreate(jsLoader, "LScript");
public static final TypeReference ReferenceError =
TypeReference.findOrCreate(jsLoader, "LReferenceError");
public static final TypeReference ReferenceError = TypeReference.findOrCreate(jsLoader, "LReferenceError");
public static final TypeReference TypeError =
TypeReference.findOrCreate(jsLoader, "LTypeError");
public static final TypeReference TypeError = TypeReference.findOrCreate(jsLoader, "LTypeError");
public static final TypeReference Primitives =
TypeReference.findOrCreate(jsLoader, "LPrimitives");
public static final TypeReference Primitives = TypeReference.findOrCreate(jsLoader, "LPrimitives");
public static final TypeReference FakeRoot =
TypeReference.findOrCreate(jsLoader, "LFakeRoot");
public static final TypeReference FakeRoot = TypeReference.findOrCreate(jsLoader, "LFakeRoot");
public static final TypeReference Boolean =
TypeReference.findOrCreate(jsLoader, "LBoolean");
public static final TypeReference Boolean = TypeReference.findOrCreate(jsLoader, "LBoolean");
public static final TypeReference String =
TypeReference.findOrCreate(jsLoader, "LString");
public static final TypeReference String = TypeReference.findOrCreate(jsLoader, "LString");
public static final TypeReference Number =
TypeReference.findOrCreate(jsLoader, "LNumber");
public static final TypeReference Number = TypeReference.findOrCreate(jsLoader, "LNumber");
public static final TypeReference Date =
TypeReference.findOrCreate(jsLoader, "LDate");
public static final TypeReference Date = TypeReference.findOrCreate(jsLoader, "LDate");
public static final TypeReference RegExp =
TypeReference.findOrCreate(jsLoader, "LRegExp");
public static final TypeReference RegExp = TypeReference.findOrCreate(jsLoader, "LRegExp");
public static final TypeReference BooleanObject =
TypeReference.findOrCreate(jsLoader, "LBooleanObject");
public static final TypeReference BooleanObject = TypeReference.findOrCreate(jsLoader, "LBooleanObject");
public static final TypeReference StringObject =
TypeReference.findOrCreate(jsLoader, "LStringObject");
public static final TypeReference StringObject = TypeReference.findOrCreate(jsLoader, "LStringObject");
public static final TypeReference NumberObject =
TypeReference.findOrCreate(jsLoader, "LNumberObject");
public static final TypeReference NumberObject = TypeReference.findOrCreate(jsLoader, "LNumberObject");
public static final TypeReference DateObject =
TypeReference.findOrCreate(jsLoader, "LDateObject");
public static final TypeReference DateObject = TypeReference.findOrCreate(jsLoader, "LDateObject");
public static final TypeReference RegExpObject =
TypeReference.findOrCreate(jsLoader, "LRegExpObject");
public static final TypeReference RegExpObject = TypeReference.findOrCreate(jsLoader, "LRegExpObject");
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.cast.test"/>
@ -11,6 +11,7 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.6.0_03"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.cast.test"/>
</launchConfiguration>

View File

@ -51,7 +51,7 @@ public class MiscellaneousHacksContextSelector implements ContextSelector {
// loader name, loader language, classname, method name, method descr
case 5: {
MethodReference ref = MethodReference.findOrCreate(TypeReference.findOrCreate(new ClassLoaderReference(Atom
.findOrCreateUnicodeAtom(descr[0]), Atom.findOrCreateUnicodeAtom(descr[1])), TypeName.string2TypeName(descr[2])), Atom
.findOrCreateUnicodeAtom(descr[0]), Atom.findOrCreateUnicodeAtom(descr[1]), null), TypeName.string2TypeName(descr[2])), Atom
.findOrCreateUnicodeAtom(descr[3]), Descriptor.findOrCreateUTF8(descr[4]));
if (cha.resolveMethod(ref) != null) {
@ -64,8 +64,7 @@ public class MiscellaneousHacksContextSelector implements ContextSelector {
// classname, method name, method descr
case 3: {
MethodReference ref = MethodReference.findOrCreate(TypeReference.findOrCreate(new ClassLoaderReference(Atom
.findOrCreateUnicodeAtom("Application"), ClassLoaderReference.Java), TypeName.string2TypeName(descr[0])), Atom
MethodReference ref = MethodReference.findOrCreate(TypeReference.findOrCreate(ClassLoaderReference.Application, TypeName.string2TypeName(descr[0])), Atom
.findOrCreateUnicodeAtom(descr[1]), Descriptor.findOrCreateUTF8(descr[2]));
methodsToSpecialize.add(cha.resolveMethod(ref).getReference());
@ -75,7 +74,7 @@ public class MiscellaneousHacksContextSelector implements ContextSelector {
// loader name, classname, meaning all methods of that class
case 2: {
IClass klass = cha.lookupClass(TypeReference.findOrCreate(new ClassLoaderReference(Atom.findOrCreateUnicodeAtom(descr[0]),
ClassLoaderReference.Java), TypeName.string2TypeName(descr[1])));
ClassLoaderReference.Java, null), TypeName.string2TypeName(descr[1])));
for (Iterator M = klass.getDeclaredMethods().iterator(); M.hasNext();) {
methodsToSpecialize.add(((IMethod) M.next()).getReference());
@ -86,8 +85,7 @@ public class MiscellaneousHacksContextSelector implements ContextSelector {
// classname, meaning all methods of that class
case 1: {
IClass klass = cha.lookupClass(TypeReference.findOrCreate(new ClassLoaderReference(Atom
.findOrCreateUnicodeAtom("Application"), ClassLoaderReference.Java), TypeName.string2TypeName(descr[0])));
IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, TypeName.string2TypeName(descr[0])));
for (Iterator M = klass.getDeclaredMethods().iterator(); M.hasNext();) {
methodsToSpecialize.add(((IMethod) M.next()).getReference());

View File

@ -160,9 +160,9 @@ public class CrossLanguageClassHierarchy implements IClassHierarchy {
return getHierarchy(A).lookupClass(A);
}
public boolean isSyntheticClass(IClass c) {
return getHierarchy(c).isSyntheticClass(c);
}
// public boolean isSyntheticClass(IClass c) {
// return getHierarchy(c).isSyntheticClass(c);
// }
public boolean isInterface(TypeReference type) {
return getHierarchy(type).isInterface(type);

View File

@ -54,7 +54,6 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.MapUtil;
import com.ibm.wala.util.config.AnalysisScopeReader;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.strings.Atom;
/**
* Representation of an analysis scope from an Eclipse project.
@ -75,19 +74,9 @@ import com.ibm.wala.util.strings.Atom;
@SuppressWarnings("restriction")
public class EclipseProjectPath {
/**
* TODO: do we really need this? Why shouldn't source files come from a "normal" class loader like any other resource?
*/
@Deprecated
public static final Atom SOURCE = Atom.findOrCreateUnicodeAtom("Source");
@Deprecated
public static final ClassLoaderReference SOURCE_REF = new ClassLoaderReference(EclipseProjectPath.SOURCE,
ClassLoaderReference.Java);
public enum Loader {
APPLICATION(ClassLoaderReference.Application), EXTENSION(ClassLoaderReference.Extension), PRIMORDIAL(
ClassLoaderReference.Primordial), SOURCE(SOURCE_REF);
ClassLoaderReference.Primordial);
private ClassLoaderReference ref;
@ -101,17 +90,12 @@ public class EclipseProjectPath {
*/
private final IJavaProject project;
private final boolean analyzeSource;
// names of OSGi bundles already processed.
private final Set<String> bundlesProcessed = HashSetFactory.make();
// SJF: Intentionally do not use HashMapFactory, since the Loader keys in the following must use
// identityHashCode. TODO: fix this source of non-determinism?
private final Map<Loader, List<Module>> binaryModules = new HashMap<Loader, List<Module>>();
@Deprecated
private final Map<Loader, List<Module>> sourceModules = new HashMap<Loader, List<Module>>();
private final Map<Loader, List<Module>> modules = new HashMap<Loader, List<Module>>();
private final Collection<IClasspathEntry> alreadyResolved = HashSetFactory.make();
@ -120,11 +104,9 @@ public class EclipseProjectPath {
throw new IllegalArgumentException("null project");
}
this.project = project;
this.analyzeSource = analyzeSource;
assert project != null;
for (Loader loader : Loader.values()) {
MapUtil.findOrCreateList(binaryModules, loader);
MapUtil.findOrCreateList(sourceModules, loader);
MapUtil.findOrCreateList(modules, loader);
}
resolveProjectClasspathEntries();
if (isPluginProject(project)) {
@ -177,13 +159,13 @@ public class EclipseProjectPath {
return;
}
if (isPrimordialJarFile(j)) {
List<Module> s = MapUtil.findOrCreateList(binaryModules, loader);
List<Module> s = MapUtil.findOrCreateList(modules, loader);
s.add(file.isDirectory() ? (Module) new BinaryDirectoryTreeModule(file) : (Module) new JarFileModule(j));
}
} else if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
final File dir = makeAbsolute(e.getPath()).toFile();
final File relDir = e.getPath().removeFirstSegments(1).toFile();
List<Module> s = MapUtil.findOrCreateList(sourceModules, Loader.SOURCE);
List<Module> s = MapUtil.findOrCreateList(modules, loader);
s.add(new SourceDirectoryTreeModule(dir) {
@Override
protected FileModule makeFile(File file) {
@ -193,9 +175,9 @@ public class EclipseProjectPath {
return new EclipseSourceFileModule(f);
}
});
if (!analyzeSource && e.getOutputLocation() != null) {
if (e.getOutputLocation() != null) {
File output = makeAbsolute(e.getOutputLocation()).toFile();
s = MapUtil.findOrCreateList(binaryModules, loader);
s = MapUtil.findOrCreateList(modules, loader);
s.add(new BinaryDirectoryTreeModule(output));
}
} else if (e.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
@ -210,11 +192,9 @@ public class EclipseProjectPath {
resolvePluginClassPath(javaProject.getProject());
}
resolveClasspathEntries(javaProject.getRawClasspath(), loader);
if (!analyzeSource) {
File output = makeAbsolute(javaProject.getOutputLocation()).toFile();
List<Module> s = MapUtil.findOrCreateList(binaryModules, loader);
s.add(new BinaryDirectoryTreeModule(output));
}
File output = makeAbsolute(javaProject.getOutputLocation()).toFile();
List<Module> s = MapUtil.findOrCreateList(modules, loader);
s.add(new BinaryDirectoryTreeModule(output));
}
} catch (CoreException e1) {
e1.printStackTrace();
@ -326,21 +306,16 @@ public class EclipseProjectPath {
public AnalysisScope toAnalysisScope(AnalysisScope scope) {
try {
List<Module> l = MapUtil.findOrCreateList(binaryModules, Loader.APPLICATION);
if (!analyzeSource) {
File dir = makeAbsolute(project.getOutputLocation()).toFile();
if (!dir.isDirectory()) {
System.err.println("PANIC: project output location is not a directory: " + dir);
} else {
l.add(new BinaryDirectoryTreeModule(dir));
}
List<Module> l = MapUtil.findOrCreateList(modules, Loader.APPLICATION);
File dir = makeAbsolute(project.getOutputLocation()).toFile();
if (!dir.isDirectory()) {
System.err.println("PANIC: project output location is not a directory: " + dir);
} else {
l.add(new BinaryDirectoryTreeModule(dir));
}
for (Loader loader : Loader.values()) {
for (Module m : binaryModules.get(loader)) {
scope.addToScope(loader.ref, m);
}
for (Module m : sourceModules.get(loader)) {
for (Module m : modules.get(loader)) {
scope.addToScope(loader.ref, m);
}
}
@ -361,11 +336,7 @@ public class EclipseProjectPath {
}
public Collection<Module> getModules(Loader loader, boolean binary) {
if (binary) {
return Collections.unmodifiableCollection(binaryModules.get(loader));
} else {
return Collections.unmodifiableCollection(sourceModules.get(loader));
}
return Collections.unmodifiableCollection(modules.get(loader));
}
@Override

View File

@ -79,13 +79,10 @@ public class AnalysisScope {
}
protected void initForJava() {
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);
ClassLoaderReference primordial = new ClassLoaderReference(PRIMORDIAL, ClassLoaderReference.Java, null);
ClassLoaderReference extension = new ClassLoaderReference(EXTENSION, ClassLoaderReference.Java, primordial);
ClassLoaderReference application = new ClassLoaderReference(APPLICATION, ClassLoaderReference.Java, extension);
ClassLoaderReference synthetic = new ClassLoaderReference(SYNTHETIC, ClassLoaderReference.Java, application);
setLoaderImpl(synthetic, "com.ibm.wala.ipa.summaries.BypassSyntheticClassLoader");
@ -193,9 +190,6 @@ public class AnalysisScope {
/**
* Add a class file to the scope for a loader
*
* @param loader
* @param file
*/
public void addClassFileToScope(ClassLoaderReference loader, File file) throws IllegalArgumentException {
List<Module> s = MapUtil.findOrCreateList(moduleMap, loader);

View File

@ -833,18 +833,6 @@ public class ClassHierarchy implements IClassHierarchy {
}
}
private final static Atom syntheticLoaderName = Atom.findOrCreateUnicodeAtom("Synthetic");
private final static ClassLoaderReference syntheticLoaderRef = new ClassLoaderReference(syntheticLoaderName, Language.JAVA
.getName());
public boolean isSyntheticClass(IClass c) {
if (c == null) {
throw new IllegalArgumentException("c is null");
}
return c.getClassLoader() == getLoader(syntheticLoaderRef);
}
/**
* Is c a subclass of T?
*

View File

@ -117,7 +117,7 @@ public interface IClassHierarchy extends Iterable<IClass> {
*/
public IClass lookupClass(TypeReference A);
public boolean isSyntheticClass(IClass c);
// public boolean isSyntheticClass(IClass c);
public boolean isInterface(TypeReference type);

View File

@ -15,8 +15,7 @@ import java.io.Serializable;
import com.ibm.wala.util.strings.Atom;
/**
* Defines the meta-information that identifies a class loader. This is
* effectively a "name" for a class loader.
* Defines the meta-information that identifies a class loader. This is effectively a "name" for a class loader.
*
* @author sfink
*
@ -24,8 +23,8 @@ import com.ibm.wala.util.strings.Atom;
public class ClassLoaderReference implements Serializable {
/* Serial version */
private static final long serialVersionUID = -3256390509887654325L;
private static final long serialVersionUID = -3256390509887654325L;
/**
* Canonical name for the Java language
*/
@ -34,17 +33,17 @@ public class ClassLoaderReference implements Serializable {
/**
* Canonical reference to primordial class loader
*/
public final static ClassLoaderReference Primordial = new ClassLoaderReference(Atom.findOrCreateUnicodeAtom("Primordial"), Java);
public final static ClassLoaderReference Primordial = new ClassLoaderReference(Atom.findOrCreateUnicodeAtom("Primordial"), Java, null);
/**
* Canonical reference to extension class loader
*/
public final static ClassLoaderReference Extension = new ClassLoaderReference(Atom.findOrCreateUnicodeAtom("Extension"), Java);
public final static ClassLoaderReference Extension = new ClassLoaderReference(Atom.findOrCreateUnicodeAtom("Extension"), Java, Primordial);
/**
* Canonical reference to application class loader
*/
public final static ClassLoaderReference Application = new ClassLoaderReference(Atom.findOrCreateUnicodeAtom("Application"), Java);
public final static ClassLoaderReference Application = new ClassLoaderReference(Atom.findOrCreateUnicodeAtom("Application"), Java, Extension);
/**
* A String which identifies this loader
@ -59,20 +58,15 @@ public class ClassLoaderReference implements Serializable {
/**
* This class loader's parent
*/
private ClassLoaderReference parent;
private final ClassLoaderReference parent;
/**
* Default constructor
*
* @param name
* String (actually Atom) name identifying the loader
*/
public ClassLoaderReference(Atom name, Atom language) {
public ClassLoaderReference(Atom name, Atom language, ClassLoaderReference parent) {
if (name == null) {
throw new IllegalArgumentException("name is null");
}
this.name = name;
this.language = language;
this.parent = parent;
}
/**
@ -96,23 +90,11 @@ public class ClassLoaderReference implements Serializable {
return parent;
}
/**
* TODO: I hate that this exists.
* @param parent
* the parent of this loader in the loader hierarchy,
*/
public void setParent(ClassLoaderReference parent) {
this.parent = parent;
}
/**
* Note: names for class loader references must be unique.
*
* @see java.lang.Object#equals(Object)
*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}

View File

@ -48,7 +48,6 @@ public class AnalysisScopeReader {
private static AnalysisScope readJavaScope(String scopeFileName, File exclusionsFile, ClassLoader javaLoader, Plugin plugIn) {
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
return read(scope, scopeFileName, exclusionsFile, javaLoader, plugIn);
}
@ -92,11 +91,11 @@ public class AnalysisScopeReader {
if (!toks.hasMoreTokens()) {
return;
}
Atom loaderName = Atom.findOrCreateUnicodeAtom(toks.nextToken());
Atom languageName = Atom.findOrCreateUnicodeAtom(toks.nextToken());
ClassLoaderReference walaLoader = new ClassLoaderReference(loaderName, languageName);
ClassLoaderReference walaLoader = scope.getLoader(loaderName);
@SuppressWarnings("unused")
String language = toks.nextToken();
String entryType = toks.nextToken();
String entryPathname = toks.nextToken();
if ("classFile".equals(entryType)) {

View File

@ -46,19 +46,12 @@ import com.ibm.wala.util.strings.Atom;
/**
* A synthetic class that models aspects of the J2EE Container.
*
* @author Julian Dolby
* @author Stephen Fink
*/
class J2EEContainerModel extends SyntheticClass implements BytecodeConstants, EJBConstants {
private final static Atom syntheticLoaderName = Atom.findOrCreateUnicodeAtom("Synthetic");
private final static Atom extensionLoaderName = Atom.findOrCreateUnicodeAtom("Extension");
private final static ClassLoaderReference syntheticLoaderRef = new ClassLoaderReference(syntheticLoaderName, ClassLoaderReference.Java);
private final static ClassLoaderReference extensionLoaderRef = new ClassLoaderReference(extensionLoaderName, ClassLoaderReference.Java);
private final static ClassLoaderReference syntheticLoaderRef = new ClassLoaderReference(syntheticLoaderName, ClassLoaderReference.Java, ClassLoaderReference.Application);
public static final TypeName containerModelName = TypeName.string2TypeName("L$ContainerModel");
@ -76,17 +69,17 @@ class J2EEContainerModel extends SyntheticClass implements BytecodeConstants, EJ
public static final TypeReference containerModelRef = TypeReference.findOrCreate(syntheticLoaderRef, containerModelName);
public static final TypeReference entityBeanRef = TypeReference.findOrCreate(extensionLoaderRef, entityBeanName);
public static final TypeReference entityBeanRef = TypeReference.findOrCreate(ClassLoaderReference.Extension, entityBeanName);
public static final TypeReference entityContextRef = TypeReference.findOrCreate(extensionLoaderRef, entityContextName);
public static final TypeReference entityContextRef = TypeReference.findOrCreate(ClassLoaderReference.Extension, entityContextName);
public static final TypeReference sessionBeanRef = TypeReference.findOrCreate(extensionLoaderRef, sessionBeanName);
public static final TypeReference sessionBeanRef = TypeReference.findOrCreate(ClassLoaderReference.Extension, sessionBeanName);
public static final TypeReference sessionContextRef = TypeReference.findOrCreate(extensionLoaderRef, sessionContextName);
public static final TypeReference sessionContextRef = TypeReference.findOrCreate(ClassLoaderReference.Extension, sessionContextName);
public static final TypeReference messageBeanRef = TypeReference.findOrCreate(extensionLoaderRef, messageBeanName);
public static final TypeReference messageBeanRef = TypeReference.findOrCreate(ClassLoaderReference.Extension, messageBeanName);
public static final TypeReference messageContextRef = TypeReference.findOrCreate(extensionLoaderRef, messageContextName);
public static final TypeReference messageContextRef = TypeReference.findOrCreate(ClassLoaderReference.Extension, messageContextName);
public static final Descriptor setEntityContextDescriptor = Descriptor.findOrCreate(new TypeName[] { entityContextName },
TypeReference.VoidName);