more robust handling of Arrays. copying methods
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2556 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
75006e83dd
commit
7550f071bc
|
@ -60,10 +60,9 @@ public class ContainerContextSelector implements ContextSelector {
|
|||
public final static MethodReference synthArraycopy = MethodReference.findOrCreate(SyntheticSystem, arraycopyAtom, arraycopyDesc);
|
||||
|
||||
private final static TypeReference Arrays = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/util/Arrays");
|
||||
private final static MethodReference ArraysAsList = MethodReference.findOrCreate(Arrays, "asList", "([Ljava/lang/Object;)Ljava/util/List;");
|
||||
private final static MethodReference ArraysCopyOfRange = MethodReference.findOrCreate(Arrays, "copyOfRange", "([CII)[C");
|
||||
private final static MethodReference ArraysCopyOf = MethodReference.findOrCreate(Arrays, "copyOf", "([Ljava/lang/Object;I)[Ljava/lang/Object;");
|
||||
private final static MethodReference ArraysCopyOf2 = MethodReference.findOrCreate(Arrays, "copyOf", "([Ljava/lang/Object;ILjava/lang/Class;)[Ljava/lang/Object;");
|
||||
private final static Atom asList = Atom.findOrCreateUnicodeAtom("asList");
|
||||
private final static Atom copyOf = Atom.findOrCreateUnicodeAtom("copyOf");
|
||||
private final static Atom copyOfRange = Atom.findOrCreateUnicodeAtom("copyOfRange");
|
||||
private final static MethodReference StringValueOf = MethodReference.findOrCreate(TypeReference.JavaLangString, "valueOf", "(Ljava/lang/Object;)Ljava/lang/String;");
|
||||
private final static MethodReference HashtableNewEntry = MethodReference.findOrCreate(JavaUtilHashtable, "newEntry", "(Ljava/lang/Object;Ljava/lang/Object;I)Ljava/util/Hashtable$Entry;");
|
||||
|
||||
|
@ -128,16 +127,7 @@ public class ContainerContextSelector implements ContextSelector {
|
|||
if (m.equals(synthArraycopy)) {
|
||||
return true;
|
||||
}
|
||||
if (m.equals(ArraysAsList)) {
|
||||
return true;
|
||||
}
|
||||
if (m.equals(ArraysCopyOfRange)) {
|
||||
return true;
|
||||
}
|
||||
if (m.equals(ArraysCopyOf)) {
|
||||
return true;
|
||||
}
|
||||
if (m.equals(ArraysCopyOf2)) {
|
||||
if (isArrayCopyMethod(m)) {
|
||||
return true;
|
||||
}
|
||||
if (m.equals(StringValueOf)) {
|
||||
|
@ -149,6 +139,19 @@ public class ContainerContextSelector implements ContextSelector {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* return true iff m represents one of the well-known methods in java.lang.reflect.Arrays that
|
||||
* do some sort of arraycopyd
|
||||
*/
|
||||
private static boolean isArrayCopyMethod(MethodReference m) {
|
||||
if (m.getDeclaringClass().equals(Arrays)) {
|
||||
if (m.getName().equals(asList) || m.getName().equals(copyOf) || m.getName().equals(copyOfRange)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method walks recursively up the definition of a context C, to see if the chain of contexts that give rise to C
|
||||
* a) includes the method M. or b) includes the method in which the receiver was allocated
|
||||
|
|
Loading…
Reference in New Issue