Closed Juby210 closed 1 year ago
I think this is because ART pre-verified your subclass before MakeClassInheritable is actually called. Try to use ClassLoader
to manually load your class after calling MakeClassInheritable
oh, yeah using
var c = AndroidTest.class.getClassLoader().loadClass("io.github.juby210.lsplant_demo.Test");
c.newInstance();
works Do you think that using class like this without reflection is possible?
You can try Test.class.newInstance()
, which should do the same trick.
You can bypass background verification by hooking _ZN3art14OatFileManager25RunBackgroundVerificationERKNSt3__16vectorIPKNS_7DexFileENS1_9allocatorIS5_EEEEP8_jobjectPKc
.
We may consider introducing a new API to discard the verification result of a specific class (in your case, the Test
class).
Thanks for the help, in the meantime I also found that if I start using the Test
class in a class that's loaded after calling makeInheritable
then it also works without using reflection
Anyway, I will close this issue because MakeClassInheritable
does work.
Hello! I found an issue with
MakeClassInheritable
, it removes final modifier only for reflection, while trying to extend modified class fails withjava.lang.VerifyError
Here's my example code:
Test.java
AndroidTest.java
It passes all assert tests, but throws VerifyError on creation of new instance of my Test class. Here's full demo repo: https://github.com/Juby210/lsplant_demo