add context for Arrays.toString()

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2709 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2008-03-17 14:13:25 +00:00
parent 3cfb242e6e
commit 7f6fbcf4db
1 changed files with 18 additions and 1 deletions

View File

@ -63,6 +63,7 @@ public class ContainerContextSelector implements ContextSelector {
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 Atom toString = Atom.findOrCreateUnicodeAtom("toString");
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;");
@ -130,6 +131,9 @@ public class ContainerContextSelector implements ContextSelector {
if (isArrayCopyMethod(m)) {
return true;
}
if (isArrayToStringMethod(m)) {
return true;
}
if (m.equals(StringValueOf)) {
return true;
}
@ -141,7 +145,7 @@ public class ContainerContextSelector implements ContextSelector {
/**
* return true iff m represents one of the well-known methods in java.lang.reflect.Arrays that
* do some sort of arraycopyd
* do some sort of arraycopy
*/
private static boolean isArrayCopyMethod(MethodReference m) {
if (m.getDeclaringClass().equals(Arrays)) {
@ -151,6 +155,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 toString() on an array
*/
private static boolean isArrayToStringMethod(MethodReference m) {
if (m.getDeclaringClass().equals(Arrays)) {
if (m.getName().equals(toString)){
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