Move more clinit code to registration functions, part 3

Moved clinit code that fetches field/method ids
to JNI registration funcitons. This will allow to
compile-time initialize these classes.

Removed dead code in DefaultProxySelector.(java|c) that
was never called.

This is last change, remaining classes have either
dependencies that we can't work around, or required
change would make their code less maintainable.

Bug: 28153851
Change-Id: I9ef9a3c07d5cba9d4608110d94b55aada265e68f
diff --git a/ojluni/src/main/java/java/io/ObjectStreamClass.java b/ojluni/src/main/java/java/io/ObjectStreamClass.java
index 1c2df71..1491aac1 100755
--- a/ojluni/src/main/java/java/io/ObjectStreamClass.java
+++ b/ojluni/src/main/java/java/io/ObjectStreamClass.java
@@ -187,14 +187,6 @@
     private ObjectStreamClass superDesc;
 
     /**
-     * Initializes native code.
-     */
-    private static native void initNative();
-    static {
-        initNative();
-    }
-
-    /**
      * Find the descriptor for a class that can be serialized.  Creates an
      * ObjectStreamClass instance if one does not exist yet for class. Null is
      * returned if the specified class does not implement java.io.Serializable
diff --git a/ojluni/src/main/java/sun/net/spi/DefaultProxySelector.java b/ojluni/src/main/java/sun/net/spi/DefaultProxySelector.java
index f0e6a59..02fd268 100755
--- a/ojluni/src/main/java/sun/net/spi/DefaultProxySelector.java
+++ b/ojluni/src/main/java/sun/net/spi/DefaultProxySelector.java
@@ -87,20 +87,6 @@
 
     private static boolean hasSystemProxies = false;
 
-    static {
-        final String key = "java.net.useSystemProxies";
-        Boolean b = AccessController.doPrivileged(
-            new PrivilegedAction<Boolean>() {
-                public Boolean run() {
-                    return NetProperties.getBoolean(key);
-                }});
-        if (b != null && b.booleanValue()) {
-            java.security.AccessController.doPrivileged(
-                      new sun.security.action.LoadLibraryAction("net"));
-            hasSystemProxies = init();
-        }
-    }
-
     /**
      * How to deal with "non proxy hosts":
      * since we do have to generate a RegexpPool we don't want to do that if
@@ -228,17 +214,7 @@
                                  * settings (Gnome & Windows) if we were
                                  * instructed to.
                                  */
-                                if (hasSystemProxies) {
-                                    String sproto;
-                                    if (proto.equalsIgnoreCase("socket"))
-                                        sproto = "socks";
-                                    else
-                                        sproto = proto;
-                                    Proxy sproxy = getSystemProxy(sproto, urlhost);
-                                    if (sproxy != null) {
-                                        return sproxy;
-                                    }
-                                }
+                                // Android-changed, hasSystemProxies is always false
                                 return Proxy.NO_PROXY;
                             }
                             // If a Proxy Host is defined for that protocol
@@ -348,7 +324,4 @@
             return -1;
         }
     }
-
-    private native static boolean init();
-    private synchronized native Proxy getSystemProxy(String protocol, String host);
 }
diff --git a/ojluni/src/main/java/sun/nio/ch/EPollArrayWrapper.java b/ojluni/src/main/java/sun/nio/ch/EPollArrayWrapper.java
index 53febe2..9265778 100755
--- a/ojluni/src/main/java/sun/nio/ch/EPollArrayWrapper.java
+++ b/ojluni/src/main/java/sun/nio/ch/EPollArrayWrapper.java
@@ -317,10 +317,6 @@
         interrupted = false;
     }
 
-    static {
-        init();
-    }
-
     private native int epollCreate();
     private native void epollCtl(int epfd, int opcode, int fd, int events);
     private native int epollWait(long pollAddress, int numfds, long timeout,
@@ -328,5 +324,4 @@
     private static native int sizeofEPollEvent();
     private static native int offsetofData();
     private static native void interrupt(int fd);
-    private static native void init();
 }
diff --git a/ojluni/src/main/java/sun/nio/ch/FileKey.java b/ojluni/src/main/java/sun/nio/ch/FileKey.java
index 50abd30..1adaab3 100755
--- a/ojluni/src/main/java/sun/nio/ch/FileKey.java
+++ b/ojluni/src/main/java/sun/nio/ch/FileKey.java
@@ -67,9 +67,4 @@
     }
 
     private native void init(FileDescriptor fd) throws IOException;
