Merge branch 'wala' into master
This commit is contained in:
commit
efb729e038
|
@ -29,6 +29,8 @@ public class Util {
|
|||
}
|
||||
}
|
||||
}
|
||||
// clear out the errors to free some memory
|
||||
((CAstAbstractLoader)loader).clearMessages();
|
||||
}
|
||||
}
|
||||
if (message != null) {
|
||||
|
@ -36,5 +38,6 @@ public class Util {
|
|||
}
|
||||
Assert.assertTrue(String.valueOf(message), message == null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -92,6 +92,11 @@ public abstract class CAstAbstractLoader implements IClassLoader {
|
|||
return errors.get(m);
|
||||
}
|
||||
|
||||
|
||||
public void clearMessages() {
|
||||
errors.clear();
|
||||
}
|
||||
|
||||
public IClass lookupClass(String className, IClassHierarchy cha) {
|
||||
assert this.cha == cha;
|
||||
return (IClass) types.get(TypeName.string2TypeName(className));
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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 demandpa;
|
||||
|
||||
/**
|
||||
* doesn't actually work; just for testing pointer analysis
|
||||
*/
|
||||
public class DummyHashMap {
|
||||
|
||||
Object[] keys = new Object[10];
|
||||
|
||||
Object[] values = new Object[10];
|
||||
|
||||
public void put(Object object, Object object2) {
|
||||
int ind = object.hashCode() % keys.length;
|
||||
keys[ind] = object;
|
||||
values[ind] = object2;
|
||||
}
|
||||
|
||||
public Iter keyIter() {
|
||||
return new Iter() {
|
||||
|
||||
public Object next() {
|
||||
return keys[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Iter valuesIter() {
|
||||
return new Iter() {
|
||||
|
||||
public Object next() {
|
||||
return values[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Object get(Object key1) {
|
||||
return values[0];
|
||||
}
|
||||
|
||||
private Iter keyOrValueIter(int type) {
|
||||
return type == 0 ? keyIter() : valuesIter();
|
||||
}
|
||||
|
||||
public Iter elements() {
|
||||
return keyOrValueIter(-1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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 demandpa;
|
||||
|
||||
public class DummyHashSet {
|
||||
|
||||
private final DummyHashMap hashMap = new DummyHashMap();
|
||||
|
||||
public void add(Object object) {
|
||||
hashMap.put(object, object);
|
||||
}
|
||||
|
||||
public Iter iterator() {
|
||||
return hashMap.keyIter();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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 demandpa;
|
||||
|
||||
public class DummyLinkedList {
|
||||
|
||||
static class Element {
|
||||
Element next;
|
||||
Object data;
|
||||
}
|
||||
|
||||
Element head = null;
|
||||
|
||||
public void add(Object o) {
|
||||
if (head == null) {
|
||||
head = new Element();
|
||||
head.data = o;
|
||||
} else {
|
||||
Element tmp = head;
|
||||
while (tmp.next != null) {
|
||||
tmp = tmp.next;
|
||||
}
|
||||
Element newElement = new Element();
|
||||
newElement.data = o;
|
||||
tmp.next = newElement;
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(int ind) {
|
||||
Element tmp = head;
|
||||
for (int i = 0; i < ind; i++) {
|
||||
tmp = tmp.next;
|
||||
}
|
||||
return tmp.data;
|
||||
}
|
||||
|
||||
public Iter iterator() {
|
||||
return new Iter() {
|
||||
|
||||
public Object next() {
|
||||
// just return some arbitrary element, from the point of view of flow-insensitive points-to analysis
|
||||
Element tmp = head;
|
||||
while (tmp.data == tmp.next) { // shouldn't be able to interpret this condition
|
||||
tmp = tmp.next;
|
||||
}
|
||||
return tmp.data;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package demandpa;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @author manu
|
||||
|
@ -18,10 +17,9 @@ import java.util.HashSet;
|
|||
*/
|
||||
public class FlowsToTestHashSet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
HashSet s1 = new HashSet();
|
||||
HashSet s2 = new HashSet();
|
||||
DummyHashSet s1 = new DummyHashSet();
|
||||
DummyHashSet s2 = new DummyHashSet();
|
||||
s1.add(new FlowsToType());
|
||||
s2.add(new Object());
|
||||
Object o1 = s1.iterator().next();
|
||||
|
|
|
@ -37,14 +37,12 @@
|
|||
*/
|
||||
package demandpa;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TestHashMapGet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
HashMap s1 = new HashMap();
|
||||
HashMap s2 = new HashMap();
|
||||
DummyHashMap s1 = new DummyHashMap();
|
||||
DummyHashMap s2 = new DummyHashMap();
|
||||
Object key1 = new Object();
|
||||
Object key2 = new Object();
|
||||
s1.put(key1, new Object());
|
||||
|
|
|
@ -37,14 +37,12 @@
|
|||
*/
|
||||
package demandpa;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class TestHashSet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
HashSet s1 = new HashSet();
|
||||
HashSet s2 = new HashSet();
|
||||
DummyHashSet s1 = new DummyHashSet();
|
||||
DummyHashSet s2 = new DummyHashSet();
|
||||
s1.add(new Object());
|
||||
s2.add(new Object());
|
||||
Object o1 = s1.iterator().next();
|
||||
|
|
|
@ -37,23 +37,21 @@
|
|||
*/
|
||||
package demandpa;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class TestHashtableEnum {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
Hashtable h1 = new Hashtable();
|
||||
Hashtable h2 = new Hashtable();
|
||||
DummyHashMap h1 = new DummyHashMap();
|
||||
DummyHashMap h2 = new DummyHashMap();
|
||||
Object key1 = new Object();
|
||||
Object key2 = new Object();
|
||||
h1.put(key1, new Object());
|
||||
h2.put(key2, new Object());
|
||||
Object o1 = h1.elements().nextElement();
|
||||
Object o2 = h2.elements().nextElement();
|
||||
Object o1 = h1.elements().next();
|
||||
Object o2 = h2.elements().next();
|
||||
TestUtil.makeVarUsed(o1);
|
||||
TestUtil.testThisVar(o2);
|
||||
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* This file is a derivative of code released by the University of
|
||||
* California under the terms listed below.
|
||||
*
|
||||
* Refinement Analysis Tools is Copyright (c) 2007 The Regents of the
|
||||
* University of California (Regents). Provided that this notice and
|
||||
* the following two paragraphs are included in any distribution of
|
||||
* Refinement Analysis Tools or its derivative work, Regents agrees
|
||||
* not to assert any of Regents' copyright rights in Refinement
|
||||
* Analysis Tools against recipient for recipient's reproduction,
|
||||
* preparation of derivative works, public display, public
|
||||
* performance, distribution or sublicensing of Refinement Analysis
|
||||
* Tools and derivative works, in source code and object code form.
|
||||
* This agreement not to assert does not confer, by implication,
|
||||
* estoppel, or otherwise any license or rights in any intellectual
|
||||
* property of Regents, including, but not limited to, any patents
|
||||
* of Regents or Regents' employees.
|
||||
*
|
||||
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||
* INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE
|
||||
* AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND FURTHER DISCLAIMS ANY STATUTORY
|
||||
* WARRANTY OF NON-INFRINGEMENT. THE SOFTWARE AND ACCOMPANYING
|
||||
* DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
|
||||
* IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
|
||||
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
package demandpa;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class TestHashtableGet {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
Hashtable h1 = new Hashtable();
|
||||
Hashtable h2 = new Hashtable();
|
||||
Object key1 = new Object();
|
||||
Object key2 = new Object();
|
||||
h1.put(key1, new Object());
|
||||
h2.put(key2, new Object());
|
||||
Object o1 = h1.get(key1);
|
||||
Object o2 = h2.get(key2);
|
||||
TestUtil.makeVarUsed(o1);
|
||||
TestUtil.testThisVar(o2);
|
||||
}
|
||||
|
||||
}
|
|
@ -37,17 +37,15 @@
|
|||
*/
|
||||
package demandpa;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TestLinkedList {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
LinkedList l1 = new LinkedList();
|
||||
LinkedList l2 = new LinkedList();
|
||||
DummyLinkedList l1 = new DummyLinkedList();
|
||||
DummyLinkedList l2 = new DummyLinkedList();
|
||||
l1.add(new Object());
|
||||
l2.add(new Object());
|
||||
Object o1 = l1.get(0);
|
||||
|
|
|
@ -37,17 +37,15 @@
|
|||
*/
|
||||
package demandpa;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TestLinkedListIter {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args) {
|
||||
LinkedList l1 = new LinkedList();
|
||||
LinkedList l2 = new LinkedList();
|
||||
DummyLinkedList l1 = new DummyLinkedList();
|
||||
DummyLinkedList l2 = new DummyLinkedList();
|
||||
l1.add(new Object());
|
||||
l2.add(new Object());
|
||||
Object o1 = l1.iterator().next();
|
||||
|
|
|
@ -6,3 +6,6 @@ com\/sun\/.*
|
|||
sun\/.*
|
||||
org\/netbeans\/.*
|
||||
org\/openide\/.*
|
||||
com\/ibm\/crypto\/.*
|
||||
com\/ibm\/security\/.*
|
||||
org\/apache\/xerces\/.*
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
|
|||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.Context;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Everywhere;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
|
@ -55,33 +56,35 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
private static AnalysisScope cachedScope;
|
||||
|
||||
|
||||
private static AnalysisScope findOrCreateAnalysisScope() throws IOException {
|
||||
if (cachedScope == null) {
|
||||
cachedScope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, "Java60RegressionExclusions.txt");
|
||||
}
|
||||
return cachedScope;
|
||||
}
|
||||
|
||||
|
||||
private static IClassHierarchy cachedCHA;
|
||||
|
||||
|
||||
private static IClassHierarchy findOrCreateCHA(AnalysisScope scope) throws ClassHierarchyException {
|
||||
if (cachedCHA == null) {
|
||||
cachedCHA = ClassHierarchy.make(scope);
|
||||
}
|
||||
return cachedCHA;
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() {
|
||||
cachedCHA = null;
|
||||
cachedScope = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test that when analyzing Reflect1.main(), there is no warning about "Integer".
|
||||
* test that when analyzing Reflect1.main(), there is no warning about
|
||||
* "Integer".
|
||||
*/
|
||||
@Test public void testReflect1() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect1() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -102,10 +105,12 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that when analyzing reflect2, the call graph includes a node for java.lang.Integer.<clinit>. This should be
|
||||
* forced by the call for Class.forName("java.lang.Integer").
|
||||
* Test that when analyzing reflect2, the call graph includes a node for
|
||||
* java.lang.Integer.<clinit>. This should be forced by the call for
|
||||
* Class.forName("java.lang.Integer").
|
||||
*/
|
||||
@Test public void testReflect2() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect2() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -120,9 +125,11 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect3, the successors of newInstance do not include reflection/Reflect3$Hash
|
||||
* Check that when analyzing Reflect3, the successors of newInstance do not
|
||||
* include reflection/Reflect3$Hash
|
||||
*/
|
||||
@Test public void testReflect3() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test
|
||||
public void testReflect3() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -150,9 +157,11 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect4, successors of newInstance() do not include FilePermission ctor.
|
||||
* Check that when analyzing Reflect4, successors of newInstance() do not
|
||||
* include FilePermission ctor.
|
||||
*/
|
||||
@Test public void testReflect4() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test
|
||||
public void testReflect4() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -178,9 +187,11 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect5, successors of newInstance do not include a Reflect5$A ctor
|
||||
* Check that when analyzing Reflect5, successors of newInstance do not
|
||||
* include a Reflect5$A ctor
|
||||
*/
|
||||
@Test public void testReflect5() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test
|
||||
public void testReflect5() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -206,9 +217,11 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check that when analyzing Reflect6, successors of newInstance do not include a Reflect6$A ctor
|
||||
* Check that when analyzing Reflect6, successors of newInstance do not
|
||||
* include a Reflect6$A ctor
|
||||
*/
|
||||
@Test public void testReflect6() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
@Test
|
||||
public void testReflect6() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -234,7 +247,8 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test public void testReflect7() throws Exception {
|
||||
@Test
|
||||
public void testReflect7() throws Exception {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -258,7 +272,8 @@ public class ReflectionTest extends WalaTestCase {
|
|||
// Get all the children of the main node(s)
|
||||
Collection<CGNode> mainChildren = getSuccNodes(cg, mainNodes);
|
||||
|
||||
// Verify that one of those children is Constructor.newInstance, where Constructor is a FilePermission constructor
|
||||
// Verify that one of those children is Constructor.newInstance, where
|
||||
// Constructor is a FilePermission constructor
|
||||
CGNode filePermConstrNewInstanceNode = null;
|
||||
|
||||
for (CGNode node : mainChildren) {
|
||||
|
@ -310,11 +325,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
}
|
||||
return succNodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing reflect8, the call graph includes a node for java.lang.Integer.toString()
|
||||
* Test that when analyzing reflect8, the call graph includes a node for
|
||||
* java.lang.Integer.toString()
|
||||
*/
|
||||
@Test public void testReflect8() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect8() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -326,11 +343,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing reflect9, the call graph includes a node for java.lang.Integer.toString()
|
||||
* Test that when analyzing reflect9, the call graph includes a node for
|
||||
* java.lang.Integer.toString()
|
||||
*/
|
||||
@Test public void testReflect9() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect9() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -342,11 +361,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect10, the call graph includes a node for java.lang.Integer.toString()
|
||||
* Test that when analyzing Reflect10, the call graph includes a node for
|
||||
* java.lang.Integer.toString()
|
||||
*/
|
||||
@Test public void testReflect10() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect10() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -358,11 +379,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect11, the call graph includes a node for java.lang.Object.wait()
|
||||
* Test that when analyzing Reflect11, the call graph includes a node for
|
||||
* java.lang.Object.wait()
|
||||
*/
|
||||
@Test public void testReflect11() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect11() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -374,12 +397,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect12, the call graph does not include a node for reflection.Helper.n
|
||||
* but does include a node for reflection.Helper.m
|
||||
* Test that when analyzing Reflect12, the call graph does not include a node
|
||||
* for reflection.Helper.n but does include a node for reflection.Helper.m
|
||||
*/
|
||||
@Test public void testReflect12() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect12() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -394,12 +418,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
nodes = cg.getNodes(mr);
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect13, the call graph includes both a node for reflection.Helper.n
|
||||
* and a node for reflection.Helper.m
|
||||
* Test that when analyzing Reflect13, the call graph includes both a node for
|
||||
* reflection.Helper.n and a node for reflection.Helper.m
|
||||
*/
|
||||
@Test public void testReflect13() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect13() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -414,12 +439,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect14, the call graph does not include a node for reflection.Helper.n
|
||||
* but does include a node for reflection.Helper.s
|
||||
* Test that when analyzing Reflect14, the call graph does not include a node
|
||||
* for reflection.Helper.n but does include a node for reflection.Helper.s
|
||||
*/
|
||||
@Test public void testReflect14() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect14() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -434,13 +460,14 @@ public class ReflectionTest extends WalaTestCase {
|
|||
nodes = cg.getNodes(mr);
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect15, the call graph includes a node for the constructor
|
||||
* of Helper that takes 2 parameters and for Helper.n, but no node for the constructors of
|
||||
* Helper that takes 0 or 1 parameters.
|
||||
* Test that when analyzing Reflect15, the call graph includes a node for the
|
||||
* constructor of Helper that takes 2 parameters and for Helper.n, but no node
|
||||
* for the constructors of Helper that takes 0 or 1 parameters.
|
||||
*/
|
||||
@Test public void testReflect15() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect15() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -461,11 +488,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect16, the call graph includes a node for java.lang.Integer.toString()
|
||||
* Test that when analyzing Reflect16, the call graph includes a node for
|
||||
* java.lang.Integer.toString()
|
||||
*/
|
||||
@Test public void testReflect16() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect16() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -477,43 +506,52 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect17, the call graph does not include a node for java.lang.Integer.toString()
|
||||
* Test that when analyzing Reflect17, the call graph does not include any
|
||||
* edges from reflection.Helper.t()
|
||||
*/
|
||||
@Test public void testReflect17() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect17() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
TestConstants.REFLECT17_MAIN);
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
CallGraph cg = CallGraphTestUtil.buildZeroOneCFA(options, new AnalysisCache(), cha, scope, false);
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertTrue(nodes.isEmpty());
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "t", "(Ljava/lang/Integer;)V");
|
||||
CGNode node = cg.getNode(cg.getClassHierarchy().resolveMethod(mr), Everywhere.EVERYWHERE);
|
||||
Assert.assertEquals(0, cg.getSuccNodeCount(node));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect18, the call graph includes a node for java.lang.Integer.toString()
|
||||
* Test that when analyzing Reflect18, the call graph includes a node for
|
||||
* java.lang.Integer.toString()
|
||||
*/
|
||||
@Test public void testReflect18() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect18() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
TestConstants.REFLECT18_MAIN);
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
CallGraph cg = CallGraphTestUtil.buildZeroOneCFA(options, new AnalysisCache(), cha, scope, false);
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lreflection/Helper");
|
||||
MethodReference mr = MethodReference.findOrCreate(tr, "t", "(Ljava/lang/Integer;)V");
|
||||
CGNode node = cg.getNode(cg.getClassHierarchy().resolveMethod(mr), Everywhere.EVERYWHERE);
|
||||
Assert.assertEquals(1, cg.getSuccNodeCount(node));
|
||||
CGNode succ = cg.getSuccNodes(node).next();
|
||||
Assert.assertEquals("Node: < Primordial, Ljava/lang/Integer, toString()Ljava/lang/String; > Context: Everywhere",
|
||||
succ.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect19, the call graph includes a node for java.lang.Integer.toString()
|
||||
* Test that when analyzing Reflect19, the call graph includes a node for
|
||||
* java.lang.Integer.toString()
|
||||
*/
|
||||
@Test public void testReflect19() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect19() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -525,11 +563,13 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect20, the call graph includes a node for Helper.o.
|
||||
* Test that when analyzing Reflect20, the call graph includes a node for
|
||||
* Helper.o.
|
||||
*/
|
||||
@Test public void testReflect20() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect20() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -541,12 +581,14 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect21, the call graph includes a node for the constructor of {@link Helper} that takes
|
||||
* two {@link Object} parameters. This is to test the support for Class.getDeclaredConstructor.
|
||||
* Test that when analyzing Reflect21, the call graph includes a node for the
|
||||
* constructor of {@link Helper} that takes two {@link Object} parameters.
|
||||
* This is to test the support for Class.getDeclaredConstructor.
|
||||
*/
|
||||
@Test public void testReflect21() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect21() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -558,12 +600,14 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect22, the call graph includes a node for the constructor of {@link Helper} that takes
|
||||
* one {@link Integer} parameters. This is to test the support for Class.getDeclaredConstructors.
|
||||
* Test that when analyzing Reflect22, the call graph includes a node for the
|
||||
* constructor of {@link Helper} that takes one {@link Integer} parameters.
|
||||
* This is to test the support for Class.getDeclaredConstructors.
|
||||
*/
|
||||
@Test public void testReflect22() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect22() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
@ -575,12 +619,14 @@ public class ReflectionTest extends WalaTestCase {
|
|||
Set<CGNode> nodes = cg.getNodes(mr);
|
||||
Assert.assertFalse(nodes.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that when analyzing Reflect22, the call graph includes a node for the constructor of {@link Helper} that takes
|
||||
* one {@link Integer} parameters. This is to test the support for Class.getDeclaredConstructors.
|
||||
* Test that when analyzing Reflect22, the call graph includes a node for the
|
||||
* constructor of {@link Helper} that takes one {@link Integer} parameters.
|
||||
* This is to test the support for Class.getDeclaredConstructors.
|
||||
*/
|
||||
@Test public void testReflect23() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
@Test
|
||||
public void testReflect23() throws WalaException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
|
|
|
@ -90,11 +90,6 @@ public abstract class AbstractPtrTest {
|
|||
*/
|
||||
protected final String scopeFile;
|
||||
|
||||
/**
|
||||
* analysis scope from latest test
|
||||
*/
|
||||
private AnalysisScope scope = null;
|
||||
|
||||
protected AbstractPtrTest(String scopeFile) {
|
||||
this.scopeFile = scopeFile;
|
||||
}
|
||||
|
@ -162,64 +157,22 @@ public abstract class AbstractPtrTest {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the computed size of some points-to test matches what is expected.
|
||||
*
|
||||
* @param mainClass the main class of the test; we choose a variable from its main() method that is passed to the method
|
||||
* TestUtil.testThisVar()
|
||||
* @param expected14Size expected p2set size when using 1.4 libraries
|
||||
* @param expected15Size expected p2set size when using 1.4 libraries
|
||||
* @param expected16Size expected p2set size when using 1.4 libraries
|
||||
* @throws ClassHierarchyException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws CancelException
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void doPointsToSizeTest(String mainClass, int expected14Size, int expected15Size, int expected16Size)
|
||||
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
assert scope == null;
|
||||
Collection<InstanceKey> pointsTo = getPointsToSetToTest(mainClass);
|
||||
if (debug) {
|
||||
System.err.println("points-to for " + mainClass + ": " + pointsTo);
|
||||
}
|
||||
assert scope != null;
|
||||
try {
|
||||
if (scope.isJava16Libraries()) {
|
||||
Assert.assertEquals(expected16Size, pointsTo.size());
|
||||
} else if (scope.isJava15Libraries()) {
|
||||
Assert.assertEquals(expected15Size, pointsTo.size());
|
||||
} else if (scope.isJava14Libraries()) {
|
||||
Assert.assertEquals(expected14Size, pointsTo.size());
|
||||
} else {
|
||||
Assertions.UNREACHABLE("unexpected library version");
|
||||
}
|
||||
} finally {
|
||||
// don't hold on to a scope pointer
|
||||
scope = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void doFlowsToSizeTest(String mainClass, int size) throws ClassHierarchyException, IllegalArgumentException,
|
||||
CancelException, IOException {
|
||||
assert scope == null;
|
||||
Collection<PointerKey> flowsTo = getFlowsToSetToTest(mainClass);
|
||||
if (debug) {
|
||||
System.err.println("flows-to for " + mainClass + ": " + flowsTo);
|
||||
}
|
||||
assert scope != null;
|
||||
try {
|
||||
Assert.assertEquals(size, flowsTo.size());
|
||||
} finally {
|
||||
// don't hold on to a scope pointer
|
||||
scope = null;
|
||||
}
|
||||
Assert.assertEquals(size, flowsTo.size());
|
||||
}
|
||||
|
||||
private Collection<PointerKey> getFlowsToSetToTest(String mainClass) throws ClassHierarchyException, IllegalArgumentException,
|
||||
CancelException, IOException {
|
||||
final DemandRefinementPointsTo dmp = makeDemandPointerAnalysis(mainClass);
|
||||
|
||||
// find the single allocation site of FlowsToType, make an InstanceKey, and query it
|
||||
// find the single allocation site of FlowsToType, make an InstanceKey, and
|
||||
// query it
|
||||
CGNode mainMethod = AbstractPtrTest.findMainMethod(dmp.getBaseCallGraph());
|
||||
InstanceKey keyToQuery = getFlowsToInstanceKey(mainMethod, dmp.getHeapModel());
|
||||
Collection<PointerKey> flowsTo = dmp.getFlowsTo(keyToQuery).snd;
|
||||
|
@ -227,12 +180,13 @@ public abstract class AbstractPtrTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the instance key corresponding to the single allocation site of type FlowsToType
|
||||
* returns the instance key corresponding to the single allocation site of
|
||||
* type FlowsToType
|
||||
*/
|
||||
private InstanceKey getFlowsToInstanceKey(CGNode mainMethod, HeapModel heapModel) {
|
||||
// TODO Auto-generated method stub
|
||||
TypeReference flowsToTypeRef = TypeReference.findOrCreate(ClassLoaderReference.Application, StringStuff
|
||||
.deployment2CanonicalTypeString("demandpa.FlowsToType"));
|
||||
TypeReference flowsToTypeRef = TypeReference.findOrCreate(ClassLoaderReference.Application,
|
||||
StringStuff.deployment2CanonicalTypeString("demandpa.FlowsToType"));
|
||||
final IR mainIR = mainMethod.getIR();
|
||||
if (debug) {
|
||||
System.err.println(mainIR);
|
||||
|
@ -248,7 +202,11 @@ public abstract class AbstractPtrTest {
|
|||
|
||||
protected void doPointsToSizeTest(String mainClass, int expectedSize) throws ClassHierarchyException, IllegalArgumentException,
|
||||
CancelException, IOException {
|
||||
doPointsToSizeTest(mainClass, expectedSize, expectedSize, expectedSize);
|
||||
Collection<InstanceKey> pointsTo = getPointsToSetToTest(mainClass);
|
||||
if (debug) {
|
||||
System.err.println("points-to for " + mainClass + ": " + pointsTo);
|
||||
}
|
||||
Assert.assertEquals(expectedSize, pointsTo.size());
|
||||
}
|
||||
|
||||
private Collection<InstanceKey> getPointsToSetToTest(String mainClass) throws ClassHierarchyException, IllegalArgumentException,
|
||||
|
@ -265,7 +223,6 @@ public abstract class AbstractPtrTest {
|
|||
protected DemandRefinementPointsTo makeDemandPointerAnalysis(String mainClass) throws ClassHierarchyException,
|
||||
IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = findOrCreateAnalysisScope();
|
||||
this.scope = scope;
|
||||
// build a type hierarchy
|
||||
IClassHierarchy cha = findOrCreateCHA(scope);
|
||||
|
||||
|
@ -279,10 +236,12 @@ public abstract class AbstractPtrTest {
|
|||
final CallGraph cg = cgBuilder.makeCallGraph(options, null);
|
||||
// System.err.println(cg.toString());
|
||||
|
||||
// MemoryAccessMap mam = new SimpleMemoryAccessMap(cg, cgBuilder.getPointerAnalysis().getHeapModel(), false);
|
||||
// MemoryAccessMap mam = new SimpleMemoryAccessMap(cg,
|
||||
// cgBuilder.getPointerAnalysis().getHeapModel(), false);
|
||||
MemoryAccessMap mam = new PABasedMemoryAccessMap(cg, cgBuilder.getPointerAnalysis());
|
||||
SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, analysisCache, cha, scope);
|
||||
DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, builder, mam, cha, options, getStateMachineFactory());
|
||||
DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, builder, mam, cha, options,
|
||||
getStateMachineFactory());
|
||||
|
||||
return fullDemandPointsTo;
|
||||
}
|
||||
|
|
|
@ -86,8 +86,8 @@ public class ContextSensitiveTest extends AbstractPtrTest {
|
|||
@Test
|
||||
public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
// 3 because
|
||||
// can't tell between key, value, and entry enumerators in Hashtable
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHTABLE_ENUM, 3);
|
||||
// can't tell between key and value enumerators in Hashtable
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHTABLE_ENUM, 2);
|
||||
}
|
||||
|
||||
@Ignore("support for this combination of context sensitivity and on-the-fly call graph refinement is not yet implemented")
|
||||
|
@ -135,12 +135,12 @@ public class ContextSensitiveTest extends AbstractPtrTest {
|
|||
|
||||
@Test
|
||||
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 2, 2, 1);
|
||||
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHMAP_GET, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -67,7 +67,7 @@ public class NoRefinePtrTest extends AbstractPtrTest {
|
|||
|
||||
@Test
|
||||
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 3, 3, 2);
|
||||
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -85,8 +85,6 @@ public class TestInfo {
|
|||
|
||||
public static final String TEST_ARRAY_LIST = "Ldemandpa/TestArrayList";
|
||||
|
||||
public static final String TEST_HASHTABLE_GET = "Ldemandpa/TestHashtableGet";
|
||||
|
||||
public static final String TEST_HASHTABLE_ENUM = "Ldemandpa/TestHashtableEnum";
|
||||
|
||||
public static final String TEST_NASTY_PTRS = "Ldemandpa/TestNastyPtrs";
|
||||
|
|
|
@ -55,8 +55,8 @@ public class TunedRefinementTest extends AbstractPtrTest {
|
|||
@Test
|
||||
public void testHashtableEnum() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
// 3 because
|
||||
// can't tell between key, value, and entry enumerators in Hashtable
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHTABLE_ENUM, 3);
|
||||
// can't tell between key and value enumerators in Hashtable
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHTABLE_ENUM, 2);
|
||||
}
|
||||
|
||||
// we know this one fails...
|
||||
|
@ -107,12 +107,12 @@ public class TunedRefinementTest extends AbstractPtrTest {
|
|||
|
||||
@Test
|
||||
public void testHashSet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 2, 2, 1);
|
||||
doPointsToSizeTest(TestInfo.TEST_HASH_SET, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashMapGet() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHMAP_GET, 2, 1, 1);
|
||||
doPointsToSizeTest(TestInfo.TEST_HASHMAP_GET, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -229,7 +229,7 @@ public class SlicerTest {
|
|||
TestConstants.SLICE7_MAIN);
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
|
||||
CallGraphBuilder builder = Util.makeVanillaZeroOneContainerCFABuilder(options, new AnalysisCache(), cha, scope);
|
||||
CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, new AnalysisCache(), cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
|
||||
CGNode main = findMainMethod(cg);
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.examples.analysis.dataflow;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
|
@ -140,11 +143,16 @@ public class DataflowTest extends WalaTestCase {
|
|||
if (delegate.getNumber() == 4) {
|
||||
IntSet solution = solver.getOut(bb).getValue();
|
||||
IntIterator intIterator = solution.intIterator();
|
||||
List<Pair<CGNode, Integer>> applicationDefs = new ArrayList<Pair<CGNode,Integer>>();
|
||||
while (intIterator.hasNext()) {
|
||||
int next = intIterator.next();
|
||||
System.out.println(reachingDefs.getNodeAndInstrForNumber(next));
|
||||
final Pair<CGNode, Integer> def = reachingDefs.getNodeAndInstrForNumber(next);
|
||||
if (def.fst.getMethod().getDeclaringClass().getClassLoader().getReference().equals(ClassLoaderReference.Application)) {
|
||||
System.out.println(def);
|
||||
applicationDefs.add(def);
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(4, solution.size());
|
||||
Assert.assertEquals(2, applicationDefs.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,11 +176,16 @@ public class DataflowTest extends WalaTestCase {
|
|||
if (delegate.getNumber() == 4) {
|
||||
IntSet solution = result.getResult(bb);
|
||||
IntIterator intIterator = solution.intIterator();
|
||||
List<Pair<CGNode, Integer>> applicationDefs = new ArrayList<Pair<CGNode,Integer>>();
|
||||
while (intIterator.hasNext()) {
|
||||
int next = intIterator.next();
|
||||
System.out.println(reachingDefs.getDomain().getMappedObject(next));
|
||||
final Pair<CGNode, Integer> def = reachingDefs.getDomain().getMappedObject(next);
|
||||
if (def.fst.getMethod().getDeclaringClass().getClassLoader().getReference().equals(ClassLoaderReference.Application)) {
|
||||
System.out.println(def);
|
||||
applicationDefs.add(def);
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(3, solution.size());
|
||||
Assert.assertEquals(1, applicationDefs.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.net.URL;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.util.PlatformUtil;
|
||||
|
||||
public class FileProviderTest {
|
||||
|
||||
@Test
|
||||
|
@ -25,7 +27,7 @@ public class FileProviderTest {
|
|||
public void testURLWithInvalidURIChars() throws MalformedURLException {
|
||||
// setup:
|
||||
URL url = new URL("file:///[Eclipse]/File.jar");
|
||||
String expected = "/[Eclipse]/File.jar";
|
||||
String expected = PlatformUtil.onWindows() ? "/C:/[Eclipse]/File.jar" : "/[Eclipse]/File.jar";
|
||||
// exercise:
|
||||
String actual = FileProvider.filePathFromURL(url);
|
||||
// verify:
|
||||
|
|
|
@ -78,7 +78,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
|
|||
/**
|
||||
* The solver
|
||||
*/
|
||||
private DataflowSolver solver;
|
||||
private DataflowSolver<BasicBlock,MachineState> solver;
|
||||
|
||||
/**
|
||||
* The control flow graph to analyze
|
||||
|
@ -257,14 +257,14 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
|
|||
}
|
||||
|
||||
public MachineState getEntryState() {
|
||||
return (MachineState) solver.getIn(cfg.entry());
|
||||
return solver.getIn(cfg.entry());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state at the entry to a given block
|
||||
*/
|
||||
public MachineState getIn(ShrikeCFG.BasicBlock bb) {
|
||||
return (MachineState) solver.getIn(bb);
|
||||
return solver.getIn(bb);
|
||||
}
|
||||
|
||||
private class MeetOperator extends AbstractMeetOperator<MachineState> {
|
||||
|
@ -547,7 +547,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
|
|||
/**
|
||||
* Representation of the state of the JVM stack machine at some program point.
|
||||
*/
|
||||
public class MachineState extends AbstractVariable {
|
||||
public class MachineState extends AbstractVariable<MachineState> {
|
||||
private int[] stack;
|
||||
|
||||
private int[] locals;
|
||||
|
@ -711,8 +711,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void copyState(IVariable v) {
|
||||
MachineState other = (MachineState) v;
|
||||
public void copyState(MachineState other) {
|
||||
if (other.stack == null) {
|
||||
stack = null;
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.ibm.wala.ssa.SymbolTable;
|
|||
*
|
||||
* @see TypeInference for the canonical client of this machinery.
|
||||
*/
|
||||
public abstract class SSAInference<T extends IVariable> extends DefaultFixedPointSolver<T> {
|
||||
public abstract class SSAInference<T extends IVariable<?>> extends DefaultFixedPointSolver<T> {
|
||||
static final boolean DEBUG = false;
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,8 @@ public interface PointerAnalysis {
|
|||
/**
|
||||
* @return all pointer keys known
|
||||
*/
|
||||
Collection<PointerKey> getPointerKeys();
|
||||
Iterable<PointerKey> getPointerKeys();
|
||||
|
||||
|
||||
/**
|
||||
* @return all instance keys known
|
||||
|
|
|
@ -38,7 +38,7 @@ import com.ibm.wala.ssa.SSAThrowInstruction;
|
|||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.collections.Iterator2Iterable;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.intset.MutableMapping;
|
||||
|
@ -538,8 +538,8 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
|
|||
/*
|
||||
* @see com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis#iteratePointerKeys()
|
||||
*/
|
||||
public Collection<PointerKey> getPointerKeys() {
|
||||
return Iterator2Collection.toSet(pointsToMap.iterateKeys());
|
||||
public Iterable<PointerKey> getPointerKeys() {
|
||||
return Iterator2Iterable.make(pointsToMap.iterateKeys());
|
||||
}
|
||||
|
||||
public IClassHierarchy getClassHierarchy() {
|
||||
|
|
|
@ -25,8 +25,7 @@ import com.ibm.wala.util.intset.IntegerUnionFind;
|
|||
/**
|
||||
* Iterative solver for a Killdall dataflow framework
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract class DataflowSolver<T, V extends IVariable> extends DefaultFixedPointSolver<V> {
|
||||
public abstract class DataflowSolver<T, V extends IVariable<?>> extends DefaultFixedPointSolver<V> {
|
||||
|
||||
/**
|
||||
* the dataflow problem to solve
|
||||
|
|
|
@ -17,8 +17,7 @@ import com.ibm.wala.fixpoint.IVariable;
|
|||
/**
|
||||
* Default implementation of a fixed point solver.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract class DefaultFixedPointSolver<T extends IVariable> extends AbstractFixedPointSolver<T> {
|
||||
public abstract class DefaultFixedPointSolver<T extends IVariable<?>> extends AbstractFixedPointSolver<T> {
|
||||
|
||||
private final DefaultFixedPointSystem<T> graph;
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ import com.ibm.wala.util.graph.traverse.Topological;
|
|||
/**
|
||||
* Default implementation of a dataflow graph
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class DefaultFixedPointSystem<T extends IVariable> implements IFixedPointSystem<T> {
|
||||
public class DefaultFixedPointSystem<T extends IVariable<?>> implements IFixedPointSystem<T> {
|
||||
static final boolean DEBUG = false;
|
||||
|
||||
/**
|
||||
|
@ -47,14 +46,14 @@ public class DefaultFixedPointSystem<T extends IVariable> implements IFixedPoint
|
|||
* equals() ... the NumberedGraph does not support this. TODO: use a custom
|
||||
* NumberedNodeManager to save space
|
||||
*/
|
||||
final private Set<GeneralStatement> equations = HashSetFactory.make();
|
||||
final private Set<GeneralStatement<?>> equations = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* We maintain a hash set of variables in order to check for equality with
|
||||
* equals() ... the NumberedGraph does not support this. TODO: use a custom
|
||||
* NumberedNodeManager to save space
|
||||
*/
|
||||
final private Set<IVariable> variables = HashSetFactory.make();
|
||||
final private Set<IVariable<?>> variables = HashSetFactory.make();
|
||||
|
||||
/**
|
||||
* @param expectedOut number of expected out edges in the "usual" case
|
||||
|
|
Loading…
Reference in New Issue