mv stuff to trunk

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@492 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2006-11-22 17:45:24 +00:00
parent df97f42b7e
commit 68270cad6f
795 changed files with 111158 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.wala.core.testdata</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,3 @@
#Tue Oct 17 11:41:36 EDT 2006
eclipse.preferences.version=1
internal.default.compliance=default

View File

@ -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

View File

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.core.testdata" default="build.update.jar" basedir=".">
<property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/>
<!-- Compiler settings. -->
<property name="javacFailOnError" value="false"/>
<property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/>
<property name="javacTarget" value="1.5"/>
<path id="path_bootclasspath">
<fileset dir="${java.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/>
</condition>
<property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
<isset property="buildTempFolder"/>
</condition>
<property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}"/>
</target>
<target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target>
<target name="build.update.jar" depends="init" description="Build the plug-in: com.ibm.wala.core.testdata for an update site.">
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<antcall target="build.jars"/>
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<zip destfile="${plugin.destination}/bin/com.ibm.wala.core.testdata_1.0.0.jar" basedir="${temp.folder}/com.ibm.wala.core.testdata_1.0.0" filesonly="false" whenempty="skip" update="false"/>
<delete dir="${temp.folder}"/>
</target>
<target name="@dot" depends="init" description="Create jar: com.ibm.wala.core.testdata @dot.">
<delete dir="${temp.folder}/@dot.bin"/>
<mkdir dir="${temp.folder}/@dot.bin"/>
<path id="@dot.classpath">
</path>
<!-- compile the source code -->
<javac destdir="${temp.folder}/@dot.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" >
<compilerarg line="${compilerArg}" compiler="${build.compiler}"/>
<classpath refid="@dot.classpath" />
<src path="src/" />
<compilerarg line="-log '${temp.folder}/@dot.bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</javac>
<!-- Copy necessary resources -->
<copy todir="${temp.folder}/@dot.bin" failonerror="true" overwrite="false">
<fileset dir="src/" excludes="**/*.java, **/package.htm*" />
</copy>
<mkdir dir="${build.result.folder}"/>
<copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false">
<fileset dir="${temp.folder}/@dot.bin" />
</copy>
<delete dir="${temp.folder}/@dot.bin"/>
</target>
<target name="src.zip" depends="init" unless="src.zip">
<mkdir dir="${build.result.folder}"/>
<zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false">
<fileset dir="src/" includes="**/*.java" />
</zip>
</target>
<target name="build.jars" depends="init" description="Build all the jars for the plug-in: com.ibm.wala.core.testdata.">
<available property="@dot" file="${build.result.folder}/@dot"/>
<antcall target="@dot"/>
</target>
<target name="build.sources" depends="init">
<available property="src.zip" file="${build.result.folder}/src.zip"/>
<antcall target="src.zip"/>
</target>
<target name="gather.bin.parts" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.testdata_1.0.0"/>
<copy todir="${destination.temp.folder}/com.ibm.wala.core.testdata_1.0.0" failonerror="true" overwrite="false">
<fileset dir="${build.result.folder}/@dot" includes="**" />
</copy>
<copy todir="${destination.temp.folder}/com.ibm.wala.core.testdata_1.0.0" failonerror="true" overwrite="false">
<fileset dir="${basedir}" includes="META-INF/" />
</copy>
</target>
<target name="build.zips" depends="init">
</target>
<target name="gather.sources" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.testdata_1.0.0"/>
<copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/com.ibm.wala.core.testdata_1.0.0" failonerror="false" overwrite="false"/>
</target>
<target name="gather.logs" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.testdata_1.0.0"/>
<copy file="${temp.folder}/@dot.bin${logExtension}" todir="${destination.temp.folder}/com.ibm.wala.core.testdata_1.0.0" failonerror="false" overwrite="false"/>
</target>
<target name="clean" depends="init" description="Clean the plug-in: com.ibm.wala.core.testdata of all the zips, jars and logs created.">
<delete dir="${build.result.folder}/@dot"/>
<delete file="${build.result.folder}/src.zip"/>
<delete file="${plugin.destination}/com.ibm.wala.core.testdata_1.0.0.jar"/>
<delete file="${plugin.destination}/com.ibm.wala.core.testdata_1.0.0.zip"/>
<delete dir="${temp.folder}"/>
</target>
<target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder.">
<eclipse.convertPath fileSystemPath="C:/temp/walaWorkspace/com.ibm.wala.core.testdata" property="resourcePath"/>
<eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/>
</target>
<target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: com.ibm.wala.core.testdata.">
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<antcall target="build.jars"/>
<antcall target="build.sources"/>
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<antcall target="gather.sources">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<delete>
<fileset dir="${temp.folder}" includes="**/*.bin${logExtension}" />
</delete>
<zip destfile="${plugin.destination}/com.ibm.wala.core.testdata_1.0.0.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/>
<delete dir="${temp.folder}"/>
</target>
</project>

View File

