From: "Roedy Green" < >
> On Sun, 2 Oct 2005 01:39:49 +0100, "John Perks and Sarah Mount"
> <> wrote or quoted :
> >Which is the definitive spec? Is it the book "Programmer's Guide and
> >Specification" (Guide) , or the online doc "Specification" v1.5
(Spec)?
> I don't think would have stood a chance getting my first JNI apps
> going without Liang's book
> http://www.amazon.com/exec/obidos/AS...nadianmindprod
That's the "Guide" I was referring to (you can download it all from
Sun). Both it and the online spec seem to regard themselves as
definitive, but sometimes they contradict one another (which functions
can be called while an exception is pending) or they're seemingly vague
(exactly which functions can FatalError in event of LocalRef
exhaustion). Whom/Where should I ask about resolving something like
that? Is there anyone here who's actually had to implement JNI itself,
and run up against speccing issues?
(I'm assuming where the Liang book contradicts itself by saying "The
virtual machine exits if it fails to allocate the memory.", then later
syaing it throws an exception (viz PushLocalFrame/EnsureLocalCapacity),
the latter is the case.)
Crucially, these documents differ over what will lead to Undefined
Behaviour (most notably in the area of pending exceptions.) While it may
be safe to assume that Sun's implementation satifies both these sets of
requirements, a different implementation may only work to the online
Spec whithout even knowing there's another "definitive" book out there,
leading to differing notions of what is safe; when I call
DeleteLocalRef() on *their* implementations, I could be engaging in
Undefined Behaviour.
http://java.sun.com/j2se/1.5.0/docs/...n.html#wp17626
"When there is a pending exception, the only JNI functions that are safe
to call are ExceptionOccurred(), ExceptionDescribe(), and
ExceptionClear()." with no mention of ExceptionCheck(), or that
currently ExceptionDescribe clears the exception as well (bug or
feature?).
I am also wondering how to program defensively. You can't just call
ExceptionOccurred(), as that might FatalError() becuause it's out of
LocalRefs. So before doing that, you call EnsureLocalCapacity()... but
you can't do that because an exception might be pending. And so on.
> Today you might stand a better chance because there is more sample
> code on the web and more people familiar with it you can ask questions
> of.
From the response, they don't seem to gather here. Where's the best
place to look? I mailed jni@java (as they suggest somewhere) some time
ago and didn't get so much as an autoreply.
> I was surprised to find Sun linking to my site as a JNI resource. That
> is even more surprising when you discover how I teased them for its
> complexity.
I don't find it complex, just under-specced in places.
Thanks
John