[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SootClass/Type and java.lang.Class




There is a one-to-one correspondance between a
soot.Type object and a java.lang.Class object.

Suggestion:
Provide methods to go back and forth.

For RefType it is easy:
public Class getRepresentativeClass() {
    Class.forName(refType.getName());
}

For ArrayTypes and numerical types it is not so easy:
Class.forName("I");
or
String name = "";
for(int i = 0; i < arrayType.getDimensions(); i++) name += "[";
name += arrayType.getElementType().getRepresentativeClass().getName();
Class.forName(name);
(This could probably be better...)

Going the other way is slightly uglier, since we can't add methods to
java.lang.Class...

BTW: This would be useful because I'm doing static evaluation of methods
where possible.
I need the Class objects so I can reflect the appropriate field.
Similarly, a method in SootMethod to return a java.lang.reflect.Method and
a method in SootField to return a java.lang.reflect.Field would be useful...

Steve