CNI namespace

Cedric Berger cedric@wireless-networks.com
Wed Apr 5 12:05:00 GMT 2000


Paul Fisher wrote:

> Cedric Berger <cedric@wireless-networks.com> writes:
>
> > class NativeQueue {
> >     native void send(Packet p);
> >     native Packet receive();
> > }
>
> [...]
>
> > will there be more than one wrapper around Packet?
>
> Each call to "send" or "receive" would result in a different proxy
> object being created.  So yes, there could be two different threads
> both dealing on the same object, but there would be a different proxy
> object for each thread that was off in native-land -- in effect, more
> than one wrapper around Packet would exist at the same time, each with
> a different JNIEnv.
>
> If this doesn't answer your question, let me know.

Ok, but then how will look the CNI functions if you want to store
Packet on a global native variable (or a queue, or whatever),
for example:

Packet *_global_variable;
NativeQueue::send(Packet *p) {
   _global_variable = p;
}
Packet *NativeQueue::receive() {
  return _global_variable;
}

since Packet is a wrapper-class, this won't work, right?

Cedric



More information about the Java mailing list