From 10207de32f3f5b4772ce801a0eeaa70d16f3e9a1 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 13 Aug 2015 09:36:14 -0700 Subject: [PATCH] 8065595: Wrong JNI_OnLoad called if just loaded lib does not have JNI_OnLoad function Add nio_util.c containing JNI_OnLoad bare bones implementation. Reviewed-by: rriggs --- jdk/make/lib/NioLibraries.gmk | 1 + jdk/make/mapfiles/libnio/mapfile-linux | 1 + jdk/make/mapfiles/libnio/mapfile-macosx | 3 +- jdk/make/mapfiles/libnio/mapfile-solaris | 1 + .../java.base/share/native/libnio/nio_util.c | 40 +++++++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 jdk/src/java.base/share/native/libnio/nio_util.c diff --git a/jdk/make/lib/NioLibraries.gmk b/jdk/make/lib/NioLibraries.gmk index 81d6e0f7e67..d78f4a7db97 100644 --- a/jdk/make/lib/NioLibraries.gmk +++ b/jdk/make/lib/NioLibraries.gmk @@ -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 \ diff --git a/jdk/make/mapfiles/libnio/mapfile-linux b/jdk/make/mapfiles/libnio/mapfile-linux index e1928c477c9..c00f6dd5379 100644 --- a/jdk/make/mapfiles/libnio/mapfile-linux +++ b/jdk/make/mapfiles/libnio/mapfile-linux @@ -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; diff --git a/jdk/make/mapfiles/libnio/mapfile-macosx b/jdk/make/mapfiles/libnio/mapfile-macosx index d4b6dc5a219..7ce9c50fde5 100644 --- a/jdk/make/mapfiles/libnio/mapfile-macosx +++ b/jdk/make/mapfiles/libnio/mapfile-macosx @@ -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; diff --git a/jdk/make/mapfiles/libnio/mapfile-solaris b/jdk/make/mapfiles/libnio/mapfile-solaris index 92d62d20174..9c5da0e2f31 100644 --- a/jdk/make/mapfiles/libnio/mapfile-solaris +++ b/jdk/make/mapfiles/libnio/mapfile-solaris @@ -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; diff --git a/jdk/src/java.base/share/native/libnio/nio_util.c b/jdk/src/java.base/share/native/libnio/nio_util.c new file mode 100644 index 00000000000..f61c65268e8 --- /dev/null +++ b/jdk/src/java.base/share/native/libnio/nio_util.c @@ -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; +}