[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Soot typing failure
Ondrej Lhotak wrote:
> On Sat, Nov 15, 2003 at 10:54:14PM -0800, Stephen Andrew Neuendorffer wrote:
>>
>>public class test {
>> public static void main(String args[]) {
>> int[] array = null;
>> System.out.println("array = " + array.length);
>> }
>>}
>>
>>Exception in thread "main" java.lang.RuntimeException:
>>soot.jimple.toolkits.typing.TypeException:
>>soot.jimple.toolkits.typing.ConstraintChecker$RuntimeTypeException: Type Error(39)
This is the context of the thrown exception [type error 39]:
class ConstraintChecker extends AbstractStmtSwitch
{
...
...
public void caseAssignStmt(AssignStmt stmt)
{
//*** we have "lhs = rhs" statement
...
...
else if(r instanceof LengthExpr)
{
//*** rhs looks like "something.length"
LengthExpr le = (LengthExpr) r;
if(!left.hasDescendantOrSelf(hierarchy.typeNode(IntType.v())))
{
//*** we make sure the lhs is of int type
error("Type Error(38)");
}
if(le.getOp() instanceof Local)
{
//*** if "something" is a local variable ...
if(!hierarchy.typeNode(((Local) le.getOp()).getType()).hasElement())
{
//*** local has better be an array type.
error("Type Error(39)");
}
}
}
...
...
What is happening is that a null_type is assigned to the local variable. ".length" tells us
that this local is an array, but nothing about what kind of array. So, currently, the typing
algorithm assumes that something else in the program tells it what it is. The constraint checker
verifies that constraints are respected. Now, as nothing other than null_type is assigned to the
variable, and null_type has no element type (it is not an array type), the checker rejects the
assigned type.
Is this a bug or a feature? Hmmm... Good question. In fact, "null_type" is supposed to be a
subclass of all possible subclasses. So, the constraint checker should probably accept this
type assignment.
I guess null_type.hasElement() should return true.
I will investigate.
Etienne
--
Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/
SableVM: http://www.sablevm.org/
SableCC: http://www.sablecc.org/