diff --git a/com.ibm.wala.core.testdata/.classpath b/com.ibm.wala.core.testdata/.classpath
new file mode 100644
index 000000000..021596729
--- /dev/null
+++ b/com.ibm.wala.core.testdata/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.testdata/.project b/com.ibm.wala.core.testdata/.project
new file mode 100644
index 000000000..3929f7404
--- /dev/null
+++ b/com.ibm.wala.core.testdata/.project
@@ -0,0 +1,28 @@
+
+
+ com.ibm.wala.core.testdata
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/com.ibm.wala.core.testdata/.settings/org.eclipse.jdt.ui.prefs b/com.ibm.wala.core.testdata/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..a6c005a5a
--- /dev/null
+++ b/com.ibm.wala.core.testdata/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Tue Oct 17 11:41:36 EDT 2006
+eclipse.preferences.version=1
+internal.default.compliance=default
diff --git a/com.ibm.wala.core.testdata/META-INF/MANIFEST.MF b/com.ibm.wala.core.testdata/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..728fa09a5
--- /dev/null
+++ b/com.ibm.wala.core.testdata/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Testdata Plug-in
+Bundle-SymbolicName: com.ibm.wala.core.testdata
+Bundle-Version: 1.0.0
+Bundle-Vendor: IBM
+Bundle-Localization: plugin
diff --git a/com.ibm.wala.core.testdata/build.properties b/com.ibm.wala.core.testdata/build.properties
new file mode 100644
index 000000000..41eb6ade2
--- /dev/null
+++ b/com.ibm.wala.core.testdata/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/com.ibm.wala.core.testdata/build.xml b/com.ibm.wala.core.testdata/build.xml
new file mode 100644
index 000000000..dd24b6fe3
--- /dev/null
+++ b/com.ibm.wala.core.testdata/build.xml
@@ -0,0 +1,150 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.testdata/scripts/cruise/config_nashira.xml b/com.ibm.wala.core.testdata/scripts/cruise/config_nashira.xml
new file mode 100644
index 000000000..c181613d7
--- /dev/null
+++ b/com.ibm.wala.core.testdata/scripts/cruise/config_nashira.xml
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.testdata/scripts/fetch.sh b/com.ibm.wala.core.testdata/scripts/fetch.sh
new file mode 100644
index 000000000..023941426
--- /dev/null
+++ b/com.ibm.wala.core.testdata/scripts/fetch.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Fetch source files or builds needed for wala.core regression tests
+#
+#
+
+fetch_jlex() {
+ echo "Fetching jlex ...";
+ makeTempFolder;
+ cd tmp;
+ mkdir JLex;
+ cd JLex;
+ wget http://www.cs.princeton.edu/~appel/modern/java/JLex/current/Main.java;
+ javac Main.java;
+ cd ..;
+ jar cvf JLex.jar JLex;
+ mv JLex.jar ../../bin;
+ cd ..;
+ removeTempFolder;
+}
+
+fetch_javacup() {
+ echo "Fetching java-cup...";
+ makeTempFolder;
+ cd tmp;
+ wget http://www2.cs.tum.edu/projects/cup/java-cup-11a.jar;
+ mv java-cup-11a.jar ../../bin;
+ cd ..;
+ removeTempFolder;
+}
+
+fetch_bcel() {
+ echo "Fetching bcel ...";
+ makeTempFolder;
+ cd tmp;
+ wget http://www.apache.org/dist/jakarta/bcel/binaries/bcel-5.2.tar.gz;
+ gunzip -c bcel-5.2.tar.gz | tar xvf - ;
+ mv bcel-5.2/bcel-5.2.jar ../../bin;
+ cd ..;
+ removeTempFolder;
+}
+
+makeTempFolder() {
+ echo "Creating tmp/";
+ mkdir tmp;
+}
+
+removeTempFolder() {
+ echo "Removing tmp/";
+ rm -rf tmp;
+}
+
+fetch_bcel;
+fetch_jlex;
+fetch_javacup;
diff --git a/com.ibm.wala.core.testdata/src/classConstant/ClassConstant.java b/com.ibm.wala.core.testdata/src/classConstant/ClassConstant.java
new file mode 100644
index 000000000..d434626b4
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/classConstant/ClassConstant.java
@@ -0,0 +1,10 @@
+package classConstant;
+
+class ClassConstant {
+
+ public static void main(String args[]) {
+ Class x = ClassConstant.class;
+ x.hashCode();
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/cornerCases/Abstract1.java b/com.ibm.wala.core.testdata/src/cornerCases/Abstract1.java
new file mode 100644
index 000000000..5e1b96852
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/cornerCases/Abstract1.java
@@ -0,0 +1,17 @@
+//Licensed Materials - Property of IBM
+//5724-D15
+//(C) Copyright IBM Corporation 2004. All Rights Reserved.
+//Note to U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+//
+//---------------------------------------------------------------------------
+
+package cornerCases;
+
+/**
+ * @author sfink
+ *
+ */
+public abstract class Abstract1 {
+
+ void foo() {}
+}
diff --git a/com.ibm.wala.core.testdata/src/cornerCases/Abstract2.java b/com.ibm.wala.core.testdata/src/cornerCases/Abstract2.java
new file mode 100644
index 000000000..0555410e3
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/cornerCases/Abstract2.java
@@ -0,0 +1,17 @@
+//Licensed Materials - Property of IBM
+//5724-D15
+//(C) Copyright IBM Corporation 2004. All Rights Reserved.
+//Note to U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+//
+//---------------------------------------------------------------------------
+
+package cornerCases;
+
+/**
+ * @author sfink
+ *
+ */
+public abstract class Abstract2 {
+
+ void foo() {}
+}
diff --git a/com.ibm.wala.core.testdata/src/cornerCases/Concrete2.java b/com.ibm.wala.core.testdata/src/cornerCases/Concrete2.java
new file mode 100644
index 000000000..2eb7ff8d3
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/cornerCases/Concrete2.java
@@ -0,0 +1,16 @@
+//Licensed Materials - Property of IBM
+//5724-D15
+//(C) Copyright IBM Corporation 2004. All Rights Reserved.
+//Note to U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+//
+//---------------------------------------------------------------------------
+
+package cornerCases;
+
+/**
+ * @author sfink
+ *
+ */
+public class Concrete2 extends Abstract2 {
+
+}
diff --git a/com.ibm.wala.core.testdata/src/cornerCases/Locals.java b/com.ibm.wala.core.testdata/src/cornerCases/Locals.java
new file mode 100644
index 000000000..5389f9e12
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/cornerCases/Locals.java
@@ -0,0 +1,22 @@
+//Licensed Materials - Property of IBM
+//5724-D15
+//(C) Copyright IBM Corporation 2004. All Rights Reserved.
+//Note to U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+//
+//---------------------------------------------------------------------------
+
+package cornerCases;
+
+/**
+ * @author sfink
+ *
+ * Simple input test for local variable table
+ */
+public class Locals {
+
+ public static void foo(String[] a) {
+ System.out.println(a);
+ Object b = a;
+ System.out.println(b);
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/cornerCases/Main.java b/com.ibm.wala.core.testdata/src/cornerCases/Main.java
new file mode 100644
index 000000000..6b61b9be6
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/cornerCases/Main.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package cornerCases;
+
+import sun.java2d.FontSupport;
+
+/**
+ * @author sfink
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ testCastToString();
+ }
+
+ /**
+ * Test bug 38496: propagation of a string constant to a checkcast
+ */
+ private static void testCastToString() {
+ Object o = "a constant string";
+ String s = (String)o;
+ s.toString();
+ }
+
+ public static class YuckyField {
+ FontSupport f;
+ }
+
+ /**
+ * Bug 38540: type inference crashed on this method when class
+ * FontSupport was not found
+ */
+ public static Object foo() {
+ getFontSupport();
+ return new YuckyField().f;
+ }
+
+ public static FontSupport getFontSupport() {
+ return null;
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/cornerCases/YuckyInterface.java b/com.ibm.wala.core.testdata/src/cornerCases/YuckyInterface.java
new file mode 100644
index 000000000..e4a421192
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/cornerCases/YuckyInterface.java
@@ -0,0 +1,21 @@
+//Licensed Materials - Property of IBM
+//5724-D15
+//(C) Copyright IBM Corporation 2004. All Rights Reserved.
+//Note to U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+//
+//---------------------------------------------------------------------------
+
+package cornerCases;
+
+import sun.java2d.FontSupport;
+
+/**
+ * @author sfink
+ *
+ * When analyzed with J2EEClassHierarchy exclusions, the superinterface
+ * FontSupport should not be found because we exclude sun.java2d.*
+ */
+public interface YuckyInterface extends FontSupport {
+
+
+}
diff --git a/com.ibm.wala.core.testdata/src/hello/Hello.java b/com.ibm.wala.core.testdata/src/hello/Hello.java
new file mode 100644
index 000000000..6af153f01
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/hello/Hello.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package hello;
+
+public class Hello {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ System.out.println("Hello world");
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/messageFormatTest/MessageFormatBench.java b/com.ibm.wala.core.testdata/src/messageFormatTest/MessageFormatBench.java
new file mode 100644
index 000000000..c1b2865b9
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/messageFormatTest/MessageFormatBench.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package messageFormatTest;
+
+import java.text.MessageFormat;
+
+public class MessageFormatBench {
+ public static void main(String[] args) {
+ Object[] testArgs = {new Long(3), "MyDisk"};
+ MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0} file(s).");
+ MessageFormat form2 = (MessageFormat) form.clone();
+ System.out.println(form2.format(testArgs));
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/multiDim/TestMultiDim.java b/com.ibm.wala.core.testdata/src/multiDim/TestMultiDim.java
new file mode 100644
index 000000000..9977b1235
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/multiDim/TestMultiDim.java
@@ -0,0 +1,18 @@
+package multiDim;
+
+public class TestMultiDim {
+
+ static void doNothing(Object o) {}
+
+ public static void main(String[] args) {
+ Object[][] multi = new Object[10][];
+ multi[0] = new Object[10];
+ testMulti(multi);
+ }
+
+ static void testMulti(Object[][] multi) {
+ Object[] t = multi[0];
+ doNothing(t);
+ }
+
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.testdata/src/pi/PiNodeCallGraphTestCase.java b/com.ibm.wala.core.testdata/src/pi/PiNodeCallGraphTestCase.java
new file mode 100644
index 000000000..900fe8345
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/pi/PiNodeCallGraphTestCase.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package pi;
+
+class PiNodeCallGraphTestCase {
+
+ interface Whatever {
+
+ void unary1();
+
+ void unary2();
+
+ void binary(Whatever arg);
+
+ }
+
+ static class This implements Whatever {
+
+ public void unary1() {
+ unary2();
+ }
+
+ public void unary2() {
+
+ }
+
+ public void binary(Whatever arg) {
+ this.unary1();
+ arg.unary2();
+ }
+
+ }
+
+ static class That implements Whatever {
+
+ public void unary1() {
+
+ }
+
+ public void unary2() {
+ unary1();
+ }
+
+ public void binary(Whatever arg) {
+ this.unary1();
+ arg.unary2();
+ }
+
+ }
+
+ public native static boolean choice();
+
+ public static void main(String[] args) {
+ Whatever x = new This();
+ Whatever y = new That();
+ Whatever z = choice()? x: y;
+
+ if (z instanceof This)
+ x.binary(z);
+ else
+ y.binary(z);
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/recurse/NList.java b/com.ibm.wala.core.testdata/src/recurse/NList.java
new file mode 100644
index 000000000..e74adde8e
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/recurse/NList.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package recurse;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author sfink
+ *
+ * A simple exercise in recursive data structures.
+ */
+public class NList implements Collection {
+
+ final int value;
+ final NList next;
+
+ public NList(int value) {
+ this.value = value;
+ if (value > 0) {
+ this.next = new NList(value - 1);
+ } else {
+ this.next = null;
+ }
+ }
+
+
+ public static void main(String[] args) {
+ new NList(100);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#size()
+ */
+ public int size() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#isEmpty()
+ */
+ public boolean isEmpty() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#contains(java.lang.Object)
+ */
+ public boolean contains(Object o) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#iterator()
+ */
+ public Iterator iterator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#toArray()
+ */
+ public Object[] toArray() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#add(java.lang.Object)
+ */
+ public boolean add(Object o) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#remove(java.lang.Object)
+ */
+ public boolean remove(Object o) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#containsAll(java.util.Collection)
+ */
+ public boolean containsAll(Collection c) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#addAll(java.util.Collection)
+ */
+ public boolean addAll(Collection c) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#removeAll(java.util.Collection)
+ */
+ public boolean removeAll(Collection c) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#retainAll(java.util.Collection)
+ */
+ public boolean retainAll(Collection c) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Collection#clear()
+ */
+ public void clear() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public Object[] toArray(Object[] a) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/reflection/Reflect1.java b/com.ibm.wala.core.testdata/src/reflection/Reflect1.java
new file mode 100644
index 000000000..6bb15e103
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/reflection/Reflect1.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package reflection;
+
+public class Reflect1 {
+
+ public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+ Class c = Class.forName("java.lang.Integer");
+ Integer i = (Integer)c.newInstance();
+ System.err.println(i);
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/A.java b/com.ibm.wala.core.testdata/src/slice/A.java
new file mode 100644
index 000000000..9c2211f9c
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/A.java
@@ -0,0 +1,19 @@
+package slice;
+
+class A {
+
+ Object f;
+ Object g;
+
+ Object foo() {
+ return new Integer(3);
+ }
+
+ public Object getF() {
+ return f;
+ }
+
+ public void setF(Object f) {
+ this.f = f;
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/B.java b/com.ibm.wala.core.testdata/src/slice/B.java
new file mode 100644
index 000000000..5aa1d852b
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/B.java
@@ -0,0 +1,7 @@
+package slice;
+
+class B extends A {
+ Object foo() {
+ return new Float(4);
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/Slice1.java b/com.ibm.wala.core.testdata/src/slice/Slice1.java
new file mode 100644
index 000000000..a70b6a99d
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/Slice1.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class Slice1 {
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ int x = foo(1);
+ int y = bar(2);
+ System.out.println(x + y);
+ }
+
+ static int foo(int x) {
+ return x + 2;
+ }
+
+ static int bar(int x) {
+ return x + 3;
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/Slice2.java b/com.ibm.wala.core.testdata/src/slice/Slice2.java
new file mode 100644
index 000000000..edf95b405
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/Slice2.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class Slice2 {
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ int x = foo(1);
+ int y = bar(2);
+ baz(x+y);
+ }
+
+ public static void baz(int z) {
+ System.out.println(z);
+ }
+
+ static int foo(int x) {
+ return x + 2;
+ }
+
+ static int bar(int x) {
+ return x + 3;
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/Slice3.java b/com.ibm.wala.core.testdata/src/slice/Slice3.java
new file mode 100644
index 000000000..52144c6bc
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/Slice3.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class Slice3 {
+ static void doNothing(Object o) {
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Object o1 = new Object();
+ Object o2 = new Object();
+ Object o3 = foo(o1, o2);
+ doNothing(o3);
+ }
+
+ static Object foo(Object x, Object y) {
+ return x;
+ }
+
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/Slice4.java b/com.ibm.wala.core.testdata/src/slice/Slice4.java
new file mode 100644
index 000000000..3f0549e67
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/Slice4.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class Slice4 {
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ int x = foo(1);
+ bar(x);
+ }
+
+ static int foo(int x) {
+ return x + 2;
+ }
+
+ static void bar(int x) {
+ return;
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/Slice5.java b/com.ibm.wala.core.testdata/src/slice/Slice5.java
new file mode 100644
index 000000000..f9a536efd
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/Slice5.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class Slice5 {
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ int x = baz();
+ bar(x);
+ }
+
+ static int baz() {
+ return foo(1);
+ }
+
+ static int foo(int x) {
+ return x + 2;
+ }
+
+ static void bar(int x) {
+ return;
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestArrays.java b/com.ibm.wala.core.testdata/src/slice/TestArrays.java
new file mode 100644
index 000000000..5ee4c1aed
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestArrays.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestArrays {
+
+ static void doNothing(Object o) {}
+ /**
+ * slice should include statements involving arr2 and i,
+ * exclude statements with arr1 and j
+ * @param args
+ */
+ public static void main(String[] args) {
+ Object[] arr1 = new Object[10], arr2 = new Object[10];
+ int i = 3;
+ int j = 4;
+ arr2[i] = new Object();
+ arr1[j] = new Object();
+ Object x = arr2[i];
+ doNothing(x);
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestCD1.java b/com.ibm.wala.core.testdata/src/slice/TestCD1.java
new file mode 100644
index 000000000..98e6dbc01
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestCD1.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestCD1 {
+
+ static void doNothing(Object o) {
+ }
+
+ /**
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ Integer I = (Integer) new A().foo();
+ int i = I.intValue();
+ if (i > 0) {
+ System.out.println("X");
+ if (i > 1) {
+ System.out.println("Y");
+ doNothing(I);
+ }
+ }
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestCD2.java b/com.ibm.wala.core.testdata/src/slice/TestCD2.java
new file mode 100644
index 000000000..a74f8b070
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestCD2.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestCD2 {
+
+ static void doNothing(Object o) {
+ }
+
+ /**
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ Integer I = (Integer) new A().foo();
+ int i = I.intValue();
+ if (i > 0) {
+ System.out.println("X");
+ doNothing(I);
+ if (i > 1) {
+ System.out.println("Y");
+ }
+ }
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestCD3.java b/com.ibm.wala.core.testdata/src/slice/TestCD3.java
new file mode 100644
index 000000000..95b834ba5
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestCD3.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestCD3 {
+
+ static void doNothing(Object o) {
+ }
+
+ /**
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ Integer I = (Integer) new A().foo();
+ int i = I.intValue();
+ try {
+ if (i > 0) {
+ System.out.println("X");
+ if (i > 1) {
+ System.out.println("Y");
+ }
+ }
+ } catch (Throwable e) {
+ }
+ doNothing(I);
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestFields.java b/com.ibm.wala.core.testdata/src/slice/TestFields.java
new file mode 100644
index 000000000..72278212e
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestFields.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestFields {
+
+ private static void doNothing(Object o) {}
+
+ /**
+ * slice should include a1 and o1, exclude
+ * a2 and o2
+ * @param args
+ */
+ public static void main(String[] args) {
+ Object o1 = new Object();
+ Object o2 = new Object();
+ A a1 = new A();
+ A a2 = new A();
+ a1.f = o1;
+ a2.f = o2;
+ Object o3 = a1.f;
+ doNothing(o3);
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestGlobal.java b/com.ibm.wala.core.testdata/src/slice/TestGlobal.java
new file mode 100644
index 000000000..1b1c2698f
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestGlobal.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestGlobal {
+
+ static Object global1;
+
+ static Object global2;
+
+ static void copyGlobals() {
+ global2 = global1;
+ }
+
+ static void doNothing(Object o) {
+ }
+
+ /**
+ * make sure global variables are being properly handled
+ * @param args
+ */
+ public static void main(String[] args) {
+ global1 = new Object();
+ copyGlobals();
+ Object x = global2;
+ doNothing(x);
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestId.java b/com.ibm.wala.core.testdata/src/slice/TestId.java
new file mode 100644
index 000000000..a11cb1cda
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestId.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestId {
+
+ static Object id(Object x) {
+ return x;
+ }
+
+ static void doNothing(Object o) {
+ }
+
+ /**
+ * check for context-sensitive handling of the identity function.
+ * o2 should be excluded
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ Object o1 = new Object(), o2 = new Object();
+ Object o3 = id(o1);
+ id(o2);
+ doNothing(o3);
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestMultiTarget.java b/com.ibm.wala.core.testdata/src/slice/TestMultiTarget.java
new file mode 100644
index 000000000..9b30cab06
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestMultiTarget.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestMultiTarget {
+
+ static void doNothing(Object o) {
+ }
+
+ /**
+ * test a virtual call with multiple targets. slice should include statements
+ * assigning to a
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ A a = null;
+ if (args[0] == null) {
+ a = new A();
+ } else {
+ a = new B();
+ }
+ Object x = a.foo();
+ doNothing(x);
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestPrimGetterSetter.java b/com.ibm.wala.core.testdata/src/slice/TestPrimGetterSetter.java
new file mode 100644
index 000000000..92aa030dd
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestPrimGetterSetter.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestPrimGetterSetter {
+
+ static class IntWrapper {
+ int i;
+
+ int getI() { return i; }
+
+ void setI(int i) {
+ this.i = i;
+ }
+ }
+
+ public static void doNothing(int i) {}
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ IntWrapper w = new IntWrapper();
+ int x = 3;
+ w.setI(x);
+ int y = w.getI();
+ doNothing(y); // slice on y
+ }
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestRecursion.java b/com.ibm.wala.core.testdata/src/slice/TestRecursion.java
new file mode 100644
index 000000000..658782d88
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestRecursion.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestRecursion {
+
+ static Object find(A a, Object o) {
+ if (o == null) {
+ return a;
+ } else {
+ return find((A) a.f, o);
+ }
+ }
+
+ static void doNothing(Object o) {
+ }
+
+ /**
+ * test of recursion. Everything for a1, a2, and a3 should
+ * be included
+ * @param args
+ */
+ public static void main(String[] args) {
+ A a1 = new A(), a2 = new A(), a3 = new A();
+ a1.f = a2;
+ a2.f = a3;
+ Object x = find(a1, args[0]);
+ doNothing(x);
+
+ }
+
+}
diff --git a/com.ibm.wala.core.testdata/src/slice/TestThin1.java b/com.ibm.wala.core.testdata/src/slice/TestThin1.java
new file mode 100644
index 000000000..24d2f648a
--- /dev/null
+++ b/com.ibm.wala.core.testdata/src/slice/TestThin1.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package slice;
+
+public class TestThin1 {
+
+ private static void doNothing(Object o) {}
+
+ /**
+ * slice should not include any statements relating to
+ * base pointers
+ */
+ public static void main(String[] args) {
+ Object o1 = new Object();
+ A a1 = new A();
+ A a2 = new A();
+ a1.f = a2;
+ a2.g = o1;
+ A a3 = (A)a1.f;
+ Object o3 = a3.g;
+ doNothing(o3);
+ }
+
+}
diff --git a/com.ibm.wala.core.tests/.classpath b/com.ibm.wala.core.tests/.classpath
new file mode 100644
index 000000000..9f23b089a
--- /dev/null
+++ b/com.ibm.wala.core.tests/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/.project b/com.ibm.wala.core.tests/.project
new file mode 100644
index 000000000..479e43e10
--- /dev/null
+++ b/com.ibm.wala.core.tests/.project
@@ -0,0 +1,28 @@
+
+
+ com.ibm.wala.core.tests
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..b3e6b9f72
--- /dev/null
+++ b/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,62 @@
+#Fri Nov 17 09:37:12 EST 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.ui.prefs b/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..1cc660ac5
--- /dev/null
+++ b/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Tue Oct 03 22:52:44 EDT 2006
+eclipse.preferences.version=1
+internal.default.compliance=default
diff --git a/com.ibm.wala.core.tests/META-INF/MANIFEST.MF b/com.ibm.wala.core.tests/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..deccade58
--- /dev/null
+++ b/com.ibm.wala.core.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: WALA Tests Plug-in
+Bundle-SymbolicName: com.ibm.wala.core.tests
+Bundle-Version: 1.0.0
+Bundle-Vendor: IBM
+Bundle-Localization: plugin
+Require-Bundle: com.ibm.wala.core,
+ org.junit,
+ org.eclipse.jface
+Export-Package: com.ibm.wala.core.tests.basic,
+ com.ibm.wala.core.tests.callGraph,
+ com.ibm.wala.core.tests.cha,
+ com.ibm.wala.core.tests.ir,
+ com.ibm.wala.core.tests.util,
+ com.ibm.wala.examples.drivers,
+ com.ibm.wala.examples.properties
diff --git a/com.ibm.wala.core.tests/build.properties b/com.ibm.wala.core.tests/build.properties
new file mode 100644
index 000000000..c7886205e
--- /dev/null
+++ b/com.ibm.wala.core.tests/build.properties
@@ -0,0 +1,5 @@
+source.. = src/,\
+ dat/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/com.ibm.wala.core.tests/build.xml b/com.ibm.wala.core.tests/build.xml
new file mode 100644
index 000000000..d46ae7f13
--- /dev/null
+++ b/com.ibm.wala.core.tests/build.xml
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.classpath b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.classpath
new file mode 100644
index 000000000..9f23b089a
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.project b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.project
new file mode 100644
index 000000000..479e43e10
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.project
@@ -0,0 +1,28 @@
+
+
+ com.ibm.wala.core.tests
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.core.prefs b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..b3e6b9f72
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,62 @@
+#Fri Nov 17 09:37:12 EST 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.ui.prefs b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..1cc660ac5
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Tue Oct 03 22:52:44 EDT 2006
+eclipse.preferences.version=1
+internal.default.compliance=default
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/META-INF/MANIFEST.MF b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..deccade58
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: WALA Tests Plug-in
+Bundle-SymbolicName: com.ibm.wala.core.tests
+Bundle-Version: 1.0.0
+Bundle-Vendor: IBM
+Bundle-Localization: plugin
+Require-Bundle: com.ibm.wala.core,
+ org.junit,
+ org.eclipse.jface
+Export-Package: com.ibm.wala.core.tests.basic,
+ com.ibm.wala.core.tests.callGraph,
+ com.ibm.wala.core.tests.cha,
+ com.ibm.wala.core.tests.ir,
+ com.ibm.wala.core.tests.util,
+ com.ibm.wala.examples.drivers,
+ com.ibm.wala.examples.properties
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/build.properties b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/build.properties
new file mode 100644
index 000000000..c7886205e
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/build.properties
@@ -0,0 +1,5 @@
+source.. = src/,\
+ dat/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/build.xml b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/build.xml
new file mode 100644
index 000000000..d46ae7f13
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/build.xml
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/GUIExclusions.xml b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/GUIExclusions.xml
new file mode 100644
index 000000000..26c02a0a9
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/GUIExclusions.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/JLex.xml b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/JLex.xml
new file mode 100644
index 000000000..7e578b02b
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/JLex.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/bcel.xml b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/bcel.xml
new file mode 100644
index 000000000..9201ec117
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/bcel.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/hello.xml b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/hello.xml
new file mode 100644
index 000000000..5d6e0eccb
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/hello.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/java_cup.xml b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/java_cup.xml
new file mode 100644
index 000000000..0935a098f
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/java_cup.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/wala.examples.properties.sample b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/wala.examples.properties.sample
new file mode 100644
index 000000000..c48518f92
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/wala.examples.properties.sample
@@ -0,0 +1,30 @@
+###############################################################################
+# WALA Examples property file
+# This file defines the default settings for the WALA examples
+###############################################################################
+
+################# Mandatory settings without default value ####################
+
+################### Mandatory settings with default value ######################
+
+
+############################ Optional settings ################################
+
+### These are needed to run various individual examples
+
+
+##### Ghostview executable
+# Path to the ghostview executable
+# For instance, on a windows OS it's typically something like C:/Progra~1/Ghostgum/gsview/gsview32.exe
+# Default value: none
+# Info: Must be absolute path
+#####
+#ghostview_exe = Your location
+
+##### DOT executable
+# Path to the AT&T Graphview DOT executable
+# For instance, on a windows OS it's typically something like C:/Progra~1/ATT/Graphviz/bin/dot.exe
+# Default value: none
+# Info: Must be absolute path
+#####
+#dot_exe = Your location
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/wala.testdata.xml b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/wala.testdata.xml
new file mode 100644
index 000000000..e579cb64e
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/dat/wala.testdata.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/javaCompiler...args b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/javaCompiler...args
new file mode 100644
index 000000000..c1f7e058e
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/javaCompiler...args
@@ -0,0 +1,42 @@
+#ADAPTER#ACCESS#com.ibm.wala.core/bin/[+com/ibm/wala/analysis/pointers/*;+com/ibm/wala/analysis/reflection/*;+com/ibm/wala/analysis/stackMachine/*;+com/ibm/wala/analysis/typeInference/*;+com/ibm/wala/cfg/*;+com/ibm/wala/cfg/cdg/*;+com/ibm/wala/classLoader/*;+com/ibm/wala/client/*;+com/ibm/wala/client/impl/*;+com/ibm/wala/core/plugin/*;+com/ibm/wala/dataflow/IFDS/*;+com/ibm/wala/dataflow/graph/*;+com/ibm/wala/dataflow/ssa/*;+com/ibm/wala/emf/wrappers/*;+com/ibm/wala/escape/*;+com/ibm/wala/fixedpoint/impl/*;+com/ibm/wala/fixpoint/*;+com/ibm/wala/ipa/callgraph/*;+com/ibm/wala/ipa/callgraph/impl/*;+com/ibm/wala/ipa/callgraph/propagation/*;+com/ibm/wala/ipa/callgraph/propagation/cfa/*;+com/ibm/wala/ipa/callgraph/propagation/rta/*;+com/ibm/wala/ipa/cfg/*;+com/ibm/wala/ipa/cha/*;+com/ibm/wala/ipa/summaries/*;+com/ibm/wala/model/*;+com/ibm/wala/model/java/lang/*;+com/ibm/wala/properties/*;+com/ibm/wala/ssa/*;+com/ibm/wala/ssa/analysis/*;+com/ibm/wala/types/*;+com/ibm/wala/util/*;+com/ibm/wala/util/bytecode/*;+com/ibm/wala/util/collections/*;+com/ibm/wala/util/config/*;+com/ibm/wala/util/debug/*;+com/ibm/wala/util/graph/*;+com/ibm/wala/util/graph/impl/*;+com/ibm/wala/util/graph/traverse/*;+com/ibm/wala/util/heapTrace/*;+com/ibm/wala/util/intertionalization/*;+com/ibm/wala/util/intset/*;+com/ibm/wala/util/io/*;+com/ibm/wala/util/logging/*;+com/ibm/wala/util/math/*;+com/ibm/wala/util/perf/*;+com/ibm/wala/util/properties/*;+com/ibm/wala/util/properties/impl/*;+com/ibm/wala/util/warnings/*;+com/ibm/wala/viz/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.core/@dot[+com/ibm/wala/analysis/pointers/*;+com/ibm/wala/analysis/reflection/*;+com/ibm/wala/analysis/stackMachine/*;+com/ibm/wala/analysis/typeInference/*;+com/ibm/wala/cfg/*;+com/ibm/wala/cfg/cdg/*;+com/ibm/wala/classLoader/*;+com/ibm/wala/client/*;+com/ibm/wala/client/impl/*;+com/ibm/wala/core/plugin/*;+com/ibm/wala/dataflow/IFDS/*;+com/ibm/wala/dataflow/graph/*;+com/ibm/wala/dataflow/ssa/*;+com/ibm/wala/emf/wrappers/*;+com/ibm/wala/escape/*;+com/ibm/wala/fixedpoint/impl/*;+com/ibm/wala/fixpoint/*;+com/ibm/wala/ipa/callgraph/*;+com/ibm/wala/ipa/callgraph/impl/*;+com/ibm/wala/ipa/callgraph/propagation/*;+com/ibm/wala/ipa/callgraph/propagation/cfa/*;+com/ibm/wala/ipa/callgraph/propagation/rta/*;+com/ibm/wala/ipa/cfg/*;+com/ibm/wala/ipa/cha/*;+com/ibm/wala/ipa/summaries/*;+com/ibm/wala/model/*;+com/ibm/wala/model/java/lang/*;+com/ibm/wala/properties/*;+com/ibm/wala/ssa/*;+com/ibm/wala/ssa/analysis/*;+com/ibm/wala/types/*;+com/ibm/wala/util/*;+com/ibm/wala/util/bytecode/*;+com/ibm/wala/util/collections/*;+com/ibm/wala/util/config/*;+com/ibm/wala/util/debug/*;+com/ibm/wala/util/graph/*;+com/ibm/wala/util/graph/impl/*;+com/ibm/wala/util/graph/traverse/*;+com/ibm/wala/util/heapTrace/*;+com/ibm/wala/util/intertionalization/*;+com/ibm/wala/util/intset/*;+com/ibm/wala/util/io/*;+com/ibm/wala/util/logging/*;+com/ibm/wala/util/math/*;+com/ibm/wala/util/perf/*;+com/ibm/wala/util/properties/*;+com/ibm/wala/util/properties/impl/*;+com/ibm/wala/util/warnings/*;+com/ibm/wala/viz/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.emf/bin/[+com/ibm/wala/ecore/common/*;+com/ibm/wala/ecore/common/impl/*;+com/ibm/wala/ecore/common/util/*;+com/ibm/wala/ecore/graph/*;+com/ibm/wala/ecore/graph/impl/*;+com/ibm/wala/ecore/graph/util/*;+com/ibm/wala/ecore/j2ee/scope/*;+com/ibm/wala/ecore/j2ee/scope/impl/*;+com/ibm/wala/ecore/j2ee/scope/util/*;+com/ibm/wala/ecore/java/*;+com/ibm/wala/ecore/java/callGraph/*;+com/ibm/wala/ecore/java/callGraph/impl/*;+com/ibm/wala/ecore/java/callGraph/util/*;+com/ibm/wala/ecore/java/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/*;+com/ibm/wala/ecore/java/pointerAnalysis/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/util/*;+com/ibm/wala/ecore/java/scope/*;+com/ibm/wala/ecore/java/scope/impl/*;+com/ibm/wala/ecore/java/scope/util/*;+com/ibm/wala/ecore/java/util/*;+com/ibm/wala/ecore/perf/*;+com/ibm/wala/ecore/perf/impl/*;+com/ibm/wala/ecore/perf/util/*;+com/ibm/wala/ecore/regex/*;+com/ibm/wala/ecore/regex/impl/*;+com/ibm/wala/ecore/regex/util/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.emf/@dot[+com/ibm/wala/ecore/common/*;+com/ibm/wala/ecore/common/impl/*;+com/ibm/wala/ecore/common/util/*;+com/ibm/wala/ecore/graph/*;+com/ibm/wala/ecore/graph/impl/*;+com/ibm/wala/ecore/graph/util/*;+com/ibm/wala/ecore/j2ee/scope/*;+com/ibm/wala/ecore/j2ee/scope/impl/*;+com/ibm/wala/ecore/j2ee/scope/util/*;+com/ibm/wala/ecore/java/*;+com/ibm/wala/ecore/java/callGraph/*;+com/ibm/wala/ecore/java/callGraph/impl/*;+com/ibm/wala/ecore/java/callGraph/util/*;+com/ibm/wala/ecore/java/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/*;+com/ibm/wala/ecore/java/pointerAnalysis/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/util/*;+com/ibm/wala/ecore/java/scope/*;+com/ibm/wala/ecore/java/scope/impl/*;+com/ibm/wala/ecore/java/scope/util/*;+com/ibm/wala/ecore/java/util/*;+com/ibm/wala/ecore/perf/*;+com/ibm/wala/ecore/perf/impl/*;+com/ibm/wala/ecore/perf/util/*;+com/ibm/wala/ecore/regex/*;+com/ibm/wala/ecore/regex/impl/*;+com/ibm/wala/ecore/regex/util/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime_3.2.0.v20060603.jar[~org/eclipse/core/internal/preferences/legacy/*;~org/eclipse/core/internal/runtime/*;+org/eclipse/core/runtime/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.osgi_3.2.0.v20060601.jar[+org/eclipse/osgi/event/*;+org/eclipse/osgi/framework/console/*;+org/eclipse/osgi/framework/eventmgr/*;+org/eclipse/osgi/framework/log/*;+org/eclipse/osgi/service/datalocation/*;+org/eclipse/osgi/service/debug/*;+org/eclipse/osgi/service/environment/*;+org/eclipse/osgi/service/localization/*;+org/eclipse/osgi/service/pluginconversion/*;+org/eclipse/osgi/service/resolver/*;+org/eclipse/osgi/service/runnable/*;+org/eclipse/osgi/service/urlconversion/*;+org/eclipse/osgi/storagemanager/*;+org/eclipse/osgi/util/*;+org/osgi/framework/*;+org/osgi/service/condpermadmin/*;+org/osgi/service/packageadmin/*;+org/osgi/service/permissionadmin/*;+org/osgi/service/startlevel/*;+org/osgi/service/url/*;+org/osgi/util/tracker/*;~org/eclipse/core/runtime/adaptor/*;~org/eclipse/core/runtime/internal/adaptor/*;~org/eclipse/core/runtime/internal/stats/*;~org/eclipse/osgi/baseadaptor/*;~org/eclipse/osgi/baseadaptor/bundlefile/*;~org/eclipse/osgi/baseadaptor/hooks/*;~org/eclipse/osgi/baseadaptor/loader/*;~org/eclipse/osgi/framework/adaptor/*;~org/eclipse/osgi/framework/debug/*;~org/eclipse/osgi/framework/internal/core/*;~org/eclipse/osgi/framework/internal/protocol/*;~org/eclipse/osgi/framework/internal/protocol/bundleentry/*;~org/eclipse/osgi/framework/internal/protocol/bundleresource/*;~org/eclipse/osgi/framework/internal/protocol/reference/*;~org/eclipse/osgi/framework/internal/reliablefile/*;~org/eclipse/osgi/framework/launcher/*;~org/eclipse/osgi/framework/util/*;~org/eclipse/osgi/internal/baseadaptor/*;~org/eclipse/osgi/internal/module/*;~org/eclipse/osgi/internal/profile/*;~org/eclipse/osgi/internal/resolver/*;~org/eclipse/osgi/internal/verifier/*;~org/eclipse/osgi/internal/provisional/verifier/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar[~org/eclipse/core/internal/runtime/*;~org/eclipse/core/internal/boot/*;+org/eclipse/core/runtime/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.jobs_3.2.0.v20060603.jar[~org/eclipse/core/internal/jobs/*;+org/eclipse/core/runtime/jobs/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/runtime_registry_compatibility.jar[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.apache.xerces_2.8.0.v200606131651/resolver.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.apache.xerces_2.8.0.v200606131651/xercesImpl.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.apache.xerces_2.8.0.v200606131651/xml-apis.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar[~org/eclipse/core/internal/preferences/*;~org/eclipse/core/internal/preferences/exchange/*;+org/eclipse/core/runtime/preferences/*;+org/osgi/service/prefs/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/@dot[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.contenttype_3.2.0.v20060603.jar[~org/eclipse/core/internal/content/*;+org/eclipse/core/runtime/content/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.emf.ecore_2.2.0.v200606271057.jar[+org/eclipse/emf/ecore/*;+org/eclipse/emf/ecore/impl/*;+org/eclipse/emf/ecore/plugin/*;+org/eclipse/emf/ecore/resource/*;+org/eclipse/emf/ecore/resource/impl/*;+org/eclipse/emf/ecore/util/*;+org/eclipse/emf/ecore/xml/namespace/*;+org/eclipse/emf/ecore/xml/namespace/impl/*;+org/eclipse/emf/ecore/xml/namespace/util/*;+org/eclipse/emf/ecore/xml/type/*;+org/eclipse/emf/ecore/xml/type/impl/*;+org/eclipse/emf/ecore/xml/type/internal/*;+org/eclipse/emf/ecore/xml/type/util/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.emf.common_2.2.0.v200606271057.jar[+org/eclipse/emf/common/*;+org/eclipse/emf/common/archive/*;+org/eclipse/emf/common/command/*;+org/eclipse/emf/common/notify/*;+org/eclipse/emf/common/notify/impl/*;+org/eclipse/emf/common/util/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.resources_3.2.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.resources.win32_3.2.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.update.configurator_3.2.0.v20060605.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.variables_3.1.100.v20060605.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.expressions_3.2.0.v20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.filesystem_1.0.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.emf.ecore.xmi_2.2.0.v200606271057.jar[+org/eclipse/emf/ecore/xmi/*;+org/eclipse/emf/ecore/xmi/impl/*;+org/eclipse/emf/ecore/xmi/util/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.shrike/bin/[+com/ibm/wala/shrike/bench/*;+com/ibm/wala/shrike/copywriter/*;+com/ibm/wala/shrike/tools/*;+com/ibm/wala/shrikeBT/*;+com/ibm/wala/shrikeBT/analysis/*;+com/ibm/wala/shrikeBT/info/*;+com/ibm/wala/shrikeBT/shrikeCT/*;+com/ibm/wala/shrikeBT/shrikeCT/tools/*;+com/ibm/wala/shrikeBT/tools/*;+com/ibm/wala/shrikeCT/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.shrike/@dot[+com/ibm/wala/shrike/bench/*;+com/ibm/wala/shrike/copywriter/*;+com/ibm/wala/shrike/tools/*;+com/ibm/wala/shrikeBT/*;+com/ibm/wala/shrikeBT/analysis/*;+com/ibm/wala/shrikeBT/info/*;+com/ibm/wala/shrikeBT/shrikeCT/*;+com/ibm/wala/shrikeBT/shrikeCT/tools/*;+com/ibm/wala/shrikeBT/tools/*;+com/ibm/wala/shrikeCT/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.jface_3.2.0.I20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.swt_3.2.0.v3232o.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232m.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.commands_3.2.0.I20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.jdt.core_3.2.0.v_671.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.text_3.2.0.v20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/com.ibm.icu_3.4.4.1.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.team.core_3.2.0.I200606051140.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.junit_3.8.1/junit.jar[+junit/awtui/*;+junit/extensions/*;+junit/framework/*;+junit/runner/*;+junit/swingui/*;+junit/swingui/icons/*;+junit/textui/*;?**/*]
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/ExportCallGraphToXML.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/ExportCallGraphToXML.launch
new file mode 100644
index 000000000..5abbcec37
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/ExportCallGraphToXML.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/ExportTypeHierarchyToXML.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/ExportTypeHierarchyToXML.launch
new file mode 100644
index 000000000..e272ce68a
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/ExportTypeHierarchyToXML.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVCallGraph.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVCallGraph.launch
new file mode 100644
index 000000000..0f56985de
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVCallGraph.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVControlDependenceGraph.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVControlDependenceGraph.launch
new file mode 100644
index 000000000..de8197e8d
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVControlDependenceGraph.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVSDG.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVSDG.launch
new file mode 100644
index 000000000..c361a3962
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVSDG.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVSlice.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVSlice.launch
new file mode 100644
index 000000000..d059c9c67
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVSlice.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVTypeHierarchy.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVTypeHierarchy.launch
new file mode 100644
index 000000000..860864583
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVTypeHierarchy.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVWalaIR.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVWalaIR.launch
new file mode 100644
index 000000000..1b04da957
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GVWalaIR.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GetEnv.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GetEnv.launch
new file mode 100644
index 000000000..ea2696a61
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/GetEnv.launch
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTCallGraph.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTCallGraph.launch
new file mode 100644
index 000000000..daac4b660
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTCallGraph.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTPointsTo.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTPointsTo.launch
new file mode 100644
index 000000000..5b6675f32
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTPointsTo.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTTypeHierarchy.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTTypeHierarchy.launch
new file mode 100644
index 000000000..f2a2fd62b
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SWTTypeHierarchy.launch
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SimpleThreadEscapeAnalysis.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SimpleThreadEscapeAnalysis.launch
new file mode 100644
index 000000000..08d5bb91c
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SimpleThreadEscapeAnalysis.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SlicerTest.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SlicerTest.launch
new file mode 100644
index 000000000..fb0df2962
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/SlicerTest.launch
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/wala.core short profile.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/wala.core short profile.launch
new file mode 100644
index 000000000..c1a77a6f1
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/wala.core short profile.launch
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/wala.core.launch b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/wala.core.launch
new file mode 100644
index 000000000..4214916d0
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/launchers/wala.core.launch
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java
new file mode 100644
index 000000000..e37aecd75
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.basic;
+
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.dataflow.graph.AbstractMeetOperator;
+import com.ibm.wala.dataflow.graph.BitVectorFilter;
+import com.ibm.wala.dataflow.graph.BitVectorFramework;
+import com.ibm.wala.dataflow.graph.BitVectorIdentity;
+import com.ibm.wala.dataflow.graph.BitVectorSolver;
+import com.ibm.wala.dataflow.graph.BitVectorUnion;
+import com.ibm.wala.dataflow.graph.BitVectorUnionConstant;
+import com.ibm.wala.dataflow.graph.DataflowSolver;
+import com.ibm.wala.dataflow.graph.ITransferFunctionProvider;
+import com.ibm.wala.fixedpoint.impl.UnaryOperator;
+import com.ibm.wala.fixpoint.BitVectorVariable;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
+import com.ibm.wala.util.intset.BitVector;
+import com.ibm.wala.util.intset.MutableMapping;
+import com.ibm.wala.util.intset.OrdinalSetMapping;
+
+/**
+ *
+ * Simple Regression test for a graph-based dataflow problem
+ *
+ * @author Donald P Pazel
+ * @author sfink
+ * @author Julian Dolby (dolby@us.ibm.com)
+ */
+public class GraphDataflowTest extends WalaTestCase {
+
+ public static final String nodeNames = "ABCDEFGH";
+ protected final static String[] nodes = new String[nodeNames.length()];
+
+ public GraphDataflowTest() {
+ super("GraphDataflowTest");
+ }
+
+ /**
+ * A simple test of the GraphBitVectorDataflow system
+ */
+ public void testSolverNodeEdge() {
+ Graph G = buildGraph();
+ String result = solveNodeEdge(G);
+ System.err.println(result);
+ if (!result.equals(expectedStringNodeEdge())) {
+ System.err.println("Uh oh.");
+ System.err.println(expectedStringNodeEdge());
+ }
+ assertEquals(expectedStringNodeEdge(), result);
+ }
+
+ public void testSolverNodeOnly() {
+ Graph G = buildGraph();
+ String result = solveNodeOnly(G);
+ System.err.println(result);
+ assertEquals(expectedStringNodeOnly(), result);
+ }
+
+ /**
+ * @return the expected dataflow result as a String
+ */
+ public static String expectedStringNodeOnly() {
+ StringBuffer result = new StringBuffer("------\n");
+ result.append("Node A(0) = { 0 }\n");
+ result.append("Node B(1) = { 0 1 }\n");
+ result.append("Node C(2) = { 0 1 2 }\n");
+ result.append("Node D(3) = { 0 1 3 }\n");
+ result.append("Node E(4) = { 0 1 2 3 4 }\n");
+ result.append("Node F(5) = { 0 1 2 3 4 5 }\n");
+ result.append("Node G(6) = { 6 }\n");
+ result.append("Node H(7) = { 7 }\n");
+ return result.toString();
+ }
+
+ public static String expectedStringNodeEdge() {
+ StringBuffer result = new StringBuffer("------\n");
+ result.append("Node A(0) = { 0 }\n");
+ result.append("Node B(1) = { 0 1 }\n");
+ result.append("Node C(2) = { 0 2 }\n");
+ result.append("Node D(3) = { 1 3 }\n");
+ result.append("Node E(4) = { 0 1 2 3 4 }\n");
+ result.append("Node F(5) = { 0 1 2 3 4 5 }\n");
+ result.append("Node G(6) = { 6 }\n");
+ result.append("Node H(7) = { 7 }\n");
+ return result.toString();
+ }
+
+ /**
+ * @return a graph with the expected structure
+ */
+ private static Graph buildGraph() {
+ Graph G = new SlowSparseNumberedGraph();
+ for (int i = 0; i < nodeNames.length(); i++) {
+ String n = nodeNames.substring(i, i + 1);
+ G.addNode(n);
+ nodes[i] = n;
+ }
+ G.addEdge(nodes[0], nodes[1]);
+ G.addEdge(nodes[1], nodes[2]);
+ G.addEdge(nodes[1], nodes[3]);
+ G.addEdge(nodes[2], nodes[4]);
+ G.addEdge(nodes[3], nodes[4]);
+ G.addEdge(nodes[4], nodes[5]);
+ return G;
+ }
+
+ /**
+ * Solve the dataflow system and return the result as a string
+ */
+ private String solveNodeOnly(Graph G) {
+ final OrdinalSetMapping values = new MutableMapping(nodes);
+ ITransferFunctionProvider functions = new ITransferFunctionProvider() {
+
+ public UnaryOperator getNodeTransferFunction(String node) {
+ return new BitVectorUnionConstant(values.getMappedIndex(node));
+ }
+
+ public boolean hasNodeTransferFunctions() {
+ return true;
+ }
+
+ public UnaryOperator getEdgeTransferFunction(String from, String to) {
+ Assertions.UNREACHABLE();
+ return null;
+ }
+
+ public boolean hasEdgeTransferFunctions() {
+ return false;
+ }
+
+ public AbstractMeetOperator getMeetOperator() {
+ return BitVectorUnion.instance();
+ }
+
+ };
+
+ BitVectorFramework F = new BitVectorFramework(G, functions, values);
+ DataflowSolver s = new BitVectorSolver(F);
+ s.solve();
+ return result2String(s);
+ }
+
+ private String solveNodeEdge(Graph G) {
+ final OrdinalSetMapping values = new MutableMapping(nodes);
+ ITransferFunctionProvider functions = new ITransferFunctionProvider() {
+
+ public UnaryOperator getNodeTransferFunction(String node) {
+ return new BitVectorUnionConstant(values.getMappedIndex(node));
+ }
+
+ public boolean hasNodeTransferFunctions() {
+ return true;
+ }
+
+ private BitVector zero() {
+ BitVector b = new BitVector();
+ b.set(0);
+ return b;
+ }
+
+ private BitVector one() {
+ BitVector b = new BitVector();
+ b.set(1);
+ return b;
+ }
+
+ public UnaryOperator getEdgeTransferFunction(String from, String to) {
+ if (from == nodes[1] && to == nodes[3])
+ return new BitVectorFilter(zero());
+ else if (from == nodes[1] && to == nodes[2])
+ return new BitVectorFilter(one());
+ else {
+ return BitVectorIdentity.instance();
+ }
+ }
+
+ public boolean hasEdgeTransferFunctions() {
+ return true;
+ }
+
+ public AbstractMeetOperator getMeetOperator() {
+ return BitVectorUnion.instance();
+ }
+
+ };
+
+ BitVectorFramework F = new BitVectorFramework(G, functions, values);
+ DataflowSolver s = new BitVectorSolver(F);
+ s.solve();
+ return result2String(s);
+ }
+
+ public static String result2String(DataflowSolver solver) {
+ StringBuffer result = new StringBuffer("------\n");
+ for (int i = 0; i < nodes.length; i++) {
+ String n = nodes[i];
+ BitVectorVariable varI = (BitVectorVariable) solver.getOut(n);
+ String s = varI.toString();
+ result.append("Node " + n + "(" + i + ") = " + s + "\n");
+ }
+ return result.toString();
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java
new file mode 100644
index 000000000..3dbe937d4
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java
@@ -0,0 +1,585 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.basic;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.util.collections.BimodalMap;
+import com.ibm.wala.util.collections.Iterator2Collection;
+import com.ibm.wala.util.collections.SmallMap;
+import com.ibm.wala.util.graph.Dominators;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.NumberedGraph;
+import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
+import com.ibm.wala.util.graph.traverse.BFSPathFinder;
+import com.ibm.wala.util.graph.traverse.BoundedBFSIterator;
+import com.ibm.wala.util.intset.BasicNonNegativeIntRelation;
+import com.ibm.wala.util.intset.BimodalMutableIntSetFactory;
+import com.ibm.wala.util.intset.BitVector;
+import com.ibm.wala.util.intset.BitVectorIntSetFactory;
+import com.ibm.wala.util.intset.IBinaryNonNegativeIntRelation;
+import com.ibm.wala.util.intset.IntPair;
+import com.ibm.wala.util.intset.IntSet;
+import com.ibm.wala.util.intset.IntSetUtil;
+import com.ibm.wala.util.intset.IntegerUnionFind;
+import com.ibm.wala.util.intset.MutableIntSet;
+import com.ibm.wala.util.intset.MutableIntSetFactory;
+import com.ibm.wala.util.intset.MutableSharedBitVectorIntSetFactory;
+import com.ibm.wala.util.intset.MutableSparseIntSetFactory;
+import com.ibm.wala.util.intset.SparseIntSet;
+
+/**
+ *
+ * JUnit tests for some primitive operations.
+ *
+ * @author sfink
+ */
+public class PrimitivesTest extends WalaTestCase {
+
+ /**
+ *
+ */
+ public PrimitivesTest() {
+ super("PrimitivesTest");
+ }
+
+ /**
+ * @param arg0
+ */
+ public PrimitivesTest(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test the MutableSparseIntSet implementation
+ */
+ private void doMutableIntSet(MutableIntSetFactory factory) {
+ MutableIntSet v = factory.parse("{9,17}");
+ MutableIntSet w = factory.make(new int[] {});
+ MutableIntSet x = factory.make(new int[] { 7, 4, 2, 4, 2, 2 });
+ MutableIntSet y = factory.make(new int[] { 7, 7, 7, 2, 7, 1 });
+ MutableIntSet z = factory.parse("{ 9 }");
+
+ System.out.println(w); // { }
+ System.out.println(x); // { 2 4 7 }
+ System.out.println(y); // { 1 2 7 }
+ System.out.println(z); // { 9 }
+
+ MutableIntSet temp = factory.makeCopy(x);
+ temp.intersectWith(y);
+ System.out.println(temp); // { 2 7 }
+ temp.copySet(x);
+ temp.addAll(y);
+ System.out.println(temp); // { 1 2 4 7 }
+ temp.copySet(x);
+ System.out.println(IntSetUtil.diff(x, y, factory)); // { 4 }
+ System.out.println(IntSetUtil.diff(v, z, factory)); // { 17 }
+ System.out.println(IntSetUtil.diff(z, v, factory)); // { }
+
+ // assertTrue(x.union(z).intersection(y.union(z)).equals(x.intersection(y).union(z)));
+ MutableIntSet temp1 = factory.makeCopy(x);
+ MutableIntSet temp2 = factory.makeCopy(x);
+ MutableIntSet tempY = factory.makeCopy(y);
+ temp1.addAll(z);
+ tempY.addAll(z);
+ temp1.intersectWith(tempY);
+ temp2.intersectWith(y);
+ temp2.addAll(z);
+ assertTrue(temp1.sameValue(temp2));
+
+ // assertTrue(x.union(z).diff(z).equals(x));
+ assertTrue(w.isEmpty());
+ assertTrue(IntSetUtil.diff(x, x, factory).isEmpty());
+ assertTrue(IntSetUtil.diff(z, v, factory).isEmpty());
+ assertTrue(IntSetUtil.diff(v, z, factory).sameValue(SparseIntSet.singleton(17)));
+ assertTrue(IntSetUtil.diff(z, v, factory).isEmpty());
+ assertTrue(z.isSubset(v));
+ temp = factory.make();
+ temp.add(4);
+ System.out.println(temp); // { 4 }
+ temp.add(7);
+ System.out.println(temp); // { 4 7 }
+ temp.add(2);
+ System.out.println(temp); // { 2 4 7 }
+ System.out.println(x); // { 2 4 7 }
+ assertTrue(temp.sameValue(x));
+
+ MutableIntSet a = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}");
+ System.out.println(a); // { 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33
+ // 35
+ // 37 39 41 43 45 47 49 51 53 55 57 59 }
+ assertTrue(a.sameValue(a));
+ IntSet i = a.intersection(temp);
+ assertTrue(i.sameValue(SparseIntSet.singleton(7)));
+ a.add(100);
+ assertTrue(a.sameValue(a));
+
+ MutableIntSet b = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,100}");
+ assertTrue(a.sameValue(b));
+ assertTrue(a.isSubset(b));
+
+ b = factory.makeCopy(a);
+ assertTrue(a.sameValue(b));
+ b.remove(1);
+ b.add(0);
+ assertTrue(!a.sameValue(b));
+
+ a = factory.parse("{1}");
+ assertFalse(a.isSubset(b));
+ b.remove(0);
+ assertFalse(a.isSubset(b));
+ a.remove(1);
+ assertTrue(a.isEmpty());
+ i = a.intersection(temp);
+ assertTrue(a.isEmpty());
+
+ temp2 = factory.make();
+ assertTrue(temp2.sameValue(a));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,51,53,55,57,59,61,63}");
+ b = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62}");
+ MutableIntSet c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ MutableIntSet d = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ MutableIntSet e = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34}");
+
+ assertTrue(e.isSubset(d));
+ e.addAll(d);
+ assertTrue(e.isSubset(d));
+ e.remove(12);
+ assertTrue(e.isSubset(d));
+ e.add(105);
+ assertFalse(e.isSubset(d));
+
+ assertFalse(b.isSubset(a));
+
+ b.add(53);
+ assertFalse(b.isSubset(a));
+
+ a.add(52);
+ a.remove(52);
+ assertFalse(b.isSubset(a));
+
+ c.add(55);
+ assertFalse(c.isSubset(b));
+
+ d.add(53);
+ assertTrue(d.isSubset(b));
+
+ d = factory.make();
+ d.copySet(c);
+ assertFalse(d.isSubset(b));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ b = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ assertFalse(a.sameValue(b));
+ b.add(50);
+ assertTrue(a.sameValue(b));
+ a.add(11);
+ b.add(11);
+ assertTrue(a.sameValue(b));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,50}");
+ b = factory.parse("{24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ a.addAll(b);
+ a.add(22);
+ assertTrue(a.sameValue(c));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,50}");
+ b = factory.parse("{24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ b.addAll(factory.parse("{22}"));
+ a.addAll(b);
+ assertTrue(a.sameValue(c));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20}");
+ b = factory.parse("{22,24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ c.remove(22);
+ a.addAll(b);
+ assertFalse(a.sameValue(c));
+
+ a = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}");
+ System.out.println(a); // { 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33
+ // 35
+ // 37 39 41 43 45 47 49 51 53 55 57 59 }
+ assertTrue(a.sameValue(a));
+ i = a.intersection(temp);
+ assertTrue(i.sameValue(SparseIntSet.singleton(7)));
+ a.add(100);
+ assertTrue(a.sameValue(a));
+
+ b = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,100}");
+ assertTrue(a.sameValue(b));
+ assertTrue(a.isSubset(b));
+
+ b = factory.makeCopy(a);
+ assertTrue(a.sameValue(b));
+ b.remove(1);
+ b.add(0);
+ assertTrue(!a.sameValue(b));
+
+ a = factory.parse("{1}");
+ assertFalse(a.isSubset(b));
+ b.remove(0);
+ assertFalse(a.isSubset(b));
+ a.remove(1);
+ assertTrue(a.isEmpty());
+ i = a.intersection(temp);
+ assertTrue(a.isEmpty());
+
+ temp2 = factory.make();
+ assertTrue(temp2.sameValue(a));
+ }
+
+ /**
+ * Test the MutableSharedBitVectorIntSet implementation
+ */
+ public void testMutableSharedBitVectorIntSet() {
+ doMutableIntSet(new MutableSharedBitVectorIntSetFactory());
+ }
+
+ /**
+ * Test the MutableSparseIntSet implementation
+ */
+ public void testMutableSparseIntSet() {
+ doMutableIntSet(new MutableSparseIntSetFactory());
+ }
+
+ /**
+ * Test the BimodalMutableSparseIntSet implementation
+ */
+ public void testBimodalMutableSparseIntSet() {
+ doMutableIntSet(new BimodalMutableIntSetFactory());
+ }
+
+ /**
+ * Test the BitVectorIntSet implementation
+ */
+ public void testBitVectorIntSet() {
+ doMutableIntSet(new BitVectorIntSetFactory());
+ }
+
+ public void testSmallMap() {
+ SmallMap M = new SmallMap();
+ Integer I1 = new Integer(1);
+ Integer I2 = new Integer(2);
+ Integer I3 = new Integer(3);
+ M.put(I1, I1);
+ M.put(I2, I2);
+ M.put(I3, I3);
+
+ Integer I = (Integer) M.get(new Integer(2));
+ assertTrue(I != null);
+ assertTrue(I.equals(I2));
+
+ I = (Integer) M.get(new Integer(4));
+ assertTrue(I == null);
+
+ I = (Integer) M.put(new Integer(2), new Integer(3));
+ assertTrue(I.equals(I2));
+ I = (Integer) M.get(I2);
+ assertTrue(I.equals(I3));
+ }
+
+ public void testBimodalMap() {
+ Map M = new BimodalMap(3);
+ Integer I1 = new Integer(1);
+ Integer I2 = new Integer(2);
+ Integer I3 = new Integer(3);
+ Integer I4 = new Integer(4);
+ Integer I5 = new Integer(5);
+ Integer I6 = new Integer(6);
+ M.put(I1, I1);
+ M.put(I2, I2);
+ M.put(I3, I3);
+
+ Integer I = M.get(new Integer(2));
+ assertTrue(I != null);
+ assertTrue(I.equals(I2));
+
+ I = M.get(new Integer(4));
+ assertTrue(I == null);
+
+ I = M.put(new Integer(2), new Integer(3));
+ assertTrue(I.equals(I2));
+ I = M.get(I2);
+ assertTrue(I.equals(I3));
+
+ M.put(I4, I4);
+ M.put(I5, I5);
+ M.put(I6, I6);
+ I = M.get(new Integer(4));
+ assertTrue(I != null);
+ assertTrue(I.equals(I4));
+
+ I = M.get(new Integer(7));
+ assertTrue(I == null);
+
+ I = M.put(new Integer(2), new Integer(6));
+ assertTrue(I.equals(I3));
+ I = M.get(I2);
+ assertTrue(I.equals(I6));
+ }
+
+ public void testBFSPathFinder() {
+ NumberedGraph G = makeBFSTestGraph();
+
+ // path from 0 to 8
+ BFSPathFinder pf = new BFSPathFinder(G, G.getNode(0), G.getNode(8));
+ List p = pf.find();
+
+ // path should be 8, 6, 4, 2, 0
+ System.out.println("Path is " + p);
+ for (int i = 0; i < p.size(); i++) {
+ assertTrue((p.get(i)).intValue() == new int[] { 8, 6, 4, 2, 0 }[i]);
+ }
+ }
+
+ public void testBoundedBFS() {
+ NumberedGraph G = makeBFSTestGraph();
+
+ BoundedBFSIterator bfs = new BoundedBFSIterator(G, G.getNode(0), 0);
+ Collection c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 1);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 1);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 3);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 2);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 5);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 3);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 7);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 4);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 9);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 5);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 10);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 500);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 10);
+ }
+
+ private NumberedGraph makeBFSTestGraph() {
+ // test graph
+ NumberedGraph G = new SlowSparseNumberedGraph();
+
+ // add 10 nodes
+ Integer[] nodes = new Integer[10];
+ for (int i = 0; i < nodes.length; i++)
+ G.addNode(nodes[i] = new Integer(i));
+
+ // edges to i-1, i+1, i+2
+ for (int i = 0; i < nodes.length; i++) {
+ if (i > 0) {
+ G.addEdge(nodes[i], nodes[i - 1]);
+ }
+ if (i < nodes.length - 1) {
+ G.addEdge(nodes[i], nodes[i + 1]);
+ if (i < nodes.length - 2) {
+ G.addEdge(nodes[i], nodes[i + 2]);
+ }
+ }
+ }
+ return G;
+ }
+
+ public void testDominatorsA() {
+ // test graph
+ Graph
+ *
+ *
+ * This observation is implemented in the obvious way:
+ *
+ *
All static fields are collected
+ *
All Thread constructor parameters are collected
+ *
The points-to sets of these values represent the base set of escapees.
+ *
All object reachable from fields of these objects are added
+ *
This process continues until a fixpoint is reached
+ *
The abstract objects in the points-to sets are converted to types
+ *
This set of types is returned
+ *
+ *
+ * @author Julian Dolby
+ */
+public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
+ private final Set applicationJarFiles;
+
+ private final String applicationMainClass;
+
+ /**
+ * The two input parameters define the program to analyze: the jars of .class
+ * files and the main class to start from.
+ */
+ public SimpleThreadEscapeAnalysis(Set applicationJarFiles, String applicationMainClass) {
+ this.applicationJarFiles = applicationJarFiles;
+ this.applicationMainClass = applicationMainClass;
+ }
+
+ /**
+ * Given a root path, add it to the set if it is a jar, or traverse it
+ * recursively if it is a directory.
+ */
+ private void collectJars(File f, Set result) throws IOException {
+ if (f.isDirectory()) {
+ File[] files = f.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ collectJars(files[i], result);
+ }
+ } else if (f.getAbsolutePath().endsWith(".jar")) {
+ result.add(new JarFile(f));
+ }
+ }
+
+ /**
+ * Collect the set of JarFiles that constitute the system libraries of the
+ * running JRE.
+ */
+ private JarFile[] getSystemJars() throws IOException {
+ Set jarFiles = HashSetFactory.make();
+
+ String javaHomePath = System.getProperty("java.home");
+
+ if (!javaHomePath.endsWith(File.separator)) {
+ javaHomePath = javaHomePath + File.separator;
+ }
+
+ collectJars(new File(javaHomePath + "lib"), jarFiles);
+
+ return jarFiles.toArray(new JarFile[jarFiles.size()]);
+ }
+
+ /**
+ * Take the given set of JarFiles that constitute the program, and return a
+ * set of Module files as expected by the WALA machinery.
+ */
+ private Set getModuleFiles() {
+ Set result = HashSetFactory.make();
+ for (Iterator jars = applicationJarFiles.iterator(); jars.hasNext();) {
+ result.add(new JarFileModule(jars.next()));
+ }
+
+ return result;
+ }
+
+ /**
+ * The heart of the analysis.
+ */
+ public Set gatherThreadEscapingClasses() throws IOException, ClassHierarchyException {
+
+ //
+ // set the application to analyze
+ //
+ setModuleFiles(getModuleFiles());
+
+ //
+ // set the system jar files to use.
+ // change this if you want to use a specific jre version
+ //
+ setJ2SELibraries(getSystemJars());
+
+ //
+ // the application and libraries are set, now build the scope...
+ //
+ buildAnalysisScope();
+
+ //
+ // ...and the class hierarchy
+ //
+ ClassHierarchy cha = buildClassHierarchy();
+ setClassHierarchy(cha);
+
+ //
+ // select the call graph construction algorithm
+ // change this if greater precision is desired
+ // (see com.ibm.wala.client.impl.*BuilderFactory)
+ //
+ setCallGraphBuilderFactory(new ZeroCFABuilderFactory());
+
+ //
+ // entrypoints are where analysis starts
+ //
+ Entrypoints roots = Util.makeMainEntrypoints(getScope(), cha, applicationMainClass);
+
+ //
+ // analysis options controls aspects of call graph construction
+ //
+ AnalysisOptions options = getDefaultOptions(roots);
+
+ //
+ // build the call graph
+ //
+ buildCallGraph(cha, options, true);
+
+ //
+ // extract data for analysis
+ //
+ CallGraph cg = getCallGraph();
+ PointerAnalysis pa = getPointerAnalysis();
+
+ //
+ // collect all places where objects can escape their creating thread:
+ // 1) all static fields
+ // 2) arguments to Thread constructors
+ //
+ Set escapeAnalysisRoots = HashSetFactory.make();
+ HeapModel heapModel = pa.getHeapModel();
+
+ // 1) static fields
+ for (Iterator clss = cha.iterateAllClasses(); clss.hasNext();) {
+ IClass cls = (IClass) clss.next();
+ Collection staticFields = cls.getDeclaredStaticFields();
+ for (Iterator sfs = staticFields.iterator(); sfs.hasNext();) {
+ IField sf = (IField) sfs.next();
+ if (sf.getFieldTypeReference().isReferenceType()) {
+ escapeAnalysisRoots.add(heapModel.getPointerKeyForStaticField(sf));
+ }
+ }
+ }
+
+ // 2) instance fields of Threads
+ // (we hack this by getting the 'this' parameter of all ctor calls;
+ // this works because the next phase will add all objects transitively
+ // reachable from fields of types in these pointer keys, and all
+ // Thread objects must be constructed somewhere)
+ Collection threads = cha.computeSubClasses(TypeReference.JavaLangThread);
+ for (Iteratorclss = threads.iterator(); clss.hasNext();) {
+ IClass cls = (IClass) clss.next();
+ for (Iterator ms = cls.getDeclaredMethods(); ms.hasNext();) {
+ IMethod m = (IMethod) ms.next();
+ if (m.isInit()) {
+ Set nodes = cg.getNodes(m.getReference());
+ for (Iterator ns = nodes.iterator(); ns.hasNext();) {
+ CGNode n = (CGNode) ns.next();
+ escapeAnalysisRoots.add(heapModel.getPointerKeyForLocal(n, 1));
+ }
+ }
+ }
+ }
+
+ //
+ // compute escaping types: all types flowing to escaping roots and
+ // all types transitively reachable through their fields.
+ //
+ Set escapingInstanceKeys = HashSetFactory.make();
+
+ //
+ // pass 1: get abstract objects (instance keys) for escaping locations
+ //
+ for (Iterator rts = escapeAnalysisRoots.iterator(); rts.hasNext();) {
+ PointerKey root = rts.next();
+ OrdinalSet objects = pa.getPointsToSet(root);
+ for (Iterator objs = objects.iterator(); objs.hasNext();) {
+ InstanceKey obj = (InstanceKey) objs.next();
+ escapingInstanceKeys.add(obj);
+ }
+ }
+
+ //
+ // passes 2+: get fields of escaping keys, and add pointed-to keys
+ //
+ Set newKeys = HashSetFactory.make();
+ do {
+ newKeys.clear();
+ for (Iterator keys = escapingInstanceKeys.iterator(); keys.hasNext();) {
+ InstanceKey key = keys.next();
+ IClass type = key.getConcreteType();
+ if (type.isReferenceType()) {
+ if (type.isArrayClass()) {
+ if (((ArrayClass) type).getElementClass() != null) {
+ PointerKey fk = heapModel.getPointerKeyForArrayContents(key);
+ OrdinalSet fobjects = pa.getPointsToSet(fk);
+ for (Iterator fobjs = fobjects.iterator(); fobjs.hasNext();) {
+ InstanceKey fobj = (InstanceKey) fobjs.next();
+ if (!escapingInstanceKeys.contains(fobj)) {
+ newKeys.add(fobj);
+ }
+ }
+ }
+ } else {
+ Collection fields = type.getAllInstanceFields();
+ for (Iterator fs = fields.iterator(); fs.hasNext();) {
+ IField f = (IField) fs.next();
+ if (f.getFieldTypeReference().isReferenceType()) {
+ PointerKey fk = heapModel.getPointerKeyForInstanceField(key, f);
+ OrdinalSet fobjects = pa.getPointsToSet(fk);
+ for (Iterator fobjs = fobjects.iterator(); fobjs.hasNext();) {
+ InstanceKey fobj = (InstanceKey) fobjs.next();
+ if (!escapingInstanceKeys.contains(fobj)) {
+ newKeys.add(fobj);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ escapingInstanceKeys.addAll(newKeys);
+ } while (!newKeys.isEmpty());
+
+ //
+ // get set of types from set of instance keys
+ //
+ Set escapingTypes = HashSetFactory.make();
+ for (Iterator keys = escapingInstanceKeys.iterator(); keys.hasNext();) {
+ InstanceKey key = keys.next();
+ escapingTypes.add(key.getConcreteType());
+ }
+
+ return escapingTypes;
+ }
+
+ public static void main(String[] args) throws IOException, ClassHierarchyException {
+ String mainClassName = args[0];
+
+ Set jars = HashSetFactory.make();
+ for (int i = 1; i < args.length; i++) {
+ jars.add(new JarFile(args[i]));
+ }
+
+ Set escapingTypes = (new SimpleThreadEscapeAnalysis(jars, mainClassName)).gatherThreadEscapingClasses();
+
+ for (Iterator types = escapingTypes.iterator(); types.hasNext();) {
+ System.out.println(types.next().getName().toString());
+ }
+ }
+}
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/ExportCallGraphToXML.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/ExportCallGraphToXML.java
new file mode 100644
index 000000000..245ce812d
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/ExportCallGraphToXML.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.ibm.wala.ecore.java.ECallSite;
+import com.ibm.wala.ecore.java.EJavaClass;
+import com.ibm.wala.ecore.java.EJavaMethod;
+import com.ibm.wala.ecore.java.callGraph.ECallGraph;
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFBridge;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.EObjectDictionary;
+import com.ibm.wala.emf.wrappers.EObjectGraph;
+import com.ibm.wala.emf.wrappers.EObjectGraphImpl;
+import com.ibm.wala.emf.wrappers.EUtil;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.util.collections.Iterator2Collection;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * This simple example application builds a call graph writes it to an XML file
+ *
+ * @author sfink
+ */
+public class ExportCallGraphToXML {
+
+ /**
+ * Usage: ExportCallGraphToXML -appJar [jar file name] The "jar file name"
+ * should be something like "c:/temp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ run(args);
+ }
+
+ /**
+ * Usage: args = "-appJar [jar file name] " The "jar file name" should be
+ * something like "c:/temp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static void run(String[] args) {
+ validateCommandLine(args);
+ run(args[1]);
+ }
+
+ /**
+ * @param appJar
+ * something like "c:/temp/testdata/java_cup.jar"
+ */
+ public static void run(String appJar) {
+ try {
+
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(appJar);
+
+ // generate a DOMO-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+ // TODO: return the warning set (need a CAPA type)
+ // invoke DOMO to build a DOMO class hierarchy object
+ WarningSet warnings = new WarningSet();
+ System.err.println("Build class hierarchy...");
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha);
+ AnalysisOptions options = new AnalysisOptions(scope, entrypoints);
+
+ // //
+ // build the call graph
+ // //
+ System.err.println("Build callgraph...");
+ com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cha, scope, warnings, null, null);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ System.err.println("Convert to EMF...");
+ com.ibm.wala.emf.wrappers.ECallGraphWrapper ccg = EMFBridge.makeCallGraph(cg);
+ ECallGraph ecg = (ECallGraph) ccg.export();
+
+ Properties p = null;
+ ;
+ try {
+ p = WalaProperties.loadProperties();
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String filename = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + "cg.xml";
+ System.err.println("Writing to file: " + filename);
+ write(ecg, filename);
+
+ // try and load it too
+
+ List l = EUtil.readEObjects(filename, ExportCallGraphToXML.class.getClassLoader());
+
+ // convert it to a default graph for kicks
+ ECallGraph output = (ECallGraph) l.get(0);
+ System.err.println(output.getClass());
+ EObjectGraph graph = EObjectGraphImpl.fromEMF(output);
+ System.err.println("read " + graph.getNumberOfNodes() + " nodes");
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void write(ECallGraph cg, String filename) throws WalaException {
+
+ // make sure every java method reachable from the call graph
+ // is a node is the call graph
+ Collection c = new Iterator2Collection(cg.getNodes().getContents().iterator());
+ for (Iterator it = c.iterator(); it.hasNext();) {
+ Object node = it.next();
+ if (node instanceof ECallSite) {
+ ECallSite site = (ECallSite) node;
+ EJavaMethod method = site.getDeclaredTarget();
+ if (!c.contains(method)) {
+ cg.getNodes().getContents().add(method);
+ }
+
+ method = site.getJavaMethod();
+ if (!c.contains(method)) {
+ cg.getNodes().getContents().add(method);
+ }
+ }
+ }
+
+ // make a canonical dictionary of all method nodes
+ EObjectDictionary methodNodes = new EObjectDictionary();
+ for (Iterator it = cg.getNodes().getContents().iterator(); it.hasNext();) {
+ Object node = it.next();
+ if (node instanceof EJavaMethod) {
+ EJavaMethod method = (EJavaMethod) node;
+ methodNodes.findOrAdd(method);
+ }
+ }
+
+ // Create a collection of EObjects to persist
+ Collection persist = new LinkedList();
+ // Persist the call graph itself
+ persist.add(cg);
+ // Persist the nodes of the call graph which are NOT contained in the
+ // ECallGraph
+ persist.add(cg.getNodes());
+
+ // Persist all Java classes reachable from the call graph,
+ // and make sure pointers are canonical
+ EObjectDictionary klasses = new EObjectDictionary();
+ for (Iterator it = cg.getNodes().getContents().iterator(); it.hasNext();) {
+ Object node = it.next();
+ if (node instanceof ECallSite) {
+ ECallSite site = (ECallSite) node;
+ EJavaMethod method = (EJavaMethod) site.getDeclaredTarget();
+ method = (EJavaMethod) methodNodes.findOrAdd(method);
+ site.setDeclaredTarget(method);
+ EJavaClass klass = (EJavaClass) klasses.findOrAdd(method.getJavaClass());
+ method.setJavaClass(klass);
+
+ method = site.getJavaMethod();
+ method = (EJavaMethod) methodNodes.findOrAdd(method);
+ site.setJavaMethod(method);
+ klass = (EJavaClass) klasses.findOrAdd(method.getJavaClass());
+ method.setJavaClass(klass);
+ } else if (node instanceof EJavaMethod) {
+ EJavaMethod method = (EJavaMethod) node;
+ EJavaClass klass = (EJavaClass) klasses.findOrAdd(method.getJavaClass());
+ method.setJavaClass(klass);
+ } else {
+ Assertions.UNREACHABLE("Unexpected type " + node.getClass());
+ }
+ }
+ persist.add(klasses.export(true));
+
+ // Save everything to a file.
+ EUtil.saveToFile(persist, filename);
+ }
+
+ /**
+ * Validate that the command-line arguments obey the expected usage.
+ *
+ * Usage:
+ *
+ *
args[0] : "-appJar"
+ *
args[1] : something like "c:/temp/testdata/java_cup.jar"
g = GVTypeHierarchy.typeHierarchy2Graph(th);
+ g = GVTypeHierarchy.pruneForAppLoader(g);
+ if (g.getNumberOfNodes() == 0) {
+ System.err.println("ERROR: The type hierarchy in " + ExportTypeHierarchyToXML.getFileName() + " has no nodes from the Application loader");
+ System.err.println("Probably something's wrong with the input jars being analyzed.");
+ System.err.println("check the files in the path: " + classpath);
+ System.err.println("Also look at these warning messages:");
+ System.err.println(warnings.toString());
+ System.exit(-1);
+ }
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private static void write(ETypeHierarchy t, String filename) throws WalaException {
+
+ if (filename == null) {
+ throw new WalaException("internal error: null filename parameter");
+ }
+
+ // Create a collection of EObjects to persist
+ Collection persist = new LinkedList();
+ // Persist the type hierarchy itself
+ persist.add(t);
+ // Persist the classes as well, which are NOT contained in the ETypeHierarchy
+ persist.add(t.getClasses().getNodes());
+ // Persist the interfaces as well, which are NOT contained in the ETypeHierarchy
+ persist.add(t.getInterfaces().getNodes());
+
+ // Save everything to a file.
+ EUtil.saveToFile(persist, filename);
+ }
+
+ static String getFileName() throws WalaException {
+ Properties p = null;;
+ try {
+ p = WalaProperties.loadProperties();
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String file = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + FILENAME;
+ return file;
+ }
+
+ public static ETypeHierarchy buildTypeHierarchy(String classpath, WarningSet warnings) throws WalaException {
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(classpath);
+
+ // generate a WALA-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+ // invoke WALA to build a class hierarchy
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ // Export the class hierarchy object to an EMF TypeHierarchy object
+ com.ibm.wala.emf.wrappers.ETypeHierarchyWrapper t1 = EMFBridge.makeTypeHierarchy(cha);
+
+ ETypeHierarchy th = (ETypeHierarchy) t1.toEMF();
+ return th;
+ }
+
+ /**
+ * Validate that the command-line arguments obey the expected usage.
+ *
+ * Usage: args[0] : "-classpath" args[1] : String, a ";"-delimited class path
+ *
+ * @param args
+ * @throws UnsupportedOperationException
+ * if command-line is malformed.
+ */
+ static void validateCommandLine(String[] args) {
+ if (args.length < 2) {
+ throw new UnsupportedOperationException("must have at least 2 command-line arguments");
+ }
+ if (!args[0].equals("-classpath")) {
+ throw new UnsupportedOperationException("invalid command-line, args[0] should be -classpath, but is " + args[0]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVCallGraph.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVCallGraph.java
new file mode 100644
index 000000000..43d420e18
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVCallGraph.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.io.File;
+import java.util.Properties;
+
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.examples.properties.WalaExamplesProperties;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.callgraph.propagation.LocalPointerKey;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.types.ClassLoaderReference;
+import com.ibm.wala.util.collections.Filter;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.io.CommandLine;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.DotUtil;
+import com.ibm.wala.viz.GVUtil;
+
+/**
+ *
+ * This simple example WALA application builds a call graph and fires off
+ * ghostview to viz a DOT representation.
+ *
+ * @author sfink
+ */
+public class GVCallGraph {
+
+ private final static String PS_FILE = "cg.ps";
+
+ /**
+ * Usage: GVCallGraph -appJar [jar file name] The "jar file name" should
+ * be something like "c:/temp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ run(args);
+ }
+
+ /**
+ * Usage: args = "-appJar [jar file name] " The "jar file name" should be
+ * something like "c:/temp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static Process run(String[] args) {
+ Properties p = CommandLine.parse(args);
+ validateCommandLine(p);
+ return run(p.getProperty("appJar"));
+ }
+
+ /**
+ * @param appJar
+ * something like "c:/temp/testdata/java_cup.jar"
+ */
+ public static Process run(String appJar) {
+ try {
+
+ Graph g = buildPrunedCallGraph(appJar);
+
+ Properties p = null;
+ try {
+ p = WalaExamplesProperties.loadProperties();
+ p.putAll(WalaProperties.loadProperties());
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String psFile = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + PS_FILE;
+
+ String dotExe = p.getProperty(WalaExamplesProperties.DOT_EXE);
+ DotUtil.dotify(g, null, GVTypeHierarchy.DOT_FILE, psFile, dotExe);
+
+ String gvExe = p.getProperty(WalaExamplesProperties.GHOSTVIEW_EXE);
+ return GVUtil.launchGV(psFile, gvExe);
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * @param appJar
+ * something like "c:/temp/testdata/java_cup.jar"
+ * @return a call graph
+ * @throws WalaException
+ */
+ public static Graph buildPrunedCallGraph(String appJar) throws WalaException {
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(appJar);
+
+ // generate a DOMO-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+
+ // TODO: return the warning set (need a CAPA type)
+ // invoke DOMO to build a DOMO class hierarchy object
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha);
+ AnalysisOptions options = new AnalysisOptions(scope, entrypoints);
+
+ // //
+ // build the call graph
+ // //
+ com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cha, scope, warnings, null, null);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ Graph g = pruneForAppLoader(cg);
+ return g;
+ }
+
+ static Graph pruneForAppLoader(CallGraph g) throws WalaException {
+ return GVTypeHierarchy.pruneGraph(g, new ApplicationLoaderFilter());
+ }
+
+ /**
+ * Validate that the command-line arguments obey the expected usage.
+ *
+ * Usage:
+ *
+ *
args[0] : "-appJar"
+ *
args[1] : something like "c:/temp/testdata/java_cup.jar"
+ *
CGNode
+ *
LocalPointerKey
+ *
+ */
+ private static class ApplicationLoaderFilter implements Filter {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.capa.util.collections.Filter#accepts(java.lang.Object)
+ */
+ public boolean accepts(Object o) {
+ if (o instanceof CGNode) {
+ CGNode n = (CGNode) o;
+ return n.getMethod().getDeclaringClass().getClassLoader().getReference().equals(ClassLoaderReference.Application);
+ } else if (o instanceof LocalPointerKey) {
+ LocalPointerKey l = (LocalPointerKey) o;
+ return accepts(l.getNode());
+ } else {
+ return false;
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVControlDependenceGraph.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVControlDependenceGraph.java
new file mode 100644
index 000000000..967d1bb80
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVControlDependenceGraph.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.io.File;
+import java.util.Properties;
+
+import com.ibm.wala.cfg.cdg.ControlDependenceGraph;
+import com.ibm.wala.classLoader.IMethod;
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.examples.properties.WalaExamplesProperties;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.impl.Everywhere;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.ssa.IR;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.util.StringStuff;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.DotUtil;
+import com.ibm.wala.viz.GVUtil;
+import com.ibm.wala.viz.GhostviewUtil;
+
+/**
+ *
+ * This simple example application builds a WALA CDG and fires off ghostview
+ * to viz a DOT representation.
+ *
+ * @author sfink
+ */
+public class GVControlDependenceGraph {
+
+ final public static boolean SANITIZE_CFG = false;
+
+ final public static String PS_FILE = "cdg.ps";
+
+ /**
+ * Usage: GVControlDependenceGraph -appJar [jar file name] -sig [method signature] The "jar
+ * file name" should be something like "c:/temp/testdata/java_cup.jar" The
+ * signature should be something like "java_cup.lexer.advance()V"
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ run(args);
+ }
+
+ /**
+ * @param args
+ * -appJar [jar file name] -sig [method signature] The "jar file
+ * name" should be something like "c:/temp/testdata/java_cup.jar" The
+ * signature should be something like "java_cup.lexer.advance()V"
+ */
+ public static Process run(String[] args) {
+ validateCommandLine(args);
+ return run(args[1], args[3]);
+ }
+
+ /**
+ * @param appJar
+ * should be something like "c:/temp/testdata/java_cup.jar"
+ * @param methodSig
+ * should be something like "java_cup.lexer.advance()V"
+ */
+ public static Process run(String appJar, String methodSig) {
+ try {
+ if (SWTCallGraph.isDirectory(appJar)) {
+ appJar = SWTCallGraph.findJarFiles(new String[] { appJar });
+ }
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(appJar);
+
+ // generate a DOMO-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+ // invoke DOMO to build a DOMO class hierarchy object
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ MethodReference mr = StringStuff.makeMethodReference(methodSig);
+
+ IMethod m = cha.resolveMethod(mr);
+ if (m == null) {
+ Assertions.UNREACHABLE("could not resolve " + mr);
+ }
+ AnalysisOptions options = new AnalysisOptions();
+ options.getSSAOptions().setUsePiNodes(true);
+ IR ir = options.getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, cha, options.getSSAOptions(), new WarningSet());
+
+ if (ir == null) {
+ Assertions.UNREACHABLE("Null IR for " + m);
+ }
+
+ System.err.println(ir.toString());
+ ControlDependenceGraph cdg = new ControlDependenceGraph(ir.getControlFlowGraph());
+
+ Properties wp = null;
+ try {
+ wp = WalaProperties.loadProperties();
+ wp.putAll(WalaExamplesProperties.loadProperties());
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String psFile = wp.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + GVControlDependenceGraph.PS_FILE;
+ String dotFile = wp.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar
+ + GVTypeHierarchy.DOT_FILE;
+ String dotExe = wp.getProperty(WalaExamplesProperties.DOT_EXE);
+ String gvExe = wp.getProperty(WalaExamplesProperties.GHOSTVIEW_EXE);
+
+ DotUtil.dotify(cdg, GhostviewUtil.makeIRDecorator(ir), dotFile, psFile, dotExe);
+
+ return GVUtil.launchGV(psFile, gvExe);
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Validate that the command-line arguments obey the expected usage.
+ *
+ * Usage:
+ *
+ *
args[0] : "-appJar"
+ *
args[1] : something like "c:/temp/testdata/java_cup.jar"
+ *
args[2] : "-sig"
+ *
args[3] : a method signature like "java_cup.lexer.advance()V"
g = pruneSDG(sdg);
+ DotUtil.dotify(g, makeNodeDecorator(), GVTypeHierarchy.DOT_FILE, psFile, dotExe);
+
+ String gvExe = p.getProperty(WalaExamplesProperties.GHOSTVIEW_EXE);
+ return GVUtil.launchGV(psFile, gvExe);
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ private static Graph pruneSDG(SDG sdg) {
+ Filter f = new Filter() {
+ public boolean accepts(Object o) {
+ Statement s = (Statement)o;
+ if (s.getNode().equals(s.getNode().getCallGraph().getFakeRootNode())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ };
+ return GraphSlicer.prune(sdg, f);
+ }
+
+ private static NodeDecorator makeNodeDecorator() {
+ return new NodeDecorator() {
+ public String getLabel(Object o) throws WalaException {
+ Statement s = (Statement) o;
+ switch (s.getKind()) {
+ case HEAP_PARAM_CALLEE:
+ case HEAP_PARAM_CALLER:
+ case HEAP_RET_CALLEE:
+ case HEAP_RET_CALLER:
+ HeapStatement h =(HeapStatement)s;
+ return s.getKind() + "\\n" + h.getNode() + "\\n" + h.getLocation();
+ case EXC_RET_CALLEE:
+ case EXC_RET_CALLER:
+ case NORMAL:
+ case NORMAL_RET_CALLEE:
+ case NORMAL_RET_CALLER:
+ case PARAM_CALLEE:
+ case PARAM_CALLER:
+ case PHI:
+ default:
+ return s.toString();
+ }
+ }
+
+ };
+ }
+
+ /**
+ * Validate that the command-line arguments obey the expected usage.
+ *
+ * Usage:
+ *
+ *
args[0] : "-appJar"
+ *
args[1] : something like "c:/temp/testdata/java_cup.jar"
+ *
args[2] : "-mainClass"
+ *
args[3] : something like "Lslice/TestRecursion"
+ *
+ * @throws UnsupportedOperationException
+ * if command-line is malformed.
+ */
+ static void validateCommandLine(Properties p) {
+ if (p.get("appJar") == null) {
+ throw new UnsupportedOperationException("expected command-line to include -appJar");
+ }
+ if (p.get("mainClass") == null) {
+ throw new UnsupportedOperationException("expected command-line to include -appJar");
+ }
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVSlice.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVSlice.java
new file mode 100644
index 000000000..bfb231727
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVSlice.java
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Properties;
+
+import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
+import com.ibm.wala.core.tests.slicer.SlicerTest;
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.examples.properties.WalaExamplesProperties;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.slicer.HeapStatement;
+import com.ibm.wala.ipa.slicer.NormalStatement;
+import com.ibm.wala.ipa.slicer.ParamStatement;
+import com.ibm.wala.ipa.slicer.SDG;
+import com.ibm.wala.ipa.slicer.Slicer;
+import com.ibm.wala.ipa.slicer.Statement;
+import com.ibm.wala.ipa.slicer.ParamStatement.CallStatementCarrier;
+import com.ibm.wala.ipa.slicer.ParamStatement.ValueNumberCarrier;
+import com.ibm.wala.ipa.slicer.Slicer.ControlDependenceOptions;
+import com.ibm.wala.ipa.slicer.Slicer.DataDependenceOptions;
+import com.ibm.wala.ipa.slicer.Statement.Kind;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.ssa.SSAInstruction;
+import com.ibm.wala.ssa.SSAInvokeInstruction;
+import com.ibm.wala.util.collections.Filter;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.GraphIntegrity;
+import com.ibm.wala.util.graph.GraphSlicer;
+import com.ibm.wala.util.graph.NodeDecorator;
+import com.ibm.wala.util.graph.GraphIntegrity.UnsoundGraphException;
+import com.ibm.wala.util.io.CommandLine;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.DotUtil;
+import com.ibm.wala.viz.GVUtil;
+
+/**
+ *
+ * This simple example WALA application builds an SDG and fires off ghostview to
+ * viz a DOT representation of a slice in the SDG
+ *
+ * @author sfink
+ */
+public class GVSlice {
+
+ private final static String PS_FILE = "slice.ps";
+
+ /**
+ * Usage: GVSDG -appJar [jar file name] -mainclass [main class] -src [method
+ * name]
+ *
+ * The "jar file name" should be something like
+ * "c:/temp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ run(args);
+ }
+
+ /**
+ */
+ public static Process run(String[] args) {
+ Properties p = CommandLine.parse(args);
+ validateCommandLine(p);
+ return run(p.getProperty("appJar"), p.getProperty("mainClass"), p.getProperty("srcCaller"), p.getProperty("srcCallee"),
+ goBackward(p), GVSDG.getDataDependenceOptions(p), GVSDG.getControlDependenceOptions(p));
+ }
+
+ private static boolean goBackward(Properties p) {
+ return !p.getProperty("dir","backward").equals("forward");
+ }
+
+ /**
+ */
+ public static Process run(String appJar, String mainClass, String srcCaller, String srcCallee, boolean goBackward, DataDependenceOptions dOptions,
+ ControlDependenceOptions cOptions) {
+ try {
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(appJar);
+
+ // generate a WALA-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+ SDG sdg = new SDG(cg, builder.getPointerAnalysis(), dOptions, cOptions);
+
+ CGNode main = SlicerTest.findMethod(cg, srcCaller);
+ Statement s = SlicerTest.findCallTo(main, srcCallee);
+ System.err.println("Statement: " + s);
+ Collection slice = null;
+ if (goBackward) {
+ slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), dOptions, cOptions);
+ } else {
+ // for forward slices ... we actually slice from the return value of calls.
+ s = getReturnStatementForCall(s);
+ slice = Slicer.computeForwardSlice(s, cg, builder.getPointerAnalysis(), dOptions, cOptions);
+ }
+ SlicerTest.dumpSlice(slice);
+
+ Graph g = pruneSDG(sdg, slice);
+ try {
+ GraphIntegrity.check(g);
+ } catch (UnsoundGraphException e1) {
+ e1.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ Assertions.productionAssertion(g.getNumberOfNodes() == slice.size(), "panic " + g.getNumberOfNodes() + " " + slice.size());
+
+ Properties p = null;
+ try {
+ p = WalaExamplesProperties.loadProperties();
+ p.putAll(WalaProperties.loadProperties());
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String psFile = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + PS_FILE;
+
+ String dotExe = p.getProperty(WalaExamplesProperties.DOT_EXE);
+
+ DotUtil.dotify(g, makeNodeDecorator(), GVTypeHierarchy.DOT_FILE, psFile, dotExe);
+
+ String gvExe = p.getProperty(WalaExamplesProperties.GHOSTVIEW_EXE);
+ return GVUtil.launchGV(psFile, gvExe);
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * If s is a call statement, return the statement representing the normal return from s
+ */
+ public static Statement getReturnStatementForCall(Statement s) {
+ if (s.getKind() == Kind.NORMAL) {
+ SSAInstruction st = ((NormalStatement)s).getInstruction();
+ if (st instanceof SSAInvokeInstruction) {
+ return new ParamStatement.NormalReturnCaller(s.getNode(),(SSAInvokeInstruction)st);
+ } else {
+ return s;
+ }
+ } else {
+ return s;
+ }
+ }
+
+ public static Graph pruneSDG(SDG sdg, final Collection slice) {
+ Filter f = new Filter() {
+ public boolean accepts(Object o) {
+ return slice.contains(o);
+ }
+ };
+ return GraphSlicer.prune(sdg, f);
+ }
+
+ public static NodeDecorator makeNodeDecorator() {
+ return new NodeDecorator() {
+ public String getLabel(Object o) throws WalaException {
+ Statement s = (Statement) o;
+ switch (s.getKind()) {
+ case HEAP_PARAM_CALLEE:
+ case HEAP_PARAM_CALLER:
+ case HEAP_RET_CALLEE:
+ case HEAP_RET_CALLER:
+ HeapStatement h = (HeapStatement) s;
+ return s.getKind() + "\\n" + h.getNode() + "\\n" + h.getLocation();
+ case NORMAL:
+ NormalStatement n = (NormalStatement) s;
+ return n.getNode() + "\\n" + n.getInstruction();
+ case PARAM_CALLEE:
+ case PARAM_CALLER:
+ if (s instanceof ValueNumberCarrier) {
+ ValueNumberCarrier vc = (ValueNumberCarrier) s;
+ if (s instanceof CallStatementCarrier) {
+ CallStatementCarrier cc = (CallStatementCarrier) s;
+ return s.getKind() + "\\n" + s.getNode() + "\\n" + cc.getCall() + "\\nv" + vc.getValueNumber();
+ } else {
+ return s.getKind() + "\\n" + s.getNode() + "\\nv" + vc.getValueNumber();
+ }
+ } else {
+ if (s instanceof CallStatementCarrier) {
+ CallStatementCarrier cc = (CallStatementCarrier) s;
+ return s.getKind() + "\\n" + s.getNode() + "\\n" + cc.getCall();
+ } else {
+ return s.toString();
+ }
+ }
+ case EXC_RET_CALLEE:
+ case EXC_RET_CALLER:
+ case NORMAL_RET_CALLEE:
+ case NORMAL_RET_CALLER:
+ case PHI:
+ default:
+ return s.toString();
+ }
+ }
+
+ };
+ }
+
+ /**
+ * Validate that the command-line arguments obey the expected usage.
+ *
+ * Usage:
+ *
+ *
args[0] : "-appJar"
+ *
args[1] : something like "c:/temp/testdata/java_cup.jar"
+ *
args[2] : "-mainClass"
+ *
args[3] : something like "Lslice/TestRecursion" *
+ *
args[4] : "-srcCallee"
+ *
args[5] : something like "print" *
+ *
args[4] : "-srcCaller"
+ *
args[5] : something like "main"
+ *
+ * @throws UnsupportedOperationException
+ * if command-line is malformed.
+ */
+ static void validateCommandLine(Properties p) {
+ if (p.get("appJar") == null) {
+ throw new UnsupportedOperationException("expected command-line to include -appJar");
+ }
+ if (p.get("mainClass") == null) {
+ throw new UnsupportedOperationException("expected command-line to include -mainClass");
+ }
+ if (p.get("srcCallee") == null) {
+ throw new UnsupportedOperationException("expected command-line to include -srcCallee");
+ }
+ if (p.get("srcCaller") == null) {
+ throw new UnsupportedOperationException("expected command-line to include -srcCaller");
+ }
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVTypeHierarchy.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVTypeHierarchy.java
new file mode 100644
index 000000000..7583f6330
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVTypeHierarchy.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.ibm.wala.ecore.java.EClassLoaderName;
+import com.ibm.wala.ecore.java.EJavaClass;
+import com.ibm.wala.ecore.java.ETypeHierarchy;
+import com.ibm.wala.emf.wrappers.EObjectGraphImpl;
+import com.ibm.wala.emf.wrappers.ETypeHierarchyWrapper;
+import com.ibm.wala.emf.wrappers.EUtil;
+import com.ibm.wala.examples.properties.WalaExamplesProperties;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.util.CollectionFilter;
+import com.ibm.wala.util.collections.Filter;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.GraphSlicer;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.DotUtil;
+import com.ibm.wala.viz.GVUtil;
+
+/**
+ *
+ * This simple example WALA application builds a TypeHierarchy and fires off
+ * ghostview to viz a DOT representation.
+ *
+ * @author sfink
+ */
+public class GVTypeHierarchy {
+
+ public final static String DOT_FILE = "temp.dt";
+
+ private final static String PS_FILE = "th.ps";
+
+ public static Properties p;
+
+ static {
+ try {
+ p = WalaProperties.loadProperties();
+ p.putAll(WalaExamplesProperties.loadProperties());
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+
+ }
+
+ public static void main(String[] args) {
+ run(args, false);
+ }
+
+ public static Process run(String[] args, boolean readFromFile) {
+ try {
+ ETypeHierarchy th = null;
+ if (readFromFile) {
+ th = readTypeHierarchy();
+ } else {
+ ExportTypeHierarchyToXML.validateCommandLine(args);
+ String classpath = args[ExportTypeHierarchyToXML.CLASSPATH_INDEX];
+ th = ExportTypeHierarchyToXML.buildTypeHierarchy(classpath, new WarningSet());
+ }
+
+ Graph g = typeHierarchy2Graph(th);
+
+ g = pruneForAppLoader(g);
+ String dotFile = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + DOT_FILE;
+ String psFile = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + PS_FILE;
+ String dotExe = p.getProperty(WalaExamplesProperties.DOT_EXE);
+ String gvExe = p.getProperty(WalaExamplesProperties.GHOSTVIEW_EXE);
+ DotUtil.dotify(g, null, dotFile, psFile, dotExe);
+ return GVUtil.launchGV(psFile, gvExe);
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.capa.core.EAnalysisEngine#processImpl()
+ */
+ public static Graph typeHierarchy2Graph(ETypeHierarchy et) throws WalaException {
+ ETypeHierarchyWrapper t = new ETypeHierarchyWrapper(et);
+ EObjectGraphImpl dg = new EObjectGraphImpl();
+ for (Iterator extends EObject> it = t.getClasses().iterateNodes(); it.hasNext();) {
+ dg.addNode(it.next());
+ }
+ for (Iterator extends EObject> it = t.getInterfaces().iterateNodes(); it.hasNext();) {
+ dg.addNode(it.next());
+ }
+ for (Iterator extends EObject> it = t.getClasses().iterateNodes(); it.hasNext();) {
+ EJavaClass x = (EJavaClass) it.next();
+ for (Iterator extends EObject> it2 = t.getClasses().getSuccNodes(x); it2.hasNext();) {
+ dg.addEdge(x, it2.next());
+ }
+ for (Iterator extends EObject> it2 = t.getImplements(x).iterator(); it2.hasNext();) {
+ dg.addEdge(it2.next(), x);
+ }
+ }
+ for (Iterator extends EObject> it = t.getInterfaces().iterateNodes(); it.hasNext();) {
+ EJavaClass x = (EJavaClass) it.next();
+ for (Iterator extends EObject> it2 = t.getInterfaces().getSuccNodes(x); it2.hasNext();) {
+ dg.addEdge(x, it2.next());
+ }
+ }
+
+ return dg;
+ }
+
+ static Graph pruneForAppLoader(Graph g) throws WalaException {
+ Filter f = new Filter() {
+ public boolean accepts(Object o) {
+ if (o instanceof EJavaClass) {
+ EJavaClass klass = (EJavaClass) o;
+ return (klass.getLoader().equals(EClassLoaderName.APPLICATION_LITERAL));
+ } else {
+ return false;
+ }
+ }
+ };
+
+ return pruneGraph(g, f);
+ }
+
+ public static Graph pruneGraph(Graph g, Filter f) throws WalaException {
+
+ Collection slice = GraphSlicer.slice(g, f);
+ return GraphSlicer.prune(g, new CollectionFilter(slice));
+ }
+
+ static ETypeHierarchy readTypeHierarchy() throws WalaException {
+
+ List l = EUtil.readEObjects(ExportTypeHierarchyToXML.getFileName(), ExportTypeHierarchyToXML.class.getClassLoader());
+ return (ETypeHierarchy) l.get(0);
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVWalaIR.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVWalaIR.java
new file mode 100644
index 000000000..ee6be019d
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/GVWalaIR.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.io.File;
+import java.util.Properties;
+
+import com.ibm.wala.classLoader.IMethod;
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.examples.properties.WalaExamplesProperties;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.impl.Everywhere;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.ssa.IR;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.util.StringStuff;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.GhostviewUtil;
+
+/**
+ *
+ * This simple example application builds a WALA IR and fires off ghostview
+ * to viz a DOT representation.
+ *
+ * @author sfink
+ */
+public class GVWalaIR {
+
+ final public static boolean SANITIZE_CFG = false;
+
+ final public static String PS_FILE = "ir.ps";
+
+ /**
+ * Usage: GVWalaIR -appJar [jar file name] -sig [method signature] The "jar
+ * file name" should be something like "c:/temp/testdata/java_cup.jar" The
+ * signature should be something like "java_cup.lexer.advance()V"
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ run(args);
+ }
+
+ /**
+ * @param args
+ * -appJar [jar file name] -sig [method signature] The "jar file
+ * name" should be something like "c:/temp/testdata/java_cup.jar" The
+ * signature should be something like "java_cup.lexer.advance()V"
+ */
+ public static Process run(String[] args) {
+ validateCommandLine(args);
+ return run(args[1], args[3]);
+ }
+
+ /**
+ * @param appJar
+ * should be something like "c:/temp/testdata/java_cup.jar"
+ * @param methodSig
+ * should be something like "java_cup.lexer.advance()V"
+ */
+ public static Process run(String appJar, String methodSig) {
+ try {
+ if (SWTCallGraph.isDirectory(appJar)) {
+ appJar = SWTCallGraph.findJarFiles(new String[] { appJar });
+ }
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(appJar);
+
+ // generate a DOMO-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+ // invoke DOMO to build a DOMO class hierarchy object
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ MethodReference mr = StringStuff.makeMethodReference(methodSig);
+
+ IMethod m = cha.resolveMethod(mr);
+ if (m == null) {
+ Assertions.UNREACHABLE("could not resolve " + mr);
+ }
+ AnalysisOptions options = new AnalysisOptions();
+ options.getSSAOptions().setUsePiNodes(true);
+ IR ir = options.getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, cha, options.getSSAOptions(), new WarningSet());
+
+ if (ir == null) {
+ Assertions.UNREACHABLE("Null IR for " + m);
+ }
+
+ System.err.println(ir.toString());
+
+ Properties wp = null;
+ try {
+ wp = WalaProperties.loadProperties();
+ wp.putAll(WalaExamplesProperties.loadProperties());
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String psFile = wp.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + GVWalaIR.PS_FILE;
+ String dotFile = wp.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar
+ + GVTypeHierarchy.DOT_FILE;
+ String dotExe = wp.getProperty(WalaExamplesProperties.DOT_EXE);
+ String gvExe = wp.getProperty(WalaExamplesProperties.GHOSTVIEW_EXE);
+
+ return GhostviewUtil.ghostviewIR(cha, ir, SANITIZE_CFG, psFile, dotFile, dotExe, gvExe);
+
+ } catch (WalaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Validate that the command-line arguments obey the expected usage.
+ *
+ * Usage:
+ *
+ *
args[0] : "-appJar"
+ *
args[1] : something like "c:/temp/testdata/java_cup.jar"
+ *
args[2] : "-sig"
+ *
args[3] : a method signature like "java_cup.lexer.advance()V"
m = Environment.readEnv();
+
+ for (Iterator> it = m.entrySet().iterator(); it.hasNext();) {
+ System.out.println(it.next());
+ }
+ } catch (WalaException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java
new file mode 100644
index 000000000..45a1235a1
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.eclipse.jface.window.ApplicationWindow;
+
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.examples.properties.WalaExamplesProperties;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.CallGraphStats;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.util.collections.HashSetFactory;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.graph.GraphIntegrity;
+import com.ibm.wala.util.graph.InferGraphRootsImpl;
+import com.ibm.wala.util.io.CommandLine;
+import com.ibm.wala.util.io.FileUtil;
+import com.ibm.wala.util.perf.EngineTimings;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.SWTTreeViewer;
+import com.ibm.wala.viz.ViewIRAction;
+
+/**
+ *
+ * This application is a WALA client: it invokes an SWT TreeViewer to visualize
+ * a Call Graph
+ *
+ * @author sfink
+ */
+public class SWTCallGraph {
+
+ private final static boolean CHECK_GRAPH = false;
+
+ /**
+ * Usage: SWTCallGraph -appJar [jar file name]
+ *
+ * The "jar file name" should be something like
+ * "c:/temp/testdata/java_cup.jar"
+ *
+ * If it's a directory, then we'll try to find all jar files under that
+ * directory.
+ *
+ * @param args
+ * @throws WalaException
+ */
+ public static void main(String[] args) throws WalaException {
+ Properties p = CommandLine.parse(args);
+ GVCallGraph.validateCommandLine(p);
+ run(p);
+ }
+
+ /**
+ * @param p
+ * should contain at least the following properties:
+ *
+ *
appJar should be something like
+ * "c:/temp/testdata/java_cup.jar"
+ *
algorithm (optional) can be one of:
+ *
+ *
"ZERO_CFA" (default value)
+ *
"RTA"
+ *
+ *
+ *
+ * @throws WalaException
+ */
+ public static ApplicationWindow run(Properties p) throws WalaException {
+
+ try {
+ String appJar = p.getProperty("appJar");
+ if (isDirectory(appJar)) {
+ appJar = SWTCallGraph.findJarFiles(new String[] { appJar });
+ }
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(appJar);
+
+ String exclusionFile = p.getProperty("exclusions");
+ if (exclusionFile != null) {
+ escope.setExclusionFileName(exclusionFile);
+ }
+
+ // generate a DOMO-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+ // TODO: return the warning set (need a CAPA type)
+ // invoke DOMO to build a DOMO class hierarchy object
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha);
+ AnalysisOptions options = new AnalysisOptions(scope, entrypoints);
+
+ // //
+ // build the call graph
+ // //
+ com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cha, scope, warnings, null, null);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ System.out.println(CallGraphStats.getStats(cg));
+
+ if (CHECK_GRAPH) {
+ GraphIntegrity.check(cg);
+ }
+
+ Properties wp = null;
+ try {
+ wp = WalaProperties.loadProperties();
+ wp.putAll(WalaExamplesProperties.loadProperties());
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String psFile = wp.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + GVWalaIR.PS_FILE;
+ String dotFile = wp.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + GVTypeHierarchy.DOT_FILE;
+ String dotExe = wp.getProperty(WalaExamplesProperties.DOT_EXE);
+ String gvExe = wp.getProperty(WalaExamplesProperties.GHOSTVIEW_EXE);
+
+ // create and run the viewer
+ final SWTTreeViewer v = new SWTTreeViewer();
+ v.setGraphInput(cg);
+ v.setRootsInput(InferGraphRootsImpl.inferRoots(cg));
+ v.getPopUpActions().add(new ViewIRAction(v, cg, psFile, dotFile, dotExe, gvExe));
+ v.run();
+ return v.getApplicationWindow();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ } finally {
+ EngineTimings.report();
+ }
+ }
+
+ // private static CallGraphConstructionAlgorithm chooseAlgorithm(Properties p)
+ // throws CapaException {
+ // String alg = p.getProperty("algorithm", "ZERO_CFA");
+ // if (alg.equals("ZERO_CFA")) {
+ // return CallGraphConstructionAlgorithm.ZERO_CFA_LITERAL;
+ // } else if (alg.equals("RTA")) {
+ // return CallGraphConstructionAlgorithm.RTA_LITERAL;
+ // } else if (alg.equals("ZERO_ONE_CFA")) {
+ // return CallGraphConstructionAlgorithm.VANILLA_ZERO_ONE_CFA_LITERAL;
+ // } else {
+ // throw new CapaException("Unsupported algorithm: " + alg);
+ // }
+ // }
+
+ static boolean isDirectory(String appJar) {
+ return (new File(appJar).isDirectory());
+ }
+
+ static String findJarFiles(String[] directories) throws WalaException {
+ Collection result = HashSetFactory.make();
+ for (int i = 0; i < directories.length; i++) {
+ for (Iterator it = FileUtil.listFiles(directories[i], ".*\\.jar", true).iterator(); it.hasNext();) {
+ File f = (File) it.next();
+ result.add(f.getAbsolutePath());
+ }
+ }
+ return composeString(result);
+ }
+
+ /**
+ * @param s
+ * Collection
+ */
+ private static String composeString(Collection s) {
+ StringBuffer result = new StringBuffer();
+ Iterator it = s.iterator();
+ for (int i = 0; i < s.size() - 1; i++) {
+ result.append(it.next());
+ result.append(';');
+ }
+ if (it.hasNext()) {
+ result.append(it.next());
+ }
+ return result.toString();
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java
new file mode 100644
index 000000000..ad78d888b
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.util.Properties;
+
+import org.eclipse.jface.window.ApplicationWindow;
+
+import com.ibm.wala.analysis.pointers.BasicHeapGraph;
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.InferGraphRootsImpl;
+import com.ibm.wala.util.io.CommandLine;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.SWTTreeViewer;
+
+/**
+ *
+ * This application is a WALA client: it invokes an SWT TreeViewer to visualize
+ * a Points-To solution
+ *
+ * @author sfink
+ */
+public class SWTPointsTo {
+
+ /**
+ * Usage: SWTPointsTo -appJar [jar file name] The "jar file name" should be
+ * something like "c:/temp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ Properties p = CommandLine.parse(args);
+ GVCallGraph.validateCommandLine(p);
+ run(p.getProperty("appJar"));
+ }
+
+ /**
+ * @param appJar
+ * should be something like "c:/temp/testdata/java_cup.jar"
+ */
+ public static ApplicationWindow run(String appJar) {
+
+ try {
+ Graph g = buildPointsTo(appJar);
+
+ // create and run the viewer
+ final SWTTreeViewer v = new SWTTreeViewer();
+ v.setGraphInput(g);
+ v.setRootsInput(InferGraphRootsImpl.inferRoots(g));
+ v.run();
+ return v.getApplicationWindow();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static Graph buildPointsTo(String appJar) throws WalaException {
+ EJavaAnalysisScope escope = JavaScopeUtil.makeAnalysisScope(appJar);
+
+ // generate a DOMO-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+
+ // TODO: return the warning set (need a CAPA type)
+ // invoke DOMO to build a DOMO class hierarchy object
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha);
+ AnalysisOptions options = new AnalysisOptions(scope, entrypoints);
+
+ // //
+ // build the call graph
+ // //
+ com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cha, scope, warnings, null, null);
+ CallGraph cg = builder.makeCallGraph(options);
+ PointerAnalysis pointerAnalysis = builder.getPointerAnalysis();
+ return new BasicHeapGraph(pointerAnalysis,cg);
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTTypeHierarchy.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTTypeHierarchy.java
new file mode 100644
index 000000000..51b80d45c
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/SWTTypeHierarchy.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.drivers;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.window.ApplicationWindow;
+
+import com.ibm.wala.ecore.java.ETypeHierarchy;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.InferGraphRootsImpl;
+import com.ibm.wala.viz.SWTTreeViewer;
+
+/**
+ *
+ * This application is a WALA client: it invokes an SWT TreeViewer to visualize
+ * a TypeHierarchy in a precomputed file serialized on disk. So, you must run
+ * ExportTypeHierarchyToXML before running this, to compute the type hierarchy and
+ * serialize it to disk.
+ *
+ * @author sfink
+ */
+public class SWTTypeHierarchy {
+
+ /**
+ * Usage: SWTTreeViewerBasicPipeline
+ */
+ public static void main(String[] args) {
+ run();
+ }
+
+ public static ApplicationWindow run() {
+
+ try {
+ ETypeHierarchy th = GVTypeHierarchy.readTypeHierarchy();
+ if (th.getClasses().getNodes().getContents().size() <1) {
+ System.err.println("PANIC: th # classes=" + th.getClasses().getNodes().getContents().size());
+ System.exit(-1);
+ }
+
+ Graph g = GVTypeHierarchy.typeHierarchy2Graph(th);
+ g = GVTypeHierarchy.pruneForAppLoader(g);
+
+ if (g.getNumberOfNodes() == 0) {
+ System.err.println("ERROR: The type hierarchy in " + ExportTypeHierarchyToXML.getFileName() + " has no nodes from the Application loader");
+ System.exit(-1);
+ }
+
+ // create and run the viewer
+ final SWTTreeViewer v =new SWTTreeViewer();
+ v.setGraphInput(g);
+ Collection roots = InferGraphRootsImpl.inferRoots(g);
+ if (roots.size() < 1) {
+ System.err.println("PANIC: roots.size()=" + roots.size());
+ System.exit(-1);
+ }
+ v.setRootsInput(roots);
+ v.run();
+ return v.getApplicationWindow();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/properties/WalaExamplesProperties.java b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/properties/WalaExamplesProperties.java
new file mode 100644
index 000000000..d84770800
--- /dev/null
+++ b/com.ibm.wala.core.tests/com.ibm.wala.core.tests/src/com/ibm/wala/examples/properties/WalaExamplesProperties.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.properties;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Properties;
+
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.util.config.FileProvider;
+import com.ibm.wala.util.warnings.WalaException;
+
+public final class WalaExamplesProperties {
+
+ public static final String GHOSTVIEW_EXE = "ghostview_exe"; //$NON-NLS-1$
+
+ public static final String DOT_EXE = "dot_exe"; //$NON-NLS-1$
+
+ public final static String PROPERTY_FILENAME = "wala.examples.properties"; //$NON-NLS-1$
+
+ public static Properties loadProperties() throws WalaException {
+
+ try {
+ Properties result = WalaProperties.loadPropertiesFromFile(PROPERTY_FILENAME);
+
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new WalaException("Unable to set up wala examples properties ", e);
+ }
+ }
+
+ public static String getWalaCoreTestsHomeDirectory() throws WalaException {
+ final URL url = WalaExamplesProperties.class.getClassLoader().getResource(PROPERTY_FILENAME);
+ if (url == null) {
+ throw new WalaException("failed to find URL for capa.examples.properties");
+ }
+
+ return new File(FileProvider.filePathFromURL(url)).getParentFile().getParentFile().getAbsolutePath();
+ }
+
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/dat/GUIExclusions.xml b/com.ibm.wala.core.tests/dat/GUIExclusions.xml
new file mode 100644
index 000000000..26c02a0a9
--- /dev/null
+++ b/com.ibm.wala.core.tests/dat/GUIExclusions.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/com.ibm.wala.core.tests/dat/JLex.xml b/com.ibm.wala.core.tests/dat/JLex.xml
new file mode 100644
index 000000000..7e578b02b
--- /dev/null
+++ b/com.ibm.wala.core.tests/dat/JLex.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/dat/bcel.xml b/com.ibm.wala.core.tests/dat/bcel.xml
new file mode 100644
index 000000000..9201ec117
--- /dev/null
+++ b/com.ibm.wala.core.tests/dat/bcel.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/dat/hello.xml b/com.ibm.wala.core.tests/dat/hello.xml
new file mode 100644
index 000000000..5d6e0eccb
--- /dev/null
+++ b/com.ibm.wala.core.tests/dat/hello.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/dat/java_cup.xml b/com.ibm.wala.core.tests/dat/java_cup.xml
new file mode 100644
index 000000000..0935a098f
--- /dev/null
+++ b/com.ibm.wala.core.tests/dat/java_cup.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/dat/wala.examples.properties.sample b/com.ibm.wala.core.tests/dat/wala.examples.properties.sample
new file mode 100644
index 000000000..c48518f92
--- /dev/null
+++ b/com.ibm.wala.core.tests/dat/wala.examples.properties.sample
@@ -0,0 +1,30 @@
+###############################################################################
+# WALA Examples property file
+# This file defines the default settings for the WALA examples
+###############################################################################
+
+################# Mandatory settings without default value ####################
+
+################### Mandatory settings with default value ######################
+
+
+############################ Optional settings ################################
+
+### These are needed to run various individual examples
+
+
+##### Ghostview executable
+# Path to the ghostview executable
+# For instance, on a windows OS it's typically something like C:/Progra~1/Ghostgum/gsview/gsview32.exe
+# Default value: none
+# Info: Must be absolute path
+#####
+#ghostview_exe = Your location
+
+##### DOT executable
+# Path to the AT&T Graphview DOT executable
+# For instance, on a windows OS it's typically something like C:/Progra~1/ATT/Graphviz/bin/dot.exe
+# Default value: none
+# Info: Must be absolute path
+#####
+#dot_exe = Your location
diff --git a/com.ibm.wala.core.tests/dat/wala.testdata.xml b/com.ibm.wala.core.tests/dat/wala.testdata.xml
new file mode 100644
index 000000000..e579cb64e
--- /dev/null
+++ b/com.ibm.wala.core.tests/dat/wala.testdata.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/javaCompiler...args b/com.ibm.wala.core.tests/javaCompiler...args
new file mode 100644
index 000000000..c1f7e058e
--- /dev/null
+++ b/com.ibm.wala.core.tests/javaCompiler...args
@@ -0,0 +1,42 @@
+#ADAPTER#ACCESS#com.ibm.wala.core/bin/[+com/ibm/wala/analysis/pointers/*;+com/ibm/wala/analysis/reflection/*;+com/ibm/wala/analysis/stackMachine/*;+com/ibm/wala/analysis/typeInference/*;+com/ibm/wala/cfg/*;+com/ibm/wala/cfg/cdg/*;+com/ibm/wala/classLoader/*;+com/ibm/wala/client/*;+com/ibm/wala/client/impl/*;+com/ibm/wala/core/plugin/*;+com/ibm/wala/dataflow/IFDS/*;+com/ibm/wala/dataflow/graph/*;+com/ibm/wala/dataflow/ssa/*;+com/ibm/wala/emf/wrappers/*;+com/ibm/wala/escape/*;+com/ibm/wala/fixedpoint/impl/*;+com/ibm/wala/fixpoint/*;+com/ibm/wala/ipa/callgraph/*;+com/ibm/wala/ipa/callgraph/impl/*;+com/ibm/wala/ipa/callgraph/propagation/*;+com/ibm/wala/ipa/callgraph/propagation/cfa/*;+com/ibm/wala/ipa/callgraph/propagation/rta/*;+com/ibm/wala/ipa/cfg/*;+com/ibm/wala/ipa/cha/*;+com/ibm/wala/ipa/summaries/*;+com/ibm/wala/model/*;+com/ibm/wala/model/java/lang/*;+com/ibm/wala/properties/*;+com/ibm/wala/ssa/*;+com/ibm/wala/ssa/analysis/*;+com/ibm/wala/types/*;+com/ibm/wala/util/*;+com/ibm/wala/util/bytecode/*;+com/ibm/wala/util/collections/*;+com/ibm/wala/util/config/*;+com/ibm/wala/util/debug/*;+com/ibm/wala/util/graph/*;+com/ibm/wala/util/graph/impl/*;+com/ibm/wala/util/graph/traverse/*;+com/ibm/wala/util/heapTrace/*;+com/ibm/wala/util/intertionalization/*;+com/ibm/wala/util/intset/*;+com/ibm/wala/util/io/*;+com/ibm/wala/util/logging/*;+com/ibm/wala/util/math/*;+com/ibm/wala/util/perf/*;+com/ibm/wala/util/properties/*;+com/ibm/wala/util/properties/impl/*;+com/ibm/wala/util/warnings/*;+com/ibm/wala/viz/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.core/@dot[+com/ibm/wala/analysis/pointers/*;+com/ibm/wala/analysis/reflection/*;+com/ibm/wala/analysis/stackMachine/*;+com/ibm/wala/analysis/typeInference/*;+com/ibm/wala/cfg/*;+com/ibm/wala/cfg/cdg/*;+com/ibm/wala/classLoader/*;+com/ibm/wala/client/*;+com/ibm/wala/client/impl/*;+com/ibm/wala/core/plugin/*;+com/ibm/wala/dataflow/IFDS/*;+com/ibm/wala/dataflow/graph/*;+com/ibm/wala/dataflow/ssa/*;+com/ibm/wala/emf/wrappers/*;+com/ibm/wala/escape/*;+com/ibm/wala/fixedpoint/impl/*;+com/ibm/wala/fixpoint/*;+com/ibm/wala/ipa/callgraph/*;+com/ibm/wala/ipa/callgraph/impl/*;+com/ibm/wala/ipa/callgraph/propagation/*;+com/ibm/wala/ipa/callgraph/propagation/cfa/*;+com/ibm/wala/ipa/callgraph/propagation/rta/*;+com/ibm/wala/ipa/cfg/*;+com/ibm/wala/ipa/cha/*;+com/ibm/wala/ipa/summaries/*;+com/ibm/wala/model/*;+com/ibm/wala/model/java/lang/*;+com/ibm/wala/properties/*;+com/ibm/wala/ssa/*;+com/ibm/wala/ssa/analysis/*;+com/ibm/wala/types/*;+com/ibm/wala/util/*;+com/ibm/wala/util/bytecode/*;+com/ibm/wala/util/collections/*;+com/ibm/wala/util/config/*;+com/ibm/wala/util/debug/*;+com/ibm/wala/util/graph/*;+com/ibm/wala/util/graph/impl/*;+com/ibm/wala/util/graph/traverse/*;+com/ibm/wala/util/heapTrace/*;+com/ibm/wala/util/intertionalization/*;+com/ibm/wala/util/intset/*;+com/ibm/wala/util/io/*;+com/ibm/wala/util/logging/*;+com/ibm/wala/util/math/*;+com/ibm/wala/util/perf/*;+com/ibm/wala/util/properties/*;+com/ibm/wala/util/properties/impl/*;+com/ibm/wala/util/warnings/*;+com/ibm/wala/viz/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.emf/bin/[+com/ibm/wala/ecore/common/*;+com/ibm/wala/ecore/common/impl/*;+com/ibm/wala/ecore/common/util/*;+com/ibm/wala/ecore/graph/*;+com/ibm/wala/ecore/graph/impl/*;+com/ibm/wala/ecore/graph/util/*;+com/ibm/wala/ecore/j2ee/scope/*;+com/ibm/wala/ecore/j2ee/scope/impl/*;+com/ibm/wala/ecore/j2ee/scope/util/*;+com/ibm/wala/ecore/java/*;+com/ibm/wala/ecore/java/callGraph/*;+com/ibm/wala/ecore/java/callGraph/impl/*;+com/ibm/wala/ecore/java/callGraph/util/*;+com/ibm/wala/ecore/java/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/*;+com/ibm/wala/ecore/java/pointerAnalysis/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/util/*;+com/ibm/wala/ecore/java/scope/*;+com/ibm/wala/ecore/java/scope/impl/*;+com/ibm/wala/ecore/java/scope/util/*;+com/ibm/wala/ecore/java/util/*;+com/ibm/wala/ecore/perf/*;+com/ibm/wala/ecore/perf/impl/*;+com/ibm/wala/ecore/perf/util/*;+com/ibm/wala/ecore/regex/*;+com/ibm/wala/ecore/regex/impl/*;+com/ibm/wala/ecore/regex/util/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.emf/@dot[+com/ibm/wala/ecore/common/*;+com/ibm/wala/ecore/common/impl/*;+com/ibm/wala/ecore/common/util/*;+com/ibm/wala/ecore/graph/*;+com/ibm/wala/ecore/graph/impl/*;+com/ibm/wala/ecore/graph/util/*;+com/ibm/wala/ecore/j2ee/scope/*;+com/ibm/wala/ecore/j2ee/scope/impl/*;+com/ibm/wala/ecore/j2ee/scope/util/*;+com/ibm/wala/ecore/java/*;+com/ibm/wala/ecore/java/callGraph/*;+com/ibm/wala/ecore/java/callGraph/impl/*;+com/ibm/wala/ecore/java/callGraph/util/*;+com/ibm/wala/ecore/java/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/*;+com/ibm/wala/ecore/java/pointerAnalysis/impl/*;+com/ibm/wala/ecore/java/pointerAnalysis/util/*;+com/ibm/wala/ecore/java/scope/*;+com/ibm/wala/ecore/java/scope/impl/*;+com/ibm/wala/ecore/java/scope/util/*;+com/ibm/wala/ecore/java/util/*;+com/ibm/wala/ecore/perf/*;+com/ibm/wala/ecore/perf/impl/*;+com/ibm/wala/ecore/perf/util/*;+com/ibm/wala/ecore/regex/*;+com/ibm/wala/ecore/regex/impl/*;+com/ibm/wala/ecore/regex/util/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime_3.2.0.v20060603.jar[~org/eclipse/core/internal/preferences/legacy/*;~org/eclipse/core/internal/runtime/*;+org/eclipse/core/runtime/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.osgi_3.2.0.v20060601.jar[+org/eclipse/osgi/event/*;+org/eclipse/osgi/framework/console/*;+org/eclipse/osgi/framework/eventmgr/*;+org/eclipse/osgi/framework/log/*;+org/eclipse/osgi/service/datalocation/*;+org/eclipse/osgi/service/debug/*;+org/eclipse/osgi/service/environment/*;+org/eclipse/osgi/service/localization/*;+org/eclipse/osgi/service/pluginconversion/*;+org/eclipse/osgi/service/resolver/*;+org/eclipse/osgi/service/runnable/*;+org/eclipse/osgi/service/urlconversion/*;+org/eclipse/osgi/storagemanager/*;+org/eclipse/osgi/util/*;+org/osgi/framework/*;+org/osgi/service/condpermadmin/*;+org/osgi/service/packageadmin/*;+org/osgi/service/permissionadmin/*;+org/osgi/service/startlevel/*;+org/osgi/service/url/*;+org/osgi/util/tracker/*;~org/eclipse/core/runtime/adaptor/*;~org/eclipse/core/runtime/internal/adaptor/*;~org/eclipse/core/runtime/internal/stats/*;~org/eclipse/osgi/baseadaptor/*;~org/eclipse/osgi/baseadaptor/bundlefile/*;~org/eclipse/osgi/baseadaptor/hooks/*;~org/eclipse/osgi/baseadaptor/loader/*;~org/eclipse/osgi/framework/adaptor/*;~org/eclipse/osgi/framework/debug/*;~org/eclipse/osgi/framework/internal/core/*;~org/eclipse/osgi/framework/internal/protocol/*;~org/eclipse/osgi/framework/internal/protocol/bundleentry/*;~org/eclipse/osgi/framework/internal/protocol/bundleresource/*;~org/eclipse/osgi/framework/internal/protocol/reference/*;~org/eclipse/osgi/framework/internal/reliablefile/*;~org/eclipse/osgi/framework/launcher/*;~org/eclipse/osgi/framework/util/*;~org/eclipse/osgi/internal/baseadaptor/*;~org/eclipse/osgi/internal/module/*;~org/eclipse/osgi/internal/profile/*;~org/eclipse/osgi/internal/resolver/*;~org/eclipse/osgi/internal/verifier/*;~org/eclipse/osgi/internal/provisional/verifier/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar[~org/eclipse/core/internal/runtime/*;~org/eclipse/core/internal/boot/*;+org/eclipse/core/runtime/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.jobs_3.2.0.v20060603.jar[~org/eclipse/core/internal/jobs/*;+org/eclipse/core/runtime/jobs/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/runtime_registry_compatibility.jar[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.apache.xerces_2.8.0.v200606131651/resolver.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.apache.xerces_2.8.0.v200606131651/xercesImpl.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.apache.xerces_2.8.0.v200606131651/xml-apis.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar[~org/eclipse/core/internal/preferences/*;~org/eclipse/core/internal/preferences/exchange/*;+org/eclipse/core/runtime/preferences/*;+org/osgi/service/prefs/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/@dot[~org/eclipse/core/internal/registry/*;~org/eclipse/core/internal/registry/osgi/*;~org/eclipse/core/internal/registry/spi/*;+org/eclipse/core/runtime/*;+org/eclipse/core/runtime/dynamichelpers/*;+org/eclipse/core/runtime/spi/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.contenttype_3.2.0.v20060603.jar[~org/eclipse/core/internal/content/*;+org/eclipse/core/runtime/content/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.emf.ecore_2.2.0.v200606271057.jar[+org/eclipse/emf/ecore/*;+org/eclipse/emf/ecore/impl/*;+org/eclipse/emf/ecore/plugin/*;+org/eclipse/emf/ecore/resource/*;+org/eclipse/emf/ecore/resource/impl/*;+org/eclipse/emf/ecore/util/*;+org/eclipse/emf/ecore/xml/namespace/*;+org/eclipse/emf/ecore/xml/namespace/impl/*;+org/eclipse/emf/ecore/xml/namespace/util/*;+org/eclipse/emf/ecore/xml/type/*;+org/eclipse/emf/ecore/xml/type/impl/*;+org/eclipse/emf/ecore/xml/type/internal/*;+org/eclipse/emf/ecore/xml/type/util/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.emf.common_2.2.0.v200606271057.jar[+org/eclipse/emf/common/*;+org/eclipse/emf/common/archive/*;+org/eclipse/emf/common/command/*;+org/eclipse/emf/common/notify/*;+org/eclipse/emf/common/notify/impl/*;+org/eclipse/emf/common/util/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.resources_3.2.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.resources.win32_3.2.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.update.configurator_3.2.0.v20060605.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.variables_3.1.100.v20060605.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.expressions_3.2.0.v20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.filesystem_1.0.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060603.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.emf.ecore.xmi_2.2.0.v200606271057.jar[+org/eclipse/emf/ecore/xmi/*;+org/eclipse/emf/ecore/xmi/impl/*;+org/eclipse/emf/ecore/xmi/util/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.shrike/bin/[+com/ibm/wala/shrike/bench/*;+com/ibm/wala/shrike/copywriter/*;+com/ibm/wala/shrike/tools/*;+com/ibm/wala/shrikeBT/*;+com/ibm/wala/shrikeBT/analysis/*;+com/ibm/wala/shrikeBT/info/*;+com/ibm/wala/shrikeBT/shrikeCT/*;+com/ibm/wala/shrikeBT/shrikeCT/tools/*;+com/ibm/wala/shrikeBT/tools/*;+com/ibm/wala/shrikeCT/*;?**/*]
+#ADAPTER#ACCESS#com.ibm.wala.shrike/@dot[+com/ibm/wala/shrike/bench/*;+com/ibm/wala/shrike/copywriter/*;+com/ibm/wala/shrike/tools/*;+com/ibm/wala/shrikeBT/*;+com/ibm/wala/shrikeBT/analysis/*;+com/ibm/wala/shrikeBT/info/*;+com/ibm/wala/shrikeBT/shrikeCT/*;+com/ibm/wala/shrikeBT/shrikeCT/tools/*;+com/ibm/wala/shrikeBT/tools/*;+com/ibm/wala/shrikeCT/*;?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.jface_3.2.0.I20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.swt_3.2.0.v3232o.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232m.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.core.commands_3.2.0.I20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.jdt.core_3.2.0.v_671.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.text_3.2.0.v20060605-1400.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/com.ibm.icu_3.4.4.1.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.eclipse.team.core_3.2.0.I200606051140.jar[?**/*]
+#ADAPTER#ACCESS#eclipse/plugins/org.junit_3.8.1/junit.jar[+junit/awtui/*;+junit/extensions/*;+junit/framework/*;+junit/runner/*;+junit/swingui/*;+junit/swingui/icons/*;+junit/textui/*;?**/*]
diff --git a/com.ibm.wala.core.tests/launchers/ExportCallGraphToXML.launch b/com.ibm.wala.core.tests/launchers/ExportCallGraphToXML.launch
new file mode 100644
index 000000000..5abbcec37
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/ExportCallGraphToXML.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/ExportTypeHierarchyToXML.launch b/com.ibm.wala.core.tests/launchers/ExportTypeHierarchyToXML.launch
new file mode 100644
index 000000000..e272ce68a
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/ExportTypeHierarchyToXML.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/GVCallGraph.launch b/com.ibm.wala.core.tests/launchers/GVCallGraph.launch
new file mode 100644
index 000000000..0f56985de
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/GVCallGraph.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/GVControlDependenceGraph.launch b/com.ibm.wala.core.tests/launchers/GVControlDependenceGraph.launch
new file mode 100644
index 000000000..de8197e8d
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/GVControlDependenceGraph.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/GVSDG.launch b/com.ibm.wala.core.tests/launchers/GVSDG.launch
new file mode 100644
index 000000000..c361a3962
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/GVSDG.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/GVSlice.launch b/com.ibm.wala.core.tests/launchers/GVSlice.launch
new file mode 100644
index 000000000..d059c9c67
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/GVSlice.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/GVTypeHierarchy.launch b/com.ibm.wala.core.tests/launchers/GVTypeHierarchy.launch
new file mode 100644
index 000000000..860864583
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/GVTypeHierarchy.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/GVWalaIR.launch b/com.ibm.wala.core.tests/launchers/GVWalaIR.launch
new file mode 100644
index 000000000..1b04da957
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/GVWalaIR.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/GetEnv.launch b/com.ibm.wala.core.tests/launchers/GetEnv.launch
new file mode 100644
index 000000000..ea2696a61
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/GetEnv.launch
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/SWTCallGraph.launch b/com.ibm.wala.core.tests/launchers/SWTCallGraph.launch
new file mode 100644
index 000000000..daac4b660
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/SWTCallGraph.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/SWTPointsTo.launch b/com.ibm.wala.core.tests/launchers/SWTPointsTo.launch
new file mode 100644
index 000000000..5b6675f32
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/SWTPointsTo.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/SWTTypeHierarchy.launch b/com.ibm.wala.core.tests/launchers/SWTTypeHierarchy.launch
new file mode 100644
index 000000000..f2a2fd62b
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/SWTTypeHierarchy.launch
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/SimpleThreadEscapeAnalysis.launch b/com.ibm.wala.core.tests/launchers/SimpleThreadEscapeAnalysis.launch
new file mode 100644
index 000000000..08d5bb91c
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/SimpleThreadEscapeAnalysis.launch
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/SlicerTest.launch b/com.ibm.wala.core.tests/launchers/SlicerTest.launch
new file mode 100644
index 000000000..fb0df2962
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/SlicerTest.launch
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/wala.core short profile.launch b/com.ibm.wala.core.tests/launchers/wala.core short profile.launch
new file mode 100644
index 000000000..c1a77a6f1
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/wala.core short profile.launch
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/launchers/wala.core.launch b/com.ibm.wala.core.tests/launchers/wala.core.launch
new file mode 100644
index 000000000..4214916d0
--- /dev/null
+++ b/com.ibm.wala.core.tests/launchers/wala.core.launch
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java
new file mode 100644
index 000000000..e37aecd75
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/GraphDataflowTest.java
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.basic;
+
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.dataflow.graph.AbstractMeetOperator;
+import com.ibm.wala.dataflow.graph.BitVectorFilter;
+import com.ibm.wala.dataflow.graph.BitVectorFramework;
+import com.ibm.wala.dataflow.graph.BitVectorIdentity;
+import com.ibm.wala.dataflow.graph.BitVectorSolver;
+import com.ibm.wala.dataflow.graph.BitVectorUnion;
+import com.ibm.wala.dataflow.graph.BitVectorUnionConstant;
+import com.ibm.wala.dataflow.graph.DataflowSolver;
+import com.ibm.wala.dataflow.graph.ITransferFunctionProvider;
+import com.ibm.wala.fixedpoint.impl.UnaryOperator;
+import com.ibm.wala.fixpoint.BitVectorVariable;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
+import com.ibm.wala.util.intset.BitVector;
+import com.ibm.wala.util.intset.MutableMapping;
+import com.ibm.wala.util.intset.OrdinalSetMapping;
+
+/**
+ *
+ * Simple Regression test for a graph-based dataflow problem
+ *
+ * @author Donald P Pazel
+ * @author sfink
+ * @author Julian Dolby (dolby@us.ibm.com)
+ */
+public class GraphDataflowTest extends WalaTestCase {
+
+ public static final String nodeNames = "ABCDEFGH";
+ protected final static String[] nodes = new String[nodeNames.length()];
+
+ public GraphDataflowTest() {
+ super("GraphDataflowTest");
+ }
+
+ /**
+ * A simple test of the GraphBitVectorDataflow system
+ */
+ public void testSolverNodeEdge() {
+ Graph G = buildGraph();
+ String result = solveNodeEdge(G);
+ System.err.println(result);
+ if (!result.equals(expectedStringNodeEdge())) {
+ System.err.println("Uh oh.");
+ System.err.println(expectedStringNodeEdge());
+ }
+ assertEquals(expectedStringNodeEdge(), result);
+ }
+
+ public void testSolverNodeOnly() {
+ Graph G = buildGraph();
+ String result = solveNodeOnly(G);
+ System.err.println(result);
+ assertEquals(expectedStringNodeOnly(), result);
+ }
+
+ /**
+ * @return the expected dataflow result as a String
+ */
+ public static String expectedStringNodeOnly() {
+ StringBuffer result = new StringBuffer("------\n");
+ result.append("Node A(0) = { 0 }\n");
+ result.append("Node B(1) = { 0 1 }\n");
+ result.append("Node C(2) = { 0 1 2 }\n");
+ result.append("Node D(3) = { 0 1 3 }\n");
+ result.append("Node E(4) = { 0 1 2 3 4 }\n");
+ result.append("Node F(5) = { 0 1 2 3 4 5 }\n");
+ result.append("Node G(6) = { 6 }\n");
+ result.append("Node H(7) = { 7 }\n");
+ return result.toString();
+ }
+
+ public static String expectedStringNodeEdge() {
+ StringBuffer result = new StringBuffer("------\n");
+ result.append("Node A(0) = { 0 }\n");
+ result.append("Node B(1) = { 0 1 }\n");
+ result.append("Node C(2) = { 0 2 }\n");
+ result.append("Node D(3) = { 1 3 }\n");
+ result.append("Node E(4) = { 0 1 2 3 4 }\n");
+ result.append("Node F(5) = { 0 1 2 3 4 5 }\n");
+ result.append("Node G(6) = { 6 }\n");
+ result.append("Node H(7) = { 7 }\n");
+ return result.toString();
+ }
+
+ /**
+ * @return a graph with the expected structure
+ */
+ private static Graph buildGraph() {
+ Graph G = new SlowSparseNumberedGraph();
+ for (int i = 0; i < nodeNames.length(); i++) {
+ String n = nodeNames.substring(i, i + 1);
+ G.addNode(n);
+ nodes[i] = n;
+ }
+ G.addEdge(nodes[0], nodes[1]);
+ G.addEdge(nodes[1], nodes[2]);
+ G.addEdge(nodes[1], nodes[3]);
+ G.addEdge(nodes[2], nodes[4]);
+ G.addEdge(nodes[3], nodes[4]);
+ G.addEdge(nodes[4], nodes[5]);
+ return G;
+ }
+
+ /**
+ * Solve the dataflow system and return the result as a string
+ */
+ private String solveNodeOnly(Graph G) {
+ final OrdinalSetMapping values = new MutableMapping(nodes);
+ ITransferFunctionProvider functions = new ITransferFunctionProvider() {
+
+ public UnaryOperator getNodeTransferFunction(String node) {
+ return new BitVectorUnionConstant(values.getMappedIndex(node));
+ }
+
+ public boolean hasNodeTransferFunctions() {
+ return true;
+ }
+
+ public UnaryOperator getEdgeTransferFunction(String from, String to) {
+ Assertions.UNREACHABLE();
+ return null;
+ }
+
+ public boolean hasEdgeTransferFunctions() {
+ return false;
+ }
+
+ public AbstractMeetOperator getMeetOperator() {
+ return BitVectorUnion.instance();
+ }
+
+ };
+
+ BitVectorFramework F = new BitVectorFramework(G, functions, values);
+ DataflowSolver s = new BitVectorSolver(F);
+ s.solve();
+ return result2String(s);
+ }
+
+ private String solveNodeEdge(Graph G) {
+ final OrdinalSetMapping values = new MutableMapping(nodes);
+ ITransferFunctionProvider functions = new ITransferFunctionProvider() {
+
+ public UnaryOperator getNodeTransferFunction(String node) {
+ return new BitVectorUnionConstant(values.getMappedIndex(node));
+ }
+
+ public boolean hasNodeTransferFunctions() {
+ return true;
+ }
+
+ private BitVector zero() {
+ BitVector b = new BitVector();
+ b.set(0);
+ return b;
+ }
+
+ private BitVector one() {
+ BitVector b = new BitVector();
+ b.set(1);
+ return b;
+ }
+
+ public UnaryOperator getEdgeTransferFunction(String from, String to) {
+ if (from == nodes[1] && to == nodes[3])
+ return new BitVectorFilter(zero());
+ else if (from == nodes[1] && to == nodes[2])
+ return new BitVectorFilter(one());
+ else {
+ return BitVectorIdentity.instance();
+ }
+ }
+
+ public boolean hasEdgeTransferFunctions() {
+ return true;
+ }
+
+ public AbstractMeetOperator getMeetOperator() {
+ return BitVectorUnion.instance();
+ }
+
+ };
+
+ BitVectorFramework F = new BitVectorFramework(G, functions, values);
+ DataflowSolver s = new BitVectorSolver(F);
+ s.solve();
+ return result2String(s);
+ }
+
+ public static String result2String(DataflowSolver solver) {
+ StringBuffer result = new StringBuffer("------\n");
+ for (int i = 0; i < nodes.length; i++) {
+ String n = nodes[i];
+ BitVectorVariable varI = (BitVectorVariable) solver.getOut(n);
+ String s = varI.toString();
+ result.append("Node " + n + "(" + i + ") = " + s + "\n");
+ }
+ return result.toString();
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java
new file mode 100644
index 000000000..3dbe937d4
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/basic/PrimitivesTest.java
@@ -0,0 +1,585 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.basic;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.util.collections.BimodalMap;
+import com.ibm.wala.util.collections.Iterator2Collection;
+import com.ibm.wala.util.collections.SmallMap;
+import com.ibm.wala.util.graph.Dominators;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.NumberedGraph;
+import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
+import com.ibm.wala.util.graph.traverse.BFSPathFinder;
+import com.ibm.wala.util.graph.traverse.BoundedBFSIterator;
+import com.ibm.wala.util.intset.BasicNonNegativeIntRelation;
+import com.ibm.wala.util.intset.BimodalMutableIntSetFactory;
+import com.ibm.wala.util.intset.BitVector;
+import com.ibm.wala.util.intset.BitVectorIntSetFactory;
+import com.ibm.wala.util.intset.IBinaryNonNegativeIntRelation;
+import com.ibm.wala.util.intset.IntPair;
+import com.ibm.wala.util.intset.IntSet;
+import com.ibm.wala.util.intset.IntSetUtil;
+import com.ibm.wala.util.intset.IntegerUnionFind;
+import com.ibm.wala.util.intset.MutableIntSet;
+import com.ibm.wala.util.intset.MutableIntSetFactory;
+import com.ibm.wala.util.intset.MutableSharedBitVectorIntSetFactory;
+import com.ibm.wala.util.intset.MutableSparseIntSetFactory;
+import com.ibm.wala.util.intset.SparseIntSet;
+
+/**
+ *
+ * JUnit tests for some primitive operations.
+ *
+ * @author sfink
+ */
+public class PrimitivesTest extends WalaTestCase {
+
+ /**
+ *
+ */
+ public PrimitivesTest() {
+ super("PrimitivesTest");
+ }
+
+ /**
+ * @param arg0
+ */
+ public PrimitivesTest(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Test the MutableSparseIntSet implementation
+ */
+ private void doMutableIntSet(MutableIntSetFactory factory) {
+ MutableIntSet v = factory.parse("{9,17}");
+ MutableIntSet w = factory.make(new int[] {});
+ MutableIntSet x = factory.make(new int[] { 7, 4, 2, 4, 2, 2 });
+ MutableIntSet y = factory.make(new int[] { 7, 7, 7, 2, 7, 1 });
+ MutableIntSet z = factory.parse("{ 9 }");
+
+ System.out.println(w); // { }
+ System.out.println(x); // { 2 4 7 }
+ System.out.println(y); // { 1 2 7 }
+ System.out.println(z); // { 9 }
+
+ MutableIntSet temp = factory.makeCopy(x);
+ temp.intersectWith(y);
+ System.out.println(temp); // { 2 7 }
+ temp.copySet(x);
+ temp.addAll(y);
+ System.out.println(temp); // { 1 2 4 7 }
+ temp.copySet(x);
+ System.out.println(IntSetUtil.diff(x, y, factory)); // { 4 }
+ System.out.println(IntSetUtil.diff(v, z, factory)); // { 17 }
+ System.out.println(IntSetUtil.diff(z, v, factory)); // { }
+
+ // assertTrue(x.union(z).intersection(y.union(z)).equals(x.intersection(y).union(z)));
+ MutableIntSet temp1 = factory.makeCopy(x);
+ MutableIntSet temp2 = factory.makeCopy(x);
+ MutableIntSet tempY = factory.makeCopy(y);
+ temp1.addAll(z);
+ tempY.addAll(z);
+ temp1.intersectWith(tempY);
+ temp2.intersectWith(y);
+ temp2.addAll(z);
+ assertTrue(temp1.sameValue(temp2));
+
+ // assertTrue(x.union(z).diff(z).equals(x));
+ assertTrue(w.isEmpty());
+ assertTrue(IntSetUtil.diff(x, x, factory).isEmpty());
+ assertTrue(IntSetUtil.diff(z, v, factory).isEmpty());
+ assertTrue(IntSetUtil.diff(v, z, factory).sameValue(SparseIntSet.singleton(17)));
+ assertTrue(IntSetUtil.diff(z, v, factory).isEmpty());
+ assertTrue(z.isSubset(v));
+ temp = factory.make();
+ temp.add(4);
+ System.out.println(temp); // { 4 }
+ temp.add(7);
+ System.out.println(temp); // { 4 7 }
+ temp.add(2);
+ System.out.println(temp); // { 2 4 7 }
+ System.out.println(x); // { 2 4 7 }
+ assertTrue(temp.sameValue(x));
+
+ MutableIntSet a = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}");
+ System.out.println(a); // { 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33
+ // 35
+ // 37 39 41 43 45 47 49 51 53 55 57 59 }
+ assertTrue(a.sameValue(a));
+ IntSet i = a.intersection(temp);
+ assertTrue(i.sameValue(SparseIntSet.singleton(7)));
+ a.add(100);
+ assertTrue(a.sameValue(a));
+
+ MutableIntSet b = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,100}");
+ assertTrue(a.sameValue(b));
+ assertTrue(a.isSubset(b));
+
+ b = factory.makeCopy(a);
+ assertTrue(a.sameValue(b));
+ b.remove(1);
+ b.add(0);
+ assertTrue(!a.sameValue(b));
+
+ a = factory.parse("{1}");
+ assertFalse(a.isSubset(b));
+ b.remove(0);
+ assertFalse(a.isSubset(b));
+ a.remove(1);
+ assertTrue(a.isEmpty());
+ i = a.intersection(temp);
+ assertTrue(a.isEmpty());
+
+ temp2 = factory.make();
+ assertTrue(temp2.sameValue(a));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,51,53,55,57,59,61,63}");
+ b = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62}");
+ MutableIntSet c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ MutableIntSet d = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ MutableIntSet e = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34}");
+
+ assertTrue(e.isSubset(d));
+ e.addAll(d);
+ assertTrue(e.isSubset(d));
+ e.remove(12);
+ assertTrue(e.isSubset(d));
+ e.add(105);
+ assertFalse(e.isSubset(d));
+
+ assertFalse(b.isSubset(a));
+
+ b.add(53);
+ assertFalse(b.isSubset(a));
+
+ a.add(52);
+ a.remove(52);
+ assertFalse(b.isSubset(a));
+
+ c.add(55);
+ assertFalse(c.isSubset(b));
+
+ d.add(53);
+ assertTrue(d.isSubset(b));
+
+ d = factory.make();
+ d.copySet(c);
+ assertFalse(d.isSubset(b));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ b = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ assertFalse(a.sameValue(b));
+ b.add(50);
+ assertTrue(a.sameValue(b));
+ a.add(11);
+ b.add(11);
+ assertTrue(a.sameValue(b));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,50}");
+ b = factory.parse("{24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ a.addAll(b);
+ a.add(22);
+ assertTrue(a.sameValue(c));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20,50}");
+ b = factory.parse("{24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ b.addAll(factory.parse("{22}"));
+ a.addAll(b);
+ assertTrue(a.sameValue(c));
+
+ a = factory.parse("{2,4,6,8,10,12,14,16,18,20}");
+ b = factory.parse("{22,24,26,28,30,32,34,36,38,40,42,44,46,48}");
+ c = factory.parse("{2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50}");
+ c.remove(22);
+ a.addAll(b);
+ assertFalse(a.sameValue(c));
+
+ a = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}");
+ System.out.println(a); // { 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33
+ // 35
+ // 37 39 41 43 45 47 49 51 53 55 57 59 }
+ assertTrue(a.sameValue(a));
+ i = a.intersection(temp);
+ assertTrue(i.sameValue(SparseIntSet.singleton(7)));
+ a.add(100);
+ assertTrue(a.sameValue(a));
+
+ b = factory.parse("{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,100}");
+ assertTrue(a.sameValue(b));
+ assertTrue(a.isSubset(b));
+
+ b = factory.makeCopy(a);
+ assertTrue(a.sameValue(b));
+ b.remove(1);
+ b.add(0);
+ assertTrue(!a.sameValue(b));
+
+ a = factory.parse("{1}");
+ assertFalse(a.isSubset(b));
+ b.remove(0);
+ assertFalse(a.isSubset(b));
+ a.remove(1);
+ assertTrue(a.isEmpty());
+ i = a.intersection(temp);
+ assertTrue(a.isEmpty());
+
+ temp2 = factory.make();
+ assertTrue(temp2.sameValue(a));
+ }
+
+ /**
+ * Test the MutableSharedBitVectorIntSet implementation
+ */
+ public void testMutableSharedBitVectorIntSet() {
+ doMutableIntSet(new MutableSharedBitVectorIntSetFactory());
+ }
+
+ /**
+ * Test the MutableSparseIntSet implementation
+ */
+ public void testMutableSparseIntSet() {
+ doMutableIntSet(new MutableSparseIntSetFactory());
+ }
+
+ /**
+ * Test the BimodalMutableSparseIntSet implementation
+ */
+ public void testBimodalMutableSparseIntSet() {
+ doMutableIntSet(new BimodalMutableIntSetFactory());
+ }
+
+ /**
+ * Test the BitVectorIntSet implementation
+ */
+ public void testBitVectorIntSet() {
+ doMutableIntSet(new BitVectorIntSetFactory());
+ }
+
+ public void testSmallMap() {
+ SmallMap M = new SmallMap();
+ Integer I1 = new Integer(1);
+ Integer I2 = new Integer(2);
+ Integer I3 = new Integer(3);
+ M.put(I1, I1);
+ M.put(I2, I2);
+ M.put(I3, I3);
+
+ Integer I = (Integer) M.get(new Integer(2));
+ assertTrue(I != null);
+ assertTrue(I.equals(I2));
+
+ I = (Integer) M.get(new Integer(4));
+ assertTrue(I == null);
+
+ I = (Integer) M.put(new Integer(2), new Integer(3));
+ assertTrue(I.equals(I2));
+ I = (Integer) M.get(I2);
+ assertTrue(I.equals(I3));
+ }
+
+ public void testBimodalMap() {
+ Map M = new BimodalMap(3);
+ Integer I1 = new Integer(1);
+ Integer I2 = new Integer(2);
+ Integer I3 = new Integer(3);
+ Integer I4 = new Integer(4);
+ Integer I5 = new Integer(5);
+ Integer I6 = new Integer(6);
+ M.put(I1, I1);
+ M.put(I2, I2);
+ M.put(I3, I3);
+
+ Integer I = M.get(new Integer(2));
+ assertTrue(I != null);
+ assertTrue(I.equals(I2));
+
+ I = M.get(new Integer(4));
+ assertTrue(I == null);
+
+ I = M.put(new Integer(2), new Integer(3));
+ assertTrue(I.equals(I2));
+ I = M.get(I2);
+ assertTrue(I.equals(I3));
+
+ M.put(I4, I4);
+ M.put(I5, I5);
+ M.put(I6, I6);
+ I = M.get(new Integer(4));
+ assertTrue(I != null);
+ assertTrue(I.equals(I4));
+
+ I = M.get(new Integer(7));
+ assertTrue(I == null);
+
+ I = M.put(new Integer(2), new Integer(6));
+ assertTrue(I.equals(I3));
+ I = M.get(I2);
+ assertTrue(I.equals(I6));
+ }
+
+ public void testBFSPathFinder() {
+ NumberedGraph G = makeBFSTestGraph();
+
+ // path from 0 to 8
+ BFSPathFinder pf = new BFSPathFinder(G, G.getNode(0), G.getNode(8));
+ List p = pf.find();
+
+ // path should be 8, 6, 4, 2, 0
+ System.out.println("Path is " + p);
+ for (int i = 0; i < p.size(); i++) {
+ assertTrue((p.get(i)).intValue() == new int[] { 8, 6, 4, 2, 0 }[i]);
+ }
+ }
+
+ public void testBoundedBFS() {
+ NumberedGraph G = makeBFSTestGraph();
+
+ BoundedBFSIterator bfs = new BoundedBFSIterator(G, G.getNode(0), 0);
+ Collection c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 1);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 1);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 3);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 2);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 5);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 3);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 7);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 4);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 9);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 5);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 10);
+
+ bfs = new BoundedBFSIterator(G, G.getNode(0), 500);
+ c = new Iterator2Collection(bfs);
+ assertTrue(c.size() == 10);
+ }
+
+ private NumberedGraph makeBFSTestGraph() {
+ // test graph
+ NumberedGraph G = new SlowSparseNumberedGraph();
+
+ // add 10 nodes
+ Integer[] nodes = new Integer[10];
+ for (int i = 0; i < nodes.length; i++)
+ G.addNode(nodes[i] = new Integer(i));
+
+ // edges to i-1, i+1, i+2
+ for (int i = 0; i < nodes.length; i++) {
+ if (i > 0) {
+ G.addEdge(nodes[i], nodes[i - 1]);
+ }
+ if (i < nodes.length - 1) {
+ G.addEdge(nodes[i], nodes[i + 1]);
+ if (i < nodes.length - 2) {
+ G.addEdge(nodes[i], nodes[i + 2]);
+ }
+ }
+ }
+ return G;
+ }
+
+ public void testDominatorsA() {
+ // test graph
+ Graph G = new SlowSparseNumberedGraph();
+
+ // add nodes
+ Object[] nodes = new Object[11];
+ for (int i = 0; i < nodes.length; i++)
+ G.addNode(nodes[i] = new Integer(i));
+
+ // add edges
+ G.addEdge(nodes[10], nodes[0]);
+ G.addEdge(nodes[10], nodes[1]);
+ G.addEdge(nodes[0], nodes[2]);
+ G.addEdge(nodes[1], nodes[3]);
+ G.addEdge(nodes[2], nodes[5]);
+ G.addEdge(nodes[3], nodes[5]);
+ G.addEdge(nodes[4], nodes[2]);
+ G.addEdge(nodes[5], nodes[8]);
+ G.addEdge(nodes[6], nodes[3]);
+ G.addEdge(nodes[7], nodes[4]);
+ G.addEdge(nodes[8], nodes[7]);
+ G.addEdge(nodes[8], nodes[9]);
+ G.addEdge(nodes[9], nodes[6]);
+
+ // compute dominators
+ Dominators D = new Dominators(G, nodes[10]);
+
+ // assertions
+ int i = 0;
+ Object[] desired4 = new Object[] { nodes[4], nodes[7], nodes[8], nodes[5], nodes[10] };
+ for (Iterator d4 = D.dominators(nodes[4]); d4.hasNext();)
+ assertTrue(d4.next() == desired4[i++]);
+
+ int j = 0;
+ Object[] desired5 = new Object[] { nodes[8] };
+ for (Iterator extends Object> t4 = D.dominatorTree().getSuccNodes(nodes[5]); t4.hasNext();)
+ assertTrue(t4.next() == desired5[j++]);
+
+ assertTrue(D.dominatorTree().getSuccNodeCount(nodes[10]) == 5);
+ }
+
+ public void testBinaryIntegerRelation() {
+ byte[] impl = new byte[] { BasicNonNegativeIntRelation.SIMPLE, BasicNonNegativeIntRelation.TWO_LEVEL,
+ BasicNonNegativeIntRelation.SIMPLE };
+ IBinaryNonNegativeIntRelation R = new BasicNonNegativeIntRelation(impl, BasicNonNegativeIntRelation.TWO_LEVEL);
+ R.add(3, 5);
+ R.add(3, 7);
+ R.add(3, 9);
+ R.add(3, 11);
+ R.add(5, 1);
+ int count = 0;
+ for (Iterator it = R.iterator(); it.hasNext();) {
+ System.err.println(it.next());
+ count++;
+ }
+ assertTrue(count == 5);
+
+ IntSet x = R.getRelated(3);
+ assertTrue(x.size() == 4);
+
+ x = R.getRelated(5);
+ assertTrue(x.size() == 1);
+
+ R.remove(5, 1);
+ x = R.getRelated(5);
+ assertTrue(x == null);
+
+ R.add(2, 1);
+ R.add(2, 2);
+ R.remove(2, 1);
+ x = R.getRelated(2);
+ assertTrue(x.size() == 1);
+
+ R.removeAll(3);
+ x = R.getRelated(3);
+ assertTrue(x == null);
+
+ x = R.getRelated(0);
+ assertTrue(x == null);
+
+ for (int i = 0; i < 100; i++) {
+ R.add(1, i);
+ }
+ assertTrue(R.getRelated(1).size() == 100);
+ R.remove(1, 1);
+ assertTrue(R.getRelated(1).size() == 99);
+ }
+
+ public void testUnionFind() {
+ int SIZE = 10000;
+ IntegerUnionFind uf = new IntegerUnionFind(SIZE);
+ int count = countEquivalenceClasses(uf);
+ assertTrue("Got count " + count, count == SIZE);
+
+ uf.union(3, 7);
+ assertTrue(uf.find(3) == uf.find(7));
+ assertTrue("Got uf.find(3)=" + uf.find(3), uf.find(3) == 3 || uf.find(3) == 7);
+
+ uf.union(7, SIZE - 1);
+ assertTrue(uf.find(3) == uf.find(SIZE - 1));
+ assertTrue("Got uf.find(3)=" + uf.find(3), uf.find(3) == 3 || uf.find(3) == 7 || uf.find(3) == SIZE - 1);
+
+ for (int i = 0; i < SIZE - 1; i++) {
+ uf.union(i, i + 1);
+ }
+ count = countEquivalenceClasses(uf);
+ assertTrue("Got count " + count, count == 1);
+
+ uf = new IntegerUnionFind(SIZE);
+ for (int i = 0; i < SIZE; i++) {
+ if ((i % 2) == 0) {
+ uf.union(i, 0);
+ } else {
+ uf.union(i, 1);
+ }
+ }
+ count = countEquivalenceClasses(uf);
+ assertTrue("Got count " + count, count == 2);
+ }
+
+ private int countEquivalenceClasses(IntegerUnionFind uf) {
+ HashSet s = new HashSet();
+ for (int i = 0; i < uf.size(); i++) {
+ s.add(new Integer(uf.find(i)));
+ }
+ return s.size();
+ }
+
+ public void testBitVectors() {
+ BitVector bv = new BitVector();
+
+ // does the following not automatically scale the bitvector to
+ // a reasonable size?
+ bv.set(55);
+
+ assertTrue(bv.max() == 55);
+ assertTrue(bv.get(55));
+
+ bv.set(59);
+ assertTrue(bv.max() == 59);
+ assertTrue(bv.get(55));
+ assertTrue(bv.get(59));
+
+ {
+ boolean[] gets = new boolean[] { false, true, true };
+ int[] bits = new int[] { 0, 55, 59 };
+ for (int i = 0, j = 0; i != -1; i = bv.nextSetBit(i + 1), j++) {
+ assertTrue(i == bits[j]);
+ assertTrue(bv.get(i) == gets[j]);
+ }
+ }
+
+ bv.set(77);
+
+ assertTrue(bv.max() == 77);
+ {
+ boolean[] gets = new boolean[] { false, true, true, true };
+ int[] bits = new int[] { 0, 55, 59, 77 };
+ for (int i = 0, j = 0; i != -1; i = bv.nextSetBit(i + 1), j++) {
+ assertTrue(i == bits[j]);
+ assertTrue(bv.get(i) == gets[j]);
+ }
+ }
+
+ bv.set(3);
+ assertTrue(bv.max() == 77);
+ {
+ boolean[] gets = new boolean[] { false, true, true, true, true };
+ int[] bits = new int[] { 0, 3, 55, 59, 77 };
+ for (int i = 0, j = 0; i != -1; i = bv.nextSetBit(i + 1), j++) {
+ assertTrue(i == bits[j]);
+ assertTrue(bv.get(i) == gets[j]);
+ }
+ }
+
+ System.out.println(bv);
+ }
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java
new file mode 100644
index 000000000..8fe18a260
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java
@@ -0,0 +1,567 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.callGraph;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.ibm.wala.cfg.CFGCache;
+import com.ibm.wala.cfg.IBasicBlock;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ecore.java.ECallSite;
+import com.ibm.wala.ecore.java.EJavaMethod;
+import com.ibm.wala.ecore.java.impl.JavaPackageImpl;
+import com.ibm.wala.emf.wrappers.ECallGraphWrapper;
+import com.ibm.wala.emf.wrappers.EMFBridge;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.CallGraphStats;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.AllApplicationEntrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.cfg.BasicBlockInContext;
+import com.ibm.wala.ipa.cfg.InterproceduralCFG;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.util.collections.HashSetFactory;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.graph.Graph;
+import com.ibm.wala.util.graph.GraphIntegrity;
+import com.ibm.wala.util.graph.GraphIntegrity.UnsoundGraphException;
+import com.ibm.wala.util.graph.traverse.DFS;
+import com.ibm.wala.util.warnings.CallGraphWarnings;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ *
+ * Tests for Call Graph construction
+ *
+ * @author sfink
+ */
+
+public class CallGraphTest extends WalaTestCase {
+
+ static {
+ JavaPackageImpl.init();
+ }
+
+ private static final String[] IGNORE_STRINGS = { "finalize", "java.lang.ThreadLocal", "java.lang.ref.Reference.get()" };
+
+ public static void main(String[] args) {
+ justThisTest(CallGraphTest.class);
+ }
+
+ /**
+ * Constructor for SpecJTest.
+ *
+ * @param arg0
+ */
+ public CallGraphTest(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * public void testOpenccg() { AnalysisScope scope =
+ * CallGraphTestUtil.makeJ2SEAnalysisScope(Config.OPENCCG); WarningSet
+ * warnings = new WarningSet(); ClassHierarchy cha =
+ * ClassHierarchy.buildClassHierarchy(scope, warnings); Entrypoints
+ * entrypoints =
+ * com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
+ * Config.OPENCCG_CROSS_VALIDATE_REALIZER); AnalysisOptions options =
+ * CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+ *
+ * Trace.println("OPENCCG Cross Validate Realizer set up warnings:\n");
+ * Trace.print(warnings.toString());
+ *
+ * doCallGraphs(options, cha, scope, null, useShortProfile(), false); }
+ *
+ * public void testKaba() { AnalysisScope scope =
+ * CallGraphTestUtil.makeJ2SEAnalysisScope(Config.KABA); WarningSet warnings =
+ * new WarningSet(); ClassHierarchy cha =
+ * ClassHierarchy.buildClassHierarchy(scope, warnings); Entrypoints
+ * entrypoints =
+ * com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
+ * Config.KABA_MAIN); AnalysisOptions options =
+ * CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+ *
+ * Trace.println("kaba verifier set up warnings:\n");
+ * Trace.print(warnings.toString());
+ *
+ * doCallGraphs(options, cha, scope, null, useShortProfile(), false); }
+ *
+ * public void testAntlr() { AnalysisScope scope =
+ * CallGraphTestUtil.makeJ2SEAnalysisScope(Config.ANTLR); WarningSet warnings =
+ * new WarningSet(); ClassHierarchy cha =
+ * ClassHierarchy.buildClassHierarchy(scope, warnings); Entrypoints
+ * entrypoints =
+ * com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
+ * Config.ANTLR_MAIN); AnalysisOptions options =
+ * CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+ *
+ * Trace.println("ANTLR verifier set up warnings:\n");
+ * Trace.print(warnings.toString());
+ *
+ * doCallGraphs(options, cha, scope, null, useShortProfile(), false); }
+ */
+
+ public void testBcelVerifier() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.BCEL);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util
+ .makeMainEntrypoints(scope, cha, TestConstants.BCEL_VERIFIER_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("bcel verifier set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ doCallGraphs(options, cha, scope, null, useShortProfile(), false);
+ }
+
+ public void testJava_cup() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.JAVA_CUP);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.JAVA_CUP_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("java_cup set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ doCallGraphs(options, cha, scope, null, useShortProfile(), false);
+ }
+
+ public void testJLex() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.JLEX);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.JLEX_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("JLex set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ doCallGraphs(options, cha, scope, null, useShortProfile(), false);
+ }
+
+ public void testCornerCases() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = new AllApplicationEntrypoints(scope, cha);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("testCornerCases set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ warnings = doCallGraphs(options, cha, scope, null, useShortProfile(), false);
+
+ // we expect a warning or two about class Abstract1, which has no concrete
+ // subclasses
+ String ws = warnings.toString();
+ assertTrue("failed to report a warning about Abstract1", ws.indexOf("cornerCases/Abstract1") > -1);
+
+ // we do not expect a warning about class Abstract2, which has a concrete
+ // subclasses
+ assertTrue("reported a warning about Abstract2", ws.indexOf("cornerCases/Abstract2") == -1);
+ }
+
+ //
+ // public void testSPECjvm98() {
+ // AnalysisScope scope = CGTUtils.makeJ2SEAnalysisScope(Config.SPECJVM);
+ //
+ // // temporary hack because 1.5 libraries still cause grief
+ // if (scope.isJava15Libraries()) {
+ // scope = CGTUtils.makeJ2EEAnalysisScope(Config.SPECJVM);
+ // }
+ //
+ // WarningSet warnings = new WarningSet();
+ // ClassHierarchy cha = ClassHierarchy.buildClassHierarchy(scope, warnings);
+ // Entrypoints entrypoints =
+ // com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
+ // Config.SPECJVM_MAIN);
+ // AnalysisOptions options = CGTUtils.makeAnalysisOptions(scope, entrypoints);
+ //
+ // Trace.println("SPECjvm98 set up warnings:\n");
+ // Trace.print(warnings.toString());
+ //
+ // doCallGraphs(options, cha, scope, Config.SPECJVM_DCG, false, false);
+ // }
+ //
+ public void testHello() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.HELLO);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.HELLO_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("hello set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ doCallGraphs(options, cha, scope, null, false, false);
+ }
+
+ public void testRecursion() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.RECURSE_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("testRecursion set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ doCallGraphs(options, cha, scope, null, useShortProfile(), false);
+ }
+
+ public void testHelloAllEntrypoints() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.HELLO);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = new AllApplicationEntrypoints(scope, cha);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("hello all entrypoints set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ doCallGraphs(options, cha, scope, null, useShortProfile(), false);
+ }
+
+ //
+ // public void testSPECjvm98AllEntrypoints() {
+ // AnalysisScope scope = CGTUtils.makeJ2SEAnalysisScope(Config.SPECJVM);
+ // WarningSet warnings = new WarningSet();
+ // ClassHierarchy cha = ClassHierarchy.buildClassHierarchy(scope, warnings);
+ // Entrypoints entrypoints = new AllApplicationEntrypoints(scope, cha);
+ // AnalysisOptions options = CGTUtils.makeAnalysisOptions(scope, entrypoints);
+ //
+ // Trace.println("SPECjvm98 set up warnings:\n");
+ // Trace.print(warnings.toString());
+ //
+ // doCallGraphs(options, cha, scope, null, useShortProfile(), true);
+ // }
+
+ /**
+ * TODO: refactor this to avoid excessive code bloat.
+ */
+ public static WarningSet doCallGraphs(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, String dcgFile,
+ boolean stopAfterZeroCFA, boolean stopAfterZeroContainerCFA) {
+
+ // ///////////////
+ // // RTA /////
+ // ///////////////
+ WarningSet warnings = new WarningSet();
+ CallGraph cg = CallGraphTestUtil.buildRTA(options, cha, scope, warnings);
+ try {
+ GraphIntegrity.check(cg);
+ } catch (UnsoundGraphException e1) {
+ e1.printStackTrace();
+ assertTrue(e1.getMessage(), false);
+ }
+ Set rtaMethods = CallGraphStats.collectMethods(cg);
+ Trace.println("RTA methods reached: " + rtaMethods.size());
+ Trace.println(CallGraphStats.getStats(cg));
+ Trace.println("RTA warnings:\n");
+ warnings.addAll(CallGraphWarnings.getWarnings(cg));
+ Trace.print(warnings.toString(cg));
+
+ // ///////////////
+ // // 0-CFA /////
+ // ///////////////
+ warnings = new WarningSet();
+ cg = CallGraphTestUtil.buildZeroCFA(options, cha, scope, warnings);
+
+ // FIXME: annoying special cases caused by clone2assign mean using
+ // the rta graph for proper graph subset checking does not work.
+ // (note that all the other such checks do use proper graph subset)
+ Graph squashZero = checkCallGraph(warnings, cg, null, rtaMethods, "0-CFA");
+
+ // test Pretransitive 0-CFA
+ // not currently supported
+ // warnings = new WarningSet();
+ // options.setUsePreTransitiveSolver(true);
+ // CallGraph cgP = CallGraphTestUtil.buildZeroCFA(options, cha, scope,
+ // warnings);
+ // options.setUsePreTransitiveSolver(false);
+ // Graph squashPT = checkCallGraph(warnings, cgP, squashZero, null, "Pre-T
+ // 1");
+ // checkCallGraph(warnings, cg, squashPT, null, "Pre-T 2");
+
+ if (stopAfterZeroCFA) {
+ return warnings;
+ }
+ // ///////////////
+ // // 0-1-CFA ///
+ // ///////////////
+ warnings = new WarningSet();
+ cg = CallGraphTestUtil.buildZeroOneCFA(options, cha, scope, warnings);
+ Graph squashZeroOne = checkCallGraph(warnings, cg, squashZero, null, "0-1-CFA");
+
+ // ///////////////////////////////////////////////////
+ // // 0-CFA augmented to disambiguate containers ///
+ // ///////////////////////////////////////////////////
+ warnings = new WarningSet();
+ cg = CallGraphTestUtil.buildZeroContainerCFA(options, cha, scope, warnings);
+ Graph squashZeroContainer = checkCallGraph(warnings, cg, squashZero, null, "0-Container-CFA");
+
+ if (stopAfterZeroContainerCFA)
+ return warnings;
+
+ // ///////////////////////////////////////////////////
+ // // 0-1-CFA augmented to disambiguate containers ///
+ // ///////////////////////////////////////////////////
+ warnings = new WarningSet();
+ cg = CallGraphTestUtil.buildZeroOneContainerCFA(options, cha, scope, warnings);
+ checkCallGraph(warnings, cg, squashZeroContainer, null, "0-1-Container-CFA");
+ checkCallGraph(warnings, cg, squashZeroOne, null, "0-1-Container-CFA");
+
+ if (dcgFile != null) {
+ checkAgainstDCG(cg, dcgFile);
+ }
+
+ // test ICFG
+ checkICFG(cg, options.getCFGCache());
+ return warnings;
+ // /////////////
+ // // 1-CFA ///
+ // /////////////
+ // warnings = new WarningSet();
+ // cg = buildOneCFA();
+
+ }
+
+ /**
+ * Check properties of the InterproceduralCFG
+ *
+ * @param cg
+ */
+ private static void checkICFG(CallGraph cg, CFGCache cfgCache) {
+ InterproceduralCFG icfg = new InterproceduralCFG(cg, cfgCache, new WarningSet());
+
+ try {
+ GraphIntegrity.check(icfg);
+ } catch (UnsoundGraphException e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+
+ // perform a little icfg exercise
+ int count = 0;
+ for (Iterator extends BasicBlockInContext> it = icfg.iterateNodes(); it.hasNext();) {
+ IBasicBlock bb = (IBasicBlock) it.next();
+ if (icfg.hasCall((BasicBlockInContext) bb)) {
+ count++;
+ }
+ }
+ }
+
+ /**
+ * Check that cg is a superset of the dynamic call graph encoded in the
+ * dcgFile
+ *
+ * @param cg
+ * @param dcgFile
+ */
+ private static void checkAgainstDCG(CallGraph cg, String dcgFile) {
+
+ Set synthLeaves = getSyntheticLeaves(cg);
+
+ com.ibm.wala.emf.wrappers.ECallGraphWrapper subG = com.ibm.wala.emf.wrappers.ECallGraphWrapper.load(dcgFile,
+ CallGraphTest.class.getClassLoader());
+ com.ibm.wala.emf.wrappers.ECallGraphWrapper superG = EMFBridge.makeCallGraph(cg);
+
+ prune(subG, synthLeaves);
+ prune(superG, synthLeaves);
+
+ checkGraphSubset(superG, subG);
+ }
+
+ /**
+ * @param superG
+ * @param subG
+ */
+ public static void checkGraphSubset(ECallGraphWrapper superG, ECallGraphWrapper subG) {
+ Set nodeDiff = Util.setify(subG.iterateNodes());
+ nodeDiff.removeAll(Util.setify(superG.iterateNodes()));
+ Set toRemove = HashSetFactory.make();
+ for (Iterator it = nodeDiff.iterator(); it.hasNext();) {
+ EObject o = it.next();
+ if (o instanceof ECallSite) {
+ toRemove.add(o);
+ }
+ }
+ // a bogus hack: ignore some stuff in the dcg that we haven't
+ // cleaned out; TODO: figure out what's happening and delete this
+ outer: for (Iterator it = nodeDiff.iterator(); it.hasNext();) {
+ EObject o = it.next();
+ for (int i = 0; i < IGNORE_STRINGS.length; i++) {
+ if (o.toString().indexOf(IGNORE_STRINGS[i]) > -1) {
+ toRemove.add(o);
+ continue outer;
+ }
+ }
+ }
+ nodeDiff.removeAll(toRemove);
+
+ if (!nodeDiff.isEmpty()) {
+ Trace.println("supergraph: ");
+ Trace.println(superG.toString());
+ Trace.println("subgraph: ");
+ Trace.println(subG.toString());
+ Trace.println("nodeDiff: ");
+ for (Iterator it = nodeDiff.iterator(); it.hasNext();) {
+ Trace.println(it.next().toString());
+ }
+ Assertions.productionAssertion(nodeDiff.isEmpty(), "bad superset, see tracefile\n");
+ }
+ }
+
+ /**
+ *
+ *
remove all methods from G that correspond to synthetic methods
+ *
remove all nodes from G that are no longer reachable from the fake
+ * root.
+ *
+ *
+ * @param G
+ * an EMF format call graph
+ * @param synthetic
+ * a set of synthetic methods
+ */
+ private static void prune(ECallGraphWrapper G, Set synthetic) {
+ // compute synthetic nodes
+ Set toRemove = HashSetFactory.make();
+ for (Iterator it = synthetic.iterator(); it.hasNext();) {
+ CGNode n = it.next();
+ EJavaMethod node = EMFBridge.makeJavaMethod(n.getMethod().getReference());
+ if (node != null) {
+ toRemove.add(node);
+ }
+ }
+
+ removeNodes(G, toRemove);
+
+ // compute nodes reachable from the fake root
+ EJavaMethod fakeRoot = EMFBridge.makeFakeRootMethod();
+ Assertions._assert(fakeRoot != null);
+ Collection c = DFS.getReachableNodes(G, Collections.singleton(fakeRoot));
+
+ // remove other nodes
+ toRemove = HashSetFactory.make();
+ for (Iterator extends EObject> it = G.iterateNodes(); it.hasNext();) {
+ EObject n = it.next();
+ if (!c.contains(n)) {
+ toRemove.add(n);
+ }
+ }
+ removeNodes(G, toRemove);
+
+ // remove call site nodes with no targets (these won't appear in the dcg)
+ toRemove = HashSetFactory.make();
+ for (Iterator extends EObject> it = G.iterateNodes(); it.hasNext();) {
+ EObject n = it.next();
+ if (n instanceof ECallSite) {
+ if (G.getSuccNodeCount(n) == 0) {
+ toRemove.add(n);
+ }
+ }
+ }
+ removeNodes(G, toRemove);
+
+ }
+
+ /**
+ * @param G
+ * @param toRemove
+ */
+ private static void removeNodes(ECallGraphWrapper G, Set toRemove) {
+ // remove all these nodes
+ for (Iterator it = toRemove.iterator(); it.hasNext();) {
+ EObject n = it.next();
+ if (G.containsNode(n)) {
+ G.removeNodeAndEdges(n);
+ }
+ }
+ }
+
+ /**
+ * @param cg
+ * @return Set in cg that are synthetic and have no call sites
+ */
+ private static Set getSyntheticLeaves(CallGraph cg) {
+ HashSet result = HashSetFactory.make();
+ for (Iterator extends CGNode> it = cg.iterateNodes(); it.hasNext();) {
+ CGNode node = (CGNode) it.next();
+ if (!node.equals(cg.getFakeRootNode())) {
+ if (node.getMethod().isSynthetic()) {
+ if (!node.iterateSites().hasNext()) {
+ result.add(node);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Check consistency of a callgraph, and check that this call graph is a
+ * subset of a super-graph
+ *
+ * @param warnings
+ * object to track warnings
+ * @param cg
+ * @param superCG
+ * @param superMethods
+ * @param thisAlgorithm
+ * @return a squashed version of cg
+ */
+ private static Graph checkCallGraph(WarningSet warnings, CallGraph cg, Graph superCG,
+ Set superMethods, String thisAlgorithm) {
+ try {
+ GraphIntegrity.check(cg);
+ } catch (UnsoundGraphException e1) {
+ assertTrue(e1.getMessage(), false);
+ }
+ Set callGraphMethods = CallGraphStats.collectMethods(cg);
+ Trace.println(thisAlgorithm + " methods reached: " + callGraphMethods.size());
+ Trace.println(CallGraphStats.getStats(cg));
+ Trace.println(thisAlgorithm + " warnings:\n");
+ warnings.addAll(CallGraphWarnings.getWarnings(cg));
+ Trace.print(warnings.toString(cg));
+
+ Graph thisCG = com.ibm.wala.ipa.callgraph.impl.Util.squashCallGraph(thisAlgorithm, cg);
+
+ if (superCG != null) {
+ com.ibm.wala.ipa.callgraph.impl.Util.checkGraphSubset(superCG, thisCG);
+ } else {
+ if (!superMethods.containsAll(callGraphMethods)) {
+ Set temp = HashSetFactory.make();
+ temp.addAll(callGraphMethods);
+ temp.removeAll(superMethods);
+ Trace.printCollection("Violations", temp);
+ Assertions.UNREACHABLE();
+ }
+ }
+
+ return thisCG;
+ }
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java
new file mode 100644
index 000000000..2122fdb53
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.callGraph;
+
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.util.Stopwatch;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ *
+ * Utilities for call graph tests
+ *
+ * @author sfink
+ */
+public class CallGraphTestUtil {
+
+ private static final ClassLoader MY_CLASSLOADER = CallGraphTestUtil.class.getClassLoader();
+
+// private static final String reflectionFile = Config.SPECJVM_REFLECTION;
+
+ public static AnalysisOptions makeAnalysisOptions(AnalysisScope scope, Entrypoints entrypoints) {
+ AnalysisOptions options = new AnalysisOptions(scope, entrypoints);
+
+// InputStream rStream = CallGraphTestUtil.class.getClassLoader().getResourceAsStream(reflectionFile);
+// ReflectionSpecification R = new XMLReflectionReader(rStream, scope);
+// options.setReflectionSpec(R);
+ return options;
+ }
+
+
+ public static AnalysisScope makeJ2SEAnalysisScope(String scopeFile) {
+ return new EMFScopeWrapper(scopeFile, "J2SEClassHierarchyExclusions.xml", MY_CLASSLOADER);
+ }
+
+ public static AnalysisScope makeJ2SEAnalysisScope(String scopeFile, String exclusionsFile) {
+ return new EMFScopeWrapper(scopeFile, exclusionsFile, MY_CLASSLOADER);
+ }
+
+ public static CallGraph buildRTA(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings) {
+ Stopwatch S = new Stopwatch("build RTA graph");
+ S.start();
+
+ CallGraphBuilder builder = Util.makeRTABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ S.stop();
+ Trace.println(S.report());
+ return cg;
+ }
+
+ public static CallGraph buildZeroCFA(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings) {
+ Stopwatch S = new Stopwatch("build ZeroCFA graph");
+ S.start();
+
+ CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ S.stop();
+ Trace.println(S.report());
+ return cg;
+ }
+
+ public static CallGraph buildVanillaZeroOneCFA(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings) {
+ Stopwatch S = new Stopwatch("build Vanila 0-1-CFA graph");
+ S.start();
+
+ CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ S.stop();
+ Trace.println(S.report());
+ return cg;
+ }
+
+ public static CallGraph buildZeroOneCFA(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings) {
+ Stopwatch S = new Stopwatch("build 0-1-CFA graph");
+ S.start();
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ S.stop();
+ Trace.println(S.report());
+ return cg;
+ }
+
+ public static CallGraph buildZeroContainerCFA(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope,
+ WarningSet warnings) {
+ Stopwatch S = new Stopwatch("build 0-1-Container-CFA graph");
+ S.start();
+
+ CallGraphBuilder builder = Util.makeZeroContainerCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ S.stop();
+ Trace.println(S.report());
+ return cg;
+ }
+
+ public static CallGraph buildZeroOneContainerCFA(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope,
+ WarningSet warnings) {
+ Stopwatch S = new Stopwatch("build 0-1-Container-CFA graph");
+ S.start();
+
+ CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ S.stop();
+ Trace.println(S.report());
+ return cg;
+ }
+
+ public static CallGraph buildOneCFA(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings) {
+ Stopwatch S = new Stopwatch("build 1-CFA graph");
+ S.start();
+
+ CallGraphBuilder builder = Util.makeOneCFABuilder(options, cha, MY_CLASSLOADER, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ S.stop();
+ Trace.println(S.report());
+ return cg;
+ }
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ClassConstantTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ClassConstantTest.java
new file mode 100644
index 000000000..c6486d19a
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ClassConstantTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.callGraph;
+
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.types.ClassLoaderReference;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.types.TypeReference;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * Check handling of class constants (test for part of 1.5 support)
+ *
+ * @author Julian Dolby (dolby@us.ibm.com)
+ */
+public class ClassConstantTest extends WalaTestCase {
+
+ public void testClassConstants() throws ClassHierarchyException {
+
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Trace.println("setup warnings:");
+ Trace.println(warnings);
+
+ // make sure we have the test class
+ TypeReference mainClassRef = TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.CLASSCONSTANT_MAIN);
+ Assert.assertTrue(cha.lookupClass(mainClassRef) != null);
+
+ // make call graph
+ Entrypoints entrypoints = Util.makeMainEntrypoints(scope, cha, TestConstants.CLASSCONSTANT_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+ CallGraph cg = CallGraphTestUtil.buildZeroCFA(options, cha, scope, warnings);
+ Trace.println("\nCall graph:");
+ Trace.println(cg);
+
+ // make sure the main method is reached
+ MethodReference mainMethodRef = MethodReference.findOrCreate(mainClassRef, "main", "([Ljava/lang/String;)V");
+ Set mainMethodNodes = cg.getNodes(mainMethodRef);
+ Assert.assertFalse(mainMethodNodes.isEmpty());
+ CGNode mainMethodNode = (CGNode) mainMethodNodes.iterator().next();
+ Trace.println("main IR:");
+ Trace.println(cg.getInterpreter(mainMethodNode).getIR(mainMethodNode, warnings));
+
+ // Make sure call to hashCode is there (it uses the class constant)
+ TypeReference classRef = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Class");
+ MethodReference hashCodeRef = MethodReference.findOrCreate(classRef, "hashCode", "()I");
+ Set hashCodeNodes = cg.getNodes(hashCodeRef);
+ Assert.assertFalse(hashCodeNodes.isEmpty());
+
+ // make sure call to hashCode from main
+ Assert.assertTrue(cg.hasEdge(mainMethodNode, hashCodeNodes.iterator().next()));
+ }
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CloneTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CloneTest.java
new file mode 100644
index 000000000..0fddc56ae
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CloneTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.callGraph;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import com.ibm.wala.classLoader.CallSiteReference;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.AllApplicationEntrypoints;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.types.ClassLoaderReference;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.types.TypeReference;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * Check properties of a call to clone() in RTA
+ *
+ * @author Bruno Dufour
+ */
+public class CloneTest extends WalaTestCase {
+
+ public void testClone() throws ClassHierarchyException {
+
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = new AllApplicationEntrypoints(scope, cha);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraph cg = CallGraphTestUtil.buildRTA(options, cha, scope, warnings);
+
+ // Find node corresp. to java.text.MessageFormat.clone()
+ TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/text/MessageFormat");
+ MethodReference m = MethodReference.findOrCreate(t, "clone", "()Ljava/lang/Object;");
+ CGNode node = (CGNode) cg.getNodes(m).iterator().next();
+
+ // Check there's exactly one target for each super call in
+ // MessageFormat.clone()
+ for (Iterator i = node.iterateSites(); i.hasNext();) {
+ CallSiteReference site = (CallSiteReference) i.next();
+ if (site.isSpecial()) {
+ if (site.getDeclaredTarget().getDeclaringClass().equals(TypeReference.JavaLangObject)) {
+ Set targets = node.getPossibleTargets(site);
+ if (targets.size() != 1) {
+ System.err.println(targets.size() + " targets found for " + site);
+ for (Iterator k = targets.iterator(); k.hasNext();) {
+ System.err.println(" " + k.next());
+ }
+ fail("found " + targets.size() + " targets for " + site + " in " + node);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CompareCDGTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CompareCDGTest.java
new file mode 100644
index 000000000..4e247de64
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CompareCDGTest.java
@@ -0,0 +1,433 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.callGraph;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;
+
+import com.ibm.wala.cfg.IBasicBlock;
+import com.ibm.wala.cfg.cdg.BVControlDependenceGraph;
+import com.ibm.wala.cfg.cdg.ControlDependenceGraph;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.CallGraphStats;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.callgraph.propagation.cfa.CFABuilder;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.shrikeBT.IInstruction;
+import com.ibm.wala.ssa.IR;
+import com.ibm.wala.ssa.SSACFG;
+import com.ibm.wala.ssa.SSAInstruction;
+import com.ibm.wala.ssa.SSACFG.BasicBlock;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+import com.ibm.wala.viz.DotUtil;
+
+/**
+ * @author Mangala Gowri Nanda (minor hacks by Julian Dolby (dolby@us.ibm.com)
+ * to fit into domo junit test framework)
+ *
+ */
+public class CompareCDGTest extends WalaTestCase {
+
+ /**
+ * Usage: CompareCDGTest
+ *
+ * The "jar file name" should be something like "/tmp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ run(args);
+ }
+
+ /**
+ * Usage: args = "-appJar [jar file name] " The "jar file name" should be
+ * something like "/tmp/testdata/java_cup.jar"
+ *
+ * @param args
+ */
+ public static void run(String[] args) {
+ try {
+ run(buildCallGraphCommandLine(args[0]));
+ } catch (WalaException e) {
+ Trace.println(e);
+ }
+ }
+
+ public static void run(CallGraph g) {
+ compareCDGs(g);
+ Trace.println(CallGraphStats.getStats(g));
+ }
+
+ private static void compareCDGs(CallGraph g) {
+ long cdgTime = 0;
+ long bvTime = 0;
+ String dotExe = "dot";
+ for (Iterator extends CGNode> it = g.iterateNodes(); it.hasNext();) {
+ CGNode n = (CGNode) it.next();
+ MethodReference mref = n.getMethod().getReference();
+ Trace.println(mref.toString());
+ // if(app.equals("Application"))
+ {
+ IR ir = g.getInterpreter(n).getIR(n, new WarningSet());
+ if (ir != null) {
+ SSACFG cfg = ir.getControlFlowGraph();
+ long startTime = System.currentTimeMillis();
+ ControlDependenceGraph cdg = new ControlDependenceGraph(cfg, true);
+ long diff = System.currentTimeMillis() - startTime;
+ cdgTime += diff;
+
+ startTime = System.currentTimeMillis();
+ BVControlDependenceGraph bvcdg = new BVControlDependenceGraph(cfg);
+ diff = System.currentTimeMillis() - startTime;
+ bvTime += diff;
+
+ if (!compatible(cfg, cdg, bvcdg)) {
+ Trace.println("\tMISMATCH!!");
+ Vector vec = checkCFG(cfg, mref);
+ if (vec != null) {
+ Trace.println(mref + " has " + vec.size() + " blocks with no predecessors");
+ }
+
+ Trace.println("\nControlDependenceGraph output::");
+ dumpCDGInfo(cfg, cdg);
+ Trace.println("\nBitVector ControlDependenceGraph output::");
+ dumpCDGInfo(cfg, bvcdg);
+ Trace.println("");
+
+ String dotFile = "tmp.dot";
+ String psFile = mref.getName() + ".cdg.ps";
+ try {
+ DotUtil.dotify(cdg, null, dotFile, psFile, dotExe);
+ } catch (WalaException e) {
+ e.printStackTrace();
+ }
+
+ psFile = mref.getName() + ".bv.ps";
+ try {
+ DotUtil.dotify(bvcdg, null, dotFile, psFile, dotExe);
+ } catch (WalaException e) {
+ e.printStackTrace();
+ }
+
+ Assertions.UNREACHABLE();
+ }
+ }
+ }
+ }
+ Trace.println("Time to compute ControlDependenceGraph=" + cdgTime);
+ Trace.println("Time to compute BVControlDependenceGraph=" + bvTime);
+ }
+
+ private static boolean compatible(SSACFG cfg, ControlDependenceGraph cdg, BVControlDependenceGraph bv) {
+ boolean ret = true;
+ for (Iterator extends IBasicBlock> it = cfg.iterateNodes(); it.hasNext();) {
+ SSACFG.BasicBlock ibb = (SSACFG.BasicBlock) it.next();
+ int cCount = cdg.getPredNodeCount(ibb);
+ int bCount = bv.getPredNodeCount(ibb);
+ if (cCount != bCount) {
+ Trace.println("\tPred Count mismatch for " + ibb);
+ ret = false;
+ }
+ Iterator extends IBasicBlock> cdit = cdg.getPredNodes(ibb);
+ while (cdit.hasNext()) {
+ SSACFG.BasicBlock cdgbb = (SSACFG.BasicBlock) cdit.next();
+ if (!bv.hasEdge(cdgbb, ibb)) {
+ Trace.println("\tPred " + cdgbb + " mismatch for " + ibb);
+ ret = false;
+ }
+ Set clabels = cdg.getEdgeLabels(cdgbb, ibb);
+ Set extends Object> blabels = bv.getEdgeLabels(cdgbb, ibb);
+ Iterator labit = clabels.iterator();
+ while (labit.hasNext()) {
+ Object lab = labit.next();
+ if (!blabels.contains(lab)) {
+ Trace.println("\tLabel " + lab + " missing at " + cdgbb + " --> " + ibb);
+ ret = false;
+ }
+ }
+ }
+
+ cCount = cdg.getSuccNodeCount(ibb);
+ bCount = bv.getSuccNodeCount(ibb);
+ if (cCount != bCount) {
+ Trace.println("\tSucc Count mismatch for " + ibb);
+ ret = false;
+ }
+ cdit = cdg.getSuccNodes(ibb);
+ while (cdit.hasNext()) {
+ SSACFG.BasicBlock cdgbb = (SSACFG.BasicBlock) cdit.next();
+ if (!bv.hasEdge(ibb, cdgbb)) {
+ Trace.println("\tSucc " + cdgbb + " mismatch for " + ibb);
+ ret = false;
+ }
+ Set clabels = cdg.getEdgeLabels(ibb, cdgbb);
+ Set extends Object> blabels = bv.getEdgeLabels(ibb, cdgbb);
+ Iterator labit = clabels.iterator();
+ while (labit.hasNext()) {
+ Object lab = labit.next();
+ if (!blabels.contains(lab)) {
+ Trace.println("\tLabel " + lab + " missing at " + ibb + " --> " + cdgbb);
+ ret = false;
+ }
+ }
+ }
+
+ }
+ return ret;
+ }
+
+ private static void dumpCDGInfo(SSACFG cfg, ControlDependenceGraph cdg) {
+ Trace.println("{\n");
+ Vector seen = new Vector();
+ SSACFG.BasicBlock entry = (SSACFG.BasicBlock) cfg.entry();
+ Vector worklist = new Vector();
+ worklist.add(entry);
+ while (worklist.size() > 0) {
+ SSACFG.BasicBlock ibb = worklist.remove(worklist.size() - 1);
+ if (seen.contains(ibb))
+ continue;
+ seen.add(ibb);
+
+ int number = ibb.getNumber();
+ Trace.print("\n\tBB ID:" + number + "::" + ibb + " (CD=");
+ Iterator extends IBasicBlock> cdit = cdg.getPredNodes(ibb);
+ while (cdit.hasNext()) {
+ SSACFG.BasicBlock cdgbb = (SSACFG.BasicBlock) cdit.next();
+ Trace.print(cdgbb.getNumber() + "[");
+ Set labels = cdg.getEdgeLabels(cdgbb, ibb);
+ Iterator labit = labels.iterator();
+ while (labit.hasNext()) {
+ Object lab = labit.next();
+ Trace.print(lab + ",");
+ }
+ Trace.print("] ");
+ }
+ Trace.print(")");
+
+ Iterator extends IBasicBlock> succ = cfg.getSuccNodes(ibb);
+ Trace.print(" (SUCC=");
+ while (succ.hasNext()) {
+ SSACFG.BasicBlock isc = (SSACFG.BasicBlock) succ.next();
+ Trace.print(isc.getNumber() + ", ");
+ worklist.add(isc);
+ }
+ Trace.print(")");
+
+ Iterator extends IBasicBlock> pred = cfg.getPredNodes(ibb);
+ Trace.print(" (PRED=");
+ while (pred.hasNext()) {
+ SSACFG.BasicBlock isc = (SSACFG.BasicBlock) pred.next();
+ Trace.print(isc.getNumber() + ", ");
+ }
+ Trace.println(") {");
+
+ Iterator extends IInstruction> it = ibb.iterateAllInstructions();
+ int j = 0;
+ while (it.hasNext()) {
+ SSAInstruction inst = (SSAInstruction) it.next();
+ if (inst != null) {
+ Trace.println("\t\t" + j++ + ":" + inst.toString());
+ }
+ }
+ Trace.println("\t}\n");
+ }
+ Trace.println("}\n");
+ }
+
+ private static void dumpCDGInfo(SSACFG cfg, BVControlDependenceGraph cdg) {
+ Trace.println("{\n");
+ Vector seen = new Vector();
+ SSACFG.BasicBlock entry = (SSACFG.BasicBlock) cfg.entry();
+ Vector worklist = new Vector();
+ worklist.add(entry);
+ while (worklist.size() > 0) {
+ SSACFG.BasicBlock ibb = worklist.remove(worklist.size() - 1);
+ if (seen.contains(ibb))
+ continue;
+ seen.add(ibb);
+
+ int number = ibb.getNumber();
+ Trace.print("\n\tBB ID:" + number + "::" + ibb + " (CD=");
+ Iterator extends IBasicBlock> cdit = cdg.getPredNodes(ibb);
+ while (cdit.hasNext()) {
+ SSACFG.BasicBlock cdgbb = (SSACFG.BasicBlock) cdit.next();
+ Trace.print(cdgbb.getNumber() + "[");
+ Set extends Object> labels = cdg.getEdgeLabels(cdgbb, ibb);
+ Iterator extends Object> labit = labels.iterator();
+ while (labit.hasNext()) {
+ Object lab = labit.next();
+ Trace.print(lab + ",");
+ }
+ Trace.print("] ");
+ }
+ Trace.print(")");
+
+ Iterator extends IBasicBlock> succ = cfg.getSuccNodes(ibb);
+ Trace.print(" (SUCC=");
+ while (succ.hasNext()) {
+ SSACFG.BasicBlock isc = (SSACFG.BasicBlock) succ.next();
+ Trace.print(isc.getNumber() + ", ");
+ worklist.add(isc);
+ }
+ Trace.print(")");
+
+ Iterator pred = cfg.getPredNodes(ibb);
+ Trace.print(" (PRED=");
+ while (pred.hasNext()) {
+ SSACFG.BasicBlock isc = (SSACFG.BasicBlock) pred.next();
+ Trace.print(isc.getNumber() + ", ");
+ }
+ Trace.println(") {");
+
+ Iterator extends IInstruction> it = ibb.iterateAllInstructions();
+ int j = 0;
+ while (it.hasNext()) {
+ SSAInstruction inst = (SSAInstruction) it.next();
+ if (inst != null) {
+ Trace.println("\t\t" + j++ + ":" + inst.toString());
+ }
+ }
+ Trace.println("\t}\n");
+ }
+ Trace.println("}\n");
+ }
+
+ /*
+ * private static void buildUncheckedCDGs(CallGraph g) { String dotExe =
+ * "dot"; int count = 0; for (Iterator it = g.iterateNodes(); it.hasNext();) {
+ * count++; CGNode n = (CGNode) it.next(); MethodReference mref =
+ * n.getMethod().getReference(); IR ir = ((SSAContextInterpreter)
+ * g.getInterpreter(n)).getIR(n, new WarningSet()); if (ir != null) { SSACFG
+ * cfg = ir.getControlFlowGraph(); Vector vec = checkCFG(cfg, mref); if ( vec !=
+ * null ) { // Trace.println(mref.toString()); ControlDependenceGraph cdg =
+ * new ControlDependenceGraph(cfg,true); boolean found = false; for ( int i=0;
+ * i0 ) { found = true; break; } } if ( !found )
+ * continue;
+ *
+ * Trace.println(mref+" has "+vec.size()+ " blocks with no predecessors"); for (
+ * int i=0 ; i checkCFG(SSACFG cfg, MethodReference mref) {
+ Vector vec = new Vector();
+ for (Iterator extends IBasicBlock> it = cfg.iterateNodes(); it.hasNext();) {
+ SSACFG.BasicBlock bb = (SSACFG.BasicBlock) it.next();
+ if (cfg.getPredNodeCount(bb) == 0)
+ vec.add(bb);
+ }
+ if (vec.size() > 1) {
+ /*
+ * Trace.println(mref+" has more than one block with no predecessors");
+ * for ( int i=0 ; i callerNodes = HashSetFactory.make();
+ callerNodes.addAll(cg.getNodes(thisBinaryRef));
+ callerNodes.addAll(cg.getNodes(thatBinaryRef));
+ Assertions._assert(callerNodes.size() == 2);
+
+ for (Iterator nodes = callerNodes.iterator(); nodes.hasNext();) {
+ CGNode n = (CGNode) nodes.next();
+ for (Iterator sites = n.iterateSites(); sites.hasNext();) {
+ CallSiteReference csRef = (CallSiteReference) sites.next();
+ if (csRef.getDeclaredTarget().equals(unary2Ref)) {
+ numberOfCalls++;
+ Assertions._assert(n.getNumberOfTargets(csRef) == desiredNumberOfTargets);
+ }
+ }
+ }
+
+ Assertions._assert(numberOfCalls == desiredNumberOfCalls);
+ }
+
+ public void testNoPiNodes() throws ClassHierarchyException {
+ checkCallAssertions(doGraph(false), 2, 2);
+ }
+
+ public void testPiNodes() throws ClassHierarchyException {
+ checkCallAssertions(doGraph(true), 1, 2);
+ }
+
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ReflectionTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ReflectionTest.java
new file mode 100644
index 000000000..7ebe2ab44
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/ReflectionTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.callGraph;
+
+import java.util.Iterator;
+
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ecore.java.impl.JavaPackageImpl;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.Warning;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ *
+ * Tests for Call Graph construction
+ *
+ * @author sfink
+ */
+
+public class ReflectionTest extends WalaTestCase {
+
+ static {
+ JavaPackageImpl.init();
+ }
+
+ public static void main(String[] args) {
+ justThisTest(ReflectionTest.class);
+ }
+
+ public void testReflect1() throws WalaException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.REFLECT1_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ Trace.println("testReflect1 set up warnings:\n");
+ Trace.print(warnings.toString());
+
+ warnings = CallGraphTest.doCallGraphs(options, cha, scope, null, useShortProfile(), false);
+ if (warnings.size() > 0) {
+ System.err.println(warnings);
+ }
+ for (Iterator it = warnings.iterator(); it.hasNext(); ) {
+ Warning w = (Warning)it.next();
+ if (w.toString().indexOf("com/ibm/jvm") > 0) {
+ continue;
+ }
+ assertTrue(w.toString(), false);
+ }
+
+ }
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/CHATest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/CHATest.java
new file mode 100644
index 000000000..b5e93e0d5
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/CHATest.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.cha;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Properties;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.ibm.wala.classLoader.IClass;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ecore.java.EJavaClass;
+import com.ibm.wala.ecore.java.ETypeHierarchy;
+import com.ibm.wala.ecore.java.impl.JavaPackageImpl;
+import com.ibm.wala.emf.wrappers.EMFBridge;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.ETypeHierarchyWrapper;
+import com.ibm.wala.emf.wrappers.EUtil;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.properties.WalaProperties;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.warnings.WalaException;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * @author sfink
+ */
+
+public class CHATest extends WalaTestCase {
+
+ static {
+ JavaPackageImpl.init();
+ }
+
+ private static final ClassLoader MY_CLASSLOADER = CHATest.class.getClassLoader();
+
+ public static void main(String[] args) {
+ justThisTest(CHATest.class);
+ }
+
+ public CHATest(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * regression test with class hierarchy of primordial loader
+ * @throws ClassHierarchyException
+ */
+ public void testPrimordial() throws ClassHierarchyException {
+ System.err.println("build ...");
+ // build a class hierarchy for the primordial loader
+ AnalysisScope scope = new EMFScopeWrapper(TestConstants.WALA_TESTDATA, "J2SEClassHierarchyExclusions.xml", MY_CLASSLOADER);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ com.ibm.wala.emf.wrappers.ETypeHierarchyWrapper t1 = EMFBridge.makeTypeHierarchy(cha);
+ System.err.println("save ...");
+ // save it to disk
+ ETypeHierarchy et = (ETypeHierarchy) t1.toEMF();
+ Properties p = null;;
+ try {
+ p = WalaProperties.loadProperties();
+ } catch (WalaException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ String outputDir = p.getProperty(WalaProperties.OUTPUT_DIR);
+ String fileName = outputDir + File.separator + "primordialTH.xml";
+ Collection persist = new LinkedList();
+ persist.add(et);
+ persist.add(et.getClasses().getNodes());
+ persist.add(et.getInterfaces().getNodes());
+ try {
+ EUtil.saveToFile(persist, fileName);
+ } catch (WalaException e1) {
+ e1.printStackTrace();
+ Assertions.UNREACHABLE("failed to save to file " + fileName + "\n. outputDir was " + outputDir);
+ }
+
+ System.err.println("read ...");
+ // load it back into memory
+ ETypeHierarchyWrapper et2 = ETypeHierarchyWrapper.loadFromFile(fileName);
+ System.err.println("check ...");
+ // check that they are isomorphic
+ // TODO: add general utilities for isomorphism
+ com.ibm.wala.ipa.callgraph.impl.Util.checkGraphSubset(t1.getClasses(), et2.getClasses());
+ com.ibm.wala.ipa.callgraph.impl.Util.checkGraphSubset(et2.getClasses(), t1.getClasses());
+ com.ibm.wala.ipa.callgraph.impl.Util.checkGraphSubset(t1.getInterfaces(), et2.getInterfaces());
+ com.ibm.wala.ipa.callgraph.impl.Util.checkGraphSubset(et2.getInterfaces(), t1.getInterfaces());
+ checkInterfaces(cha, et2);
+ }
+
+ /**
+ * check that the set of interfaces for each class is consistent between cha
+ * and T.
+ *
+ * @param cha
+ * @param T
+ */
+ private void checkInterfaces(ClassHierarchy cha, ETypeHierarchyWrapper T) {
+ try {
+ for (Iterator it = cha.iterateAllClasses(); it.hasNext();) {
+ IClass klass = (IClass) it.next();
+ if (!klass.isInterface()) {
+ EJavaClass eKlass = EMFBridge.makeJavaClass(klass.getReference());
+ HashSet impls = new HashSet(5);
+ for (Iterator it2 = klass.getDirectInterfaces().iterator(); it2.hasNext();) {
+ IClass iface = (IClass) it2.next();
+ impls.add(EMFBridge.makeJavaClass(iface.getReference()));
+ }
+ Collection c = T.getImplements(eKlass);
+ checkSetsEqual(impls, c);
+ }
+ }
+ } catch (ClassHierarchyException e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ }
+
+ private void checkSetsEqual(Collection c1, Collection c2) {
+ if (!c1.containsAll(c2)) {
+ c2.removeAll(c1);
+ Trace.printCollection("DIFF: c2 contains but not c1 ", c2);
+ assertTrue("c1 not superset of c2, see trace file for details", false);
+ return;
+ }
+ if (!c2.containsAll(c1)) {
+ c1.removeAll(c2);
+ Trace.printCollection("DIFF: c1 contains but not c2 ", c1);
+ assertTrue("c2 not superset of c1, see trace file for details", false);
+ return;
+ }
+ }
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/LibraryVersionTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/LibraryVersionTest.java
new file mode 100644
index 000000000..c007d3038
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/LibraryVersionTest.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.cha;
+
+import junit.framework.Assert;
+
+import com.ibm.wala.core.tests.ir.DeterministicIRTest;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+
+/**
+ * Test code that attempts to find the library version from
+ * the analysis scope.
+ *
+ * @author JulianDolby (dolby@us.ibm.com)
+ */
+public class LibraryVersionTest extends WalaTestCase {
+
+ private static final ClassLoader MY_CLASSLOADER = DeterministicIRTest.class.getClassLoader();
+
+ public void testLibraryVersion() {
+ AnalysisScope scope = new EMFScopeWrapper(TestConstants.WALA_TESTDATA, "J2SEClassHierarchyExclusions.xml", MY_CLASSLOADER);
+ System.err.println("java library version is " + scope.getJavaLibraryVersion());
+ Assert.assertTrue(scope.isJava15Libraries()||scope.isJava14Libraries());
+ }
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/SourceMapTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/SourceMapTest.java
new file mode 100644
index 000000000..4ca6d9d27
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/cha/SourceMapTest.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.cha;
+
+import com.ibm.wala.classLoader.IClass;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.types.TypeReference;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * A test of support for source file mapping
+ *
+ * @author sfink
+ */
+public class SourceMapTest extends WalaTestCase {
+ private static final ClassLoader MY_CLASSLOADER = SourceMapTest.class.getClassLoader();
+
+ private final static String CLASS_IN_PRIMORDIAL_JAR = "Lcom/ibm/wala/model/SyntheticFactory";
+
+ public void testHello() throws ClassHierarchyException {
+ AnalysisScope scope = null;
+ scope = new EMFScopeWrapper(TestConstants.HELLO, null, MY_CLASSLOADER);
+ // TODO: it's annoying to have to build a class hierarchy here.
+ // see feature 38676
+ ClassHierarchy cha = ClassHierarchy.make(scope, new WarningSet());
+ TypeReference t = TypeReference.findOrCreate(scope.getApplicationLoader(), TestConstants.HELLO_MAIN);
+ IClass klass = cha.lookupClass(t);
+ assertTrue("failed to load " + t, klass != null);
+ String sourceFile = klass.getSourceFileName();
+ System.err.println("Source file: " + sourceFile);
+ assertTrue(sourceFile != null);
+ }
+
+ public void testFromJar() throws ClassHierarchyException {
+ AnalysisScope scope = null;
+ scope = new EMFScopeWrapper(TestConstants.HELLO, null, MY_CLASSLOADER);
+ // TODO: it's annoying to have to build a class hierarchy here.
+ // open a feature to fix this
+ ClassHierarchy cha = ClassHierarchy.make(scope, new WarningSet());
+ TypeReference t = TypeReference.findOrCreate(scope.getPrimordialLoader(), CLASS_IN_PRIMORDIAL_JAR);
+ IClass klass = cha.lookupClass(t);
+ assertTrue(klass != null);
+ String sourceFile = klass.getSourceFileName();
+ assertTrue(sourceFile != null);
+ System.err.println("Source file: " + sourceFile);
+ }
+}
\ No newline at end of file
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGTest.java
new file mode 100644
index 000000000..98cdb8515
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CFGTest.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.ir;
+
+import com.ibm.wala.cfg.ControlFlowGraph;
+import com.ibm.wala.cfg.TwoExitCFG;
+import com.ibm.wala.classLoader.IMethod;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ecore.java.scope.EJavaAnalysisScope;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.emf.wrappers.JavaScopeUtil;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.impl.Everywhere;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ssa.IR;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.util.StringStuff;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.graph.GraphIntegrity;
+import com.ibm.wala.util.graph.GraphIntegrity.UnsoundGraphException;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * Test integrity of CFGs
+ */
+public class CFGTest extends WalaTestCase {
+
+ public static void main(String[] args) {
+ justThisTest(CFGTest.class);
+ }
+
+ /**
+ * Build an IR, then check integrity on two flavors of CFG
+ */
+ private void doMethod(String methodSig) {
+ try {
+ EJavaAnalysisScope escope = JavaScopeUtil.makePrimordialScope();
+
+ // generate a DOMO-consumable wrapper around the incoming scope object
+ EMFScopeWrapper scope = EMFScopeWrapper.generateScope(escope);
+
+ // invoke DOMO to build a DOMO class hierarchy object
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+
+ MethodReference mr = StringStuff.makeMethodReference(methodSig);
+
+ IMethod m = cha.resolveMethod(mr);
+ if (m == null) {
+ Assertions.UNREACHABLE("could not resolve " + mr);
+ }
+ AnalysisOptions options = new AnalysisOptions();
+ options.getSSAOptions().setUsePiNodes(true);
+ IR ir = options.getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, cha, options.getSSAOptions(), new WarningSet());
+
+ ControlFlowGraph cfg = ir.getControlFlowGraph();
+ try {
+ GraphIntegrity.check(cfg);
+ } catch (UnsoundGraphException e) {
+ e.printStackTrace();
+ Trace.println(ir);
+ assertTrue(" failed cfg integrity check for " + methodSig, false);
+ }
+
+ cfg = new TwoExitCFG(cfg);
+ try {
+ GraphIntegrity.check(cfg);
+ } catch (UnsoundGraphException e) {
+ e.printStackTrace();
+ Trace.println(ir);
+ Trace.println(cfg);
+ assertTrue(" failed 2-exit cfg integrity check for " + methodSig, false);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assertions.UNREACHABLE();
+ }
+ }
+
+ /**
+ * this method does not exist in 1.5 libraries public void testFDBigInt() {
+ * doMethod("java.lang.FDBigInt.class$(Ljava/lang/String;)Ljava/lang/Class;"); }
+ */
+
+ public void testResolveProxyClass() {
+ doMethod("java.io.ObjectInputStream.resolveProxyClass([Ljava/lang/String;)Ljava/lang/Class;");
+ }
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CornerCasesTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CornerCasesTest.java
new file mode 100644
index 000000000..ade83e2ae
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/CornerCasesTest.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.ir;
+
+import com.ibm.wala.analysis.typeInference.TypeInference;
+import com.ibm.wala.classLoader.IClass;
+import com.ibm.wala.classLoader.IMethod;
+import com.ibm.wala.classLoader.ShrikeCTMethodWrapper;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.impl.Everywhere;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.ssa.IR;
+import com.ibm.wala.types.Descriptor;
+import com.ibm.wala.types.Selector;
+import com.ibm.wala.types.TypeReference;
+import com.ibm.wala.util.Atom;
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * tests for weird corner cases, such as when the input program doesn't verify
+ *
+ * @author sfink
+ */
+public class CornerCasesTest extends WalaTestCase {
+
+ private static final ClassLoader MY_CLASSLOADER = CornerCasesTest.class.getClassLoader();
+
+ /**
+ * test that getMethod() works even if a declared ancester interface doesn't
+ * exist
+ * @throws ClassHierarchyException
+ */
+ public void testBug38484() throws ClassHierarchyException {
+ AnalysisScope scope = null;
+ scope = new EMFScopeWrapper(TestConstants.WALA_TESTDATA, "J2SEClassHierarchyExclusions.xml", MY_CLASSLOADER);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "YuckyInterface");
+ IClass klass = cha.lookupClass(t);
+ assertTrue(klass != null);
+ IMethod m = klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("x"), Descriptor.findOrCreateUTF8("()V")));
+ assertTrue(m == null);
+ Trace.print(warnings.toString());
+ }
+
+ /**
+ * test that type inference works in the presence of a getfield where the
+ * field's declared type cannot be loaded
+ * @throws ClassHierarchyException
+ */
+ public void testBug38540() throws ClassHierarchyException {
+ AnalysisScope scope = null;
+ scope = new EMFScopeWrapper(TestConstants.WALA_TESTDATA, "J2SEClassHierarchyExclusions.xml", MY_CLASSLOADER);
+ AnalysisOptions options = new AnalysisOptions();
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "Main");
+ IClass klass = cha.lookupClass(t);
+ assertTrue(klass != null);
+ ShrikeCTMethodWrapper m = (ShrikeCTMethodWrapper) klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("foo"), Descriptor
+ .findOrCreateUTF8("()Ljava/lang/Object;")));
+ assertTrue(m != null);
+ IR ir = options.getIRFactory().makeIR(m, Everywhere.EVERYWHERE, cha, options.getSSAOptions(), warnings);
+ new TypeInference(ir, cha);
+
+ Trace.print(warnings.toString());
+ }
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java
new file mode 100644
index 000000000..9adaf30f5
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ir/DeterministicIRTest.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.ir;
+
+import java.util.Iterator;
+
+import com.ibm.wala.classLoader.ClassLoaderFactory;
+import com.ibm.wala.classLoader.ClassLoaderFactoryImpl;
+import com.ibm.wala.classLoader.IMethod;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.emf.wrappers.EMFScopeWrapper;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.impl.Everywhere;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.ssa.IR;
+import com.ibm.wala.ssa.SSAInstruction;
+import com.ibm.wala.types.MethodReference;
+import com.ibm.wala.util.Atom;
+import com.ibm.wala.util.ImmutableByteArray;
+import com.ibm.wala.util.UTF8Convert;
+import com.ibm.wala.util.graph.GraphIntegrity;
+import com.ibm.wala.util.graph.GraphIntegrity.UnsoundGraphException;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ * Test that the SSA-numbering of variables in the IR is deterministic.
+ *
+ * Introduced 05-AUG-03; the default implementation of hashCode was being
+ * invoked. Object.hashCode is a source of random numbers and has no place in a
+ * deterministic program.
+ */
+public class DeterministicIRTest extends WalaTestCase {
+
+ private static final ClassLoader MY_CLASSLOADER = DeterministicIRTest.class.getClassLoader();
+
+ private WarningSet warnings;
+ private AnalysisScope scope;
+ private ClassHierarchy cha;
+ private AnalysisOptions options;
+
+ public static void main(String[] args) {
+ justThisTest(DeterministicIRTest.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+
+ warnings = new WarningSet();
+ scope = new EMFScopeWrapper(TestConstants.WALA_TESTDATA, "J2SEClassHierarchyExclusions.xml", MY_CLASSLOADER);
+
+ options = new AnalysisOptions(scope, null);
+ ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions(), warnings);
+
+ warnings = new WarningSet();
+
+ try {
+ cha = ClassHierarchy.make(scope, factory, warnings);
+ } catch (ClassHierarchyException e) {
+ throw new Exception();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ warnings = null;
+ scope = null;
+ cha = null;
+ super.tearDown();
+ }
+
+ /**
+ * @param method
+ */
+ private IR doMethod(MethodReference method) {
+ assertNotNull("method not found", method);
+ IMethod imethod = cha.resolveMethod(method);
+ assertNotNull("imethod not found", imethod);
+ IR ir1 = options.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, cha, options.getSSAOptions(), warnings);
+ options.getSSACache().wipe();
+
+ checkNotAllNull(ir1.getInstructions());
+ checkNoneNull(ir1.iterateAllInstructions());
+ try {
+ GraphIntegrity.check(ir1.getControlFlowGraph());
+ } catch (UnsoundGraphException e) {
+ System.err.println(ir1);
+ e.printStackTrace();
+ assertTrue("unsound CFG for ir1", false);
+ }
+
+ IR ir2 = options.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, cha, options.getSSAOptions(), warnings);
+ options.getSSACache().wipe();
+
+ try {
+ GraphIntegrity.check(ir2.getControlFlowGraph());
+ } catch (UnsoundGraphException e1) {
+ System.err.println(ir2);
+ e1.printStackTrace();
+ assertTrue("unsound CFG for ir2", false);
+ }
+
+ assertEquals(ir1.toString(), ir2.toString());
+ return ir1;
+ }
+
+ // The Tests ///////////////////////////////////////////////////////
+
+ /**
+ * @param iterator
+ */
+ private void checkNoneNull(Iterator> iterator) {
+ while (iterator.hasNext()) {
+ assertTrue(iterator.next() != null);
+ }
+
+ }
+
+ /**
+ * @param instructions
+ */
+ private static void checkNotAllNull(SSAInstruction[] instructions) {
+ for (int i = 0; i < instructions.length; i++) {
+ if (instructions[i] != null) {
+ return;
+ }
+ }
+ assertTrue("no instructions generated", false);
+ }
+
+ public void testIR1() {
+ // 'remove' is a nice short method
+ doMethod(scope.findMethod(AnalysisScope.APPLICATION, "Ljava/util/HashMap", Atom.findOrCreateUnicodeAtom("remove"),
+ new ImmutableByteArray(UTF8Convert.toUTF8("(Ljava/lang/Object;)Ljava/lang/Object;"))));
+ }
+
+ public void testIR2() {
+ // 'equals' is a nice medium-sized method
+ doMethod(scope.findMethod(AnalysisScope.APPLICATION, "Ljava/lang/String", Atom.findOrCreateUnicodeAtom("equals"),
+ new ImmutableByteArray(UTF8Convert.toUTF8("(Ljava/lang/Object;)Z"))));
+ }
+
+ public void testIR3() {
+ // 'resolveProxyClass' is a nice long method (at least in Sun libs)
+ doMethod(scope.findMethod(AnalysisScope.APPLICATION, "Ljava/io/ObjectInputStream", Atom
+ .findOrCreateUnicodeAtom("resolveProxyClass"), new ImmutableByteArray(UTF8Convert
+ .toUTF8("([Ljava/lang/String;)Ljava/lang/Class;"))));
+ }
+
+ public void testLocalNamesWithoutPiNodes() {
+ boolean save = options.getSSAOptions().getUsePiNodes();
+ options.getSSAOptions().setUsePiNodes( false );
+ IR ir = doMethod(scope.findMethod(AnalysisScope.APPLICATION, "LcornerCases/Locals", Atom.findOrCreateUnicodeAtom("foo"),
+ new ImmutableByteArray(UTF8Convert.toUTF8("([Ljava/lang/String;)V"))));
+ options.getSSAOptions().setUsePiNodes( save );
+
+
+ // v1 should be the parameter "a" at pc 0
+ String[] names = ir.getLocalNames(0,1);
+ assertTrue("failed local name resolution for v1@0" , names != null);
+ assertTrue("incorrect number of local names for v1@0: " + names.length , names.length == 1);
+ assertTrue("incorrect local name resolution for v1@0: " + names[0], names[0].equals("a"));
+
+ // v2 is a compiler-induced temporary
+ assertTrue("didn't expect name for v2 at pc 2" , ir.getLocalNames(2,2) == null);
+
+ // at pc 5, v1 should represent the locals "a" and "b"
+ names = ir.getLocalNames(5,1);
+ assertTrue("failed local name resolution for v1@5" , names != null);
+ assertTrue("incorrect number of local names for v1@5: " + names.length , names.length == 2);
+ assertTrue("incorrect local name resolution #0 for v1@5: " + names[0], names[0].equals("a"));
+ assertTrue("incorrect local name resolution #1 for v1@5: " + names[1], names[1].equals("b"));
+ }
+
+ public void testLocalNamesWithPiNodes() {
+ boolean save = options.getSSAOptions().getUsePiNodes();
+ options.getSSAOptions().setUsePiNodes( true );
+ IR ir = doMethod(scope.findMethod(AnalysisScope.APPLICATION, "LcornerCases/Locals", Atom.findOrCreateUnicodeAtom("foo"),
+ new ImmutableByteArray(UTF8Convert.toUTF8("([Ljava/lang/String;)V"))));
+ options.getSSAOptions().setUsePiNodes( save );
+
+ // v1 should be the parameter "a" at pc 0
+ String[] names = ir.getLocalNames(0,1);
+ assertTrue("failed local name resolution for v1@0" , names != null);
+ assertTrue("incorrect number of local names for v1@0: " + names.length , names.length == 1);
+ assertTrue("incorrect local name resolution for v1@0: " + names[0], names[0].equals("a"));
+
+ // v2 is a compiler-induced temporary
+ assertTrue("didn't expect name for v2 at pc 2" , ir.getLocalNames(2,2) == null);
+
+ // at pc 5, v1 should represent the locals "a" and "b"
+ names = ir.getLocalNames(5,1);
+ assertTrue("failed local name resolution for v1@5" , names != null);
+ assertTrue("incorrect number of local names for v1@5: " + names.length , names.length == 2);
+ assertTrue("incorrect local name resolution #0 for v1@5: " + names[0], names[0].equals("a"));
+ assertTrue("incorrect local name resolution #1 for v1@5: " + names[1], names[1].equals("b"));
+ }
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java
new file mode 100644
index 000000000..cb94b715e
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.ptrs;
+
+import java.util.Iterator;
+
+import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.core.tests.util.WalaTestCase;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
+import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
+import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.intset.OrdinalSet;
+import com.ibm.wala.util.warnings.WarningSet;
+
+/**
+ *
+ * Test for pointer analysis of multidimensional arrays
+ *
+ * @author sfink
+ */
+
+public class MultiDimArrayTest extends WalaTestCase {
+
+
+ public static void main(String[] args) {
+ justThisTest(MultiDimArrayTest.class);
+ }
+
+ /**
+ * Constructor for SpecJTest.
+ *
+ * @param arg0
+ */
+ public MultiDimArrayTest(String arg0) {
+ super(arg0);
+ }
+
+
+ public void testMultiDim() throws ClassHierarchyException {
+
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util
+ .makeMainEntrypoints(scope, cha, TestConstants.MULTI_DIM_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+ PointerAnalysis pa = builder.getPointerAnalysis();
+ System.err.println(pa);
+
+ CGNode node = findDoNothingNode(cg);
+ PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node, 1);
+ OrdinalSet ptsTo = pa.getPointsToSet(pk);
+ assertEquals(1, ptsTo.size());
+ }
+
+ private final static CGNode findDoNothingNode(CallGraph cg) {
+ for (Iterator extends CGNode> it = cg.iterateNodes(); it.hasNext(); ) {
+ CGNode n = it.next();
+ if (n.getMethod().getName().toString().equals("doNothing")) {
+ return n;
+ }
+ }
+ Assertions.UNREACHABLE("Unexpected: failed to find doNothing node");
+ return null;
+ }
+
+
+
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/slicer/SlicerTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/slicer/SlicerTest.java
new file mode 100644
index 000000000..9d5db355a
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/slicer/SlicerTest.java
@@ -0,0 +1,542 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.slicer;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
+import com.ibm.wala.core.tests.util.TestConstants;
+import com.ibm.wala.examples.drivers.GVSlice;
+import com.ibm.wala.ipa.callgraph.AnalysisOptions;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.ipa.callgraph.CGNode;
+import com.ibm.wala.ipa.callgraph.CallGraph;
+import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
+import com.ibm.wala.ipa.callgraph.Entrypoints;
+import com.ibm.wala.ipa.callgraph.impl.Util;
+import com.ibm.wala.ipa.cha.ClassHierarchy;
+import com.ibm.wala.ipa.cha.ClassHierarchyException;
+import com.ibm.wala.ipa.slicer.NormalStatement;
+import com.ibm.wala.ipa.slicer.Slicer;
+import com.ibm.wala.ipa.slicer.Statement;
+import com.ibm.wala.ipa.slicer.Slicer.ControlDependenceOptions;
+import com.ibm.wala.ipa.slicer.Slicer.DataDependenceOptions;
+import com.ibm.wala.ssa.IR;
+import com.ibm.wala.ssa.SSAArrayLoadInstruction;
+import com.ibm.wala.ssa.SSAConditionalBranchInstruction;
+import com.ibm.wala.ssa.SSAGetInstruction;
+import com.ibm.wala.ssa.SSAInstruction;
+import com.ibm.wala.ssa.SSAInvokeInstruction;
+import com.ibm.wala.ssa.SSANewInstruction;
+import com.ibm.wala.ssa.SSAPutInstruction;
+import com.ibm.wala.types.Descriptor;
+import com.ibm.wala.util.Atom;
+import com.ibm.wala.util.debug.Assertions;
+import com.ibm.wala.util.intset.IntSet;
+import com.ibm.wala.util.warnings.WarningSet;
+
+public class SlicerTest extends TestCase {
+
+ public void testSlice1() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE1_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallTo(main, "print");
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(18, slice.size());
+ }
+
+ public void testSlice2() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE2_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMethod(cg, "baz");
+
+ Statement s = findCallTo(main, "print");
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(22, slice.size());
+ }
+
+ public void testSlice3() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE3_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMethod(cg, "main");
+
+ Statement s = findCallTo(main, "doNothing");
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(1, countAllocations(slice));
+ }
+
+ public void testSlice4() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE4_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+ Statement s = findCallTo(main, "foo");
+ s = GVSlice.getReturnStatementForCall(s);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeForwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(4, slice.size());
+ }
+
+ public void testSlice5() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE5_MAIN);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode n = findMethod(cg, "baz");
+ Statement s = findCallTo(n, "foo");
+ s = GVSlice.getReturnStatementForCall(s);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeForwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(7, slice.size());
+ }
+
+ public void testTestCD1() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTCD1);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NONE,
+ ControlDependenceOptions.FULL);
+ dumpSlice(slice);
+ assertEquals(2, countConditionals(slice));
+ }
+
+ public void testTestCD2() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTCD2);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NONE,
+ ControlDependenceOptions.FULL);
+ dumpSlice(slice);
+ assertEquals(1, countConditionals(slice));
+ }
+
+ public void testTestCD3() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTCD3);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NONE,
+ ControlDependenceOptions.FULL);
+ dumpSlice(slice);
+ assertEquals(0, countConditionals(slice));
+ }
+
+ public void testTestId() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTID);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(1, countAllocations(slice));
+ }
+
+ public void testTestArrays() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTARRAYS);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(2, countAllocations(slice));
+ assertEquals(1, countAloads(slice));
+ }
+
+ public void testTestFields() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTFIELDS);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(2, countAllocations(slice));
+ assertEquals(1, countPutfields(slice));
+ }
+
+ public void testThin1() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTTHIN1);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+
+ // compute normal data slice
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(3, countAllocations(slice));
+ assertEquals(2, countPutfields(slice));
+
+ // compute thin slice .. ignore base pointers
+ slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.NO_BASE_PTRS,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(2, countAllocations(slice));
+ assertEquals(1, countPutfields(slice));
+ }
+
+ public void testTestGlobal() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTGLOBAL);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(1, countAllocations(slice));
+ assertEquals(2, countPutstatics(slice));
+ assertEquals(2, countGetstatics(slice));
+ }
+
+ public void testTestMultiTarget() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
+ TestConstants.SLICE_TESTMULTITARGET);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(2, countAllocations(slice));
+ }
+
+ public void testTestRecursion() throws ClassHierarchyException {
+ AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA);
+ WarningSet warnings = new WarningSet();
+ ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
+ Entrypoints entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
+ TestConstants.SLICE_TESTRECURSION);
+ AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
+
+ CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cha, scope, warnings);
+ CallGraph cg = builder.makeCallGraph(options);
+
+ CGNode main = findMainMethod(cg);
+
+ Statement s = findCallToDoNothing(main);
+ System.err.println("Statement: " + s);
+
+ // compute a data slice
+ Collection slice = Slicer.computeBackwardSlice(s, cg, builder.getPointerAnalysis(), DataDependenceOptions.FULL,
+ ControlDependenceOptions.NONE);
+ dumpSlice(slice);
+ assertEquals(3, countAllocations(slice));
+ assertEquals(2, countPutfields(slice));
+ }
+
+ private int countAllocations(Collection slice) {
+ int count = 0;
+ for (Statement s : slice) {
+ if (s.getKind().equals(Statement.Kind.NORMAL)) {
+ NormalStatement ns = (NormalStatement) s;
+ if (ns.getInstruction() instanceof SSANewInstruction) {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+ private int countAloads(Collection slice) {
+ int count = 0;
+ for (Statement s : slice) {
+ if (s.getKind().equals(Statement.Kind.NORMAL)) {
+ NormalStatement ns = (NormalStatement) s;
+ if (ns.getInstruction() instanceof SSAArrayLoadInstruction) {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+ private int countConditionals(Collection slice) {
+ int count = 0;
+ for (Statement s : slice) {
+ if (s.getKind().equals(Statement.Kind.NORMAL)) {
+ NormalStatement ns = (NormalStatement) s;
+ if (ns.getInstruction() instanceof SSAConditionalBranchInstruction) {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+ private int countPutfields(Collection slice) {
+ int count = 0;
+ for (Statement s : slice) {
+ if (s.getKind().equals(Statement.Kind.NORMAL)) {
+ NormalStatement ns = (NormalStatement) s;
+ if (ns.getInstruction() instanceof SSAPutInstruction) {
+ SSAPutInstruction p = (SSAPutInstruction) ns.getInstruction();
+ if (!p.isStatic()) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+ }
+
+ private int countPutstatics(Collection slice) {
+ int count = 0;
+ for (Statement s : slice) {
+ if (s.getKind().equals(Statement.Kind.NORMAL)) {
+ NormalStatement ns = (NormalStatement) s;
+ if (ns.getInstruction() instanceof SSAPutInstruction) {
+ SSAPutInstruction p = (SSAPutInstruction) ns.getInstruction();
+ if (p.isStatic()) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+ }
+
+ private int countGetstatics(Collection slice) {
+ int count = 0;
+ for (Statement s : slice) {
+ if (s.getKind().equals(Statement.Kind.NORMAL)) {
+ NormalStatement ns = (NormalStatement) s;
+ if (ns.getInstruction() instanceof SSAGetInstruction) {
+ SSAGetInstruction p = (SSAGetInstruction) ns.getInstruction();
+ if (p.isStatic()) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+ }
+
+ public static void dumpSlice(Collection slice) {
+ dumpSlice(slice,new PrintWriter(System.err));
+ }
+
+ public static void dumpSlice(Collection slice, PrintWriter w) {
+ w.println("SLICE:\n");
+ int i = 1;
+ for (Statement s : slice) {
+ String line = (i++) + " " + s;
+ w.println(line);
+ w.flush();
+ }
+ }
+
+ public static void dumpSliceToFile(Collection slice, String fileName) throws FileNotFoundException {
+ File f = new File(fileName);
+ FileOutputStream fo = new FileOutputStream(f);
+ PrintWriter w = new PrintWriter(fo);
+ dumpSlice(slice,w);
+ }
+
+ public static CGNode findMainMethod(CallGraph cg) {
+ Descriptor d = Descriptor.findOrCreateUTF8("([Ljava/lang/String;)V");
+ Atom name = Atom.findOrCreateUnicodeAtom("main");
+ for (Iterator extends CGNode> it = cg.getSuccNodes(cg.getFakeRootNode()); it.hasNext();) {
+ CGNode n = it.next();
+ if (n.getMethod().getName().equals(name) && n.getMethod().getDescriptor().equals(d)) {
+ return n;
+ }
+ }
+ Assertions.UNREACHABLE("failed to find main() method");
+ return null;
+ }
+
+
+ public static CGNode findMethod(CallGraph cg, String name) {
+ Atom a = Atom.findOrCreateUnicodeAtom(name);
+ for (Iterator extends CGNode> it = cg.iterateNodes(); it.hasNext();) {
+ CGNode n = it.next();
+ if (n.getMethod().getName().equals(a)) {
+ return n;
+ }
+ }
+ System.err.println("call graph " + cg);
+ Assertions.UNREACHABLE("failed to find method " + name);
+ return null;
+ }
+
+ public static Statement findCallTo(CGNode n, String methodName) {
+ IR ir = n.getCallGraph().getInterpreter(n).getIR(n, new WarningSet());
+ for (Iterator it = ir.iterateAllInstructions(); it.hasNext();) {
+ SSAInstruction s = it.next();
+ if (s instanceof SSAInvokeInstruction) {
+ if (s.toString().indexOf(methodName) > -1) {
+ IntSet indices = ir.getCallInstructionIndices(((SSAInvokeInstruction) s).getCallSite());
+ Assertions.productionAssertion(indices.size()== 1, "expected 1 but got " + indices.size());
+ return new NormalStatement(n, indices.intIterator().next());
+ }
+ }
+ }
+ Assertions.UNREACHABLE("failed to find call to " + methodName + " in " + n);
+ return null;
+ }
+
+ private static Statement findCallToDoNothing(CGNode n) {
+ return findCallTo(n, "doNothing");
+ }
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/TestConstants.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/TestConstants.java
new file mode 100644
index 000000000..91b58e70b
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/TestConstants.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.util;
+
+public interface TestConstants {
+
+ public final static String WALA_TESTDATA = "wala.testdata.xml";
+
+ public static final String CLASSCONSTANT_MAIN = "LclassConstant/ClassConstant";
+ public static final String PI_TEST_MAIN = "Lpi/PiNodeCallGraphTestCase";
+ public static final String RECURSE_MAIN = "Lrecurse/NList";
+
+ public final static String HELLO = "hello.xml";
+ public final static String HELLO_MAIN = "Lhello/Hello";
+
+ public final static String BCEL = "bcel.xml";
+ public final static String BCEL_VERIFIER_MAIN = "Lorg/apache/bcel/verifier/Verifier";
+
+ public final static String JLEX = "JLex.xml";
+ public final static String JLEX_MAIN = "LJLex/Main";
+
+ public final static String JAVA_CUP = "java_cup.xml";
+ public final static String JAVA_CUP_MAIN = "Ljava_cup/Main";
+
+ public final static String MULTI_DIM_MAIN = "LmultiDim/TestMultiDim";
+
+ public final static String REFLECT1_MAIN = "Lreflection/Reflect1";
+
+ public final static String SLICE1_MAIN = "Lslice/Slice1";
+ public final static String SLICE2_MAIN = "Lslice/Slice2";
+ public final static String SLICE3_MAIN = "Lslice/Slice3";
+ public final static String SLICE4_MAIN = "Lslice/Slice4";
+ public final static String SLICE5_MAIN = "Lslice/Slice5";
+ public final static String SLICE_TESTCD1 = "Lslice/TestCD1";
+ public final static String SLICE_TESTCD2 = "Lslice/TestCD2";
+ public final static String SLICE_TESTCD3 = "Lslice/TestCD3";
+ public final static String SLICE_TESTID = "Lslice/TestId";
+ public final static String SLICE_TESTARRAYS = "Lslice/TestArrays";
+ public final static String SLICE_TESTFIELDS = "Lslice/TestFields";
+ public final static String SLICE_TESTGLOBAL = "Lslice/TestGlobal";
+ public final static String SLICE_TESTMULTITARGET = "Lslice/TestMultiTarget";
+ public final static String SLICE_TESTRECURSION = "Lslice/TestRecursion";
+ public final static String SLICE_TESTTHIN1 = "Lslice/TestThin1";
+
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/WalaTestCase.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/WalaTestCase.java
new file mode 100644
index 000000000..94d6891f2
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/util/WalaTestCase.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2002 - 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.core.tests.util;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import com.ibm.wala.util.debug.Trace;
+import com.ibm.wala.util.heapTrace.HeapTracer;
+
+/**
+ *
+ * Simple extension to JUnit test case.
+ *
+ * @author sfink
+ */
+public abstract class WalaTestCase extends TestCase {
+
+ final private static boolean ANALYZE_LEAKS = false;
+
+ public static boolean useShortProfile() {
+ String profile = System.getProperty("com.ibm.wala.junit.profile", "long");
+ if (profile.equals("short")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private String baseTraceFile;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ baseTraceFile = Trace.getTraceFile();
+ if (baseTraceFile != null) {
+ Trace.setTraceFile(baseTraceFile + "." + getName());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ if (baseTraceFile != null) {
+ Trace.setTraceFile(baseTraceFile);
+ }
+ if (ANALYZE_LEAKS) {
+ HeapTracer.analyzeLeaks();
+ }
+ }
+
+ public WalaTestCase() {
+ super("DomoTestCase");
+ }
+
+ /**
+ * Utility function: each DetoxTestCase subclass can have a main() method that
+ * calls this, to create a test suite consisting of just this test. Useful
+ * when investigating a single failing test.
+ */
+ protected static void justThisTest(Class> testClass) {
+ TestSuite suite = new TestSuite(testClass.getName());
+ suite.addTestSuite(testClass);
+ junit.textui.TestRunner.run(suite);
+ }
+
+ /**
+ * @param arg0
+ */
+ public WalaTestCase(String arg0) {
+ super(arg0);
+ }
+
+ protected static void assertBound(String tag, double quantity, double bound) {
+ String msg = tag + ", quantity: " + quantity + ", bound:" + bound;
+ Trace.println(msg);
+ assertTrue(msg, quantity <= bound);
+ }
+
+ protected static void assertBound(String tag, int quantity, int bound) {
+ String msg = tag + ", quantity: " + quantity + ", bound:" + bound;
+ Trace.println(msg);
+ assertTrue(msg, quantity <= bound);
+ }
+
+}
diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/SimpleThreadEscapeAnalysis.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/SimpleThreadEscapeAnalysis.java
new file mode 100644
index 000000000..1e1fc7aa9
--- /dev/null
+++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/SimpleThreadEscapeAnalysis.java
@@ -0,0 +1,299 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package com.ibm.wala.examples.analysis;
+
+import com.ibm.wala.classLoader.*;
+import com.ibm.wala.client.impl.*;
+import com.ibm.wala.ipa.callgraph.*;
+import com.ibm.wala.ipa.callgraph.impl.*;
+import com.ibm.wala.ipa.callgraph.propagation.*;
+import com.ibm.wala.ipa.cha.*;
+import com.ibm.wala.types.*;
+import com.ibm.wala.util.collections.HashSetFactory;
+import com.ibm.wala.util.intset.*;
+
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+
+/**
+ *
+ * A simple thread-level escape analysis: this code computes the set of classes
+ * of which some instance may be accessed by some thread other than the one that
+ * created it.
+ *
+ *
+ *
+ * The algorithm is not very bright; it is based on the observation that there
+ * are only three ways for an object to pass from one thread to another.
+ *
+ *
The object is stored into a static variable.
+ *
The object is stored into an instance field of a Thread
+ *
The object is reachable from a field of another escaping object.
+ *
+ *
+ *
+ *
+ * This observation is implemented in the obvious way:
+ *
+ *
All static fields are collected
+ *
All Thread constructor parameters are collected
+ *
The points-to sets of these values represent the base set of escapees.
+ *
All object reachable from fields of these objects are added
+ *
This process continues until a fixpoint is reached
+ *
The abstract objects in the points-to sets are converted to types
+ *
This set of types is returned
+ *
+ *
+ * @author Julian Dolby
+ */
+public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
+ private final Set applicationJarFiles;
+
+ private final String applicationMainClass;
+
+ /**
+ * The two input parameters define the program to analyze: the jars of .class
+ * files and the main class to start from.
+ */
+ public SimpleThreadEscapeAnalysis(Set applicationJarFiles, String applicationMainClass) {
+ this.applicationJarFiles = applicationJarFiles;
+ this.applicationMainClass = applicationMainClass;
+ }
+
+ /**
+ * Given a root path, add it to the set if it is a jar, or traverse it
+ * recursively if it is a directory.
+ */
+ private void collectJars(File f, Set result) throws IOException {
+ if (f.isDirectory()) {
+ File[] files = f.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ collectJars(files[i], result);
+ }
+ } else if (f.getAbsolutePath().endsWith(".jar")) {
+ result.add(new JarFile(f));
+ }
+ }
+
+ /**
+ * Collect the set of JarFiles that constitute the system libraries of the
+ * running JRE.
+ */
+ private JarFile[] getSystemJars() throws IOException {
+ Set jarFiles = HashSetFactory.make();
+
+ String javaHomePath = System.getProperty("java.home");
+
+ if (!javaHomePath.endsWith(File.separator)) {
+ javaHomePath = javaHomePath + File.separator;
+ }
+
+ collectJars(new File(javaHomePath + "lib"), jarFiles);
+
+ return jarFiles.toArray(new JarFile[jarFiles.size()]);
+ }
+
+ /**
+ * Take the given set of JarFiles that constitute the program, and return a
+ * set of Module files as expected by the WALA machinery.
+ */
+ private Set getModuleFiles() {
+ Set result = HashSetFactory.make();
+ for (Iterator jars = applicationJarFiles.iterator(); jars.hasNext();) {
+ result.add(new JarFileModule(jars.next()));
+ }
+
+ return result;
+ }
+
+ /**
+ * The heart of the analysis.
+ */
+ public Set gatherThreadEscapingClasses() throws IOException, ClassHierarchyException {
+
+ //
+ // set the application to analyze
+ //
+ setModuleFiles(getModuleFiles());
+
+ //
+ // set the system jar files to use.
+ // change this if you want to use a specific jre version
+ //
+ setJ2SELibraries(getSystemJars());
+
+ //
+ // the application and libraries are set, now build the scope...
+ //
+ buildAnalysisScope();
+
+ //
+ // ...and the class hierarchy
+ //
+ ClassHierarchy cha = buildClassHierarchy();
+ setClassHierarchy(cha);
+
+ //
+ // select the call graph construction algorithm
+ // change this if greater precision is desired
+ // (see com.ibm.wala.client.impl.*BuilderFactory)
+ //
+ setCallGraphBuilderFactory(new ZeroCFABuilderFactory());
+
+ //
+ // entrypoints are where analysis starts
+ //
+ Entrypoints roots = Util.makeMainEntrypoints(getScope(), cha, applicationMainClass);
+
+ //
+ // analysis options controls aspects of call graph construction
+ //
+ AnalysisOptions options = getDefaultOptions(roots);
+
+ //
+ // build the call graph
+ //
+ buildCallGraph(cha, options, true);
+
+ //
+ // extract data for analysis
+ //
+ CallGraph cg = getCallGraph();
+ PointerAnalysis pa = getPointerAnalysis();
+
+ //
+ // collect all places where objects can escape their creating thread:
+ // 1) all static fields
+ // 2) arguments to Thread constructors
+ //
+ Set escapeAnalysisRoots = HashSetFactory.make();
+ HeapModel heapModel = pa.getHeapModel();
+
+ // 1) static fields
+ for (Iterator clss = cha.iterateAllClasses(); clss.hasNext();) {
+ IClass cls = (IClass) clss.next();
+ Collection staticFields = cls.getDeclaredStaticFields();
+ for (Iterator sfs = staticFields.iterator(); sfs.hasNext();) {
+ IField sf = (IField) sfs.next();
+ if (sf.getFieldTypeReference().isReferenceType()) {
+ escapeAnalysisRoots.add(heapModel.getPointerKeyForStaticField(sf));
+ }
+ }
+ }
+
+ // 2) instance fields of Threads
+ // (we hack this by getting the 'this' parameter of all ctor calls;
+ // this works because the next phase will add all objects transitively
+ // reachable from fields of types in these pointer keys, and all
+ // Thread objects must be constructed somewhere)
+ Collection threads = cha.computeSubClasses(TypeReference.JavaLangThread);
+ for (Iteratorclss = threads.iterator(); clss.hasNext();) {
+ IClass cls = (IClass) clss.next();
+ for (Iterator ms = cls.getDeclaredMethods(); ms.hasNext();) {
+ IMethod m = (IMethod) ms.next();
+ if (m.isInit()) {
+ Set nodes = cg.getNodes(m.getReference());
+ for (Iterator ns = nodes.iterator(); ns.hasNext();) {
+ CGNode n = (CGNode) ns.next();
+ escapeAnalysisRoots.add(heapModel.getPointerKeyForLocal(n, 1));
+ }
+ }
+ }
+ }
+
+ //
+ // compute escaping types: all types flowing to escaping roots and
+ // all types transitively reachable through their fields.
+ //
+ Set escapingInstanceKeys = HashSetFactory.make();
+
+ //
+ // pass 1: get abstract objects (instance keys) for escaping locations
+ //
+ for (Iterator rts = escapeAnalysisRoots.iterator(); rts.hasNext();) {
+ PointerKey root = rts.next();
+ OrdinalSet objects = pa.getPointsToSet(root);
+ for (Iterator objs = objects.iterator(); objs.hasNext();) {
+ InstanceKey obj = (InstanceKey) objs.next();
+ escapingInstanceKeys.add(obj);
+ }
+ }
+
+ //
+ // passes 2+: get fields of escaping keys, and add pointed-to keys
+ //
+ Set newKeys = HashSetFactory.make();
+ do {
+ newKeys.clear();
+ for (Iterator keys = escapingInstanceKeys.iterator(); keys.hasNext();) {
+ InstanceKey key = keys.next();
+ IClass type = key.getConcreteType();
+ if (type.isReferenceType()) {
+ if (type.isArrayClass()) {
+ if (((ArrayClass) type).getElementClass() != null) {
+ PointerKey fk = heapModel.getPointerKeyForArrayContents(key);
+ OrdinalSet fobjects = pa.getPointsToSet(fk);
+ for (Iterator fobjs = fobjects.iterator(); fobjs.hasNext();) {
+ InstanceKey fobj = (InstanceKey) fobjs.next();
+ if (!escapingInstanceKeys.contains(fobj)) {
+ newKeys.add(fobj);
+ }
+ }
+ }
+ } else {
+ Collection fields = type.getAllInstanceFields();
+ for (Iterator fs = fields.iterator(); fs.hasNext();) {
+ IField f = (IField) fs.next();
+ if (f.getFieldTypeReference().isReferenceType()) {
+ PointerKey fk = heapModel.getPointerKeyForInstanceField(key, f);
+ OrdinalSet fobjects = pa.getPointsToSet(fk);
+ for (Iterator fobjs = fobjects.iterator(); fobjs.hasNext();) {
+ InstanceKey fobj = (InstanceKey) fobjs.next();
+ if (!escapingInstanceKeys.contains(fobj)) {
+ newKeys.add(fobj);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ escapingInstanceKeys.addAll(newKeys);
+ } while (!newKeys.isEmpty());
+
+ //
+ // get set of types from set of instance keys
+ //
+ Set