Native Class — netty Architecture
Architecture documentation for the Native class in Native.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 67956c01_800f_62e3_c02e_32defdb23f9b["Native"] 25e7eacc_b5cc_2450_1f0a_5455fe41b261["Native.java"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|defined in| 25e7eacc_b5cc_2450_1f0a_5455fe41b261 6d46636f_6121_6e57_2228_c2e1dfe31c85["registerUnix()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 6d46636f_6121_6e57_2228_c2e1dfe31c85 10650759_77d7_1b5f_9136_4ae8e7ad62c6["FileDescriptor()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 10650759_77d7_1b5f_9136_4ae8e7ad62c6 dca5ef10_e5f0_a4c4_ee36_b74a5fab37e3["isSupportingUdpSegment()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| dca5ef10_e5f0_a4c4_ee36_b74a5fab37e3 57eb2aca_5c03_a5db_d7e3_44c27e52141b["eventFd()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 57eb2aca_5c03_a5db_d7e3_44c27e52141b f5895f73_df0b_9d6e_2992_740d1bc98a1b["timerFd()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| f5895f73_df0b_9d6e_2992_740d1bc98a1b 8245f909_2f70_2072_673a_26bab4a40baa["eventFdWrite()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 8245f909_2f70_2072_673a_26bab4a40baa 31607da2_b220_d5ed_11fd_d0f39bda09e1["eventFdRead()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 31607da2_b220_d5ed_11fd_d0f39bda09e1 e7f04708_2d54_838f_2c34_0affc4c4efe9["epollCreate()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| e7f04708_2d54_838f_2c34_0affc4c4efe9 2820dc3b_b00d_6479_1c1c_9aa2cd6606c9["epollWait()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 2820dc3b_b00d_6479_1c1c_9aa2cd6606c9 0740640f_dcec_a559_c486_583cd33cb0d0["epollReady()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 0740640f_dcec_a559_c486_583cd33cb0d0 ae916562_f571_5636_d0f2_38ec790b4224["epollTimerWasUsed()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| ae916562_f571_5636_d0f2_38ec790b4224 12ef510f_040b_76fd_2616_b92f7a53a716["epollBusyWait()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| 12ef510f_040b_76fd_2616_b92f7a53a716 c2a9447b_93df_748a_700a_a466c3e41d45["epollWait0()"] 67956c01_800f_62e3_c02e_32defdb23f9b -->|method| c2a9447b_93df_748a_700a_a466c3e41d45
Relationship Graph
Source Code
transport-classes-epoll/src/main/java/io/netty/channel/epoll/Native.java lines 54–349
public final class Native {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(Native.class);
static final InetAddress INET6_ANY;
static final InetAddress INET_ANY;
static {
Selector selector = null;
try {
// We call Selector.open() as this will under the hood cause IOUtil to be loaded.
// This is a workaround for a possible classloader deadlock that could happen otherwise:
//
// See https://github.com/netty/netty/issues/10187
selector = Selector.open();
} catch (IOException ignore) {
// Just ignore
}
try {
INET_ANY = InetAddress.getByName("0.0.0.0");
INET6_ANY = InetAddress.getByName("::");
} catch (UnknownHostException e) {
throw new ExceptionInInitializerError(e);
}
// Preload all classes that will be used in the OnLoad(...) function of JNI to eliminate the possiblity of a
// class-loader deadlock. This is a workaround for https://github.com/netty/netty/issues/11209.
// This needs to match all the classes that are loaded via NETTY_JNI_UTIL_LOAD_CLASS or looked up via
// NETTY_JNI_UTIL_FIND_CLASS.
ClassInitializerUtil.tryLoadClasses(Native.class,
// netty_epoll_linuxsocket
PeerCredentials.class, DefaultFileRegion.class, FileChannel.class, java.io.FileDescriptor.class,
// netty_epoll_native
NativeDatagramPacketArray.NativeDatagramPacket.class
);
try {
// First, try calling a side-effect free JNI method to see if the library was already
// loaded by the application.
offsetofEpollData();
} catch (UnsatisfiedLinkError ignore) {
// The library was not previously loaded, load it now.
loadNativeLibrary();
} finally {
try {
if (selector != null) {
selector.close();
}
} catch (IOException ignore) {
// Just ignore
}
}
Unix.registerInternal(new Runnable() {
@Override
public void run() {
registerUnix();
}
});
}
private static native int registerUnix();
// EventLoop operations and constants
public static final int EPOLLIN = epollin();
public static final int EPOLLOUT = epollout();
public static final int EPOLLRDHUP = epollrdhup();
public static final int EPOLLET = epollet();
public static final int EPOLLERR = epollerr();
public static final boolean IS_SUPPORTING_SENDMMSG = isSupportingSendmmsg();
static final boolean IS_SUPPORTING_RECVMMSG = isSupportingRecvmmsg();
static final boolean IS_SUPPORTING_UDP_SEGMENT = isSupportingUdpSegment();
private static final int TFO_ENABLED_CLIENT_MASK = 0x1;
private static final int TFO_ENABLED_SERVER_MASK = 0x2;
private static final int TCP_FASTOPEN_MODE = tcpFastopenMode();
/**
* <a href ="https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt">tcp_fastopen</a> client mode enabled
* state.
*/
static final boolean IS_SUPPORTING_TCP_FASTOPEN_CLIENT =
(TCP_FASTOPEN_MODE & TFO_ENABLED_CLIENT_MASK) == TFO_ENABLED_CLIENT_MASK;
Source
Frequently Asked Questions
What is the Native class?
Native is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/Native.java.
Where is Native defined?
Native is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/Native.java at line 54.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free