@ -0,0 +1,229 @@
<cruisecontrol>
<!-- ************************************************************************** -->
<!-- ***************************** Basic configuration ************************ -->
<!-- ************************************************************************** -->
<system>
<configuration>
<threads count="2" />
</configuration>
</system>
<!-- ************************************************************************** -->
<!-- ************************* Meta-config (copy CC scripts) ****************** -->
<!-- ************************************************************************** -->
<!-- Meta-config
<project name="update-scripts" default="build" basedir="scripts/cruisescripts">
<modificationset quietperiod="10">
<cvs cvsroot=":ext:eyahav@cvs.cs.opensource.ibm.com:/cvsroot/safe/" module="cruisescripts" />
</modificationset>
<schedule interval="600">
<ant timeout="120" antscript="c:/devTools/apache-ant-1.6.5/bin/ant.bat"
buildfile="update-scripts.xml"
target="build" uselogger="true" usedebug="false"/>
</schedule>
</project>
-->
<!-- ************************************************************************** -->
<!-- *********************************** WALA ********************************* -->
<!-- ************************************************************************** -->
<project name="com.ibm.wala.core">
<listeners>
<currentbuildstatuslistener
file="logs/${project.name}/status.txt" />
</listeners>
<bootstrappers>
<svnbootstrapper
localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}" />
</modificationset>
<schedule interval="300">
<ant anthome="apache-ant-1.6.5"
buildfile="projects/${project.name}/build.xml"
target="build.update.jar" />
</schedule>
<log>
<merge dir="projects/${project.name}/output" />
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}"
dir="projects/${project.name}/output" />
</onsuccess>
<email spamwhilebroken="false"
buildresultsurl="http://nashira.watson.ibm.com:8001"
returnaddress="sjfink@us.ibm.com" mailhost="us.ibm.com">
<failure address="sjfink@us.ibm.com" />
</email>
</publishers>
</project>
<project name="com.ibm.wala.core.testdata">
<listeners>
<currentbuildstatuslistener
file="logs/${project.name}/status.txt" />
</listeners>
<bootstrappers>
<svnbootstrapper
localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}" />
</modificationset>
<schedule interval="300">
<ant anthome="apache-ant-1.6.5"
buildfile="projects/${project.name}/build.xml"
target="build.update.jar" />
</schedule>
<log>
<merge dir="projects/${project.name}/output" />
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}"
dir="projects/${project.name}/output" />
</onsuccess>
<email spamwhilebroken="false"
buildresultsurl="http://nashira.watson.ibm.com:8001"
returnaddress="sjfink@us.ibm.com" mailhost="us.ibm.com">
<failure address="sjfink@us.ibm.com" />
</email>
</publishers>
</project>
<project name="com.ibm.wala.core.tests">
<listeners>
<currentbuildstatuslistener
file="logs/${project.name}/status.txt" />
</listeners>
<bootstrappers>
<svnbootstrapper
localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}" />
</modificationset>
<schedule interval="300">
<ant anthome="apache-ant-1.6.5"
buildfile="projects/${project.name}/build.xml" target="buildAndRun" />
</schedule>
<log>
<merge dir="projects/${project.name}/output" />
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}"
dir="projects/${project.name}/output" />
</onsuccess>
<email spamwhilebroken="false"
buildresultsurl="http://nashira.watson.ibm.com:8001"
returnaddress="sjfink@us.ibm.com" mailhost="us.ibm.com">
<failure address="sjfink@us.ibm.com" />
</email>
</publishers>
</project>
<project name="com.ibm.wala.emf">
<listeners>
<currentbuildstatuslistener
file="logs/${project.name}/status.txt" />
</listeners>
<bootstrappers>
<svnbootstrapper
localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}" />
</modificationset>
<schedule interval="300">
<ant anthome="apache-ant-1.6.5"
buildfile="projects/${project.name}/build.xml"
target="build.update.jar" />
</schedule>
<log>
<merge dir="projects/${project.name}/output" />
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}"
dir="projects/${project.name}/output" />
</onsuccess>
<email spamwhilebroken="false"
buildresultsurl="http://nashira.watson.ibm.com:8001"
returnaddress="sjfink@us.ibm.com" mailhost="us.ibm.com">
<failure address="sjfink@us.ibm.com" />
</email>
</publishers>
</project>
<project name="com.ibm.wala.j2ee">
<listeners>
<currentbuildstatuslistener
file="logs/${project.name}/status.txt" />
</listeners>
<bootstrappers>
<svnbootstrapper
localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}" />
</modificationset>
<schedule interval="300">
<ant anthome="apache-ant-1.6.5"
buildfile="projects/${project.name}/build.xml"
target="build.update.jar" />
</schedule>
<log>
<merge dir="projects/${project.name}/output" />
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}"
dir="projects/${project.name}/output" />
</onsuccess>
<email spamwhilebroken="false"
buildresultsurl="http://nashira.watson.ibm.com:8001"
returnaddress="sjfink@us.ibm.com" mailhost="us.ibm.com">
<failure address="sjfink@us.ibm.com" />
</email>
</publishers>
</project>
<project name="com.ibm.wala.shrike">
<listeners>
<currentbuildstatuslistener
file="logs/${project.name}/status.txt" />
</listeners>
<bootstrappers>
<svnbootstrapper
localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}" />
</modificationset>
<schedule interval="300">
<ant anthome="apache-ant-1.6.5"
buildfile="projects/${project.name}/build.xml"
target="build.update.jar" />
</schedule>
<log>
<merge dir="projects/${project.name}/output" />
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}"
dir="projects/${project.name}/output" />
</onsuccess>
<email spamwhilebroken="false"
buildresultsurl="http://nashira.watson.ibm.com:8001"
returnaddress="sjfink@us.ibm.com" mailhost="us.ibm.com">
<failure address="sjfink@us.ibm.com" />
</email>
</publishers>
</project>
</cruisecontrol>

View File

@ -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;

View File

@ -0,0 +1,10 @@
package classConstant;
class ClassConstant {
public static void main(String args[]) {
Class x = ClassConstant.class;
x.hashCode();
}
}

View File

@ -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() {}
}

View File

@ -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() {}
}

View File

@ -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 {
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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 {
}

View File

@ -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");
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,7 @@
package slice;
class B extends A {
Object foo() {
return new Float(4);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}
}
}

View File

@ -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");
}
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="dat"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.wala.core.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -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

View File

@ -0,0 +1,3 @@
#Tue Oct 03 22:52:44 EDT 2006
eclipse.preferences.version=1
internal.default.compliance=default

View File

@ -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

View File

@ -0,0 +1,5 @@
source.. = src/,\
dat/
output.. = bin/
bin.includes = META-INF/,\
.

View File

