Title: RE: JNI/CNI Revisited

Aaron M. Renn wrote:
[...]
> Needed for java.io (except File)
> --------------------------------
>   void nativeInit(); // For any required initialization
>
>   void nativeSync(long fd) throws SyncFailedException

I really don't like this model, because it forces the VM into using a long for the file descriptor. IMHO a better alternative would be to have instance methods in java.io.FileDescriptor that call a static native.

class FileDescriptor
{
  private long fd;

  void sync() {
    nativeSync(fd);
  }

  private static native void nativeSync(long fd);
}

This allows VMs (such as mine) that don't use an integer as a file handle, to replace FileDescriptor with a different implementation, but leave all other i/o classes as is.

There is a tiny overhead in this approach, but I think it is worth it (but then, I'm biased ;-)).

Regards,
Jeroen

_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to