简体   繁体   中英

How java.net package works?

Android developer documentation describes the java.net package to be use for networking by apps. Now Android has a Linux kernel, so eventually any HTTP request made by the package has to translate into some system call.

What I want to ask is whether this library also ships with some JNI layer code, and does it rely on libc library to interact with the kernel ?

In Oracle JVM net.dll is loaded inside AbstractPlainSocketImpl which is present in jre/bin .

/**
 * Load net library into runtime.
 */
static {
    java.security.AccessController.doPrivileged(
        new java.security.PrivilegedAction<Void>() {
            public Void run() {
                System.loadLibrary("net");
                return null;
            }
        });
}

Android's Dalvik also works the same way. Take a look at the following links:

https://github.com/android/platform_system_core/tree/master/libcutils
https://github.com/android/platform_system_core/blob/master/libcutils/socket_network_client.c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM