Accessing UNIX FileDescriptor id without reflection

Peter Levart peter.levart at
Mon May 8 15:01:48 UTC 2017

Hi Enrico, is a public class, part of public API. There's 
one version for JVMs running on UNIX-based OSes and another for JVMs 
running on Windows. Both contain int field 'fd'. But you already know 
that if you access this field using reflection. Now instead of doing 
this in Java and then passing the numberic 'fd' down to native code, you 
could pass the whole FileDescriptor object to native code and access the 
field using JNI. There's no restriction imposed by Jigsaw in JNI.

Regards, Peter

On 05/08/2017 03:16 PM, Enrico Olivelli wrote:
> Hi,
> I am trying to port a project (Apache BookKeeper) to Java9, actually
> this code uses reflection in order to access the 'fd' field of the
> FileDescriptor class.
> We have to access that ID in order to call low level native functions
> See
> # getSysFileDescriptor
> Is there any way to access the FD handle without using reflecttion ?
> If not, is it possibile to enhance the FileDescriptor API in order to
> given access to the internal "fd" field ?
> Thank you
> Enrico Olivelli

More information about the core-libs-dev mailing list