@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.core.tests" default="build.jars" basedir=".">
<property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/>
<!-- Compiler settings. -->
<property name="javacFailOnError" value="false"/>
<property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/>
<property name="javacTarget" value="1.5"/>
<path id="path_bootclasspath">
<fileset dir="${java.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="buildAndRun" depends="build.update.jar,runtests">
</target>
<!--
===================================================================
Runs unit tests
===================================================================
-->
<target name="runtests" depends="build.update.jar" description="-> runs unit tests">
<!-- fork=true is required to enable assertions in the tests' JVM. -->
<junit fork="true" printsummary="yes" haltonerror="no" failureproperty="junit_test_failed">
<!-- Enable assertions - required by certain tests. -->
<jvmarg value="-ea" />
<jvmarg value="-Xmx1000M" />
<classpath>
<pathelement path="bin/"/>
<pathelement path="@dot/"/>
<pathelement path="../com.ibm.wala.core.testdata/bin/"/>
<pathelement path="../com.ibm.wala.core.testdata/@dot/"/>
<pathelement path="../com.ibm.wala.core/bin/"/>
<pathelement path="../com.ibm.wala.core/@dot"/>
<pathelement path="../com.ibm.wala.emf/bin/"/>
<pathelement path="../com.ibm.wala.emf/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime_3.2.0.v20060603.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.osgi_3.2.0.v20060601.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.jobs_3.2.0.v20060603.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/runtime_registry_compatibility.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/resolver.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xercesImpl.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xml-apis.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.contenttype_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.common_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.win32_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.update.configurator_3.2.0.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.variables_3.1.100.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.expressions_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore.xmi_2.2.0.v200606271057.jar"/>
<pathelement path="../com.ibm.wala.shrike/bin/"/>
<pathelement path="../com.ibm.wala.shrike/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jface_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt_3.2.0.v3232o.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232m.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.commands_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jdt.core_3.2.0.v_671.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.text_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/com.ibm.icu_3.4.4.1.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.team.core_3.2.0.I200606051140.jar"/>
<pathelement path="${eclipse.root}/plugins/org.junit_3.8.1/junit.jar"/>
</classpath>
<formatter type="xml" />
<batchtest todir="${basedir}/output" fork="true">
<fileset dir="${basedir}/src">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<fail if="junit_test_failed" message="One or more JUnit tests failed"/>
</target>
<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/>
</condition>
<property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.tests">
<isset property="buildTempFolder"/>
</condition>
<property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}/output"/>
<property name="eclipse.root" value="c:/eclipse"/>
</target>
<target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target>
<target name="build.update.jar" depends="init" description="Build the plug-in: com.ibm.wala.core.tests for an update site.">
<delete dir="@dot"/>
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<delete dir="${plugin.destination}"/>
<mkdir dir="${plugin.destination}"/>
<antcall target="build.jars"/>
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<zip destfile="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.jar" basedir="${temp.folder}/com.ibm.wala.core.tests_1.0.0" filesonly="false" whenempty="skip" update="false"/>
<delete dir="${temp.folder}"/>
</target>
<target name="@dot" depends="init" description="Create jar: com.ibm.wala.core.tests @dot.">
<delete dir="${temp.folder}/@dot.bin"/>
<mkdir dir="${temp.folder}/@dot.bin"/>
<path id="@dot.classpath">
<pathelement path="../com.ibm.wala.core/bin/"/>
<pathelement path="../com.ibm.wala.core/@dot"/>
<pathelement path="../com.ibm.wala.emf/bin/"/>
<pathelement path="../com.ibm.wala.emf/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.osgi_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.jobs_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/runtime_registry_compatibility.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/resolver.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xercesImpl.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xml-apis.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.contenttype_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.common_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.win32_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.update.configurator_3.2.0.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.variables_3.1.100.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.expressions_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore.xmi_2.2.0.v200606271057.jar"/>
<pathelement path="../com.ibm.wala.shrike/bin/"/>
<pathelement path="../com.ibm.wala.shrike/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jface_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt_3.2.0.v3232o.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232m.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.commands_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jdt.core_3.2.0.v_671.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.text_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/com.ibm.icu_3.4.4.1.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.team.core_3.2.0.I200606051140.jar"/>
<pathelement path="${eclipse.root}/plugins/org.junit_3.8.1/junit.jar"/>
</path>
<!-- compile the source code -->
<javac destdir="${temp.folder}/@dot.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" >
<compilerarg line="${compilerArg}" compiler="${build.compiler}"/>
<classpath refid="@dot.classpath" />
<src path="src/" />
<compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<compilerarg line="-log '${temp.folder}/@dot.bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</javac>
<!-- Copy necessary resources -->
<copy todir="${temp.folder}/@dot.bin" failonerror="true" overwrite="false">
<fileset dir="src/" excludes="**/*.java, **/package.htm*" />
<fileset dir="dat/" excludes="**/*.java, **/package.htm*" />
</copy>
<mkdir dir="${build.result.folder}"/>
<copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false">
<fileset dir="${temp.folder}/@dot.bin" />
</copy>
<delete dir="${temp.folder}/@dot.bin"/>
</target>
<target name="src.zip" depends="init" unless="src.zip">
<mkdir dir="${build.result.folder}"/>
<zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false">
<fileset dir="src/" includes="**/*.java" />
</zip>
</target>
<target name="build.jars" depends="init" description="Build all the jars for the plug-in: com.ibm.wala.core.tests.">
<available property="@dot" file="${build.result.folder}/@dot"/>
<antcall target="@dot"/>
</target>
<target name="build.sources" depends="init">
<available property="src.zip" file="${build.result.folder}/src.zip"/>
<antcall target="src.zip"/>
</target>
<target name="gather.bin.parts" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0"/>
<copy todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="true" overwrite="false">
<fileset dir="${build.result.folder}/@dot" includes="**" />
</copy>
<copy todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="true" overwrite="false">
<fileset dir="${basedir}" includes="META-INF/" />
</copy>
</target>
<target name="build.zips" depends="init">
</target>
<target name="gather.sources" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0"/>
<copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="false" overwrite="false"/>
</target>
<target name="gather.logs" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0"/>
<copy file="${temp.folder}/@dot.bin${logExtension}" todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="false" overwrite="false"/>
</target>
<target name="clean" depends="init" description="Clean the plug-in: com.ibm.wala.core.tests of all the zips, jars and logs created.">
<delete dir="${build.result.folder}/@dot"/>
<delete file="${build.result.folder}/src.zip"/>
<delete file="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.jar"/>
<delete file="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.zip"/>
<delete dir="${temp.folder}"/>
</target>
<target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder.">
<eclipse.convertPath fileSystemPath="C:/temp/walaWorkspace/com.ibm.wala.core.tests" property="resourcePath"/>
<eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/>
</target>
<target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: com.ibm.wala.core.tests.">
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<antcall target="build.jars"/>
<antcall target="build.sources"/>
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<antcall target="gather.sources">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<delete>
<fileset dir="${temp.folder}" includes="**/*.bin${logExtension}" />
</delete>
<zip destfile="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/>
<delete dir="${temp.folder}"/>
</target>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="dat"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.ibm.wala.core.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -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

View File

@ -0,0 +1,3 @@
#Tue Oct 03 22:52:44 EDT 2006
eclipse.preferences.version=1
internal.default.compliance=default

View File

@ -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

View File

@ -0,0 +1,5 @@
source.. = src/,\
dat/
output.. = bin/
bin.includes = META-INF/,\
.

View File

