classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: JNI/CNI Revisited


From: Jeroen Frijters
Subject: RE: JNI/CNI Revisited
Date: Sat, 1 Mar 2003 09:50:52 +0100


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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]