diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index 7387a57f4a6..627dfceced2 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -123,6 +123,7 @@ LIBJAVA_SRC_DIRS := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/l $(JDK_TOPDIR)/src/share/native/java/security \ $(JDK_TOPDIR)/src/share/native/common \ $(JDK_TOPDIR)/src/share/native/sun/misc \ + $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/misc \ $(JDK_TOPDIR)/src/share/native/sun/reflect \ $(JDK_TOPDIR)/src/share/native/java/util \ $(JDK_TOPDIR)/src/share/native/java/util/concurrent/atomic \ @@ -187,7 +188,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ LIBRARY := java, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ SRC := $(LIBJAVA_SRC_DIRS), \ - EXCLUDES := fdlibm/src zip, \ + EXCLUDES := fdlibm/src zip prefs, \ EXCLUDE_FILES := $(LIBJAVA_EXCLUDE_FILES), \ LANG := C, \ OPTIMIZATION := HIGH, \ @@ -285,6 +286,41 @@ BUILD_LIBRARIES += $(BUILD_LIBZIP) ########################################################################################## +ifeq ($(OPENJDK_TARGET_OS), macosx) + LIBPREF_SRC_DIRS := $(JDK_TOPDIR)/src/macosx/native/java/util/prefs +else + LIBPREF_SRC_DIRS := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util/prefs +endif + +$(eval $(call SetupNativeCompilation,BUILD_LIBPREFS, \ + LIBRARY := prefs, \ + OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ + SRC := $(LIBPREF_SRC_DIRS), \ + LANG := C, \ + OPTIMIZATION := HIGH, \ + CFLAGS := $(CFLAGS_JDKLIB), \ + MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libprefs/mapfile-vers, \ + LDFLAGS := $(LDFLAGS_JDKLIB) \ + $(call SET_SHARED_LIBRARY_ORIGIN), \ + LDFLAGS_SUFFIX_linux := -ljvm -ljava, \ + LDFLAGS_SUFFIX_solaris := -ljvm -ljava -lc, \ + LDFLAGS_SUFFIX_aix := -ljvm -ljava, \ + LDFLAGS_SUFFIX_windows := advapi32.lib, \ + LDFLAGS_SUFFIX_macosx := -ljvm -framework CoreFoundation, \ + VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ + RC_FLAGS := $(RC_FLAGS) \ + -D "JDK_FNAME=prefs.dll" \ + -D "JDK_INTERNAL_NAME=prefs" \ + -D "JDK_FTYPE=0x2L", \ + OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libprefs, \ + DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + +$(BUILD_LIBPREFS): $(BUILD_LIBJAVA) + +BUILD_LIBRARIES += $(BUILD_LIBPREFS) + +########################################################################################## + $(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \ LIBRARY := unpack, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ diff --git a/jdk/make/lib/PlatformLibraries.gmk b/jdk/make/lib/PlatformLibraries.gmk index f12aa186c40..f17e8304279 100644 --- a/jdk/make/lib/PlatformLibraries.gmk +++ b/jdk/make/lib/PlatformLibraries.gmk @@ -95,7 +95,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) LIBOSX_DIRS := \ $(JDK_TOPDIR)/src/macosx/native/com/apple/concurrent \ - $(JDK_TOPDIR)/src/macosx/native/java/util \ $(JDK_TOPDIR)/src/macosx/native/com/apple/eio \ $(JDK_TOPDIR)/src/macosx/native/apple/security \ $(JDK_TOPDIR)/src/macosx/native/apple/launcher diff --git a/jdk/make/lib/SecurityLibraries.gmk b/jdk/make/lib/SecurityLibraries.gmk index 2a1721bc1c4..66c55b8264d 100644 --- a/jdk/make/lib/SecurityLibraries.gmk +++ b/jdk/make/lib/SecurityLibraries.gmk @@ -128,8 +128,13 @@ ifneq ($(BUILD_CRYPTO), no) ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib else ifeq ($(OPENJDK_TARGET_OS), macosx) BUILD_LIBKRB5_NAME := osxkrb5 - BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/share/native/sun/security/krb5 - BUILD_LIBKRB5_LIBS := -framework Kerberos + BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/share/native/sun/security/krb5 \ + $(JDK_TOPDIR)/src/macosx/native/sun/security/krb5 + BUILD_LIBKRB5_LIBS := -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ + -framework JavaNativeFoundation \ + -framework Cocoa \ + -framework SystemConfiguration \ + -framework Kerberos endif ifneq ($(BUILD_LIBKRB5_NAME), ) @@ -140,8 +145,9 @@ ifneq ($(BUILD_CRYPTO), no) LANG := C, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ - -I$(JDK_TOPDIR)/src/share/native/sun/security/krb5 \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/krb5, \ + -I$(JDK_TOPDIR)/src/share/native/sun/security/krb5, \ + CFLAGS_windows := -I$(JDK_TOPDIR)/src/windows/native/sun/security/krb5, \ + CFLAGS_macosx := -F/System/Library/Frameworks/JavaVM.framework/Frameworks, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX := $(BUILD_LIBKRB5_LIBS), \ diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index 760babc2ee1..9034580f1b9 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -236,10 +236,6 @@ SUNWprivate_1.1 { Java_java_util_TimeZone_getSystemTimeZoneID; Java_java_util_TimeZone_getSystemGMTOffsetID; Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8; - Java_java_util_prefs_FileSystemPreferences_chmod; - Java_java_util_prefs_FileSystemPreferences_lockFile0; - Java_java_util_prefs_FileSystemPreferences_unlockFile0; - Java_java_util_logging_FileHandler_isSetUID; Java_sun_misc_MessageUtils_toStderr; Java_sun_misc_MessageUtils_toStdout; Java_sun_misc_NativeSignalHandler_handle0; @@ -274,17 +270,13 @@ SUNWprivate_1.1 { Java_sun_misc_Version_getJvmVersionInfo; Java_sun_misc_Version_getJvmSpecialVersion; Java_sun_misc_VM_latestUserDefinedLoader; + Java_sun_misc_VM_isSetUID; Java_sun_misc_VM_initialize; Java_sun_misc_VMSupport_initAgentProperties; # ZipFile.c needs this one throwFileNotFoundException; -# Java_sun_misc_VM_getState; threads.c -# Java_sun_misc_VM_threadsSuspended; threads.c -# Java_sun_misc_VM_unsuspendSomeThreads; threads.c -# Java_sun_misc_VM_unsuspendThreads; threads.c - # Outcalls from libjvm done using dlsym(). VerifyClassCodes; diff --git a/jdk/make/mapfiles/libprefs/mapfile-vers b/jdk/make/mapfiles/libprefs/mapfile-vers new file mode 100644 index 00000000000..395d175080b --- /dev/null +++ b/jdk/make/mapfiles/libprefs/mapfile-vers @@ -0,0 +1,36 @@ +# +# Copyright (c) 2014, 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. +# + +# Define public interface. + +SUNWprivate_1.1 { + global: + Java_java_util_prefs_FileSystemPreferences_chmod; + Java_java_util_prefs_FileSystemPreferences_lockFile0; + Java_java_util_prefs_FileSystemPreferences_unlockFile0; + + local: + *; +}; diff --git a/jdk/make/profile-includes.txt b/jdk/make/profile-includes.txt index 105f9d36689..f8fbef0c69a 100644 --- a/jdk/make/profile-includes.txt +++ b/jdk/make/profile-includes.txt @@ -130,6 +130,7 @@ PROFILE_3_JRE_LIB_FILES := \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management.diz \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX) \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt.diz \ + $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)prefs$(SHARED_LIBRARY_SUFFIX) \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX) \ jvm.hprof.txt \ management-agent.jar \ diff --git a/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java b/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java index ce63833da81..400368c1c62 100644 --- a/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java +++ b/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java @@ -82,7 +82,7 @@ class MacOSXPreferencesFile { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Void run() { - System.loadLibrary("osx"); + System.loadLibrary("prefs"); return null; } }); diff --git a/jdk/src/macosx/native/java/util/MacOSXPreferencesFile.m b/jdk/src/macosx/native/java/util/prefs/MacOSXPreferencesFile.m similarity index 100% rename from jdk/src/macosx/native/java/util/MacOSXPreferencesFile.m rename to jdk/src/macosx/native/java/util/prefs/MacOSXPreferencesFile.m diff --git a/jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m b/jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m similarity index 100% rename from jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m rename to jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java index b2ac0d9d3e0..0318489bbf8 100644 --- a/jdk/src/share/classes/java/util/logging/FileHandler.java +++ b/jdk/src/share/classes/java/util/logging/FileHandler.java @@ -535,7 +535,7 @@ public class FileHandler extends StreamHandler { continue; } else if (ch2 == 'h') { file = new File(System.getProperty("user.home")); - if (isSetUID()) { + if (sun.misc.VM.isSetUID()) { // Ok, we are in a set UID program. For safety's sake // we disallow attempts to open files relative to %h. throw new IOException("can't use %h in set UID program"); @@ -669,9 +669,4 @@ public class FileHandler extends StreamHandler { lastException = ex; } } - - /** - * check if we are in a set UID program. - */ - private static native boolean isSetUID(); } diff --git a/jdk/src/share/classes/sun/misc/VM.java b/jdk/src/share/classes/sun/misc/VM.java index 8b77e2297fa..d6fdad114d6 100644 --- a/jdk/src/share/classes/sun/misc/VM.java +++ b/jdk/src/share/classes/sun/misc/VM.java @@ -367,6 +367,11 @@ public class VM { */ public static native ClassLoader latestUserDefinedLoader(); + /** + * Returns {@code true} if we are in a set UID program. + */ + public static native boolean isSetUID(); + static { initialize(); } diff --git a/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java b/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java index 8d632379d16..f94a1372054 100644 --- a/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java +++ b/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java @@ -42,7 +42,7 @@ public class SCDynamicStoreConfig { public Boolean run() { String osname = System.getProperty("os.name"); if (osname.contains("OS X")) { - System.loadLibrary("osx"); + System.loadLibrary("osxkrb5"); return true; } return false; diff --git a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java index 166fcd97d69..6ca10d10c93 100644 --- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java +++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java @@ -48,6 +48,15 @@ import sun.util.logging.PlatformLogger; * @since 1.4 */ class FileSystemPreferences extends AbstractPreferences { + + static { + PrivilegedAction load = () -> { + System.loadLibrary("prefs"); + return null; + }; + AccessController.doPrivileged(load); + } + /** * Sync interval in seconds. */ @@ -868,7 +877,7 @@ class FileSystemPreferences extends AbstractPreferences { /** * Returns the node name corresponding to the specified directory name. - * (Inverts the transformation of dirName(String). + * (Inverts the transformation of dirName(String). */ private static String nodeName(String dirName) { if (dirName.charAt(0) != '_') diff --git a/jdk/src/solaris/native/java/util/FileSystemPreferences.c b/jdk/src/solaris/native/java/util/prefs/FileSystemPreferences.c similarity index 100% rename from jdk/src/solaris/native/java/util/FileSystemPreferences.c rename to jdk/src/solaris/native/java/util/prefs/FileSystemPreferences.c diff --git a/jdk/src/solaris/native/java/util/logging.c b/jdk/src/solaris/native/sun/misc/VM_md.c similarity index 91% rename from jdk/src/solaris/native/java/util/logging.c rename to jdk/src/solaris/native/sun/misc/VM_md.c index af50903c642..7fe336274a4 100644 --- a/jdk/src/solaris/native/java/util/logging.c +++ b/jdk/src/solaris/native/sun/misc/VM_md.c @@ -23,16 +23,12 @@ * questions. */ -/* - * Solaris/Linux specific code to support logging. - */ - #include #include "jni_util.h" JNIEXPORT jboolean JNICALL -Java_java_util_logging_FileHandler_isSetUID(JNIEnv *env, jclass thisclass) { +Java_sun_misc_VM_isSetUID(JNIEnv *env, jclass thisclass) { /* Return true if we are in a set UID or set GID process. */ if (getuid() != geteuid() || getgid() != getegid()) { diff --git a/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java b/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java index 53678e5424a..6844234d39d 100644 --- a/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java +++ b/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java @@ -29,6 +29,9 @@ import java.util.Map; import java.util.TreeMap; import java.util.StringTokenizer; import java.io.ByteArrayOutputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; + import sun.util.logging.PlatformLogger; /** @@ -45,6 +48,14 @@ import sun.util.logging.PlatformLogger; class WindowsPreferences extends AbstractPreferences{ + static { + PrivilegedAction load = () -> { + System.loadLibrary("prefs"); + return null; + }; + AccessController.doPrivileged(load); + } + /** * Logger for error messages */ diff --git a/jdk/src/windows/native/java/util/WindowsPreferences.c b/jdk/src/windows/native/java/util/prefs/WindowsPreferences.c similarity index 100% rename from jdk/src/windows/native/java/util/WindowsPreferences.c rename to jdk/src/windows/native/java/util/prefs/WindowsPreferences.c diff --git a/jdk/src/windows/native/java/util/logging.c b/jdk/src/windows/native/sun/misc/VM_md.c similarity index 91% rename from jdk/src/windows/native/java/util/logging.c rename to jdk/src/windows/native/sun/misc/VM_md.c index 41b7cf657d2..165ad2713ea 100644 --- a/jdk/src/windows/native/java/util/logging.c +++ b/jdk/src/windows/native/sun/misc/VM_md.c @@ -23,15 +23,11 @@ * questions. */ -/* - * Win32 specific code to support logging. - */ - #include "jni_util.h" JNIEXPORT jboolean JNICALL -Java_java_util_logging_FileHandler_isSetUID(JNIEnv *env, jclass thisclass) { +Java_sun_misc_VM_isSetUID(JNIEnv *env, jclass thisclass) { /* There is no set UID on Windows. */ return JNI_FALSE;