List of usage examples for java.io FileDescriptor getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static int getFd(FileDescriptor fileDescriptor) { int fdInt = -1; try {/*from w w w. jav a 2s .co m*/ if (fileDescriptor != null) { Field descriptor = fileDescriptor.getClass().getDeclaredField("descriptor"); descriptor.setAccessible(true); fdInt = descriptor.getInt(fileDescriptor); } } catch (Exception ex) { ex.printStackTrace(); } return fdInt; }
From source file:org.apache.cassandra.utils.CLibrary.java
/** * Get system file descriptor from FileDescriptor object. * @param descriptor - FileDescriptor objec to get fd from * @return file descriptor, -1 or error/*from w w w . ja v a2 s .c om*/ */ public static int getfd(FileDescriptor descriptor) { Field field = FBUtilities.getProtectedField(descriptor.getClass(), "fd"); if (field == null) return -1; try { return field.getInt(descriptor); } catch (Exception e) { logger.warn("unable to read fd field from FileDescriptor"); } return -1; }