ReadyTalk / avian

[INACTIVE] Avian is a lightweight virtual machine and class library designed to provide a useful subset of Java's features, suitable for building self-contained applications.
https://readytalk.github.io/avian/
Other
1.22k stars 173 forks source link

Possibly wrong method intercept logic #393

Closed lostdj closed 9 years ago

lostdj commented 9 years ago

Is there a reason for marking the original method as native in intercept(): https://github.com/ReadyTalk/avian/blob/master/src/avian/classpath-common.h#L614 ?

I have a managed intercepted method which will fail to invoke() again provided the original GcMethod reference. It's going to look for its native original impl and there is none.


Edit: I think I understand. You can either provide pointer to your function, or let it find a JNI interceptor function to call. So is it okay to make a clone of the original method regardless of updateRuntimeData value, and keep original's m->flags() unchanged?

dicej commented 9 years ago

Yeah, it looks like it might be wrong, but I'm surprised we haven't noticed a problem with it before. Do you have a test case that demonstrates the error?

Anyway, yeah, I think the solution will be to make the clone first, then set m->flags() |= ACC_PRIVATE, so the clone's flags don't change.

lostdj commented 9 years ago

Do you have a test case that demonstrates the error?

I do not, they do: http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/42770c335bf7/src/java.base/share/classes/java/io/FileInputStream.java#l187 :)