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:
sjfink 2009-05-01 12:50:17 +00:00
parent 9939142eae
commit 948dab4d0d
9 changed files with 59 additions and 73 deletions

View File

@ -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.InstanceKeyFactory;
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.util.collections.HashSetFactory;
import com.ibm.wala.util.debug.Assertions;
public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
@ -38,7 +36,6 @@ public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
protected LexicalParent[] getParents(InstanceKey base) {
IClass cls = base.getConcreteType();
if (isPossiblyLexicalClass(cls)) {
try {
Set<LexicalParent> result = HashSetFactory.make();
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()]);
}
} catch (ClassHierarchyException e) {
Assertions.UNREACHABLE();
}
}
if (AstTranslator.DEBUG_LEXICAL)

View File

@ -202,7 +202,7 @@ abstract public class AstClass implements IClass, ClassConstants {
return result;
}
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
public Collection<IMethod> getAllMethods() {
Collection<IMethod> result = HashSetFactory.make();
for (Iterator<IMethod> ms = getDeclaredMethods().iterator(); ms.hasNext();) {
result.add(ms.next());

View File

@ -23,7 +23,6 @@ import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ipa.callgraph.CGNode;
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.ssa.ConstantValue;
import com.ibm.wala.ssa.DefUse;
@ -45,8 +44,8 @@ import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.debug.Assertions;
/**
* An {@link SSAContextInterpreter} specialized to interpret methods on java.lang.Class in a {@link JavaTypeContext}
* which represents the point-type of the class object created by the call.
* An {@link SSAContextInterpreter} specialized to interpret methods on java.lang.Class in a {@link JavaTypeContext} which
* represents the point-type of the class object created by the call.
*
* Currently supported methods:
* <ul>
@ -172,10 +171,9 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
return false;
}
MethodReference mRef = node.getMethod().getReference();
return mRef.equals(GET_CONSTRUCTOR) || mRef.equals(GET_CONSTRUCTORS)
|| 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_METHODS);
return mRef.equals(GET_CONSTRUCTOR) || mRef.equals(GET_CONSTRUCTORS) || 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_METHODS);
}
public Iterator<NewSiteReference> iterateNewSites(CGNode node) {
@ -219,12 +217,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
private Collection<IMethod> getAllNormalPublicMethods(IClass cls) {
Collection<IMethod> result = HashSetFactory.make();
Collection<IMethod> allMethods = null;
try {
allMethods = cls.getAllMethods();
} catch (ClassHierarchyException e) {
Assertions.UNREACHABLE();
e.printStackTrace();
}
for (IMethod m : allMethods) {
if (!m.isInit() && !m.isClinit() && m.isPublic()) {
result.add(m);
@ -233,7 +226,6 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
return result;
}
/**
* Get all the constructors of a class
*/
@ -287,8 +279,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
int index = i++;
int indexVn = nextLocal++;
constants.put(indexVn, new ConstantValue(index));
SSAArrayStoreInstruction store = insts.ArrayStoreInstruction(retValue, indexVn, c,
TypeReference.JavaLangReflectConstructor);
SSAArrayStoreInstruction store = insts
.ArrayStoreInstruction(retValue, indexVn, c, TypeReference.JavaLangReflectConstructor);
statements.add(store);
}
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
* creates a return statement for each possible return value, each of which is a {@link ConstantValue} for an
* {@link IMethod}.
* create statements for methods like getConstructor() and getDeclaredMethod(), which return a single method. This creates a
* return statement for each possible return value, each of which is a {@link ConstantValue} for an {@link IMethod}.
*
* @param returnValues the possible return values for this method.
*/

View File

@ -295,7 +295,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @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();
}

View File

@ -317,7 +317,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
/*
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
*/
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
public Collection<IMethod> getAllMethods() {
Collection<IMethod> result = new LinkedList<IMethod>();
Iterator<IMethod> declaredMethods = getDeclaredMethods().iterator();
while (declaredMethods.hasNext()) {

View File

@ -134,7 +134,7 @@ public interface IClass extends IClassHierarchyDweller {
/**
* 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.

View File

@ -219,7 +219,7 @@ public class FakeRootClass extends SyntheticClass {
/*
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
*/
public Collection<IMethod> getAllMethods() throws UnsupportedOperationException, ClassHierarchyException {
public Collection<IMethod> getAllMethods() {
throw new UnsupportedOperationException();
}

View File

@ -221,7 +221,7 @@ public class BypassSyntheticClass extends SyntheticClass {
/*
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
*/
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
public Collection<IMethod> getAllMethods() {
return realType.getAllMethods();
}

View File

@ -77,7 +77,7 @@ public class ActionFormFactoryMethod extends SummarizedMethod {
return Collections.emptySet();
}
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
public Collection<IMethod> getAllMethods() {
// TODO Auto-generated method stub
assert false;
return null;