@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="com.ibm.wala.core.tests" default="build.jars" basedir=".">
<property name="basews" value="${ws}"/>
<property name="baseos" value="${os}"/>
<property name="basearch" value="${arch}"/>
<property name="basenl" value="${nl}"/>
<!-- Compiler settings. -->
<property name="javacFailOnError" value="false"/>
<property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="false"/>
<property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/>
<property name="javacSource" value="1.5"/>
<property name="javacTarget" value="1.5"/>
<path id="path_bootclasspath">
<fileset dir="${java.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/>
<target name="buildAndRun" depends="build.update.jar,runtests">
</target>
<!--
===================================================================
Runs unit tests
===================================================================
-->
<target name="runtests" depends="build.update.jar" description="-> runs unit tests">
<!-- fork=true is required to enable assertions in the tests' JVM. -->
<junit fork="true" printsummary="yes" haltonerror="no" failureproperty="junit_test_failed">
<!-- Enable assertions - required by certain tests. -->
<jvmarg value="-ea" />
<jvmarg value="-Xmx1000M" />
<classpath>
<pathelement path="bin/"/>
<pathelement path="@dot/"/>
<pathelement path="../com.ibm.wala.core.testdata/bin/"/>
<pathelement path="../com.ibm.wala.core.testdata/@dot/"/>
<pathelement path="../com.ibm.wala.core/bin/"/>
<pathelement path="../com.ibm.wala.core/@dot"/>
<pathelement path="../com.ibm.wala.emf/bin/"/>
<pathelement path="../com.ibm.wala.emf/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime_3.2.0.v20060603.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.osgi_3.2.0.v20060601.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.jobs_3.2.0.v20060603.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/runtime_registry_compatibility.jar" />
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/resolver.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xercesImpl.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xml-apis.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.contenttype_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.common_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.win32_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.update.configurator_3.2.0.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.variables_3.1.100.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.expressions_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore.xmi_2.2.0.v200606271057.jar"/>
<pathelement path="../com.ibm.wala.shrike/bin/"/>
<pathelement path="../com.ibm.wala.shrike/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jface_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt_3.2.0.v3232o.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232m.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.commands_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jdt.core_3.2.0.v_671.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.text_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/com.ibm.icu_3.4.4.1.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.team.core_3.2.0.I200606051140.jar"/>
<pathelement path="${eclipse.root}/plugins/org.junit_3.8.1/junit.jar"/>
</classpath>
<formatter type="xml" />
<batchtest todir="${basedir}/output" fork="true">
<fileset dir="${basedir}/src">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<fail if="junit_test_failed" message="One or more JUnit tests failed"/>
</target>
<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
<isset property="buildTempFolder"/>
</condition>
<property name="pluginTemp" value="${basedir}"/>
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.tests">
<isset property="buildTempFolder"/>
</condition>
<property name="build.result.folder" value="${basedir}"/>
<property name="temp.folder" value="${basedir}/temp.folder"/>
<property name="plugin.destination" value="${basedir}/output"/>
<property name="eclipse.root" value="c:/eclipse"/>
</target>
<target name="properties" if="eclipse.running">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</target>
<target name="build.update.jar" depends="init" description="Build the plug-in: com.ibm.wala.core.tests for an update site.">
<delete dir="@dot"/>
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<delete dir="${plugin.destination}"/>
<mkdir dir="${plugin.destination}"/>
<antcall target="build.jars"/>
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<zip destfile="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.jar" basedir="${temp.folder}/com.ibm.wala.core.tests_1.0.0" filesonly="false" whenempty="skip" update="false"/>
<delete dir="${temp.folder}"/>
</target>
<target name="@dot" depends="init" description="Create jar: com.ibm.wala.core.tests @dot.">
<delete dir="${temp.folder}/@dot.bin"/>
<mkdir dir="${temp.folder}/@dot.bin"/>
<path id="@dot.classpath">
<pathelement path="../com.ibm.wala.core/bin/"/>
<pathelement path="../com.ibm.wala.core/@dot"/>
<pathelement path="../com.ibm.wala.emf/bin/"/>
<pathelement path="../com.ibm.wala.emf/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.osgi_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.common_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.jobs_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/runtime_registry_compatibility.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/resolver.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xercesImpl.jar"/>
<pathelement path="${eclipse.root}/plugins/org.apache.xerces_2.8.0.v200606131651/xml-apis.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060603/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.contenttype_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.common_2.2.0.v200606271057.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.resources.win32_3.2.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.update.configurator_3.2.0.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.variables_3.1.100.v20060605.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.expressions_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060603.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.emf.ecore.xmi_2.2.0.v200606271057.jar"/>
<pathelement path="../com.ibm.wala.shrike/bin/"/>
<pathelement path="../com.ibm.wala.shrike/@dot"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jface_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt_3.2.0.v3232o.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232m.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.core.commands_3.2.0.I20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.jdt.core_3.2.0.v_671.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.text_3.2.0.v20060605-1400.jar"/>
<pathelement path="${eclipse.root}/plugins/com.ibm.icu_3.4.4.1.jar"/>
<pathelement path="${eclipse.root}/plugins/org.eclipse.team.core_3.2.0.I200606051140.jar"/>
<pathelement path="${eclipse.root}/plugins/org.junit_3.8.1/junit.jar"/>
</path>
<!-- compile the source code -->
<javac destdir="${temp.folder}/@dot.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" >
<compilerarg line="${compilerArg}" compiler="${build.compiler}"/>
<classpath refid="@dot.classpath" />
<src path="src/" />
<compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<compilerarg line="-log '${temp.folder}/@dot.bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</javac>
<!-- Copy necessary resources -->
<copy todir="${temp.folder}/@dot.bin" failonerror="true" overwrite="false">
<fileset dir="src/" excludes="**/*.java, **/package.htm*" />
<fileset dir="dat/" excludes="**/*.java, **/package.htm*" />
</copy>
<mkdir dir="${build.result.folder}"/>
<copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false">
<fileset dir="${temp.folder}/@dot.bin" />
</copy>
<delete dir="${temp.folder}/@dot.bin"/>
</target>
<target name="src.zip" depends="init" unless="src.zip">
<mkdir dir="${build.result.folder}"/>
<zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false">
<fileset dir="src/" includes="**/*.java" />
</zip>
</target>
<target name="build.jars" depends="init" description="Build all the jars for the plug-in: com.ibm.wala.core.tests.">
<available property="@dot" file="${build.result.folder}/@dot"/>
<antcall target="@dot"/>
</target>
<target name="build.sources" depends="init">
<available property="src.zip" file="${build.result.folder}/src.zip"/>
<antcall target="src.zip"/>
</target>
<target name="gather.bin.parts" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0"/>
<copy todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="true" overwrite="false">
<fileset dir="${build.result.folder}/@dot" includes="**" />
</copy>
<copy todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="true" overwrite="false">
<fileset dir="${basedir}" includes="META-INF/" />
</copy>
</target>
<target name="build.zips" depends="init">
</target>
<target name="gather.sources" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0"/>
<copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="false" overwrite="false"/>
</target>
<target name="gather.logs" depends="init" if="destination.temp.folder">
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0"/>
<copy file="${temp.folder}/@dot.bin${logExtension}" todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.0.0" failonerror="false" overwrite="false"/>
</target>
<target name="clean" depends="init" description="Clean the plug-in: com.ibm.wala.core.tests of all the zips, jars and logs created.">
<delete dir="${build.result.folder}/@dot"/>
<delete file="${build.result.folder}/src.zip"/>
<delete file="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.jar"/>
<delete file="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.zip"/>
<delete dir="${temp.folder}"/>
</target>
<target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder.">
<eclipse.convertPath fileSystemPath="C:/temp/walaWorkspace/com.ibm.wala.core.tests" property="resourcePath"/>
<eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/>
</target>
<target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: com.ibm.wala.core.tests.">
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}"/>
<antcall target="build.jars"/>
<antcall target="build.sources"/>
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<antcall target="gather.sources">
<param name="destination.temp.folder" value="${temp.folder}/"/>
</antcall>
<delete>
<fileset dir="${temp.folder}" includes="**/*.bin${logExtension}" />
</delete>
<zip destfile="${plugin.destination}/com.ibm.wala.core.tests_1.0.0.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/>
<delete dir="${temp.folder}"/>
</target>
</project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="ASCII"?>
<com.ibm.wala.common:EContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:com.ibm.wala.common="http:///com/ibm/wala/wala.ecore.common" xmlns:com.ibm.wala.regex="http:///com/ibm/wala/wala.ecore.regex">
<contents xsi:type="com.ibm.wala.regex:EPattern" pattern="java\/awt\/.*"/>
</com.ibm.wala.common:EContainer>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.wala.java.scope:EJavaAnalysisScope xmlns:com.ibm.wala.java.scope="http:///com/ibm/wala/wala.ecore.java.scope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<loaders loaderName="Primordial">
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule"/>
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule" id="primordial_jar_model"/>
</loaders>
<loaders loaderName="Application">
<modules url="JLex.jar" xsi:type="com.ibm.wala.java.scope:EJarFile"/>
</loaders>
</com.ibm.wala.java.scope:EJavaAnalysisScope>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.wala.java.scope:EJavaAnalysisScope xmlns:com.ibm.wala.java.scope="http:///com/ibm/wala/wala.ecore.java.scope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<loaders loaderName="Primordial">
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule"/>
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule" id="primordial_jar_model"/>
</loaders>
<loaders loaderName="Application">
<modules url="bcel-5.2.jar" xsi:type="com.ibm.wala.java.scope:EJarFile"/>
</loaders>
</com.ibm.wala.java.scope:EJavaAnalysisScope>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.wala.java.scope:EJavaAnalysisScope xmlns:com.ibm.wala.java.scope="http:///com/ibm/wala/wala.ecore.java.scope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<loaders loaderName="Primordial">
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule"/>
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule" id="primordial_jar_model"/>
</loaders>
<loaders loaderName="Application">
<modules url="hello/Hello.class" xsi:type="com.ibm.wala.java.scope:EClassFile"/>
<modules url="hello/Hello.java" xsi:type="com.ibm.wala.java.scope:ESourceFile"/>
</loaders>
</com.ibm.wala.java.scope:EJavaAnalysisScope>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.wala.java.scope:EJavaAnalysisScope xmlns:com.ibm.wala.java.scope="http:///com/ibm/wala/wala.ecore.java.scope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<loaders loaderName="Primordial">
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule"/>
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule" id="primordial_jar_model"/>
</loaders>
<loaders loaderName="Application">
<modules url="java-cup-11a.jar" xsi:type="com.ibm.wala.java.scope:EJarFile"/>
</loaders>
</com.ibm.wala.java.scope:EJavaAnalysisScope>

