jjfiv / dalvik-js

Project for CS 691ST - Dalvik VM implementation in Javascript
23 stars 11 forks source link

check-cast #85

Closed etosch closed 12 years ago

etosch commented 12 years ago

Throw a ClassCastException if the reference in the given register cannot be cast to the indicated type. Note: Since A must always be a reference (and not a primitive value), this will necessarily fail at runtime (that is, it will throw an exception) if B refers to a primitive type.

My current implementation is more permissive than this; I believe it would allow "references" to primitive types to pass because there is not currently a distinction in our system, other than type annotation (someone correct me if I'm wrong). I'm going to modify check-cast to assert that the contents of the reference cell is not a primitive type. Any other suggestions? Is this something we might want to try to test? Will an appropriate test case even pass the java compiler?

jjfiv commented 12 years ago

I'm going to modify check-cast to assert that the contents of the reference cell is not a primitive type. Any other suggestions?

I think you implemented this without an assert; we really need to see what Java does, if it's not a compile error, before we make it an assert.

etosch commented 12 years ago

Yeah, now it just has the check for whether it's a primitive. I'm not sure what to do; we could stick an assert in to be safe and make the call of whether or not we really need once we get a few more data points...

jjfiv commented 12 years ago

There seems to be a separate issue #87 for testing this, so I'm going to close-hammer this one.