├── src ├── generalJava │ ├── Null2.java │ ├── Null1.java │ ├── StaticVariables1.java │ ├── Exception1.java │ ├── SuperClasses1.java │ ├── Exception2.java │ ├── Interface1.java │ └── OuterClass1.java ├── benchmark │ ├── objects │ │ ├── I.java │ │ ├── P.java │ │ ├── B.java │ │ ├── G.java │ │ ├── H.java │ │ ├── N.java │ │ ├── Q.java │ │ └── A.java │ └── internal │ │ └── Benchmark.java ├── basic │ ├── SimpleAlias1.java │ ├── Parameter1.java │ ├── ReturnValue1.java │ ├── Parameter2.java │ ├── ReturnValue2.java │ ├── ReturnValue3.java │ ├── Interprocedural1.java │ ├── Branching1.java │ ├── Interprocedural2.java │ ├── Loops1.java │ ├── Loops2.java │ └── Recursion1.java ├── cornerCases │ ├── FlowSensitivity1.java │ ├── AccessPath1.java │ ├── StrongUpdate2.java │ ├── StrongUpdate1.java │ ├── ObjectSensitivity2.java │ ├── FieldSensitivity1.java │ ├── ObjectSensitivity1.java │ ├── FieldSensitivity2.java │ ├── ContextSensitivity1.java │ ├── ContextSensitivity2.java │ └── ContextSensitivity3.java └── collections │ ├── Array1.java │ ├── List1.java │ ├── List2.java │ ├── Map1.java │ └── Set1.java ├── .gitignore └── README.md /src/generalJava/Null2.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secure-software-engineering/PointerBench/HEAD/src/generalJava/Null2.java -------------------------------------------------------------------------------- /src/benchmark/objects/I.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | public interface I { 4 | // G and H implement I 5 | 6 | public A foo(A a); 7 | } 8 | -------------------------------------------------------------------------------- /src/benchmark/objects/P.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | public class P extends Q { 4 | 5 | public P(A a) { 6 | super(a); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/benchmark/objects/B.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | public class B { 4 | 5 | // Object B used as attribute of objects of type A 6 | 7 | public B() { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/benchmark/objects/G.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | public class G implements I { 4 | // G and H implement I 5 | 6 | A a; 7 | 8 | public A foo(A a) { 9 | this.a = a; 10 | return a; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/benchmark/objects/H.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | public class H implements I { 4 | // G and H implement I 5 | 6 | A a; 7 | 8 | public A foo(A a) { 9 | this.a = a; 10 | return a; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/benchmark/objects/N.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | import benchmark.internal.Benchmark; 4 | 5 | public class N { 6 | public String value = ""; 7 | public N next; 8 | 9 | public N() { 10 | Benchmark.alloc(2); 11 | next = new N(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/benchmark/objects/Q.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | public class Q { 4 | // Class P extends class Q 5 | 6 | private A a; 7 | 8 | public Q(A a) { 9 | this.a = a; 10 | } 11 | 12 | public void alias(A x) { 13 | this.a = x; 14 | } 15 | 16 | public A getA(){ 17 | return a; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/benchmark/internal/Benchmark.java: -------------------------------------------------------------------------------- 1 | package benchmark.internal; 2 | 3 | 4 | public class Benchmark { 5 | 6 | public static void alloc(int id) { 7 | 8 | } 9 | 10 | public static void test(String targetVariable, String results) { 11 | 12 | } 13 | 14 | public static void use(Object o) { 15 | //A method to be used to avoid the compiler to prune the Object 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/benchmark/objects/A.java: -------------------------------------------------------------------------------- 1 | package benchmark.objects; 2 | 3 | public class A { 4 | 5 | // Object A with attributes of type B 6 | 7 | public int i = 5; 8 | 9 | public B f = new B(); 10 | public B g = new B(); 11 | public B h; 12 | 13 | public A() { 14 | } 15 | 16 | public A(B b) { 17 | this.f = b; 18 | } 19 | 20 | public B getF() { 21 | return f; 22 | } 23 | public B getH() { 24 | return h; 25 | } 26 | public B id(B b) { 27 | return b; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/basic/SimpleAlias1.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase SimpleAlias1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Direct alias 15 | */ 16 | public class SimpleAlias1 { 17 | 18 | public static void main(String[] args) { 19 | 20 | Benchmark.alloc(1); 21 | A a = new A(); 22 | 23 | A b = a; 24 | Benchmark.test("b", 25 | "{allocId:1, mayAlias:[a,b], notMayAlias:[], mustAlias:[a,b], notMustAlias:[]}"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/cornerCases/FlowSensitivity1.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase FlowSensitivity1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Is the analysis flow-sensitive? 15 | */ 16 | public class FlowSensitivity1 { 17 | 18 | public static void main(String[] args) { 19 | 20 | A a = new A(); 21 | Benchmark.alloc(1); 22 | A b = new A(); 23 | 24 | Benchmark.test("b", 25 | "{allocId:1, mayAlias:[b], notMayAlias:[a], mustAlias:[b], notMustAlias:[a]}"); 26 | 27 | b = a; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/cornerCases/AccessPath1.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase AccessPath1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Query for access paths 15 | */ 16 | public class AccessPath1 { 17 | 18 | public static void main(String[] args) { 19 | 20 | Benchmark.alloc(1); 21 | A a = new A(); 22 | A b = new A(); 23 | 24 | a.f = b.f; 25 | Benchmark 26 | .test("a.f", 27 | "{allocId:1, mayAlias:[a.f,b.f], notMayAlias:[a,b], mustAlias:[a.f,b.f], notMustAlias:[a,b]}"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/generalJava/Null1.java: -------------------------------------------------------------------------------- 1 | package generalJava; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase Null1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Direct alias to null 16 | */ 17 | public class Null1 { 18 | 19 | public static void main(String[] args) { 20 | 21 | // No allocation site 22 | A h = new A(); 23 | B a = h.getH(); 24 | B b = a; 25 | Benchmark.test("b", 26 | "{NULLALLOC, mayAlias:[], notMayAlias:[b,a], mustAlias:[b,a], notMustAlias:[i]}"); 27 | Benchmark.use(b); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/basic/Parameter1.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase ParameterAlias1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Aliasing through static method parameter 15 | */ 16 | public class Parameter1 { 17 | 18 | public static void test(A x) { 19 | A b = x; 20 | Benchmark.test("b", 21 | "{allocId:1, mayAlias:[b,x], notMayAlias:[], mustAlias:[b,x], notMustAlias:[]}"); 22 | } 23 | 24 | public static void main(String[] args) { 25 | 26 | Benchmark.alloc(1); 27 | A a = new A(); 28 | test(a); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/basic/ReturnValue1.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase ReturnValue1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Alias to a return value from a static method 15 | */ 16 | public class ReturnValue1 { 17 | 18 | public static A id(A x) { 19 | return x; 20 | } 21 | 22 | public static void main(String[] args) { 23 | 24 | Benchmark.alloc(1); 25 | A a = new A(); 26 | A b = id(a); 27 | Benchmark.test("b", 28 | "{allocId:1, mayAlias:[a,b], notMayAlias:[], mustAlias:[a,b], notMustAlias:[]}"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/generalJava/StaticVariables1.java: -------------------------------------------------------------------------------- 1 | package generalJava; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase StaticVariables1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Alias to a static variable, allocation site at the static variable site 15 | */ 16 | public class StaticVariables1 { 17 | 18 | private static A a; 19 | 20 | public static void main(String[] args) { 21 | Benchmark.alloc(1); 22 | a = new A(); 23 | A b = a; 24 | A c = a; 25 | Benchmark.test("b", 26 | "{allocId:1, mayAlias:[b,c], notMayAlias:[], mustAlias:[b,c], notMustAlias:[]}"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/collections/Array1.java: -------------------------------------------------------------------------------- 1 | package collections; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase Array1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Array alias 15 | */ 16 | public class Array1 { 17 | 18 | public static void main(String[] args) { 19 | 20 | A[] array = new A[] {}; 21 | A a = new A(); 22 | Benchmark.alloc(1); 23 | A b = new A(); 24 | array[0] = a; 25 | array[1] = b; 26 | A c = array[1]; 27 | Benchmark 28 | .test("c", 29 | "{allocId:1, mayAlias:[c,b], notMayAlias:[a,array], mustAlias:[c,b], notMustAlias:[a,array]}"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/cornerCases/StrongUpdate2.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase StrongUpdate1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Indirect alias of a.f and b.f through alias of a and b 16 | */ 17 | public class StrongUpdate2 { 18 | 19 | public static void main(String[] args) { 20 | 21 | A a = new A(); 22 | A b = a; 23 | B x = b.f; 24 | Benchmark.alloc(1); 25 | a.f = new B(); 26 | B y = b.f; 27 | Benchmark.test("y", 28 | "{allocId:1, mayAlias:[y], notMayAlias:[x], mustAlias:[y], notMustAlias:[x]}"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/cornerCases/StrongUpdate1.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase StrongUpdate1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Indirect alias of a.f and b.f through alias of a and b 16 | */ 17 | public class StrongUpdate1 { 18 | 19 | public static void main(String[] args) { 20 | 21 | A a = new A(); 22 | A b = a; 23 | Benchmark.alloc(1); 24 | a.f = new B(); 25 | B y = a.f; 26 | B x = b.f; 27 | Benchmark.test("x", 28 | "{allocId:1, mayAlias:[x,y], notMayAlias:[a,b], mustAlias:[x,y], notMustAlias:[a,b]}"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/generalJava/Exception1.java: -------------------------------------------------------------------------------- 1 | package generalJava; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase Exception1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Alias in exception 15 | */ 16 | public class Exception1 { 17 | 18 | public static void main(String[] args) { 19 | 20 | Benchmark.alloc(1); 21 | A a = new A(); 22 | A b = new A(); 23 | 24 | try { 25 | b = a; 26 | throw new RuntimeException(); 27 | 28 | } catch (RuntimeException e) { 29 | Benchmark.test("b", 30 | "{allocId:1, mayAlias:[a,b], notMayAlias:[], mustAlias:[a,b], notMustAlias:[]}"); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/basic/Parameter2.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase ParameterAlias2 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Aliasing through non static method parameter 15 | */ 16 | public class Parameter2 { 17 | 18 | public Parameter2() {} 19 | 20 | public void test(A x) { 21 | A b = x; 22 | Benchmark.test("b", 23 | "{allocId:1, mayAlias:[b,x], notMayAlias:[], mustAlias:[b,x], notMustAlias:[]}"); 24 | } 25 | 26 | public static void main(String[] args) { 27 | 28 | Benchmark.alloc(1); 29 | A a = new A(); 30 | Parameter2 p2 = new Parameter2(); 31 | p2.test(a); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/generalJava/SuperClasses1.java: -------------------------------------------------------------------------------- 1 | package generalJava; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.P; 6 | 7 | /* 8 | * @testcase SuperClass1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Alias from method in super class 16 | */ 17 | public class SuperClasses1 { 18 | 19 | private static void main(String[] args) { 20 | Benchmark.alloc(1); 21 | A a = new A(); 22 | A b = new A(); 23 | 24 | P p = new P(a); 25 | p.alias(b); 26 | A h = p.getA(); 27 | Benchmark.test("h", 28 | "{allocId:1, mayAlias:[h,b], notMayAlias:[a,p], mustAlias:[b,a], notMustAlias:[p]}"); 29 | Benchmark.use(h); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/collections/List1.java: -------------------------------------------------------------------------------- 1 | package collections; 2 | 3 | import java.util.ArrayList; 4 | 5 | import benchmark.internal.Benchmark; 6 | import benchmark.objects.A; 7 | 8 | /* 9 | * @testcase List1 10 | * 11 | * @version 1.0 12 | * 13 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 14 | * Institute SIT) 15 | * 16 | * @description ArrayList 17 | */ 18 | public class List1 { 19 | 20 | public static void main(String[] args) { 21 | 22 | ArrayList list = new ArrayList(); 23 | A a = new A(); 24 | Benchmark.alloc(1); 25 | A b = new A(); 26 | list.add(a); 27 | list.add(b); 28 | A c = list.get(1); 29 | Benchmark 30 | .test("b", 31 | "{allocId:1, mayAlias:[c,b], notMayAlias:[a,list], mustAlias:[c,b], notMustAlias:[a,list]}"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/collections/List2.java: -------------------------------------------------------------------------------- 1 | package collections; 2 | 3 | import java.util.LinkedList; 4 | 5 | import benchmark.internal.Benchmark; 6 | import benchmark.objects.A; 7 | 8 | /* 9 | * @testcase List2 10 | * 11 | * @version 1.0 12 | * 13 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 14 | * Institute SIT) 15 | * 16 | * @description LinkedList 17 | */ 18 | public class List2 { 19 | 20 | public static void main(String[] args) { 21 | 22 | LinkedList list = new LinkedList(); 23 | A a = new A(); 24 | Benchmark.alloc(1); 25 | A b = new A(); 26 | list.add(a); 27 | list.add(b); 28 | A c = list.get(1); 29 | Benchmark 30 | .test("b", 31 | "{allocId:1, mayAlias:[c,b], notMayAlias:[a,list], mustAlias:[c,b], notMustAlias:[a,list]}"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/collections/Map1.java: -------------------------------------------------------------------------------- 1 | package collections; 2 | 3 | import java.util.HashMap; 4 | 5 | import benchmark.internal.Benchmark; 6 | import benchmark.objects.A; 7 | 8 | /* 9 | * @testcase Map1 10 | * 11 | * @version 1.0 12 | * 13 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 14 | * Institute SIT) 15 | * 16 | * @description HashMap 17 | */ 18 | public class Map1 { 19 | 20 | public static void main(String[] args) { 21 | 22 | HashMap map = new HashMap(); 23 | A a = new A(); 24 | Benchmark.alloc(1); 25 | A b = new A(); 26 | map.put("first", a); 27 | map.put("second", b); 28 | A c = map.get("second"); 29 | Benchmark.test("c", 30 | "{allocId:1, mayAlias:[c,b], notMayAlias:[a,map], mustAlias:[c,b], notMustAlias:[a,map]}"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/generalJava/Exception2.java: -------------------------------------------------------------------------------- 1 | package generalJava; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase Exception2 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description No alias in exception (exception never triggered) 15 | */ 16 | public class Exception2 { 17 | 18 | public static void main(String[] args) { 19 | 20 | A a = new A(); 21 | Benchmark.alloc(1); 22 | A b = new A(); 23 | 24 | try { 25 | Integer.parseInt("abc"); 26 | a = b; 27 | 28 | } catch (RuntimeException e) { 29 | Benchmark.test("b", 30 | "{allocId:1, mayAlias:[b], notMayAlias:[a], mustAlias:[b], notMustAlias:[a]}"); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/basic/ReturnValue2.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase ReturnValue1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Alias to a return value from a static method 15 | */ 16 | public class ReturnValue2 { 17 | 18 | public ReturnValue2() {} 19 | 20 | public A id(A x) { 21 | return x; 22 | } 23 | 24 | public static void main(String[] args) { 25 | 26 | Benchmark.alloc(1); 27 | A a = new A(); 28 | ReturnValue2 rv2 = new ReturnValue2(); 29 | A b = rv2.id(a); 30 | Benchmark.test("b", 31 | "{allocId:1, mayAlias:[a,b], notMayAlias:[rv2], mustAlias:[a,b], notMustAlias:[rv2]}"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/basic/ReturnValue3.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase ReturnValue1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Alias to a return value from a static method 16 | */ 17 | public class ReturnValue3 { 18 | 19 | public static A id(A x) { 20 | A y = new A(); 21 | Benchmark.alloc(1); 22 | y.f = new B(); 23 | return y; 24 | } 25 | 26 | public static void main(String[] args) { 27 | 28 | A a = new A(); 29 | A b = id(a); 30 | B x = b.f; 31 | B y = a.f; 32 | Benchmark.test("x", 33 | "{allocId:1, mayAlias:[x], notMayAlias:[a,b,y], mustAlias:[x], notMustAlias:[a,b,y]}"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/cornerCases/ObjectSensitivity2.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase ObjectSensitivity2 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Object sensitive alias from parameter object 16 | */ 17 | public class ObjectSensitivity2 { 18 | 19 | public static void main(String[] args) { 20 | 21 | B b1 = new B(); 22 | Benchmark.alloc(1); 23 | B b2 = new B(); 24 | 25 | A a = new A(); 26 | 27 | B b3 = a.id(b1); 28 | B b4 = a.id(b2); 29 | 30 | Benchmark 31 | .test("b4", 32 | "{allocId:1, mayAlias:[b4,b2], notMayAlias:[a,b1,b3], mustAlias:[b4,b2], notMustAlias:[a,b1,b3]}"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/basic/Interprocedural1.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase Method1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Alias in a static method 16 | */ 17 | public class Interprocedural1 { 18 | 19 | public static void alloc(A x, A y) { 20 | x.f = y.f; 21 | } 22 | 23 | public static void main(String[] args) { 24 | 25 | A a = new A(); 26 | A b = new A(); 27 | 28 | Benchmark.alloc(1); 29 | b.f = new B(); 30 | alloc(a, b); 31 | 32 | B x = a.f; 33 | B y = b.f; 34 | Benchmark.test("x", 35 | "{allocId:1, mayAlias:[x,y], notMayAlias:[a,b], mustAlias:[x,y], notMustAlias:[a,b]}"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/basic/Branching1.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase Branching1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Condition. a and b alias on one path, not on the other 15 | */ 16 | public class Branching1 { 17 | 18 | public static void main(String[] args) { 19 | int i = 0; 20 | 21 | Benchmark.alloc(1); 22 | A a = new A(); 23 | Benchmark.alloc(2); 24 | A b = new A(); 25 | 26 | if (i < 0) 27 | a = b; 28 | 29 | Benchmark.test("a", 30 | "{allocId:1, mayAlias:[a], notMayAlias:[i,b], mustAlias:[a], notMustAlias:[i,b]}," 31 | + "{allocId:2, mayAlias:[a,b], notMayAlias:[i], mustAlias:[a], notMustAlias:[i,b]}"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/generalJava/Interface1.java: -------------------------------------------------------------------------------- 1 | package generalJava; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.G; 6 | import benchmark.objects.H; 7 | 8 | /* 9 | * @testcase Interface1 10 | * 11 | * @version 1.0 12 | * 13 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 14 | * Institute SIT) 15 | * 16 | * @description Alias from method in interface 17 | */ 18 | public class Interface1 { 19 | 20 | public static void main(String[] args) { 21 | 22 | A a = new A(); 23 | Benchmark.alloc(1); 24 | A b = new A(); 25 | 26 | G g = new G(); 27 | H h = new H(); 28 | g.foo(a); 29 | A c = h.foo(b); 30 | 31 | Benchmark.test("c", 32 | "{allocId:1, mayAlias:[c,b], notMayAlias:[a,g,h], mustAlias:[c,b], notMustAlias:[a,g,h]}"); 33 | 34 | Benchmark.use(c); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Eclipse ### 4 | *.pydevproject 5 | .metadata 6 | .gradle 7 | bin/ 8 | tmp/ 9 | *.tmp 10 | *.bak 11 | *.swp 12 | *~.nib 13 | local.properties 14 | .settings/ 15 | .loadpath 16 | 17 | # Eclipse Core 18 | .project 19 | 20 | # External tool builders 21 | .externalToolBuilders/ 22 | 23 | # Locally stored "Eclipse launch configurations" 24 | *.launch 25 | 26 | # CDT-specific 27 | .cproject 28 | 29 | # JDT-specific (Eclipse Java Development Tools) 30 | .classpath 31 | 32 | # PDT-specific 33 | .buildpath 34 | 35 | # sbteclipse plugin 36 | .target 37 | 38 | # TeXlipse plugin 39 | .texlipse 40 | 41 | 42 | ### Java ### 43 | *.class 44 | 45 | # Mobile Tools for Java (J2ME) 46 | .mtj.tmp/ 47 | 48 | # Package Files # 49 | *.jar 50 | *.war 51 | *.ear 52 | 53 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 54 | hs_err_pid* 55 | -------------------------------------------------------------------------------- /src/collections/Set1.java: -------------------------------------------------------------------------------- 1 | package collections; 2 | 3 | import java.util.HashSet; 4 | 5 | import benchmark.internal.Benchmark; 6 | import benchmark.objects.A; 7 | 8 | /* 9 | * @testcase Set1 10 | * 11 | * @version 1.0 12 | * 13 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 14 | * Institute SIT) 15 | * 16 | * @description HashSet 17 | */ 18 | public class Set1 { 19 | 20 | public static void main(String[] args) { 21 | 22 | HashSet set = new HashSet(); 23 | A a = new A(); 24 | A c = null; 25 | Benchmark.alloc(1); 26 | A b = new A(); 27 | set.add(a); 28 | set.add(b); 29 | for (A i : set) { 30 | c = i; 31 | break; 32 | } 33 | a = null; 34 | Benchmark.test("c", 35 | "{allocId:1, mayAlias:[c], notMayAlias:[a,b,set], mustAlias:[c], notMustAlias:[a,b,set]}"); 36 | Benchmark.use(c); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/cornerCases/FieldSensitivity1.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase FieldSensitivity1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Field Sensitivity with static method 16 | */ 17 | public class FieldSensitivity1 { 18 | 19 | private static void assign(A x, A y) { 20 | y.f = x.f; 21 | } 22 | 23 | public static void main(String[] args) { 24 | 25 | Benchmark.alloc(1); 26 | B b = new B(); 27 | A a = new A(b); 28 | A c = new A(); 29 | assign(a, c); 30 | B d = c.f; 31 | 32 | Benchmark.test("d", 33 | "{allocId:1, mayAlias:[d,b], notMayAlias:[a,c], mustAlias:[d,b], notMustAlias:[a,c]}"); 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/cornerCases/ObjectSensitivity1.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase ObjectSensitivity1 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Object sensitive alias from caller object 16 | */ 17 | public class ObjectSensitivity1 { 18 | 19 | public static void main(String[] args) { 20 | 21 | B b1 = new B(); 22 | Benchmark.alloc(1); 23 | B b2 = new B(); 24 | 25 | A a1 = new A(b1); 26 | A a2 = new A(b2); 27 | 28 | B b3 = a1.getF(); 29 | B b4 = a2.getF(); 30 | 31 | Benchmark 32 | .test( 33 | "b4", 34 | "{allocId:1, mayAlias:[b4,b2], notMayAlias:[a1,a2,b1,b3], mustAlias:[b4,b2], notMustAlias:[a1,a2,b1,b3]}"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/basic/Interprocedural2.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase Method2 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Alias in a method 16 | */ 17 | public class Interprocedural2 { 18 | 19 | public Interprocedural2() {} 20 | 21 | public void alloc(A x, A y) { 22 | x.f = y.f; 23 | } 24 | 25 | public static void main(String[] args) { 26 | 27 | A a = new A(); 28 | A b = new A(); 29 | 30 | Benchmark.alloc(1); 31 | b.f = new B(); 32 | Interprocedural2 m2 = new Interprocedural2(); 33 | m2.alloc(a, b); 34 | 35 | B x = a.f; 36 | B y = b.f; 37 | Benchmark 38 | .test("x", 39 | "{allocId:1, mayAlias:[x,y], notMayAlias:[a,b,m2], mustAlias:[x,y], notMustAlias:[a,b,m2]}"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/cornerCases/FieldSensitivity2.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | import benchmark.objects.B; 6 | 7 | /* 8 | * @testcase FieldSensitivity2 9 | * 10 | * @version 1.0 11 | * 12 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 13 | * Institute SIT) 14 | * 15 | * @description Field Sensitivity without static method 16 | */ 17 | public class FieldSensitivity2 { 18 | 19 | public FieldSensitivity2() {} 20 | 21 | private void assign(A x, A y) { 22 | y.f = x.f; 23 | } 24 | 25 | private void test() { 26 | Benchmark.alloc(1); 27 | B b = new B(); 28 | A a = new A(b); 29 | A c = new A(); 30 | assign(a, c); 31 | B d = c.f; 32 | 33 | Benchmark.test("d", 34 | "{allocId:1, mayAlias:[d,b], notMayAlias:[a,c], mustAlias:[d,b], notMustAlias:[a,c]}"); 35 | } 36 | 37 | public static void main(String[] args) { 38 | 39 | FieldSensitivity2 fs2 = new FieldSensitivity2(); 40 | fs2.test(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/basic/Loops1.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | 5 | /* 6 | * @testcase Loops1 7 | * 8 | * @version 1.0 9 | * 10 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 11 | * Institute SIT) 12 | * 13 | * @description The analysis must support loop constructs. No allocation site in N 14 | */ 15 | public class Loops1 { 16 | 17 | public class N { 18 | public String value = ""; 19 | public N next; 20 | 21 | public N() { 22 | next = null; 23 | } 24 | } 25 | 26 | private void test() { 27 | Benchmark.alloc(1); 28 | N node = new N(); 29 | 30 | int i = 0; 31 | while (i < 10) { 32 | node = node.next; 33 | i++; 34 | } 35 | 36 | N o = node.next; 37 | N p = node.next.next; 38 | N q = node.next.next.next; 39 | 40 | Benchmark 41 | .test("node", 42 | "{allocId:1, mayAlias:[node], notMayAlias:[i,o,p,q], mustAlias:[node], notMustAlias:[i,o,p,q]}"); 43 | } 44 | 45 | public static void main(String[] args) { 46 | Loops1 l1 = new Loops1(); 47 | l1.test(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/generalJava/OuterClass1.java: -------------------------------------------------------------------------------- 1 | package generalJava; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase OuterClass1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Alias from method in inner class 15 | */ 16 | public class OuterClass1 { 17 | 18 | public OuterClass1() {} 19 | 20 | public class InnerClass { 21 | private A a; 22 | 23 | public InnerClass(A a) { 24 | this.a = a; 25 | } 26 | 27 | public void alias(A x) { 28 | this.a = x; 29 | } 30 | } 31 | 32 | private void test() { 33 | Benchmark.alloc(1); 34 | A a = new A(); 35 | A b = new A(); 36 | 37 | InnerClass i = new InnerClass(a); 38 | i.alias(b); 39 | A h = i.a; 40 | Benchmark.test("h", 41 | "{allocId:1, mayAlias:[b,h], notMayAlias:[i,a], mustAlias:[b,a], notMustAlias:[i]}"); 42 | } 43 | 44 | private static void main(String[] args) { 45 | OuterClass1 oc1 = new OuterClass1(); 46 | oc1.test(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/basic/Loops2.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | 5 | /* 6 | * @testcase Loops2 7 | * 8 | * @version 1.0 9 | * 10 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 11 | * Institute SIT) 12 | * 13 | * @description The analysis must support loop constructs. Allocation site in N 14 | */ 15 | public class Loops2 { 16 | 17 | public class N { 18 | public String value = ""; 19 | public N next; 20 | 21 | public N() { 22 | Benchmark.alloc(2); 23 | next = new N(); 24 | } 25 | } 26 | 27 | private void test() { 28 | Benchmark.alloc(1); 29 | N node = new N(); 30 | 31 | int i = 0; 32 | while (i < 10) { 33 | node = node.next; 34 | i++; 35 | } 36 | 37 | N o = node.next; 38 | N p = node.next.next; 39 | Benchmark.test("node", 40 | "{allocId:1, mayAlias:[node], notMayAlias:[i,o,p], mustAlias:[node], notMustAlias:[p]}," 41 | + "{allocId:2, mayAlias:[o], notMayAlias:[node], mustAlias:[o], notMustAlias:[p]}"); 42 | } 43 | 44 | public static void main(String[] args) { 45 | Loops2 l1 = new Loops2(); 46 | l1.test(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/cornerCases/ContextSensitivity1.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase ContextSensitivity1 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Object sensitive alias from caller object (1-CS) 15 | */ 16 | public class ContextSensitivity1 { 17 | 18 | public ContextSensitivity1() {} 19 | 20 | public void callee(A a, A b) { 21 | Benchmark.test("b", 22 | "{allocId:1, mayAlias:[a,b], notMayAlias:[], mustAlias:[a,b], notMustAlias:[]}," 23 | + "{allocId:2, mayAlias:[a], notMayAlias:[b], mustAlias:[a], notMustAlias:[b]}"); 24 | } 25 | 26 | public void test1() { 27 | Benchmark.alloc(1); 28 | A a1 = new A(); 29 | A b1 = a1; 30 | callee(a1, b1); 31 | } 32 | 33 | public void test2() { 34 | A a2 = new A(); 35 | Benchmark.alloc(2); 36 | A b2 = new A(); 37 | callee(a2, b2); 38 | } 39 | 40 | public static void main(String[] args) { 41 | ContextSensitivity1 cs1 = new ContextSensitivity1(); 42 | cs1.test1(); 43 | cs1.test2(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/basic/Recursion1.java: -------------------------------------------------------------------------------- 1 | package basic; 2 | 3 | import benchmark.internal.Benchmark; 4 | 5 | /* 6 | * @testcase Recursion1 7 | * 8 | * @version 1.0 9 | * 10 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 11 | * Institute SIT) 12 | * 13 | * @description The analysis must support recursion 14 | */ 15 | public class Recursion1 { 16 | 17 | public Recursion1() {} 18 | 19 | public class N { 20 | public String value; 21 | public N next; 22 | 23 | public N(String value) { 24 | this.value = value; 25 | next = null; 26 | } 27 | } 28 | 29 | public N recursive(int i, N m) { 30 | if (i < 10) { 31 | int j = i + 1; 32 | return recursive(j, m.next); 33 | } 34 | return m; 35 | } 36 | 37 | public void test() { 38 | Benchmark.alloc(1); 39 | N node = new N(""); 40 | 41 | Recursion1 r1 = new Recursion1(); 42 | N n = r1.recursive(0, node); 43 | 44 | N o = node.next; 45 | N p = node.next.next; 46 | N q = node.next.next.next; 47 | 48 | Benchmark.test("n", 49 | "{allocId:1, mayAlias:[n], notMayAlias:[o,p,q], mustAlias:[n], notMustAlias:[o,p,q]}"); 50 | } 51 | 52 | public static void main(String[] args) { 53 | Recursion1 r1 = new Recursion1(); 54 | r1.test(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/cornerCases/ContextSensitivity2.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase ContextSensitivity2 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Object sensitive alias from caller object (2-CS) 15 | */ 16 | public class ContextSensitivity2 { 17 | 18 | public ContextSensitivity2() {} 19 | 20 | public void callee(A a, A b) { 21 | Benchmark.test("b", 22 | "{allocId:1, mayAlias:[a,b], notMayAlias:[], mustAlias:[a,b], notMustAlias:[]}," 23 | + "{allocId:2, mayAlias:[a], notMayAlias:[b], mustAlias:[a], notMustAlias:[b]}"); 24 | } 25 | 26 | public void test1() { 27 | Benchmark.alloc(1); 28 | A a1 = new A(); 29 | A b1 = a1; 30 | test11(a1, b1); 31 | } 32 | 33 | private void test11(A a1, A b1) { 34 | callee(a1, b1); 35 | } 36 | 37 | public void test2() { 38 | A a2 = new A(); 39 | Benchmark.alloc(2); 40 | A b2 = new A(); 41 | test22(a2, b2); 42 | } 43 | 44 | private void test22(A a2, A b2) { 45 | callee(a2, b2); 46 | } 47 | 48 | public static void main(String[] args) { 49 | ContextSensitivity2 cs1 = new ContextSensitivity2(); 50 | cs1.test1(); 51 | cs1.test2(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/cornerCases/ContextSensitivity3.java: -------------------------------------------------------------------------------- 1 | package cornerCases; 2 | 3 | import benchmark.internal.Benchmark; 4 | import benchmark.objects.A; 5 | 6 | /* 7 | * @testcase ContextSensitivity3 8 | * 9 | * @version 1.0 10 | * 11 | * @author Johannes Späth, Nguyen Quang Do Lisa (Secure Software Engineering Group, Fraunhofer 12 | * Institute SIT) 13 | * 14 | * @description Object sensitive alias from caller object (3-CS) 15 | */ 16 | public class ContextSensitivity3 { 17 | 18 | public ContextSensitivity3() {} 19 | 20 | public void callee(A a, A b) { 21 | Benchmark.test("b", 22 | "{allocId:1, mayAlias:[a,b], notMayAlias:[], mustAlias:[a,b], notMustAlias:[]}," 23 | + "{allocId:2, mayAlias:[a], notMayAlias:[b], mustAlias:[a], notMustAlias:[b]}"); 24 | } 25 | 26 | public void test1() { 27 | Benchmark.alloc(1); 28 | A a1 = new A(); 29 | A b1 = a1; 30 | test11(a1, b1); 31 | } 32 | 33 | private void test11(A a1, A b1) { 34 | test111(a1, b1); 35 | } 36 | 37 | private void test111(A a1, A b1) { 38 | callee(a1, b1); 39 | } 40 | 41 | public void test2() { 42 | A a2 = new A(); 43 | Benchmark.alloc(2); 44 | A b2 = new A(); 45 | test22(a2, b2); 46 | } 47 | 48 | private void test22(A a2, A b2) { 49 | test222(a2, b2); 50 | } 51 | 52 | private void test222(A a2, A b2) { 53 | callee(a2, b2); 54 | } 55 | 56 | public static void main(String[] args) { 57 | ContextSensitivity3 cs1 = new ContextSensitivity3(); 58 | cs1.test1(); 59 | cs1.test2(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [](#pointerbench---a-points-to-and-alias-analysis-benchmark-suite)PointerBench - A Points-to and Alias Analysis Benchmark Suite 2 | 3 | Evaluating precision and soundness of pointer analyses has been a tedious task. This is because of a missing ground truth. The ground truth for pointer analyses hold the information about (1) where an object may/must have been created and (2) what are its may/must aliases. On arbitrary programs, this information can hardly be retrieved. That is why we created PointerBench. 4 | 5 | PointerBench is an open benchmark suite for various types of pointer analyses. It consists of various small test programs. Each of them is designed to test pointer analyses strength and weaknesses (Field, Flow or Context-Senstivity). Different aspects are separated from each other (as far as possible). 6 | 7 | The test cases contain special function calls (see instructions below). The statement and argument of the function calls describe the variable to test and its aliases. To test different analyses, these function calls must be parsed and interpreted. These deliver input and output to the analyses. 8 | 9 | ### [](#list-of-tests)List of tests 10 | 11 | | Basic | No. of Tests | 12 | | --- | :-: | 13 | | Simple aliasing | 1 | 14 | | Branching | 1 | 15 | | Parameters | 2 | 16 | | Method alias | 2 | 17 | | Return value | 2 | 18 | | Loops | 2 | 19 | | Recursion | 1 | 20 | 21 | | General Java | No. of Tests | 22 | | --- | :-: | 23 | | Static variables | 1 | 24 | | Interfaces | 1 | 25 | | Super classes | 1 | 26 | | Outer classes | 1 | 27 | | Null aliasing | 2 | 28 | | Exceptions | 2 | 29 | 30 | | Corner cases | No. of Tests | 31 | | --- | :-: | 32 | | Access paths | 1 | 33 | | Object sensitive | 2 | 34 | | Field sensitive | 1 | 35 | | Flow sensitive | 1 | 36 | | Context sensitive | 3 | 37 | | Strong updates | 2 | 38 | 39 | | Collections | No. of Tests | 40 | | --- | :-: | 41 | | Arrays | 1 | 42 | | Lists (ArrayList, LinkedList) | 2 | 43 | | Maps (HashMap) | 1 | 44 | | Sets (HashSet) | 1 | 45 | 46 | ### [](#instructions-on-special-function-calls)Instructions on special function calls 47 | 48 | There are two static functions within package `benchmark.internal`. 49 | 50 | `Benchmark.alloc(int)` and `Benchmark.test(String,String)`. Both are used to describe the test cases variable, allocation sites and its aliases directly within the test program's code. To use this benchmark, the appropriate information must be parsed from this function calls. 51 | 52 | `Benchmark.alloc(1);` Used to mark an allocation site. The allocation site is the following new statement. 1 is the id of the allocation site. We refer to it at test. 53 | 54 | `Benchmark.test("a.f", "{allocId:1, mayAlias:[b,a.f], notMayAlias:[], mustAlias:[b,x], notMustAlias:[]}, {allocId:2, mayAlias:[a,d], notMayAlias:[c], mustAlias:[a], notMustAlias:[c,d]}");` This call defines the statement at which the test is conducted and contains the ground truth. The first argument, `"a.f"` is the access path for which the test runs. Full pointer information for `"a.f"` at this statement is described in the second argument. For each possible allocation site: `allocId` refers to the `Benchmark.alloc()` statement `mayAlias` and `mustAlias` give the access paths which alias to `"a.f"` through the referenced allocation site `notMayAlias` and `notMustAlias` give all access paths of the program that do not alias to `"a.f"` through the referenced allocation site. Together, the `alias` and `notAlias` information is the full set of variables in the scope of the current method. Note, to avoid the test case being polluted by unnecessary allocation sites, two Strings are supplied as arguments. 55 | 56 | ### [](#how-to-test-a-pointer-analysis)How to test a pointer analysis 57 | 58 | #### [](#alias-analysis)Alias Analysis 59 | 60 | Query: at statement `s`, do `a` and `b` alias? 61 | 62 | Only consider the `Benchmark.test()` statement. The statement `s` is given through the invocation of that method. Parse the `mayAlias` and `notMayAlias` information (or `must` information, according to what is tested) union over all allocation sites. For each variable in the `mayAlias` set, remove the possible duplicates in the `mayNotAlias` set. For each variable in the `mayAlias` set, make sure that it aliases to the test access path of test (`"a.f"`). For each variable in the `notMayAlias` set, make sure that it does not alias to the test access path (`"a.f"`). 63 | 64 | #### [](#points-to-analysis)Points-to Analysis 65 | 66 | Query: What are the possible allocation sites of a variable/access path `a` at statement `s`? 67 | 68 | The statement `s` is given through the statement at which `Benchmark.test()` is called. Parse all `allocId` given at the statement within the call. Match them to the ids given at the `Benchmark.alloc(int)`. For each matching `Benchmark.alloc()`, make sure that the the allocation site following the `Benchmark.alloc(int)` statement is within the computed points-to set for `a` and `s`. 69 | 70 | #### [](#points-to-and-all-alias-analysis-such-as-boomerang)Points-to and All-alias Analysis (such as Boomerang) 71 | 72 | Query: What are the possible allocation sites of variable/access path `a` at some statement `s` and what are the access paths/graphs possibly pointing to those allocation sites? 73 | 74 | All this information is provided through the second argument. --------------------------------------------------------------------------------