GetLastError() (with and without debugger)
Pedro Lamarão
pedro.lamarao at prodist.com.br
Tue Aug 16 01:19:07 UTC 2022
Em seg., 15 de ago. de 2022 às 20:08, David Holmes <david.holmes at oracle.com>
escreveu:
> > I don't understand what you mean by library in this instance.
> > There are three calls, one to write, next to last-error, finally to log;
> > the application is doing nothing else in this snippet.
>
> I started my response with the generalized snippet:
>
> doSomeNativeAPIStuff();
> // <what can go here?>
> getLastErrorFromDoSomeNativeAPIStuff();
>
> You claimed libraries don't have to be responsible for preserving
> last-error, but other things are. But what do you define as a library here?
>
I am naming "library" something the application explicitly calls into,
and therefore falls into the programmer's responsibility to call in the
correct order.
The programmer must not, say, call into the system, then call some NIO
method, then try to observe the last result of the first call.
This is incorrect; NIO is not responsible for saving the programmer from
this mistake.
It doesn't matter that the programmer is calling a Java method that
indirectly calls into the system.
FFI it seems is introducing this problem, but nothing in the existing
> Java ecosystem is prepared to handle it: not the VM, not the debugger,
> not agents, nothing. It is simply not a problem that has been on
> anyone's radar when it comes to the application logic.
>
It is perfectly understandable that none of this was ever relevant, never a
problem, until now.
As has been observed by Maurizio, most JNI companion libraries "bundle" the
two calls in one for convenience, apparently with the effect of obtaining
some kind of "atomicity" from the perspective of the rest of the system.
If we must continue to do companion libraries to achieve correct results,
so be it.
I suppose all there is left to do is document this fact.
--
Pedro Lamarão
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20220815/6d352c4f/attachment.htm>
More information about the panama-dev
mailing list