RFR: 8259343: [macOS] Update JNI error handling in Cocoa code.
Phil Race
prr at openjdk.java.net
Sat Jan 9 01:33:06 UTC 2021
On Fri, 8 Jan 2021 04:40:36 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
>> But then "env" would need to be passed explicitly. I don't think the churn is worth it.
>> And a method would then need a .m or .c file ...
>
> But that could be merged to the CallXXXMethod and placed somewhere in the libosxapp
You mean those methods or macros that we already discussed and I explained why I do not want to do that ?
This is a small update for error checking not revisiting everything done before.
>> I don't think "most" of the time is very likely. JNI lookup failures don't cause exceptions to be thrown.
>> Is that what you are tihinking ?
>>
>> And separately, with either the current code of clearing exceptions or the change here to the practice of throwing NSException on seeing a Java Exception I think it very unlikely.
>
> Then how we get NoSuchMethodError here? https://bugs.openjdk.java.net/browse/JDK-8259232?
> https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetMethodID
> Calling Instance Methods: GetMethodID
> RETURNS:
> Returns a method ID, or NULL if the specified method cannot be found.
> THROWS:
> NoSuchMethodError: if the specified method cannot be found.
> ExceptionInInitializerError: if the class initializer fails due to an exception.
> OutOfMemoryError: if the system runs out of memory.
>
> Same for fields:
> https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetFieldID
Ok. I will only create my own if none is pending.
>> In my testing that code does not get called. The new code does. So the old code could probably be deleted as useless but it is also harmless and just maybe it'll catch something else, even if it isn't doing anything that I can see.
>
> That code for sure should be called, it is even improved recently by JDK-8255681
> I'll check how it was intended to work.
I hadn't noticed that line - and definintely not realised it was recent.
I suppose he must have had a way to trigger it.
But I don't think it hurts to have both.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1967
More information about the build-dev
mailing list