View File

@ -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

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.wala.java.scope:EJavaAnalysisScope xmlns:com.ibm.wala.java.scope="http:///com/ibm/wala/wala.ecore.java.scope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<loaders loaderName="Primordial">
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule"/>
<modules xsi:type="com.ibm.wala.java.scope:EBuiltInModule" id="primordial_jar_model"/>
</loaders>
<loaders loaderName="Application">
<modules url="com.ibm.wala.core.testdata_1.0.0.jar" xsi:type="com.ibm.wala.java.scope:EJarFile"/>
</loaders>
</com.ibm.wala.java.scope:EJavaAnalysisScope>

View File

@ -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/*;?**/*]

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.ExportCallGraphToXML"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar c:/temp/testdata/java_cup.jar"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.ExportTypeHierarchyToXML"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-classpath c:/temp/testdata/JLex.jar"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.GVCallGraph"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar c:/temp/testdata/java_cup.jar"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.GVControlDependenceGraph"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar c:/temp/walaWorkspace/com.ibm.wala.core.testdata/bin/com.ibm.wala.core.testdata_1.0.0.jar -sig slice.TestCD3.main([Ljava/lang/String;)V"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx200M -verbose:gc"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.GVSDG"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar &quot;c:/temp/walaWorkspace/com.ibm.wala.core.testdata/bin/com.ibm.wala.core.testdata_1.0.0.jar&quot; -mainClass &quot;Lslice/Slice4&quot; -srcCaller &quot;main&quot; -srcCallee &quot;foo&quot; -dd &quot;no_base_no_heap&quot; -cd &quot;none&quot; -dir &quot;forward&quot;"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.GVSlice"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar &quot;c:/temp/walaWorkspace/com.ibm.wala.core.testdata/bin/com.ibm.wala.core.testdata_1.0.0.jar&quot; -mainClass &quot;Lslice/Slice4&quot; -srcCaller &quot;main&quot; -srcCallee &quot;foo&quot; -dd &quot;no_base_no_heap&quot; -cd &quot;none&quot; -dir &quot;forward&quot;"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M -Dcom.ibm.wala.tracefile=c:/temp/domotrace.txt -ea"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.GVTypeHierarchy"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-classpath c:/temp/testdata/java_cup.jar"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.GVWalaIR"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar c:/temp/testdata/SPECjvm98.jar -sig sun.awt.font.AdvanceCache.&lt;clinit&gt;()V"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx200M -verbose:gc"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.GetEnv"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.pde.ui.swtLaunchConfig">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.SWTCallGraph"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar c:/temp/testdata/java_cup.jar"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M -verbose:gc"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.pde.ui.swtLaunchConfig">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.SWTPointsTo"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-appJar c:/temp/testdata/java_cup.jar"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M -verbose:gc"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.pde.ui.swtLaunchConfig">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.drivers.SWTTypeHierarchy"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.examples.analysis.SimpleThreadEscapeAnalysis"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="LJLex/Main c:/temp/testdata/JLex.jar"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.core.tests.slicer.SlicerTest"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M -Dcom.ibm.wala.tracefile=c:/temp/domotrace.txt -ea"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="c:/temp/console"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;slicer&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#13;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;slicer&quot;/&gt;&#13;&#10;&lt;/runtimeClasspathEntry&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;com.ibm.wala.core.testdata&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.ibm.wala.core.tests"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
</launchConfiguration>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;com.ibm.wala.core.tests&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#13;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;com.ibm.wala.core.tests&quot;/&gt;&#13;&#10;&lt;/runtimeClasspathEntry&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;com.ibm.wala.core.testdata&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M -verbose:gc -Dcom.ibm.wala.junit.profile=short"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.core.tests"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
</launchConfiguration>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;com.ibm.wala.core.tests&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#13;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;com.ibm.wala.core.tests&quot;/&gt;&#13;&#10;&lt;/runtimeClasspathEntry&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;com.ibm.wala.core.testdata&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx500M -verbose:gc"/>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.core.tests"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
</launchConfiguration>

View File

