Open mychris opened 5 years ago
@fengxue-IS Since you're already looking at #5784, can you pick this up as well?
will do
Currently we don't consider JNI::ExceptionClear()
as catching an exception.
Looking at how exception throw event is generate from JNI, I think we need a new flag in J9VMThread
similar to J9_PRIVATE_FLAGS_REPORT_EXCEPTION_THROW
for the catch part as well.
Also note that the spec is not specific on how to handle exception thrown in the same JNI frame. As exception event requires the thrown exception to reach Java level, I am assuming that only exceptions which already triggered the exception throw event can trigger the catch event. (ie. calling JNI::Throw
then JNI::ExceptionClear
in the same JNI native call will not generate any of the two event)
@DanHeidinga do you have any suggestions?
I am assuming that only exceptions which already triggered the exception throw event can trigger the catch event. (ie. calling JNI::Throw then JNI::ExceptionClear in the same JNI native call will not generate any of the two event)
Sounds like a great test case to write to validate that belief
I'm going to move this out of the 0.15.0
milestone as the correct behaviour isn't clear from the specification.
Moving to 0.18.0
as still waiting on OpenJDK to determine the specified behaviour for this case
Java -version output
Summary of problem
The JVMTI event
JVMTI_EVENT_EXCEPTION_CATCH
is not generated if the exception is caught in native code. The JVMTI documentation indicates, that the event should be generated "as soon as control is returned to a Java programming language method". The OpenJDK HotSpot VM currently has the same issue.The behavior is the same for all OpenJ9 versions available from https://adoptopenjdk.net.
Please see the example application and JVMTI agent at the end.
Output of the example application
OpenJ9:
Expected output:
Example application