changeset 32145:83cedbbcd7ba

8065595: Wrong JNI_OnLoad called if just loaded lib does not have JNI_OnLoad function Summary: Add nio_util.c containing JNI_OnLoad bare bones implementation. Reviewed-by: rriggs
author bpb
date Thu, 13 Aug 2015 09:36:14 -0700
parents fa1b56b9ad5c
children 66720550ef13
files jdk/make/lib/NioLibraries.gmk jdk/make/mapfiles/libnio/mapfile-linux jdk/make/mapfiles/libnio/mapfile-macosx jdk/make/mapfiles/libnio/mapfile-solaris jdk/src/java.base/share/native/libnio/nio_util.c
diffstat 5 files changed, 45 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/make/lib/NioLibraries.gmk	Thu Aug 13 19:09:18 2015 +0530
+++ b/jdk/make/lib/NioLibraries.gmk	Thu Aug 13 09:36:14 2015 -0700
@@ -24,6 +24,7 @@
 #
 
 BUILD_LIBNIO_SRC := \
+    $(JDK_TOPDIR)/src/java.base/share/native/libnio \
     $(JDK_TOPDIR)/src/java.base/share/native/libnio/ch \
     $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio \
     $(sort $(wildcard \
--- a/jdk/make/mapfiles/libnio/mapfile-linux	Thu Aug 13 19:09:18 2015 +0530
+++ b/jdk/make/mapfiles/libnio/mapfile-linux	Thu Aug 13 09:36:14 2015 -0700
@@ -25,6 +25,7 @@
 
 SUNWprivate_1.1 {
 	global:
+                JNI_OnLoad;
                 Java_java_nio_MappedByteBuffer_force0;
                 Java_java_nio_MappedByteBuffer_isLoaded0;
                 Java_java_nio_MappedByteBuffer_load0;
--- a/jdk/make/mapfiles/libnio/mapfile-macosx	Thu Aug 13 19:09:18 2015 +0530
+++ b/jdk/make/mapfiles/libnio/mapfile-macosx	Thu Aug 13 09:36:14 2015 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2001, 2015, 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
@@ -25,6 +25,7 @@
 
 SUNWprivate_1.1 {
 	global:
+                JNI_OnLoad;
                 Java_java_nio_MappedByteBuffer_force0;
                 Java_java_nio_MappedByteBuffer_isLoaded0;
                 Java_java_nio_MappedByteBuffer_load0;
--- a/jdk/make/mapfiles/libnio/mapfile-solaris	Thu Aug 13 19:09:18 2015 +0530
+++ b/jdk/make/mapfiles/libnio/mapfile-solaris	Thu Aug 13 09:36:14 2015 -0700
@@ -25,6 +25,7 @@
 
 SUNWprivate_1.1 {
 	global:
+                JNI_OnLoad;
                 Java_java_nio_MappedByteBuffer_force0;
                 Java_java_nio_MappedByteBuffer_isLoaded0;
                 Java_java_nio_MappedByteBuffer_load0;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/native/libnio/nio_util.c	Thu Aug 13 09:36:14 2015 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015, 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 "jvm.h"
+#include "jni_util.h"
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+    JNIEnv *env;
+
+    if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_2) != JNI_OK) {
+        return JNI_EVERSION; /* JNI version not supported */
+    }
+
+    return JNI_VERSION_1_2;
+}