@ -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<String> 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<String> 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<String> buildGraph() {
Graph<String> G = new SlowSparseNumberedGraph<String>();
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<String> G) {
final OrdinalSetMapping<String> values = new MutableMapping<String>(nodes);
ITransferFunctionProvider<String> functions = new ITransferFunctionProvider<String>() {
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<String,String> F = new BitVectorFramework<String,String>(G, functions, values);
DataflowSolver<String> s = new BitVectorSolver<String>(F);
s.solve();
return result2String(s);
}
private String solveNodeEdge(Graph<String> G) {
final OrdinalSetMapping<String> values = new MutableMapping<String>(nodes);
ITransferFunctionProvider<String> functions = new ITransferFunctionProvider<String>() {
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<String,String> F = new BitVectorFramework<String,String>(G, functions, values);
DataflowSolver<String> s = new BitVectorSolver<String>(F);
s.solve();
return result2String(s);
}
public static String result2String(DataflowSolver<String> 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();
}
}

View File

@ -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<Integer,Integer> M = new SmallMap<Integer,Integer>();
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<Integer, Integer> M = new BimodalMap<Integer, Integer>(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<Integer> G = makeBFSTestGraph();
// path from 0 to 8
BFSPathFinder<Integer> pf = new BFSPathFinder<Integer>(G, G.getNode(0), G.getNode(8));
List<Integer> 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<Integer> G = makeBFSTestGraph();
BoundedBFSIterator<Integer> bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 0);
Collection<Integer> c = new Iterator2Collection<Integer>(bfs);
assertTrue(c.size() == 1);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 1);
c = new Iterator2Collection<Integer>(bfs);
assertTrue(c.size() == 3);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 2);
c = new Iterator2Collection<Integer>(bfs);
assertTrue(c.size() == 5);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 3);
c = new Iterator2Collection<Integer>(bfs);
assertTrue(c.size() == 7);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 4);
c = new Iterator2Collection<Integer>(bfs);
assertTrue(c.size() == 9);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 5);
c = new Iterator2Collection<Integer>(bfs);
assertTrue(c.size() == 10);
bfs = new BoundedBFSIterator<Integer>(G, G.getNode(0), 500);
c = new Iterator2Collection<Integer>(bfs);
assertTrue(c.size() == 10);
}
private NumberedGraph<Integer> makeBFSTestGraph() {
// test graph
NumberedGraph<Integer> G = new SlowSparseNumberedGraph<Integer>();
// 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<Object> G = new SlowSparseNumberedGraph<Object>();
// 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<Object> D = new Dominators<Object>(G, nodes[10]);
// assertions
int i = 0;
Object[] desired4 = new Object[] { nodes[4], nodes[7], nodes[8], nodes[5], nodes[10] };
for (Iterator<Object> 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<IntPair> 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<Integer> s = new HashSet<Integer>();
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);
}
}

View File

@ -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<MethodReference> 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<MethodReference> 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<MethodReference> 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<MethodReference> 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<CGNode> 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<EObject> nodeDiff = Util.setify(subG.iterateNodes());
nodeDiff.removeAll(Util.setify(superG.iterateNodes()));
Set<EObject> toRemove = HashSetFactory.make();
for (Iterator<EObject> 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<EObject> 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<EObject> it = nodeDiff.iterator(); it.hasNext();) {
Trace.println(it.next().toString());
}
Assertions.productionAssertion(nodeDiff.isEmpty(), "bad superset, see tracefile\n");
}
}
/**
* <ul>
* <li>remove all methods from G that correspond to synthetic methods
* <li>remove all nodes from G that are no longer reachable from the fake
* root.
* <ul>
*
* @param G
* an EMF format call graph
* @param synthetic
* a set of synthetic methods
*/
private static void prune(ECallGraphWrapper G, Set<CGNode> synthetic) {
// compute synthetic nodes
Set<EObject> toRemove = HashSetFactory.make();
for (Iterator<CGNode> 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<EObject> 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<EObject> toRemove) {
// remove all these nodes
for (Iterator<EObject> it = toRemove.iterator(); it.hasNext();) {
EObject n = it.next();
if (G.containsNode(n)) {
G.removeNodeAndEdges(n);
}
}
}
/**
* @param cg
* @return Set <CGNode>in cg that are synthetic and have no call sites
*/
private static Set<CGNode> getSyntheticLeaves(CallGraph cg) {
HashSet<CGNode> 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<MethodReference> checkCallGraph(WarningSet warnings, CallGraph cg, Graph<MethodReference> superCG,
Set<MethodReference> superMethods, String thisAlgorithm) {
try {
GraphIntegrity.check(cg);
} catch (UnsoundGraphException e1) {
assertTrue(e1.getMessage(), false);
}
Set<MethodReference> 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<MethodReference> 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<MethodReference> temp = HashSetFactory.make();
temp.addAll(callGraphMethods);
temp.removeAll(superMethods);
Trace.printCollection("Violations", temp);
Assertions.UNREACHABLE();
}
}
return thisCG;
}
}

View File

@ -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;
}
}

View File

@ -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<CGNode> 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<CGNode> hashCodeNodes = cg.getNodes(hashCodeRef);
Assert.assertFalse(hashCodeNodes.isEmpty());
// make sure call to hashCode from main
Assert.assertTrue(cg.hasEdge(mainMethodNode, hashCodeNodes.iterator().next()));
}
}

View File

@ -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<CallSiteReference> i = node.iterateSites(); i.hasNext();) {
CallSiteReference site = (CallSiteReference) i.next();
if (site.isSpecial()) {
if (site.getDeclaredTarget().getDeclaringClass().equals(TypeReference.JavaLangObject)) {
Set<CGNode> targets = node.getPossibleTargets(site);
if (targets.size() != 1) {
System.err.println(targets.size() + " targets found for " + site);
for (Iterator<CGNode> k = targets.iterator(); k.hasNext();) {
System.err.println(" " + k.next());
}
fail("found " + targets.size() + " targets for " + site + " in " + node);
}
}
}
}
}
}

View File

@ -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 <jar file name>
*
* 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<BasicBlock> 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<Object> clabels = cdg.getEdgeLabels(cdgbb, ibb);
Set<? extends Object> blabels = bv.getEdgeLabels(cdgbb, ibb);
Iterator<Object> 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<Object> clabels = cdg.getEdgeLabels(ibb, cdgbb);
Set<? extends Object> blabels = bv.getEdgeLabels(ibb, cdgbb);
Iterator<Object> 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<SSACFG.BasicBlock> seen = new Vector<SSACFG.BasicBlock>();
SSACFG.BasicBlock entry = (SSACFG.BasicBlock) cfg.entry();
Vector<SSACFG.BasicBlock> worklist = new Vector<SSACFG.BasicBlock>();
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<Object> labels = cdg.getEdgeLabels(cdgbb, ibb);
Iterator<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<? 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<SSACFG.BasicBlock> seen = new Vector<SSACFG.BasicBlock>();
SSACFG.BasicBlock entry = (SSACFG.BasicBlock) cfg.entry();
Vector<SSACFG.BasicBlock> worklist = new Vector<SSACFG.BasicBlock>();
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<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 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;
* i<vec.size() ; i++ ) { Object o = vec.get(i); if (
* cdg.getSuccNodeCount(o)>0 ) { found = true; break; } } if ( !found )
* continue;
*
* Trace.println(mref+" has "+vec.size()+ " blocks with no predecessors"); for (
* int i=0 ; i<vec.size() ; i++ ) { SSACFG.BasicBlock bb =
* (SSACFG.BasicBlock)vec.get(i); Trace.println("\t"+dumpIBB(bb, cfg)); }
*
* String dotFile = "tmp.dot"; String psFile = ""+mref.getName()+count+".ps";
* try { DotUtil.dotify(cdg, null, dotFile, psFile, dotExe); } catch
* (WalaException e) { e.printStackTrace(); } } } } }
*/
private static Vector<BasicBlock> checkCFG(SSACFG cfg, MethodReference mref) {
Vector<SSACFG.BasicBlock> vec = new Vector<SSACFG.BasicBlock>();
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<vec.size() ; i++ ) { SSACFG.BasicBlock bb =
* (SSACFG.BasicBlock)vec.get(i); Trace.println("\t"+dumpIBB(bb, cfg)); }
*/
return vec;
}
return null;
}
/*
* private static String dumpIBB ( SSACFG.BasicBlock ibb, SSACFG ssaCfg ) {
* int number = ibb.getNumber(); String ret = ""; ret += "BB ID:"+number +
* "::" + ibb; Iterator succ = ssaCfg.getSuccNodes(ibb); ret += " (SUCC=";
* while (succ.hasNext()) { SSACFG.BasicBlock isc = (SSACFG.BasicBlock)
* succ.next(); ret += "" + isc.getNumber()+", "; } ret += ")";
*
* Iterator pred = ssaCfg.getPredNodes(ibb); ret += " (PRED="; while
* (pred.hasNext()) { SSACFG.BasicBlock isc = (SSACFG.BasicBlock) pred.next();
* ret += "" + isc.getNumber()+", "; } ret += ") {\n";
*
* Iterator it = ibb.iterateAllInstructions(); int j = 0; while (it.hasNext()) {
* SSAInstruction inst = (SSAInstruction) it.next(); if ( inst != null ) { ret +=
* "\t\t"+ j++ + ":" + inst.toString() + "\n"; } } ret += "\t}\n"; return ret; }
*/
/**
* @param appJar
* something like "c:/temp/testdata/java_cup.jar"
* @return a call graph
* @throws WalaException
* @throws ClassHierarchyException
*/
public static CallGraph buildCallGraphCommandLine(String appJar) throws WalaException, ClassHierarchyException {
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
// 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
// //
CFABuilder builder = Util.makeZeroCFABuilder(options, cha, scope, warnings, null, null);
CallGraph cg = builder.makeCallGraph(options);
return cg;
}
public void testJavaCup() 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);
run(CallGraphTestUtil.buildZeroCFA(options, cha, scope, warnings));
}
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);
run(CallGraphTestUtil.buildZeroCFA(options, cha, scope, warnings));
}
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);
run(CallGraphTestUtil.buildZeroCFA(options, cha, scope, warnings));
}
}

