remove ClassHierarchyException from IClass.getAllMethods
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3557 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
9939142eae
commit
948dab4d0d
|
@ -23,10 +23,8 @@ import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory;
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
|
import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
|
||||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
|
||||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||||
import com.ibm.wala.util.collections.HashSetFactory;
|
import com.ibm.wala.util.collections.HashSetFactory;
|
||||||
import com.ibm.wala.util.debug.Assertions;
|
|
||||||
|
|
||||||
public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
|
public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
|
||||||
|
|
||||||
|
@ -38,7 +36,6 @@ public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
|
||||||
protected LexicalParent[] getParents(InstanceKey base) {
|
protected LexicalParent[] getParents(InstanceKey base) {
|
||||||
IClass cls = base.getConcreteType();
|
IClass cls = base.getConcreteType();
|
||||||
if (isPossiblyLexicalClass(cls)) {
|
if (isPossiblyLexicalClass(cls)) {
|
||||||
try {
|
|
||||||
Set<LexicalParent> result = HashSetFactory.make();
|
Set<LexicalParent> result = HashSetFactory.make();
|
||||||
|
|
||||||
for (Iterator MS = cls.getAllMethods().iterator(); MS.hasNext();) {
|
for (Iterator MS = cls.getAllMethods().iterator(); MS.hasNext();) {
|
||||||
|
@ -58,9 +55,7 @@ public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
|
||||||
|
|
||||||
return (LexicalParent[]) result.toArray(new LexicalParent[result.size()]);
|
return (LexicalParent[]) result.toArray(new LexicalParent[result.size()]);
|
||||||
}
|
}
|
||||||
} catch (ClassHierarchyException e) {
|
|
||||||
Assertions.UNREACHABLE();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AstTranslator.DEBUG_LEXICAL)
|
if (AstTranslator.DEBUG_LEXICAL)
|
||||||
|
|
|
@ -202,7 +202,7 @@ abstract public class AstClass implements IClass, ClassConstants {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
|
public Collection<IMethod> getAllMethods() {
|
||||||
Collection<IMethod> result = HashSetFactory.make();
|
Collection<IMethod> result = HashSetFactory.make();
|
||||||
for (Iterator<IMethod> ms = getDeclaredMethods().iterator(); ms.hasNext();) {
|
for (Iterator<IMethod> ms = getDeclaredMethods().iterator(); ms.hasNext();) {
|
||||||
result.add(ms.next());
|
result.add(ms.next());
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
|
||||||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||||
import com.ibm.wala.ssa.ConstantValue;
|
import com.ibm.wala.ssa.ConstantValue;
|
||||||
import com.ibm.wala.ssa.DefUse;
|
import com.ibm.wala.ssa.DefUse;
|
||||||
|
@ -45,8 +44,8 @@ import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||||
import com.ibm.wala.util.debug.Assertions;
|
import com.ibm.wala.util.debug.Assertions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link SSAContextInterpreter} specialized to interpret methods on java.lang.Class in a {@link JavaTypeContext}
|
* An {@link SSAContextInterpreter} specialized to interpret methods on java.lang.Class in a {@link JavaTypeContext} which
|
||||||
* which represents the point-type of the class object created by the call.
|
* represents the point-type of the class object created by the call.
|
||||||
*
|
*
|
||||||
* Currently supported methods:
|
* Currently supported methods:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -172,10 +171,9 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MethodReference mRef = node.getMethod().getReference();
|
MethodReference mRef = node.getMethod().getReference();
|
||||||
return mRef.equals(GET_CONSTRUCTOR) || mRef.equals(GET_CONSTRUCTORS)
|
return mRef.equals(GET_CONSTRUCTOR) || mRef.equals(GET_CONSTRUCTORS) || mRef.equals(GET_METHOD) || mRef.equals(GET_METHODS)
|
||||||
|| mRef.equals(GET_METHOD) || mRef.equals(GET_METHODS)
|
|| mRef.equals(GET_DECLARED_CONSTRUCTOR) || mRef.equals(GET_DECLARED_CONSTRUCTORS) || mRef.equals(GET_DECLARED_METHOD)
|
||||||
|| mRef.equals(GET_DECLARED_CONSTRUCTOR) || mRef.equals(GET_DECLARED_CONSTRUCTORS)
|
|| mRef.equals(GET_DECLARED_METHODS);
|
||||||
|| mRef.equals(GET_DECLARED_METHOD) || mRef.equals(GET_DECLARED_METHODS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterator<NewSiteReference> iterateNewSites(CGNode node) {
|
public Iterator<NewSiteReference> iterateNewSites(CGNode node) {
|
||||||
|
@ -219,12 +217,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
private Collection<IMethod> getAllNormalPublicMethods(IClass cls) {
|
private Collection<IMethod> getAllNormalPublicMethods(IClass cls) {
|
||||||
Collection<IMethod> result = HashSetFactory.make();
|
Collection<IMethod> result = HashSetFactory.make();
|
||||||
Collection<IMethod> allMethods = null;
|
Collection<IMethod> allMethods = null;
|
||||||
try {
|
|
||||||
allMethods = cls.getAllMethods();
|
allMethods = cls.getAllMethods();
|
||||||
} catch (ClassHierarchyException e) {
|
|
||||||
Assertions.UNREACHABLE();
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
for (IMethod m : allMethods) {
|
for (IMethod m : allMethods) {
|
||||||
if (!m.isInit() && !m.isClinit() && m.isPublic()) {
|
if (!m.isInit() && !m.isClinit() && m.isPublic()) {
|
||||||
result.add(m);
|
result.add(m);
|
||||||
|
@ -233,7 +226,6 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the constructors of a class
|
* Get all the constructors of a class
|
||||||
*/
|
*/
|
||||||
|
@ -287,8 +279,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
int index = i++;
|
int index = i++;
|
||||||
int indexVn = nextLocal++;
|
int indexVn = nextLocal++;
|
||||||
constants.put(indexVn, new ConstantValue(index));
|
constants.put(indexVn, new ConstantValue(index));
|
||||||
SSAArrayStoreInstruction store = insts.ArrayStoreInstruction(retValue, indexVn, c,
|
SSAArrayStoreInstruction store = insts
|
||||||
TypeReference.JavaLangReflectConstructor);
|
.ArrayStoreInstruction(retValue, indexVn, c, TypeReference.JavaLangReflectConstructor);
|
||||||
statements.add(store);
|
statements.add(store);
|
||||||
}
|
}
|
||||||
SSAReturnInstruction R = insts.ReturnInstruction(retValue, false);
|
SSAReturnInstruction R = insts.ReturnInstruction(retValue, false);
|
||||||
|
@ -307,9 +299,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create statements for methods like getConstructor() and getDeclaredMethod(), which return a single method. This
|
* create statements for methods like getConstructor() and getDeclaredMethod(), which return a single method. This creates a
|
||||||
* creates a return statement for each possible return value, each of which is a {@link ConstantValue} for an
|
* return statement for each possible return value, each of which is a {@link ConstantValue} for an {@link IMethod}.
|
||||||
* {@link IMethod}.
|
|
||||||
*
|
*
|
||||||
* @param returnValues the possible return values for this method.
|
* @param returnValues the possible return values for this method.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -295,7 +295,7 @@ public class ArrayClass implements IClass, Constants {
|
||||||
/*
|
/*
|
||||||
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
||||||
*/
|
*/
|
||||||
public Collection<IMethod> getAllMethods() throws UnimplementedError, ClassHierarchyException {
|
public Collection<IMethod> getAllMethods() {
|
||||||
return loader.lookupClass(getClassLoader().getLanguage().getRootType().getName()).getAllMethods();
|
return loader.lookupClass(getClassLoader().getLanguage().getRootType().getName()).getAllMethods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,7 +317,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
|
||||||
/*
|
/*
|
||||||
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
||||||
*/
|
*/
|
||||||
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
|
public Collection<IMethod> getAllMethods() {
|
||||||
Collection<IMethod> result = new LinkedList<IMethod>();
|
Collection<IMethod> result = new LinkedList<IMethod>();
|
||||||
Iterator<IMethod> declaredMethods = getDeclaredMethods().iterator();
|
Iterator<IMethod> declaredMethods = getDeclaredMethods().iterator();
|
||||||
while (declaredMethods.hasNext()) {
|
while (declaredMethods.hasNext()) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ public interface IClass extends IClassHierarchyDweller {
|
||||||
/**
|
/**
|
||||||
* Compute the methods declared by this class or any of its superclasses.
|
* Compute the methods declared by this class or any of its superclasses.
|
||||||
*/
|
*/
|
||||||
Collection<IMethod> getAllMethods() throws ClassHierarchyException;
|
Collection<IMethod> getAllMethods();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the instance fields declared by this class.
|
* Compute the instance fields declared by this class.
|
||||||
|
|
|
@ -219,7 +219,7 @@ public class FakeRootClass extends SyntheticClass {
|
||||||
/*
|
/*
|
||||||
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
||||||
*/
|
*/
|
||||||
public Collection<IMethod> getAllMethods() throws UnsupportedOperationException, ClassHierarchyException {
|
public Collection<IMethod> getAllMethods() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ public class BypassSyntheticClass extends SyntheticClass {
|
||||||
/*
|
/*
|
||||||
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
||||||
*/
|
*/
|
||||||
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
|
public Collection<IMethod> getAllMethods() {
|
||||||
return realType.getAllMethods();
|
return realType.getAllMethods();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class ActionFormFactoryMethod extends SummarizedMethod {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
|
public Collection<IMethod> getAllMethods() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
assert false;
|
assert false;
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue