OSDN Git Service

Workaround invokesuper underspecified behavior.
authorAart Bik <ajcbik@google.com>
Tue, 5 Apr 2016 00:28:59 +0000 (17:28 -0700)
committerNicolas Geoffray <ngeoffray@google.com>
Tue, 10 May 2016 08:17:07 +0000 (09:17 +0100)
commitffaa91d39baf82006afe74ad6e59cfd498334017
treedab2ce329bc65dd770cdec619b35ae28a337289e
parentceeb3b73f84e8b11f362605007d382405d08d95c
Workaround invokesuper underspecified behavior.

The verifier allows invokesuper on a class unrelated
to the referring class. However, the runtime uses the vtable of
the super class of the referring class to lookup the ArtMethod.
Since the receiver has no relation to the referring class, this lead
to either jumping to a wrong method, or "luckily" throw a
NoSuchMethodError if the vtable index is out of bounds of the super
class of the referring class.

This changes the runtime behavior to always throw NoSuchMethodError
when hitting such invokesuper.

Also, we make the verifier consistent with the runtime by treating
such calls unresolved.

bug=27627004

(cherry picked from commit f663e341c550d1aa6f8f587d0ae0dbf7d254ff55)

Change-Id: Ibec5a1e3a3320c474e1e0e5634a9ef62ea734cdf
compiler/optimizing/instruction_builder.cc
runtime/entrypoints/entrypoint_utils-inl.h
runtime/verifier/method_verifier.cc
test/594-invoke-super/expected.txt [new file with mode: 0644]
test/594-invoke-super/info.txt [new file with mode: 0644]
test/594-invoke-super/smali/invoke-super.smali [new file with mode: 0644]
test/594-invoke-super/src/Main.java [new file with mode: 0644]