-    private static native void initIDs();
-
-    static {
-        initIDs();
-    }
 }
diff --git a/ojluni/src/main/java/sun/nio/ch/NativeThread.java b/ojluni/src/main/java/sun/nio/ch/NativeThread.java
index 4d7a7f1..83392c0 100755
--- a/ojluni/src/main/java/sun/nio/ch/NativeThread.java
+++ b/ojluni/src/main/java/sun/nio/ch/NativeThread.java
@@ -50,11 +50,4 @@
     // no effect.
     //
     static native void signal(long nt);
-
-    static native void init();
-
-    static {
-        init();
-    }
-
 }
diff --git a/ojluni/src/main/java/sun/nio/ch/Net.java b/ojluni/src/main/java/sun/nio/ch/Net.java
index 5b41ba6..99d2629 100755
--- a/ojluni/src/main/java/sun/nio/ch/Net.java
+++ b/ojluni/src/main/java/sun/nio/ch/Net.java
@@ -617,11 +617,4 @@
     static native void setInterface6(FileDescriptor fd, int index) throws IOException;
 
     static native int getInterface6(FileDescriptor fd) throws IOException;
-
-    private static native void initIDs();
-
-    static {
-        initIDs();
-    }
-
 }
diff --git a/ojluni/src/main/native/DefaultProxySelector.c b/ojluni/src/main/native/DefaultProxySelector.c
deleted file mode 100755
index ee00aac..0000000
--- a/ojluni/src/main/native/DefaultProxySelector.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "jni.h"
-#include "jni_util.h"
-#include "jvm.h"
-#include "jvm_md.h"
-#include "jlong.h"
-#include <dlfcn.h>
-#include <stdio.h>
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-#include "JNIHelp.h"
-
-#define NATIVE_METHOD(className, functionName, signature) \
-{ #functionName, signature, (void*)(className ## _ ## functionName) }
-
-/**
- * These functions are used by the sun.net.spi.DefaultProxySelector class
- * to access some platform specific settings.
- * This is the Solaris/Linux Gnome 2.x code using the GConf-2 library.
- * Everything is loaded dynamically so no hard link with any library exists.
- * The GConf-2 settings used are:
- * - /system/http_proxy/use_http_proxy          boolean
- * - /system/http_proxy/use_authentcation       boolean
- * - /system/http_proxy/use_same_proxy          boolean
- * - /system/http_proxy/host                    string
- * - /system/http_proxy/authentication_user     string
- * - /system/http_proxy/authentication_password string
- * - /system/http_proxy/port                    int
- * - /system/proxy/socks_host                   string
- * - /system/proxy/mode                         string
- * - /system/proxy/ftp_host                     string
- * - /system/proxy/secure_host                  string
- * - /system/proxy/socks_port                   int
- * - /system/proxy/ftp_port                     int
- * - /system/proxy/secure_port                  int
- * - /system/proxy/no_proxy_for                 list
- * - /system/proxy/gopher_host                  string
- * - /system/proxy/gopher_port                  int
- */
-typedef void* gconf_client_get_default_func();
-typedef char* gconf_client_get_string_func(void *, char *, void**);
-typedef int   gconf_client_get_int_func(void*, char *, void**);
-typedef int   gconf_client_get_bool_func(void*, char *, void**);
-typedef int   gconf_init_func(int, char**, void**);
-typedef void  g_type_init_func ();
-gconf_client_get_default_func* my_get_default_func = NULL;
-gconf_client_get_string_func* my_get_string_func = NULL;
-gconf_client_get_int_func* my_get_int_func = NULL;
-gconf_client_get_bool_func* my_get_bool_func = NULL;
-gconf_init_func* my_gconf_init_func = NULL;
-g_type_init_func* my_g_type_init_func = NULL;
-
-static jclass proxy_class;
-static jclass isaddr_class;
-static jclass ptype_class;
-static jmethodID isaddr_createUnresolvedID;
-static jmethodID proxy_ctrID;
-static jfieldID pr_no_proxyID;
-static jfieldID ptype_httpID;
-static jfieldID ptype_socksID;
-
-static int gconf_ver = 0;
-static void* gconf_client = NULL;
-
-#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI errror at line %d\n", __LINE__); }
-
-/*
- * Class:     sun_net_spi_DefaultProxySelector
- * Method:    init
- * Signature: ()Z
- */
-JNIEXPORT jboolean JNICALL
-DefaultProxySelector_init(JNIEnv *env, jclass clazz) {
-  jclass cls = NULL;
-  CHECK_NULL(cls = (*env)->FindClass(env,"java/net/Proxy"));
-  proxy_class = (*env)->NewGlobalRef(env, cls);
-  CHECK_NULL(cls = (*env)->FindClass(env,"java/net/Proxy$Type"));
-  ptype_class = (*env)->NewGlobalRef(env, cls);
-  CHECK_NULL(cls = (*env)->FindClass(env, "java/net/InetSocketAddress"));
-  isaddr_class = (*env)->NewGlobalRef(env, cls);
-  proxy_ctrID = (*env)->GetMethodID(env, proxy_class, "<init>", "(Ljava/net/Proxy$Type;Ljava/net/SocketAddress;)V");
-  pr_no_proxyID = (*env)->GetStaticFieldID(env, proxy_class, "NO_PROXY", "Ljava/net/Proxy;");
-  ptype_httpID = (*env)->GetStaticFieldID(env, ptype_class, "HTTP", "Ljava/net/Proxy$Type;");
-  ptype_socksID = (*env)->GetStaticFieldID(env, ptype_class, "SOCKS", "Ljava/net/Proxy$Type;");
-  isaddr_createUnresolvedID = (*env)->GetStaticMethodID(env, isaddr_class, "createUnresolved", "(Ljava/lang/String;I)Ljava/net/InetSocketAddress;");
-
-  /**
-   * Let's try to load le GConf-2 library
-   */
-  if (dlopen(JNI_LIB_NAME("gconf-2"), RTLD_GLOBAL | RTLD_LAZY) != NULL ||
-      dlopen(VERSIONED_JNI_LIB_NAME("gconf-2", "4"),
-             RTLD_GLOBAL | RTLD_LAZY) != NULL) {
-    gconf_ver = 2;
-  }
-  if (gconf_ver > 0) {
-    /*
-     * Now let's get pointer to the functions we need.
-     */
-    my_g_type_init_func = (g_type_init_func*) dlsym(RTLD_DEFAULT, "g_type_init");
-    my_get_default_func = (gconf_client_get_default_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_default");
-    if (my_g_type_init_func != NULL && my_get_default_func != NULL) {
-      /**
-       * Try to connect to GConf.
-       */
-      (*my_g_type_init_func)();
-      gconf_client = (*my_get_default_func)();
-      if (gconf_client != NULL) {
-        my_get_string_func = (gconf_client_get_string_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_string");
-        my_get_int_func = (gconf_client_get_int_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_int");
-        my_get_bool_func = (gconf_client_get_bool_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_bool");
-        if (my_get_int_func != NULL && my_get_string_func != NULL &&
-            my_get_bool_func != NULL) {
-          /**
-           * We did get all we need. Let's enable the System Proxy Settings.
-           */
-          return JNI_TRUE;
-        }
-      }
-    }
-  }
-  return JNI_FALSE;
-}
-
-
-/*
- * Class:     sun_net_spi_DefaultProxySelector
- * Method:    getSystemProxy
- * Signature: ([Ljava/lang/String;Ljava/lang/String;)Ljava/net/Proxy;
- */
-JNIEXPORT jobject JNICALL
-DefaultProxySelector_getSystemProxy(JNIEnv *env,
-                                                     jobject this,
-                                                     jstring proto,
-                                                     jstring host)
-{
-  char *phost = NULL;
-  char *mode = NULL;
-  int pport = 0;
-  int use_proxy = 0;
-  int use_same_proxy = 0;
-  const char* urlhost;
-  jobject isa = NULL;
-  jobject proxy = NULL;
-  jobject type_proxy = NULL;
-  jobject no_proxy = NULL;
-  const char *cproto;
-  jboolean isCopy;
-
-  if (gconf_ver > 0) {
-    if (gconf_client == NULL) {
-      (*my_g_type_init_func)();
-      gconf_client = (*my_get_default_func)();
-    }
-    if (gconf_client != NULL) {
-      cproto = (*env)->GetStringUTFChars(env, proto, &isCopy);
-      if (cproto != NULL) {
-        /**
-         * We will have to check protocol by protocol as they do use different
-         * entries.
-         */
-
-        use_same_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_same_proxy", NULL);
-        if (use_same_proxy) {
-          use_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_http_proxy", NULL);
-          if (use_proxy) {
-            phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL);
-            pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL);
-          }
-        }
-
-        /**
-         * HTTP:
-         * /system/http_proxy/use_http_proxy (boolean)
-         * /system/http_proxy/host (string)
-         * /system/http_proxy/port (integer)
-         */
-        if (strcasecmp(cproto, "http") == 0) {
-          use_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_http_proxy", NULL);
-          if (use_proxy) {
-            if (!use_same_proxy) {
-              phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL);
-              pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL);
-            }
-            CHECK_NULL(type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID));
-          }
-        }
-
-        /**
-         * HTTPS:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/secure_host (string)
-         * /system/proxy/secure_port (integer)
-         */
-        if (strcasecmp(cproto, "https") == 0) {
-          mode =  (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = (*my_get_string_func)(gconf_client, "/system/proxy/secure_host", NULL);
-              pport = (*my_get_int_func)(gconf_client, "/system/proxy/secure_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
-          }
-        }
-
-        /**
-         * FTP:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/ftp_host (string)
-         * /system/proxy/ftp_port (integer)
-         */
-        if (strcasecmp(cproto, "ftp") == 0) {
-          mode =  (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = (*my_get_string_func)(gconf_client, "/system/proxy/ftp_host", NULL);
-              pport = (*my_get_int_func)(gconf_client, "/system/proxy/ftp_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
-          }
-        }
-
-        /**
-         * GOPHER:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/gopher_host (string)
-         * /system/proxy/gopher_port (integer)
-         */
-        if (strcasecmp(cproto, "gopher") == 0) {
-          mode =  (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = (*my_get_string_func)(gconf_client, "/system/proxy/gopher_host", NULL);
-              pport = (*my_get_int_func)(gconf_client, "/system/proxy/gopher_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID);
-          }
-        }
-
-        /**
-         * SOCKS:
-         * /system/proxy/mode (string) [ "manual" means use proxy settings ]
-         * /system/proxy/socks_host (string)
-         * /system/proxy/socks_port (integer)
-         */
-        if (strcasecmp(cproto, "socks") == 0) {
-          mode =  (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL);
-          if (mode != NULL && (strcasecmp(mode,"manual") == 0)) {
-            if (!use_same_proxy) {
-              phost = (*my_get_string_func)(gconf_client, "/system/proxy/socks_host", NULL);
-              pport = (*my_get_int_func)(gconf_client, "/system/proxy/socks_port", NULL);
-            }
-            use_proxy = (phost != NULL);
-            if (use_proxy)
-              type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_socksID);
-          }
-        }
-
-        if (isCopy == JNI_TRUE)
-          (*env)->ReleaseStringUTFChars(env, proto, cproto);
-
-        if (use_proxy && (phost != NULL)) {
-          jstring jhost;
-          char *noproxyfor;
-          char *s;
-
-          /**
-           * check for the exclude list (aka "No Proxy For" list).
-           * It's a list of comma separated suffixes (e.g. domain name).
-           */
-          noproxyfor = (*my_get_string_func)(gconf_client, "/system/proxy/no_proxy_for", NULL);
-          if (noproxyfor != NULL) {
-            char *tmpbuf[512];
-
-            s = strtok_r(noproxyfor, ", ", tmpbuf);
-            urlhost = (*env)->GetStringUTFChars(env, host, &isCopy);
-            if (urlhost != NULL) {
-              while (s != NULL && strlen(s) <= strlen(urlhost)) {
-                if (strcasecmp(urlhost+(strlen(urlhost) - strlen(s)), s) == 0) {
-                  /**
-                   * the URL host name matches with one of the sufixes,
-                   * therefore we have to use a direct connection.
-                   */
-                  use_proxy = 0;
-                  break;
-                }
-                s = strtok_r(NULL, ", ", tmpbuf);
-              }
-              if (isCopy == JNI_TRUE)
-                (*env)->ReleaseStringUTFChars(env, host, urlhost);
-            }
-          }
-          if (use_proxy) {
-            jhost = (*env)->NewStringUTF(env, phost);
-            isa = (*env)->CallStaticObjectMethod(env, isaddr_class, isaddr_createUnresolvedID, jhost, pport);
-            proxy = (*env)->NewObject(env, proxy_class, proxy_ctrID, type_proxy, isa);
-            return proxy;
-          }
-        }
-      }
-    }
-  }
-
-  CHECK_NULL(no_proxy = (*env)->GetStaticObjectField(env, proxy_class, pr_no_proxyID));
-  return no_proxy;
-}
-
-static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(DefaultProxySelector, getSystemProxy, "(Ljava/lang/String;Ljava/lang/String;)Ljava/net/Proxy;"),
-  NATIVE_METHOD(DefaultProxySelector, init, "()Z"),
-};
-
-void register_sun_net_spi_DefaultProxySelector(JNIEnv* env) {
-  jniRegisterNativeMethods(env, "sun/net/spi/DefaultProxySelector", gMethods, NELEM(gMethods));
-}
diff --git a/ojluni/src/main/native/EPollArrayWrapper.c b/ojluni/src/main/native/EPollArrayWrapper.c
index f039bcf..f14a85a 100644
--- a/ojluni/src/main/native/EPollArrayWrapper.c
+++ b/ojluni/src/main/native/EPollArrayWrapper.c
@@ -75,11 +75,6 @@
     }
 }
 
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_EPollArrayWrapper_init(JNIEnv *env, jclass this)
-{
-}
-
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_EPollArrayWrapper_epollCreate(JNIEnv *env, jobject this)
 {
@@ -170,7 +165,6 @@
   NATIVE_METHOD(EPollArrayWrapper, sizeofEPollEvent, "()I"),
   NATIVE_METHOD(EPollArrayWrapper, offsetofData, "()I"),
   NATIVE_METHOD(EPollArrayWrapper, interrupt, "(I)V"),
-  NATIVE_METHOD(EPollArrayWrapper, init, "()V"),
 };
 
 void register_sun_nio_ch_EPollArrayWrapper(JNIEnv* env) {
diff --git a/ojluni/src/main/native/FileKey.c b/ojluni/src/main/native/FileKey.c
index 31552eb..22fd0b0 100755
--- a/ojluni/src/main/native/FileKey.c
+++ b/ojluni/src/main/native/FileKey.c
@@ -43,9 +43,9 @@
 static jfieldID key_st_ino;    /* id for FileKey.st_ino */
 
 
-JNIEXPORT void JNICALL
-FileKey_initIDs(JNIEnv *env, jclass clazz)
+static void FileKey_initIDs(JNIEnv *env)
 {
+    jclass clazz = (*env)->FindClass(env, "sun/nio/ch/FileKey");
     key_st_dev = (*env)->GetFieldID(env, clazz, "st_dev", "J");
     key_st_ino = (*env)->GetFieldID(env, clazz, "st_ino", "J");
 }
@@ -67,10 +67,10 @@
 }
 
 static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(FileKey, initIDs, "()V"),
   NATIVE_METHOD(FileKey, init, "(Ljava/io/FileDescriptor;)V"),
 };
 
 void register_sun_nio_ch_FileKey(JNIEnv* env) {
-  jniRegisterNativeMethods(env, "sun/nio/ch/FileKey", gMethods, NELEM(gMethods));
+    jniRegisterNativeMethods(env, "sun/nio/ch/FileKey", gMethods, NELEM(gMethods));
+    FileKey_initIDs(env);
 }