View File

@ -0,0 +1,65 @@
/*******************************************************************************
* 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 com.ibm.wala.core.tests.util.WalaTestCase;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.util.intset.BimodalMutableIntSetFactory;
import com.ibm.wala.util.intset.BitVectorIntSetFactory;
import com.ibm.wala.util.intset.DebuggingMutableIntSetFactory;
import com.ibm.wala.util.intset.IntSetUtil;
import com.ibm.wala.util.intset.MutableIntSetFactory;
import com.ibm.wala.util.intset.MutableSharedBitVectorIntSetFactory;
import com.ibm.wala.util.intset.MutableSparseIntSetFactory;
/**
*
* Run the call graph only test with paranoid debugging bit vectors
*
* @author Julian Dolby
*/
public class DebuggingBitsetCallGraphTest extends WalaTestCase {
public static void main(String[] args) {
justThisTest(DebuggingBitsetCallGraphTest.class);
}
private final CallGraphTest graphTest;
public DebuggingBitsetCallGraphTest(String arg0) {
super(arg0);
graphTest = new CallGraphTest(arg0);
}
private void runBitsetTest(MutableIntSetFactory p, MutableIntSetFactory s) throws ClassHierarchyException {
MutableIntSetFactory save = IntSetUtil.getDefaultIntSetFactory();
IntSetUtil.setDefaultIntSetFactory(new DebuggingMutableIntSetFactory(p, s));
graphTest.testJLex();
IntSetUtil.setDefaultIntSetFactory(save);
}
public void testBimodalSparse() throws ClassHierarchyException {
runBitsetTest(new BimodalMutableIntSetFactory(), new MutableSparseIntSetFactory());
}
public void testSharedBimodal() throws ClassHierarchyException {
runBitsetTest(new MutableSharedBitVectorIntSetFactory(), new BimodalMutableIntSetFactory());
}
public void testSharedSparse() throws ClassHierarchyException {
runBitsetTest(new MutableSharedBitVectorIntSetFactory(), new MutableSparseIntSetFactory());
}
public void testSharedBitVector() throws ClassHierarchyException {
runBitsetTest(new MutableSharedBitVectorIntSetFactory(), new BitVectorIntSetFactory());
}
}

View File

@ -0,0 +1,48 @@
/*******************************************************************************
* 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 com.ibm.wala.core.tests.util.WalaTestCase;
import com.ibm.wala.ecore.java.impl.JavaPackageImpl;
import com.ibm.wala.util.warnings.WalaException;
/**
*
* Tests for Call Graph construction
*
* @author sfink
*/
public class EclipseCallGraphTest extends WalaTestCase {
static {
JavaPackageImpl.init();
}
public static void main(String[] args) {
justThisTest(EclipseCallGraphTest.class);
}
public void testOrgEclipseCoreResources() throws WalaException {
// not ready yet .. SJF
// EclipseAnalysisScope scope = new EclipseAnalysisScope("org.eclipse.core.resources");
// WarningSet warnings = new WarningSet();
// ClassHierarchy cha = ClassHierarchy.make(scope, warnings);
// Entrypoints entrypoints = new EclipseEntrypoints(scope, cha, false);
// AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
//
// Trace.println("org.eclipse.core.resources set up warnings:\n");
// Trace.print(warnings.toString());
//
// CallGraphTest.doCallGraphs(options, cha, scope, null, true, true);
}
}

View File

@ -0,0 +1,115 @@
/*******************************************************************************
* 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.ecore.java.impl.JavaPackageImpl;
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.cha.ClassHierarchy;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.Atom;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.warnings.WarningSet;
/**
* @author Julian Dolby
*
*/
public class PiNodeCallGraphTest extends WalaTestCase {
static {
JavaPackageImpl.init();
}
public static void main(String[] args) {
justThisTest(PiNodeCallGraphTest.class);
}
private static final String whateverName = TestConstants.PI_TEST_MAIN + "$Whatever";
private static final String thisName = TestConstants.PI_TEST_MAIN + "$This";
private static final String thatName = TestConstants.PI_TEST_MAIN + "$That";
private static final ClassLoaderReference loader = new ClassLoaderReference(Atom.findOrCreateUnicodeAtom("Application"));
private static final TypeReference whateverRef = TypeReference.findOrCreate(loader, TypeName.string2TypeName(whateverName));
private static final TypeReference thisRef = TypeReference.findOrCreate(loader, TypeName.string2TypeName(thisName));
private static final TypeReference thatRef = TypeReference.findOrCreate(loader, TypeName.string2TypeName(thatName));
private static final MethodReference thisBinaryRef = MethodReference.findOrCreate(thisRef,
Atom.findOrCreateUnicodeAtom("binary"), Descriptor.findOrCreateUTF8("(" + whateverName + ";)V"));
private static final MethodReference thatBinaryRef = MethodReference.findOrCreate(thatRef,
Atom.findOrCreateUnicodeAtom("binary"), Descriptor.findOrCreateUTF8("(" + whateverName + ";)V"));
private static final MethodReference unary2Ref = MethodReference.findOrCreate(whateverRef,
Atom.findOrCreateUnicodeAtom("unary2"), Descriptor.findOrCreateUTF8("()V"));
private CallGraph doGraph(boolean usePiNodes) 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.PI_TEST_MAIN);
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
options.getSSAOptions().setUsePiNodes(usePiNodes);
warnings = new WarningSet();
return CallGraphTestUtil.buildZeroCFA(options, cha, scope, warnings);
}
private void checkCallAssertions(CallGraph cg, int desiredNumberOfTargets, int desiredNumberOfCalls) {
int numberOfCalls = 0;
Set<CGNode> callerNodes = HashSetFactory.make();
callerNodes.addAll(cg.getNodes(thisBinaryRef));
callerNodes.addAll(cg.getNodes(thatBinaryRef));
Assertions._assert(callerNodes.size() == 2);
for (Iterator<CGNode> nodes = callerNodes.iterator(); nodes.hasNext();) {
CGNode n = (CGNode) nodes.next();
for (Iterator<CallSiteReference> 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);
}
}

