harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Archie Cobbs <arc...@dellroad.org>
Subject Re: [classlib][NIO|VMI]JNI 1.4 enhancement on ByteBuffer
Date Tue, 13 Jun 2006 13:17:18 GMT
Paulex Yang wrote:
> There is some enhancement on JNI spec in JDK 1.4[1], and three methods 
> are related to java.nio.ByteBuffer.
>    * |NewDirectByteBuffer|
> <http://java.sun.com/j2se/1.4.2/docs/guide/jni/jni-14.html#NewDirectByteBuffer>

>    * |GetDirectBufferAddress|
> <http://java.sun.com/j2se/1.4.2/docs/guide/jni/jni-14.html#GetDirectBufferAddress>

>    * |GetDirectBufferCapacity|
> <http://java.sun.com/j2se/1.4.2/docs/guide/jni/jni-14.html#GetDirectBufferCapacity>

> Because these methods are actually classlib dependent and JNI 
> implementation must know some details of ByteBuffer implementation, 
> current IBM VME hasn't them implemented, and seems DRLVM doesn't 
> implemented thoroughly(please correct me if I made mistake here, seems 
> DRLVM tries to get some non-api method/field of ByteBuffer, and if 
> fails, it return NULL or -1 as JNI spec says). And I have no idea how 
> Sable/JCHEVM/BootJVM deals with this issue yet.(anyone kindly let me know?)

FYI, here is how this is handled in Classpath-based VMs like JCHEVM.

The direct buffer classes derive from a common superclass containing
the well known fields "data" and "capacity". The latter is an int,
while the former is of type gnu.classpath.Pointer32 (or Pointer64),
which is just a container that stores a native pointer in an int/long.
The native pointer points to the native buffer. These two fields are
accessed by GetDirectBufferAddress() and GetDirectBufferCapacity().

There is also a constructor available for the JNI code to call,
taking: gnu.classpath.Pointer32/64, and int (capacity). This is
used for NewDirectByteBuffer().

The resulting JNI code is fairly simple. You can see it on line 2580 of


Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com

Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

View raw message