diff --git a/ojluni/src/main/native/NativeThread.c b/ojluni/src/main/native/NativeThread.c
index f27284f..8a12f5d 100755
--- a/ojluni/src/main/native/NativeThread.c
+++ b/ojluni/src/main/native/NativeThread.c
@@ -47,10 +47,7 @@
 {
 }
 
-
-
-JNIEXPORT void JNICALL
-NativeThread_init(JNIEnv *env, jclass cl)
+static void  NativeThread_init(JNIEnv *env)
 {
 
     /* Install the null handler for INTERRUPT_SIGNAL.  This might overwrite the
@@ -84,11 +81,11 @@
 }
 
 static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(NativeThread, init, "()V"),
   NATIVE_METHOD(NativeThread, current, "()J"),
   NATIVE_METHOD(NativeThread, signal, "(J)V"),
 };
 
 void register_sun_nio_ch_NativeThread(JNIEnv* env) {
   jniRegisterNativeMethods(env, "sun/nio/ch/NativeThread", gMethods, NELEM(gMethods));
+  NativeThread_init(env);
 }
diff --git a/ojluni/src/main/native/Net.c b/ojluni/src/main/native/Net.c
index e7cd5d7..02fa69c 100644
--- a/ojluni/src/main/native/Net.c
+++ b/ojluni/src/main/native/Net.c
@@ -116,12 +116,6 @@
 }
 #endif
 
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz)
-{
-    /* Here because Windows native code does need to init IDs */
-}
-
 JNIEXPORT jboolean JNICALL
 Java_sun_nio_ch_Net_isIPv6Available0(JNIEnv* env, jclass cl)
 {
@@ -723,7 +717,6 @@
   NATIVE_METHOD(Net, getInterface4, "(Ljava/io/FileDescriptor;)I"),
   NATIVE_METHOD(Net, setInterface6, "(Ljava/io/FileDescriptor;I)V"),
   NATIVE_METHOD(Net, getInterface6, "(Ljava/io/FileDescriptor;)I"),
-  NATIVE_METHOD(Net, initIDs, "()V"),
 };
 
 void register_sun_nio_ch_Net(JNIEnv* env) {
diff --git a/ojluni/src/main/native/ObjectStreamClass.c b/ojluni/src/main/native/ObjectStreamClass.c
index faf5ad6..c57166e 100755
--- a/ojluni/src/main/native/ObjectStreamClass.c
+++ b/ojluni/src/main/native/ObjectStreamClass.c
@@ -33,15 +33,7 @@
 
 static jclass noSuchMethodErrCl;
 
-/*
- * Class:     java_io_ObjectStreamClass
- * Method:    initNative
- * Signature: ()V
- *
- * Native code initialization hook.
- */
-JNIEXPORT void JNICALL
-ObjectStreamClass_initNative(JNIEnv *env, jclass this)
+static void ObjectStreamClass_initNative(JNIEnv *env)
 {
     jclass cl = (*env)->FindClass(env, "java/lang/NoSuchMethodError");
     if (cl == NULL) {           /* exception thrown */
@@ -101,10 +93,10 @@
 }
 
 static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(ObjectStreamClass, initNative, "()V"),
   NATIVE_METHOD(ObjectStreamClass, hasStaticInitializer, "(Ljava/lang/Class;)Z"),
 };
 
 void register_java_io_ObjectStreamClass(JNIEnv* env) {
   jniRegisterNativeMethods(env, "java/io/ObjectStreamClass", gMethods, NELEM(gMethods));
+  ObjectStreamClass_initNative(env);
 }
diff --git a/ojluni/src/main/native/Register.cpp b/ojluni/src/main/native/Register.cpp
index 06bd421..8e522d6 100644
--- a/ojluni/src/main/native/Register.cpp
+++ b/ojluni/src/main/native/Register.cpp
@@ -70,7 +70,6 @@
 extern void register_java_util_zip_Inflater(JNIEnv*);
 extern void register_java_util_zip_ZipFile(JNIEnv*);
 extern void register_java_util_prefs_FileSystemPreferences(JNIEnv*);
-extern void register_sun_net_spi_DefaultProxySelector(JNIEnv*);
 extern void register_sun_nio_ch_DatagramChannelImpl(JNIEnv*);
 extern void register_sun_nio_ch_DatagramDispatcher(JNIEnv*);
 extern void register_sun_nio_ch_FileChannelImpl(JNIEnv*);
@@ -128,7 +127,6 @@
     register_java_net_SocketInputStream(env);
     register_java_net_SocketOutputStream(env);
     register_java_nio_Bits(env);
-    register_sun_net_spi_DefaultProxySelector(env);
     register_java_lang_Character(env);
     register_java_lang_Float(env);
     register_java_lang_Double(env);
diff --git a/ojluni/src/main/native/openjdksub.mk b/ojluni/src/main/native/openjdksub.mk
index 1f88335..bf0f632 100644
--- a/ojluni/src/main/native/openjdksub.mk
+++ b/ojluni/src/main/native/openjdksub.mk
@@ -53,7 +53,6 @@
     ServerSocketChannelImpl.c \
     SocketInputStream.c \
     SocketOutputStream.c \
-    DefaultProxySelector.c \
     Float.c \
     Double.c \
     StrictMath.c \