View File

@ -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<Warning> it = warnings.iterator(); it.hasNext(); ) {
Warning w = (Warning)it.next();
if (w.toString().indexOf("com/ibm/jvm") > 0) {
continue;
}
assertTrue(w.toString(), false);
}
}
}

View File

@ -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<EObject> persist = new LinkedList<EObject>();
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<IClass> it = cha.iterateAllClasses(); it.hasNext();) {
IClass klass = (IClass) it.next();
if (!klass.isInterface()) {
EJavaClass eKlass = EMFBridge.makeJavaClass(klass.getReference());
HashSet<EJavaClass> impls = new HashSet<EJavaClass>(5);
for (Iterator<IClass> it2 = klass.getDirectInterfaces().iterator(); it2.hasNext();) {
IClass iface = (IClass) it2.next();
impls.add(EMFBridge.makeJavaClass(iface.getReference()));
}
Collection<EJavaClass> c = T.getImplements(eKlass);
checkSetsEqual(impls, c);
}
}
} catch (ClassHierarchyException e) {
e.printStackTrace();
Assertions.UNREACHABLE();
}
}
private void checkSetsEqual(Collection<EJavaClass> c1, Collection<EJavaClass> 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;
}
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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;");
}
}

View File

@ -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());
}
}

View File

@ -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"));
}
}

View File

@ -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<InstanceKey> 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;
}
}

View File

@ -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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> 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<Statement> slice) {
dumpSlice(slice,new PrintWriter(System.err));
}
public static void dumpSlice(Collection<Statement> 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<Statement> 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<SSAInstruction> 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");
}
}

View File

@ -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";
}

View File

@ -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);
}
}

View File

@ -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.*;
/**
* <P>
* 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.
* </P>
*
* <P>
* 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.
* <UL>
* <LI> The object is stored into a static variable.
* <LI> The object is stored into an instance field of a Thread
* <LI> The object is reachable from a field of another escaping object.
* </UL>
* </P>
*
* <P>
* This observation is implemented in the obvious way:
* <OL>
* <LI> All static fields are collected
* <LI> All Thread constructor parameters are collected
* <LI> The points-to sets of these values represent the base set of escapees.
* <LI> All object reachable from fields of these objects are added
* <LI> This process continues until a fixpoint is reached
* <LI> The abstract objects in the points-to sets are converted to types
* <LI> This set of types is returned
* </OL></P>
*
* @author Julian Dolby
*/
public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
private final Set<JarFile> 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<JarFile> 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<JarFile> 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<JarFile> 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<JarFileModule> getModuleFiles() {
Set<JarFileModule> result = HashSetFactory.make();
for (Iterator<JarFile> jars = applicationJarFiles.iterator(); jars.hasNext();) {
result.add(new JarFileModule(jars.next()));
}
return result;
}
/**
* The heart of the analysis.
*/
public Set<IClass> 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<PointerKey> escapeAnalysisRoots = HashSetFactory.make();
HeapModel heapModel = pa.getHeapModel();
// 1) static fields
for (Iterator<IClass> clss = cha.iterateAllClasses(); clss.hasNext();) {
IClass cls = (IClass) clss.next();
Collection<IField> staticFields = cls.getDeclaredStaticFields();
for (Iterator<IField> 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<IClass> threads = cha.computeSubClasses(TypeReference.JavaLangThread);
for (Iterator<IClass>clss = threads.iterator(); clss.hasNext();) {
IClass cls = (IClass) clss.next();
for (Iterator<IMethod> ms = cls.getDeclaredMethods(); ms.hasNext();) {
IMethod m = (IMethod) ms.next();
if (m.isInit()) {
Set<CGNode> nodes = cg.getNodes(m.getReference());
for (Iterator<CGNode> 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<InstanceKey> escapingInstanceKeys = HashSetFactory.make();
//
// pass 1: get abstract objects (instance keys) for escaping locations
//
for (Iterator<PointerKey> rts = escapeAnalysisRoots.iterator(); rts.hasNext();) {
PointerKey root = rts.next();
OrdinalSet<InstanceKey> objects = pa.getPointsToSet(root);
for (Iterator<InstanceKey> 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<InstanceKey> newKeys = HashSetFactory.make();
do {
newKeys.clear();
for (Iterator<InstanceKey> 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<InstanceKey> fobjects = pa.getPointsToSet(fk);
for (Iterator<InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
InstanceKey fobj = (InstanceKey) fobjs.next();
if (!escapingInstanceKeys.contains(fobj)) {
newKeys.add(fobj);
}
}
}
} else {
Collection<IField> fields = type.getAllInstanceFields();
for (Iterator<IField> fs = fields.iterator(); fs.hasNext();) {
IField f = (IField) fs.next();
if (f.getFieldTypeReference().isReferenceType()) {
PointerKey fk = heapModel.getPointerKeyForInstanceField(key, f);
OrdinalSet<InstanceKey> fobjects = pa.getPointsToSet(fk);
for (Iterator<InstanceKey> 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<IClass> escapingTypes = HashSetFactory.make();
for (Iterator<InstanceKey> 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<JarFile> jars = HashSetFactory.make();
for (int i = 1; i < args.length; i++) {
jars.add(new JarFile(args[i]));
}
Set<IClass> escapingTypes = (new SimpleThreadEscapeAnalysis(jars, mainClassName)).gatherThreadEscapingClasses();
for (Iterator<IClass> types = escapingTypes.iterator(); types.hasNext();) {
System.out.println(types.next().getName().toString());
}
}
}

View File

@ -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<EObject> 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<EObject>(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<EJavaMethod> 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<EJavaMethod> 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:
* <ul>
* <li> args[0] : "-appJar"
* <li> args[1] : something like "c:/temp/testdata/java_cup.jar" </ul?
*
* @param args
* @throws UnsupportedOperationException
* if command-line is malformed.
*/
static void validateCommandLine(String[] args) {
if (args.length != 2) {
throw new UnsupportedOperationException("must have at exactly 2 command-line arguments");
}
if (!args[0].equals("-appJar")) {
throw new UnsupportedOperationException("invalid command-line, args[0] should be -appJar, but is " + args[0]);
}
}
}

Some files were not shown because too many files have changed in this diff Show More