Make verifier field/method resolution conformant.
The VM spec spells out a particular way to look for fields. It assumes
that static and virtual fields are piled together into a single pool,
so it makes sense to scan through both kinds when resolving. In Dalvik,
field definitions are separated by scope, so we can save a little time
by only searching through the appropriate list.
It turns out that you can create a situation where a field with the same
name is available in both static and virtual forms in the same class.
javac won't let you do this in a single class, but with separate
compilation and inheritance you can pull it off. In these situations,
Dalvik can do the wrong thing. For example, if you ask for a static
field, Dalvik will happily use the static field from a superclass without
realizing that there's an instance field with the same name in the current
class. It's supposed to find the instance field, realize that it's not
static, and throw an exception.
This change updates the verifier to do an "untyped" scan like the VM
spec wants. Problematic situations are identifed and result in an
"incompatible class change" exception.
This does not alter "direct" method lookups (constructors, private
methods).
I also altered the annotation "ambiguous" method lookup to use the new
function, since that's probably the desired behavior there as well.
4 files changed