Merge
authorprr
Tue, 11 Feb 2014 14:42:17 -0800
changeset 23292 009134c9d572
parent 23291 e97e8471b683 (current diff)
parent 22956 322ce28a7e20 (diff)
child 23293 94f894482549
Merge
jdk/make/CompileJavaClasses.gmk
jdk/make/lib/Awt2dLibraries.gmk
jdk/src/macosx/native/java/util/MacOSXPreferencesFile.m
jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m
jdk/src/solaris/native/java/util/FileSystemPreferences.c
jdk/src/solaris/native/java/util/logging.c
jdk/src/solaris/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c
jdk/src/windows/native/java/util/WindowsPreferences.c
jdk/src/windows/native/java/util/logging.c
--- a/jdk/make/CompileJavaClasses.gmk	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/CompileJavaClasses.gmk	Tue Feb 11 14:42:17 2014 -0800
@@ -44,6 +44,10 @@
     com/sun/tools/example/debug/event \
     com/sun/tools/example/debug/gui
 
+ifeq ($(RMICONNECTOR_IIOP), false)
+  EXCLUDES += com/sun/jmx/remote/protocol/iiop
+endif
+
 ifdef OPENJDK
   EXCLUDES += sun/dc \
       com/sun/jmx/snmp \
--- a/jdk/make/GenerateClasses.gmk	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/GenerateClasses.gmk	Tue Feb 11 14:42:17 2014 -0800
@@ -52,7 +52,7 @@
 
 ##########################################################################################
 
-BTRMIC_CP := $(CORBA_OUTPUTDIR)/btjars/btcorba.jar$(PATH_SEP)$(JDK_OUTPUTDIR)/btclasses_rmic$(PATH_SEP)$(BOOTSTRAP_JAVAC_JAR)
+BTRMIC_CP := $(INTERIM_CORBA_JAR)$(PATH_SEP)$(JDK_OUTPUTDIR)/btclasses_rmic$(PATH_SEP)$(INTERIM_LANGTOOLS_JAR)
 BTRMIC_ARGS := "-Xbootclasspath/p:$(BTRMIC_CP)" -cp "$(BTRMIC_CP)"
 RMIC := $(JAVA) $(BTRMIC_ARGS) sun.rmi.rmic.Main
 
@@ -89,21 +89,25 @@
 # For RMI/IIOP call rmic a second time with -standardPackage option
 # so that *_tie classes are generated in package without the prefix
 # org.omg.stub (6375696)
-JMAN_RMI_CLASSES := javax.management.remote.rmi.RMIConnectionImpl \
+JMX_RMI_CLASSES := javax.management.remote.rmi.RMIConnectionImpl \
     javax.management.remote.rmi.RMIServerImpl
+GENRMIIIOPCLASSES :=
+ifneq ($(RMICONNECTOR_IIOP), false)
+  GENRMIIIOPCLASSES := $(RMICONNECTOR_IIOP)
+endif
 $(eval $(call SetupRMICompilation,RMI_IIOP, \
-    CLASSES := $(JMAN_RMI_CLASSES), \
+    CLASSES := $(JMX_RMI_CLASSES), \
     CLASSES_DIR := $(CLASSES_DIR), \
     STUB_CLASSES_DIR := $(STUB_CLASSES_DIR), \
     RUN_V12 := true, \
-    RUN_IIOP := true, \
-    RUN_IIOP_STDPKG := true))
+    RUN_IIOP := $(GENRMIIIOPCLASSES), \
+    RUN_IIOP_STDPKG := $(GENRMIIIOPCLASSES)))
 GENCLASSES += $(RMI_IIOP)
 
 # Keep generated RMI/JRMP Stub source files and copy them to RMIC_GENSRC_DIR
 # so that javadoc can include them in the API (4997471)
 $(eval $(call SetupRMICompilation,RMI_SRC, \
-    CLASSES := $(JMAN_RMI_CLASSES), \
+    CLASSES := $(JMX_RMI_CLASSES), \
     CLASSES_DIR := $(CLASSES_DIR), \
     STUB_CLASSES_DIR := $(RMIC_GENSRC_DIR), \
     RUN_V12 := true, \
--- a/jdk/make/Tools.gmk	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/Tools.gmk	Tue Feb 11 14:42:17 2014 -0800
@@ -122,12 +122,12 @@
 TOOL_CLDRCONVERTER = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
     build.tools.cldrconverter.CLDRConverter
 
-TOOL_CHECKDEPS = $(JAVA) -Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
+TOOL_CHECKDEPS = $(JAVA) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
     -cp $(JDK_OUTPUTDIR)/btclasses:$(JDK_OUTPUTDIR) \
     build.tools.deps.CheckDeps
 
 TOOL_ADDTORESTRICTEDPKGS=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
- 	build.tools.addtorestrictedpkgs.AddToRestrictedPkgs
+    build.tools.addtorestrictedpkgs.AddToRestrictedPkgs
 
 ##########################################################################################
 
--- a/jdk/make/lib/Awt2dLibraries.gmk	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/lib/Awt2dLibraries.gmk	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -792,9 +792,9 @@
 endif
 
 BUILD_LIBFONTMANAGER_CFLAGS_COMMON := \
+    $(FONT_HEADERS) \
     $(X_CFLAGS) \
     -DLE_STANDALONE -DHEADLESS \
-    $(FONT_HEADERS) \
     -I$(JDK_TOPDIR)/src/share/native/sun/font \
     -I$(JDK_TOPDIR)/src/share/native/sun/font/layout \
     -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
--- a/jdk/make/lib/CoreLibraries.gmk	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/lib/CoreLibraries.gmk	Tue Feb 11 14:42:17 2014 -0800
@@ -123,15 +123,16 @@
     $(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 \
     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util
 
-ifneq ($(OPENJDK_TARGET_OS), macosx)
+ifeq ($(OPENJDK_TARGET_OS), windows)
   LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/util/locale/provider
-else
+else ifeq ($(OPENJDK_TARGET_OS), macosx)
   LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/util/locale/provider
 endif
 
@@ -187,7 +188,7 @@
     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 @@
 
 ##########################################################################################
 
+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), \
--- a/jdk/make/lib/PlatformLibraries.gmk	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/lib/PlatformLibraries.gmk	Tue Feb 11 14:42:17 2014 -0800
@@ -95,7 +95,6 @@
 
   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
--- a/jdk/make/lib/SecurityLibraries.gmk	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/lib/SecurityLibraries.gmk	Tue Feb 11 14:42:17 2014 -0800
@@ -128,8 +128,13 @@
         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 @@
         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), \
--- a/jdk/make/mapfiles/libjava/mapfile-vers	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/mapfiles/libjava/mapfile-vers	Tue Feb 11 14:42:17 2014 -0800
@@ -79,7 +79,7 @@
 		Java_java_io_FileInputStream_close0;
 		Java_java_io_FileInputStream_initIDs;
 		Java_java_io_FileInputStream_open;
-		Java_java_io_FileInputStream_read;
+		Java_java_io_FileInputStream_read0;
 		Java_java_io_FileInputStream_readBytes;
 		Java_java_io_FileInputStream_skip;
 		Java_java_io_FileOutputStream_close0;
@@ -98,11 +98,11 @@
 		Java_java_io_RandomAccessFile_initIDs;
 		Java_java_io_RandomAccessFile_length;
 		Java_java_io_RandomAccessFile_open;
-		Java_java_io_RandomAccessFile_read;
+		Java_java_io_RandomAccessFile_read0;
 		Java_java_io_RandomAccessFile_readBytes;
 		Java_java_io_RandomAccessFile_seek0;
 		Java_java_io_RandomAccessFile_setLength;
-		Java_java_io_RandomAccessFile_write;
+		Java_java_io_RandomAccessFile_write0;
 		Java_java_io_RandomAccessFile_writeBytes;
 		Java_java_io_UnixFileSystem_canonicalize0;
 		Java_java_io_UnixFileSystem_checkAccess;
@@ -236,10 +236,6 @@
 		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,19 +270,13 @@
                 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
-
-		Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPattern;
-
 	# Outcalls from libjvm done using dlsym().
 
 		VerifyClassCodes;
--- a/jdk/make/mapfiles/libjfr/mapfile-vers	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/mapfiles/libjfr/mapfile-vers	Tue Feb 11 14:42:17 2014 -0800
@@ -34,6 +34,7 @@
       Java_oracle_jrockit_jfr_VMJFR_getPeriod;
       Java_oracle_jrockit_jfr_VMJFR_descriptors;
       Java_oracle_jrockit_jfr_VMJFR_redefineClass0;
+      Java_oracle_jrockit_jfr_VMJFR_retransformClasses0;
       JNI_OnLoad;
   local:
       *;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/mapfiles/libprefs/mapfile-vers	Tue Feb 11 14:42:17 2014 -0800
@@ -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:
+		*;
+};
--- a/jdk/make/profile-includes.txt	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/make/profile-includes.txt	Tue Feb 11 14:42:17 2014 -0800
@@ -130,6 +130,7 @@
     $(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 \
--- a/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java	Tue Feb 11 14:42:17 2014 -0800
@@ -82,7 +82,7 @@
         java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<Void>() {
                 public Void run() {
-                    System.loadLibrary("osx");
+                    System.loadLibrary("prefs");
                     return null;
                 }
             });
--- a/jdk/src/macosx/native/java/util/MacOSXPreferencesFile.m	Tue Feb 11 12:40:16 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,999 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, 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.
- */
-
-/*
-   Hierarchical storage layout:
-
-   <dict>
-     <key>/</key>
-     <dict>
-       <key>foo</key>
-       <string>/foo's value</string>
-       <key>foo/</key>
-       <dict>
-         <key>bar</key>
-         <string>/foo/bar's value</string>
-       </dict>
-     </dict>
-   </dict>
-
-   Java pref nodes are stored in several different files. Pref nodes
-   with at least three components in the node name (e.g. /com/MyCompany/MyApp/)
-   are stored in a CF prefs file with the first three components as the name.
-   This way, all preferences for MyApp end up in com.MyCompany.MyApp.plist .
-   Pref nodes with shorter names are stored in com.apple.java.util.prefs.plist
-
-   The filesystem is assumed to be case-insensitive (like HFS+).
-   Java pref node names are case-sensitive. If two pref node names differ
-   only in case, they may end up in the same pref file. This is ok
-   because the CF keys identifying the node span the entire absolute path
-   to the node and are case-sensitive.
-
-   Java node names may contain '.' . When mapping to the CF file name,
-   these dots are left as-is, even though '/' is mapped to '.' .
-   This is ok because the CF key contains the correct node name.
-*/
-
-
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#include "jni_util.h"
-#include "jlong.h"
-#include "jvm.h"
-
-
-// Throw an OutOfMemoryError with the given message.
-static void throwOutOfMemoryError(JNIEnv *env, const char *msg)
-{
-    static jclass exceptionClass = NULL;
-    jclass c;
-
-    if (exceptionClass) {
-        c = exceptionClass;
-    } else {
-        c = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
-        if ((*env)->ExceptionOccurred(env)) return;
-        exceptionClass = (*env)->NewGlobalRef(env, c);
-    }
-
-    (*env)->ThrowNew(env, c, msg);
-}
-
-
-// throwIfNull macro
-// If var is NULL, throw an OutOfMemoryError and goto badvar.
-// var must be a variable. env must be the current JNIEnv.
-// fixme throw BackingStoreExceptions sometimes?
-#define throwIfNull(var, msg) \
-    do { \
-        if (var == NULL) { \
-            throwOutOfMemoryError(env, msg); \
-            goto bad##var; \
-        } \
-    } while (0)
-
-
-// Converts CFNumber, CFBoolean, CFString to CFString
-// returns NULL if value is of some other type
-// throws and returns NULL on memory error
-// result must be released (even if value was already a CFStringRef)
-// value must not be null
-static CFStringRef copyToCFString(JNIEnv *env, CFTypeRef value)
-{
-    CFStringRef result;
-    CFTypeID type;
-
-    type = CFGetTypeID(value);
-
-    if (type == CFStringGetTypeID()) {
-        result = (CFStringRef)CFRetain(value);
-    }
-    else if (type == CFBooleanGetTypeID()) {
-        // Java Preferences API expects "true" and "false" for boolean values.
-        result = CFStringCreateCopy(NULL, (value == kCFBooleanTrue) ? CFSTR("true") : CFSTR("false"));
-        throwIfNull(result, "copyToCFString failed");
-    }
-    else if (type == CFNumberGetTypeID()) {
-        CFNumberRef number = (CFNumberRef) value;
-        if (CFNumberIsFloatType(number)) {
-            double d;
-            CFNumberGetValue(number, kCFNumberDoubleType, &d);
-            result = CFStringCreateWithFormat(NULL, NULL, CFSTR("%g"), d);
-            throwIfNull(result, "copyToCFString failed");
-        }
-        else {
-            long l;
-            CFNumberGetValue(number, kCFNumberLongType, &l);
-            result = CFStringCreateWithFormat(NULL, NULL, CFSTR("%ld"), l);
-            throwIfNull(result, "copyToCFString failed");
-        }
-    }
-    else {
-        // unknown type - return NULL
-        result = NULL;
-    }
-
- badresult:
-    return result;
-}
-
-
-// Create a Java string from the given CF string.
-// returns NULL if cfString is NULL
-// throws and returns NULL on memory error
-static jstring toJavaString(JNIEnv *env, CFStringRef cfString)
-{
-    if (cfString == NULL) {
-        return NULL;
-    } else {
-        jstring javaString = NULL;
-
-        CFIndex length = CFStringGetLength(cfString);
-        const UniChar *constchars = CFStringGetCharactersPtr(cfString);
-        if (constchars) {
-            javaString = (*env)->NewString(env, constchars, length);
-        } else {
-            UniChar *chars = malloc(length * sizeof(UniChar));
-            throwIfNull(chars, "toJavaString failed");
-            CFStringGetCharacters(cfString, CFRangeMake(0, length), chars);
-            javaString = (*env)->NewString(env, chars, length);
-            free(chars);
-        }
-    badchars:
-        return javaString;
-    }
-}
-
-
-
-// Create a CF string from the given Java string.
-// returns NULL if javaString is NULL
-// throws and returns NULL on memory error
-static CFStringRef toCF(JNIEnv *env, jstring javaString)
-{
-    if (javaString == NULL) {
-        return NULL;
-    } else {
-        CFStringRef result = NULL;
-        jsize length = (*env)->GetStringLength(env, javaString);
-        const jchar *chars = (*env)->GetStringChars(env, javaString, NULL);
-        throwIfNull(chars, "toCF failed");
-        result =
-            CFStringCreateWithCharacters(NULL, (const UniChar *)chars, length);
-        (*env)->ReleaseStringChars(env, javaString, chars);
-        throwIfNull(result, "toCF failed");
-    badchars:
-    badresult:
-        return result;
-    }
-}
-
-
-// Create an empty Java string array of the given size.
-// Throws and returns NULL on error.
-static jarray createJavaStringArray(JNIEnv *env, CFIndex count)
-{
-    static jclass stringClass = NULL;
-    jclass c;
-
-    if (stringClass) {
-        c = stringClass;
-    } else {
-        c = (*env)->FindClass(env, "java/lang/String");
-        if ((*env)->ExceptionOccurred(env)) return NULL;
-        stringClass = (*env)->NewGlobalRef(env, c);
-    }
-
-    return (*env)->NewObjectArray(env, count, c, NULL); // AWT_THREADING Safe (known object)
-}
-
-
-// Java accessors for CF constants.
-JNIEXPORT jlong JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_currentUser(JNIEnv *env,
-                                                       jobject klass)
-{
-    return ptr_to_jlong(kCFPreferencesCurrentUser);
-}
-
-JNIEXPORT jlong JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_anyUser(JNIEnv *env, jobject klass)
-{
-    return ptr_to_jlong(kCFPreferencesAnyUser);
-}
-
-JNIEXPORT jlong JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_currentHost(JNIEnv *env,
-                                                       jobject klass)
-{
-    return ptr_to_jlong(kCFPreferencesCurrentHost);
-}
-
-JNIEXPORT jlong JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_anyHost(JNIEnv *env, jobject klass)
-{
-    return ptr_to_jlong(kCFPreferencesAnyHost);
-}
-
-
-// Create an empty node.
-// Does not store the node in any prefs file.
-// returns NULL on memory error
-static CFMutableDictionaryRef createEmptyNode(void)
-{
-    return CFDictionaryCreateMutable(NULL, 0,
-                                     &kCFTypeDictionaryKeyCallBacks,
-                                     &kCFTypeDictionaryValueCallBacks);
-}
-
-
-// Create a string that consists of path minus its last component.
-// path must end with '/'
-// The result will end in '/' (unless path itself is '/')
-static CFStringRef copyParentOf(CFStringRef path)
-{
-    CFRange searchRange;
-    CFRange slashRange;
-    CFRange parentRange;
-    Boolean found;
-
-    searchRange = CFRangeMake(0, CFStringGetLength(path) - 1);
-    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange,
-                                    kCFCompareBackwards, &slashRange);
-    if (!found) return CFSTR("");
-    parentRange = CFRangeMake(0, slashRange.location + 1); // include '/'
-    return CFStringCreateWithSubstring(NULL, path, parentRange);
-}
-
-
-// Create a string that consists of path's last component.
-// path must end with '/'
-// The result will end in '/'.
-// The result will not start with '/' (unless path itself is '/')
-static CFStringRef copyChildOf(CFStringRef path)
-{
-    CFRange searchRange;
-    CFRange slashRange;
-    CFRange childRange;
-    Boolean found;
-    CFIndex length = CFStringGetLength(path);
-
-    searchRange = CFRangeMake(0, length - 1);
-    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange,
-                                    kCFCompareBackwards, &slashRange);
-    if (!found) return CFSTR("");
-    childRange = CFRangeMake(slashRange.location + 1,
-                             length - slashRange.location - 1); // skip '/'
-    return CFStringCreateWithSubstring(NULL, path, childRange);
-}
-
-
-// Return the first three components of path, with leading and trailing '/'.
-// If path does not have three components, return NULL.
-// path must begin and end in '/'
-static CFStringRef copyFirstThreeComponentsOf(CFStringRef path)
-{
-    CFRange searchRange;
-    CFRange slashRange;
-    CFRange prefixRange;
-    CFStringRef prefix;
-    Boolean found;
-    CFIndex length = CFStringGetLength(path);
-
-    searchRange = CFRangeMake(1, length - 1);  // skip leading '/'
-    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange, 0,
-                                    &slashRange);
-    if (!found) return NULL;  // no second slash!
-
-    searchRange = CFRangeMake(slashRange.location + 1,
-                              length - slashRange.location - 1);
-    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange, 0,
-                                    &slashRange);
-    if (!found) return NULL;  // no third slash!
-
-    searchRange = CFRangeMake(slashRange.location + 1,
-                              length - slashRange.location - 1);
-    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange, 0,
-                                    &slashRange);
-    if (!found) return NULL;  // no fourth slash!
-
-    prefixRange = CFRangeMake(0, slashRange.location + 1); // keep last '/'
-    prefix = CFStringCreateWithSubstring(NULL, path, prefixRange);
-
-    return prefix;
-}
-
-
-// Copy the CFPreferences key and value at the base of path's tree.
-// path must end in '/'
-// topKey or topValue may be NULL
-// Returns NULL on error or if there is no tree for path in this file.
-static void copyTreeForPath(CFStringRef path, CFStringRef name,
-                            CFStringRef user, CFStringRef host,
-                            CFStringRef *topKey, CFDictionaryRef *topValue)
-{
-    CFStringRef key;
-    CFPropertyListRef value;
-
-    if (topKey) *topKey = NULL;
-    if (topValue) *topValue = NULL;
-
-    if (CFEqual(name, CFSTR("com.apple.java.util.prefs"))) {
-        // Top-level file. Only key "/" is an acceptable root.
-        key = (CFStringRef) CFRetain(CFSTR("/"));
-    } else {
-        // Second-level file. Key must be the first three components of path.
-        key = copyFirstThreeComponentsOf(path);
-        if (!key) return;
-    }
-
-    value = CFPreferencesCopyValue(key, name, user, host);
-    if (value) {
-        if (CFGetTypeID(value) == CFDictionaryGetTypeID()) {
-            // (key, value) is acceptable
-            if (topKey) *topKey = (CFStringRef)CFRetain(key);
-            if (topValue) *topValue = (CFDictionaryRef)CFRetain(value);
-        }
-        CFRelease(value);
-    }
-    CFRelease(key);
-}
-
-
-// Find the node for path in the given tree.
-// Returns NULL on error or if path doesn't have a node in this tree.
-// path must end in '/'
-static CFDictionaryRef copyNodeInTree(CFStringRef path, CFStringRef topKey,
-                                      CFDictionaryRef topValue)
-{
-    CFMutableStringRef p;
-    CFDictionaryRef result = NULL;
-
-    p = CFStringCreateMutableCopy(NULL, 0, path);
-    if (!p) return NULL;
-    CFStringDelete(p, CFRangeMake(0, CFStringGetLength(topKey)));
-    result = topValue;
-
-    while (CFStringGetLength(p) > 0) {
-        CFDictionaryRef child;
-        CFStringRef part = NULL;
-        CFRange slashRange = CFStringFind(p, CFSTR("/"), 0);
-        // guaranteed to succeed because path must end in '/'
-        CFRange partRange = CFRangeMake(0, slashRange.location + 1);
-        part = CFStringCreateWithSubstring(NULL, p, partRange);
-        if (!part) { result = NULL; break; }
-        CFStringDelete(p, partRange);
-
-        child = CFDictionaryGetValue(result, part);
-        CFRelease(part);
-        if (child  &&  CFGetTypeID(child) == CFDictionaryGetTypeID()) {
-            // continue search
-            result = child;
-        } else {
-            // didn't find target node
-            result = NULL;
-            break;
-        }
-    }
-
-    CFRelease(p);
-    if (result) return (CFDictionaryRef)CFRetain(result);
-    else return NULL;
-}
-
-
-// Return a retained copy of the node at path from the given file.
-// path must end in '/'
-// returns NULL if node doesn't exist.
-// returns NULL if the value for key "path" isn't a valid node.
-static CFDictionaryRef copyNodeIfPresent(CFStringRef path, CFStringRef name,
-                                         CFStringRef user, CFStringRef host)
-{
-    CFStringRef topKey;
-    CFDictionaryRef topValue;
-    CFDictionaryRef result;
-
-    copyTreeForPath(path, name, user, host, &topKey, &topValue);
-    if (!topKey) return NULL;
-
-    result = copyNodeInTree(path, topKey, topValue);
-
-    CFRelease(topKey);
-    if (topValue) CFRelease(topValue);
-    return result;
-}
-
-
-// Create a new tree that would store path in the given file.
-// Only the root of the tree is created, not all of the links leading to path.
-// returns NULL on error
-static void createTreeForPath(CFStringRef path, CFStringRef name,
-                              CFStringRef user, CFStringRef host,
-                              CFStringRef *outTopKey,
-                              CFMutableDictionaryRef *outTopValue)
-{
-    *outTopKey = NULL;
-    *outTopValue = NULL;
-
-    // if name is "com.apple.java.util.prefs" then create tree "/"
-    // else create tree "/foo/bar/baz/"
-    // "com.apple.java.util.prefs.plist" is also in MacOSXPreferences.java
-    if (CFEqual(name, CFSTR("com.apple.java.util.prefs"))) {
-        *outTopKey = CFSTR("/");
-        *outTopValue = createEmptyNode();
-    } else {
-        CFStringRef prefix = copyFirstThreeComponentsOf(path);
-        if (prefix) {
-            *outTopKey = prefix;
-            *outTopValue = createEmptyNode();
-        }
-    }
-}
-
-
-// Return a mutable copy of the tree containing path and the dict for
-//   path itself. *outTopKey and *outTopValue can be used to write the
-//   modified tree back to the prefs file.
-// *outTopKey and *outTopValue must be released iff the actual return
-//   value is not NULL.
-static CFMutableDictionaryRef
-copyMutableNode(CFStringRef path, CFStringRef name,
-                CFStringRef user, CFStringRef host,
-                CFStringRef *outTopKey,
-                CFMutableDictionaryRef *outTopValue)
-{
-    CFStringRef topKey = NULL;
-    CFDictionaryRef oldTopValue = NULL;
-    CFMutableDictionaryRef topValue;
-    CFMutableDictionaryRef result = NULL;
-    CFMutableStringRef p;
-
-    if (outTopKey) *outTopKey = NULL;
-    if (outTopValue) *outTopValue = NULL;
-
-    copyTreeForPath(path, name, user, host, &topKey, &oldTopValue);
-    if (!topKey) {
-        createTreeForPath(path, name, user, host, &topKey, &topValue);
-    } else {
-        topValue = (CFMutableDictionaryRef)
-            CFPropertyListCreateDeepCopy(NULL, (CFPropertyListRef)oldTopValue,
-                                         kCFPropertyListMutableContainers);
-    }
-    if (!topValue) goto badtopValue;
-
-    p = CFStringCreateMutableCopy(NULL, 0, path);
-    if (!p) goto badp;
-    CFStringDelete(p, CFRangeMake(0, CFStringGetLength(topKey)));
-    result = topValue;
-
-    while (CFStringGetLength(p) > 0) {
-        CFMutableDictionaryRef child;
-        CFStringRef part = NULL;
-        CFRange slashRange = CFStringFind(p, CFSTR("/"), 0);
-        // guaranteed to succeed because path must end in '/'
-        CFRange partRange = CFRangeMake(0, slashRange.location + 1);
-        part = CFStringCreateWithSubstring(NULL, p, partRange);
-        if (!part) { result = NULL; break; }
-        CFStringDelete(p, partRange);
-
-        child = (CFMutableDictionaryRef)CFDictionaryGetValue(result, part);
-        if (child  &&  CFGetTypeID(child) == CFDictionaryGetTypeID()) {
-            // continue search
-            result = child;
-        } else {
-            // didn't find target node - add it and continue
-            child = createEmptyNode();
-            if (!child) { CFRelease(part); result = NULL; break; }
-            CFDictionaryAddValue(result, part, child);
-            result = child;
-        }
-        CFRelease(part);
-    }
-
-    if (result) {
-        *outTopKey = (CFStringRef)CFRetain(topKey);
-        *outTopValue = (CFMutableDictionaryRef)CFRetain(topValue);
-        CFRetain(result);
-    }
-
-    CFRelease(p);
- badp:
-    CFRelease(topValue);
- badtopValue:
-    if (topKey) CFRelease(topKey);
-    if (oldTopValue) CFRelease(oldTopValue);
-    return result;
-}
-
-
-JNIEXPORT jboolean JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_addNode
-(JNIEnv *env, jobject klass, jobject jpath,
- jobject jname, jlong juser, jlong jhost)
-{
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFDictionaryRef node = NULL;
-    jboolean neededNewNode = false;
-
-    if (!path  ||  !name) goto badparams;
-
-    node = copyNodeIfPresent(path, name, user, host);
-
-    if (node) {
-        neededNewNode = false;
-        CFRelease(node);
-    } else {
-        CFStringRef topKey = NULL;
-        CFMutableDictionaryRef topValue = NULL;
-
-        neededNewNode = true;
-
-        // copyMutableNode creates the node if necessary
-        node = copyMutableNode(path, name, user, host, &topKey, &topValue);
-        throwIfNull(node, "copyMutableNode failed");
-
-        CFPreferencesSetValue(topKey, topValue, name, user, host);
-
-        CFRelease(node);
-        if (topKey) CFRelease(topKey);
-        if (topValue) CFRelease(topValue);
-    }
-
- badnode:
- badparams:
-    if (path) CFRelease(path);
-    if (name) CFRelease(name);
-
-    return neededNewNode;
-}
-
-
-JNIEXPORT void JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_removeNode
-(JNIEnv *env, jobject klass, jobject jpath,
- jobject jname, jlong juser, jlong jhost)
-{
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFStringRef parentName;
-    CFStringRef childName;
-    CFDictionaryRef constParent;
-
-    if (!path  ||  !name) goto badparams;
-
-    parentName = copyParentOf(path);
-    throwIfNull(parentName, "copyParentOf failed");
-    childName  = copyChildOf(path);
-    throwIfNull(childName, "copyChildOf failed");
-
-    // root node is not allowed to be removed, so parentName is never empty
-
-    constParent = copyNodeIfPresent(parentName, name, user, host);
-    if (constParent  &&  CFDictionaryContainsKey(constParent, childName)) {
-        CFStringRef topKey;
-        CFMutableDictionaryRef topValue;
-        CFMutableDictionaryRef parent;
-
-        parent = copyMutableNode(parentName, name, user, host,
-                                 &topKey, &topValue);
-        throwIfNull(parent, "copyMutableNode failed");
-
-        CFDictionaryRemoveValue(parent, childName);
-        CFPreferencesSetValue(topKey, topValue, name, user, host);
-
-        CFRelease(parent);
-        if (topKey) CFRelease(topKey);
-        if (topValue) CFRelease(topValue);
-    } else {
-        // might be trying to remove the root itself in a non-root file
-        CFStringRef topKey;
-        CFDictionaryRef topValue;
-        copyTreeForPath(path, name, user, host, &topKey, &topValue);
-        if (topKey) {
-            if (CFEqual(topKey, path)) {
-                CFPreferencesSetValue(topKey, NULL, name, user, host);
-            }
-
-            if (topKey) CFRelease(topKey);
-            if (topValue) CFRelease(topValue);
-        }
-    }
-
-
- badparent:
-    if (constParent) CFRelease(constParent);
-    CFRelease(childName);
- badchildName:
-    CFRelease(parentName);
- badparentName:
- badparams:
-    if (path) CFRelease(path);
-    if (name) CFRelease(name);
-}
-
-
-// child must end with '/'
-JNIEXPORT Boolean JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_addChildToNode
-(JNIEnv *env, jobject klass, jobject jpath, jobject jchild,
- jobject jname, jlong juser, jlong jhost)
-{
-    // like addNode, but can put a three-level-deep dict into the root file
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef child = toCF(env, jchild);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFMutableDictionaryRef parent;
-    CFDictionaryRef node;
-    CFStringRef topKey;
-    CFMutableDictionaryRef topValue;
-    Boolean beforeAdd = false;
-
-    if (!path  ||  !child  ||  !name) goto badparams;
-
-    node = createEmptyNode();
-    throwIfNull(node, "createEmptyNode failed");
-
-    // copyMutableNode creates the node if necessary
-    parent = copyMutableNode(path, name, user, host, &topKey, &topValue);
-    throwIfNull(parent, "copyMutableNode failed");
-    beforeAdd = CFDictionaryContainsKey(parent, child);
-    CFDictionaryAddValue(parent, child, node);
-    if (!beforeAdd)
-        beforeAdd = CFDictionaryContainsKey(parent, child);
-    else
-        beforeAdd = false;
-    CFPreferencesSetValue(topKey, topValue, name, user, host);
-
-    CFRelease(parent);
-    if (topKey) CFRelease(topKey);
-    if (topValue) CFRelease(topValue);
- badparent:
-    CFRelease(node);
- badnode:
- badparams:
-    if (path) CFRelease(path);
-    if (child) CFRelease(child);
-    if (name) CFRelease(name);
-    return beforeAdd;
-}
-
-
-JNIEXPORT void JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_removeChildFromNode
-(JNIEnv *env, jobject klass, jobject jpath, jobject jchild,
- jobject jname, jlong juser, jlong jhost)
-{
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef child = toCF(env, jchild);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFDictionaryRef constParent;
-
-    if (!path  ||  !child  ||  !name) goto badparams;
-
-    constParent = copyNodeIfPresent(path, name, user, host);
-    if (constParent  &&  CFDictionaryContainsKey(constParent, child)) {
-        CFStringRef topKey;
-        CFMutableDictionaryRef topValue;
-        CFMutableDictionaryRef parent;
-
-        parent = copyMutableNode(path, name, user, host, &topKey, &topValue);
-        throwIfNull(parent, "copyMutableNode failed");
-
-        CFDictionaryRemoveValue(parent, child);
-        CFPreferencesSetValue(topKey, topValue, name, user, host);
-
-        CFRelease(parent);
-        if (topKey) CFRelease(topKey);
-        if (topValue) CFRelease(topValue);
-    }
-
- badparent:
-    if (constParent) CFRelease(constParent);
- badparams:
-    if (path) CFRelease(path);
-    if (child) CFRelease(child);
-    if (name) CFRelease(name);
-}
-
-
-
-JNIEXPORT void JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_addKeyToNode
-(JNIEnv *env, jobject klass, jobject jpath, jobject jkey, jobject jvalue,
- jobject jname, jlong juser, jlong jhost)
-{
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef key = toCF(env, jkey);
-    CFStringRef value = toCF(env, jvalue);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFMutableDictionaryRef node = NULL;
-    CFStringRef topKey;
-    CFMutableDictionaryRef topValue;
-
-    if (!path  ||  !key  || !value  ||  !name) goto badparams;
-
-    // fixme optimization: check whether old value and new value are identical
-    node = copyMutableNode(path, name, user, host, &topKey, &topValue);
-    throwIfNull(node, "copyMutableNode failed");
-
-    CFDictionarySetValue(node, key, value);
-    CFPreferencesSetValue(topKey, topValue, name, user, host);
-
-    CFRelease(node);
-    if (topKey) CFRelease(topKey);
-    if (topValue) CFRelease(topValue);
-
- badnode:
- badparams:
-    if (path) CFRelease(path);
-    if (key) CFRelease(key);
-    if (value) CFRelease(value);
-    if (name) CFRelease(name);
-}
-
-
-JNIEXPORT void JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_removeKeyFromNode
-(JNIEnv *env, jobject klass, jobject jpath, jobject jkey,
- jobject jname, jlong juser, jlong jhost)
-{
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef key = toCF(env, jkey);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFDictionaryRef constNode;
-
-    if (!path  ||  !key  ||  !name) goto badparams;
-
-    constNode = copyNodeIfPresent(path, name, user, host);
-    if (constNode  &&  CFDictionaryContainsKey(constNode, key)) {
-        CFStringRef topKey;
-        CFMutableDictionaryRef topValue;
-        CFMutableDictionaryRef node;
-
-        node = copyMutableNode(path, name, user, host, &topKey, &topValue);
-        throwIfNull(node, "copyMutableNode failed");
-
-        CFDictionaryRemoveValue(node, key);
-        CFPreferencesSetValue(topKey, topValue, name, user, host);
-
-        CFRelease(node);
-        if (topKey) CFRelease(topKey);
-        if (topValue) CFRelease(topValue);
-    }
-
- badnode:
-    if (constNode) CFRelease(constNode);
- badparams:
-    if (path) CFRelease(path);
-    if (key) CFRelease(key);
-    if (name) CFRelease(name);
-}
-
-
-// path must end in '/'
-JNIEXPORT jstring JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_getKeyFromNode
-(JNIEnv *env, jobject klass, jobject jpath, jobject jkey,
- jobject jname, jlong juser, jlong jhost)
-{
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef key = toCF(env, jkey);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFPropertyListRef value;
-    CFDictionaryRef node;
-    jstring result = NULL;
-
-    if (!path  ||  !key  ||  !name) goto badparams;
-
-    node = copyNodeIfPresent(path, name, user, host);
-    if (node) {
-        value = (CFPropertyListRef)CFDictionaryGetValue(node, key);
-        if (!value) {
-            // key doesn't exist, or other error - no Java errors available
-            result = NULL;
-        } else {
-            CFStringRef cfString = copyToCFString(env, value);
-            if ((*env)->ExceptionOccurred(env)) {
-                // memory error in copyToCFString
-                result = NULL;
-            } else if (cfString == NULL) {
-                // bogus value type in prefs file - no Java errors available
-                result = NULL;
-            } else {
-                // good cfString
-                result = toJavaString(env, cfString);
-                CFRelease(cfString);
-            }
-        }
-        CFRelease(node);
-    }
-
- badparams:
-    if (path) CFRelease(path);
-    if (key) CFRelease(key);
-    if (name) CFRelease(name);
-
-    return result;
-}
-
-
-typedef struct {
-    jarray result;
-    JNIEnv *env;
-    CFIndex used;
-    Boolean allowSlash;
-} BuildJavaArrayArgs;
-
-// CFDictionary applier function that builds an array of Java strings
-//   from a CFDictionary of CFPropertyListRefs.
-// If args->allowSlash, only strings that end in '/' are added to the array,
-//   with the slash removed. Otherwise, only strings that do not end in '/'
-//   are added.
-// args->result must already exist and be large enough to hold all
-//   strings from the dictionary.
-// After complete application, args->result may not be full because
-//   some of the dictionary values weren't convertible to string. In
-//   this case, args->used will be the count of used elements.
-static void BuildJavaArrayFn(const void *key, const void *value, void *context)
-{
-    BuildJavaArrayArgs *args = (BuildJavaArrayArgs *)context;
-    CFPropertyListRef propkey = (CFPropertyListRef)key;
-    CFStringRef cfString = NULL;
-    JNIEnv *env = args->env;
-
-    if ((*env)->ExceptionOccurred(env)) return; // already failed
-
-    cfString = copyToCFString(env, propkey);
-    if ((*env)->ExceptionOccurred(env)) {
-        // memory error in copyToCFString
-    } else if (!cfString) {
-        // bogus value type in prefs file - no Java errors available
-    } else if (args->allowSlash != CFStringHasSuffix(cfString, CFSTR("/"))) {
-        // wrong suffix - ignore
-    } else {
-        // good cfString
-        jstring javaString;
-        if (args->allowSlash) {
-            CFRange range = CFRangeMake(0, CFStringGetLength(cfString) - 1);
-            CFStringRef s = CFStringCreateWithSubstring(NULL, cfString, range);
-            CFRelease(cfString);
-            cfString = s;
-        }
-        if (CFStringGetLength(cfString) <= 0) goto bad; // ignore empty
-        javaString = toJavaString(env, cfString);
-        if ((*env)->ExceptionOccurred(env)) goto bad;
-        (*env)->SetObjectArrayElement(env, args->result,args->used,javaString);
-        if ((*env)->ExceptionOccurred(env)) goto bad;
-        args->used++;
-    }
-
- bad:
-    if (cfString) CFRelease(cfString);
-}
-
-
-static jarray getStringsForNode(JNIEnv *env, jobject klass, jobject jpath,
-                                jobject jname, jlong juser, jlong jhost,
-                                Boolean allowSlash)
-{
-    CFStringRef path = toCF(env, jpath);
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    CFDictionaryRef node;
-    jarray result = NULL;
-    CFIndex count;
-
-    if (!path  ||  !name) goto badparams;
-
-    node = copyNodeIfPresent(path, name, user, host);
-    if (!node) {
-        result = createJavaStringArray(env, 0);
-    } else {
-        count = CFDictionaryGetCount(node);
-        result = createJavaStringArray(env, count);
-        if (result) {
-            BuildJavaArrayArgs args;
-            args.result = result;
-            args.env = env;
-            args.used = 0;
-            args.allowSlash = allowSlash;
-            CFDictionaryApplyFunction(node, BuildJavaArrayFn, &args);
-            if (!(*env)->ExceptionOccurred(env)) {
-                // array construction succeeded
-                if (args.used < count) {
-                    // finished array is smaller than expected.
-                    // Make a new array of precisely the right size.
-                    jarray newresult = createJavaStringArray(env, args.used);
-                    if (newresult) {
-                        JVM_ArrayCopy(env,0, result,0, newresult,0, args.used);
-                        result = newresult;
-                    }
-                }
-            }
-        }
-
-        CFRelease(node);
-    }
-
- badparams:
-    if (path) CFRelease(path);
-    if (name) CFRelease(name);
-
-    return result;
-}
-
-
-JNIEXPORT jarray JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_getKeysForNode
-(JNIEnv *env, jobject klass, jobject jpath,
- jobject jname, jlong juser, jlong jhost)
-{
-    return getStringsForNode(env, klass, jpath, jname, juser, jhost, false);
-}
-
-JNIEXPORT jarray JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_getChildrenForNode
-(JNIEnv *env, jobject klass, jobject jpath,
- jobject jname, jlong juser, jlong jhost)
-{
-    return getStringsForNode(env, klass, jpath, jname, juser, jhost, true);
-}
-
-
-// Returns false on error instead of throwing.
-JNIEXPORT jboolean JNICALL
-Java_java_util_prefs_MacOSXPreferencesFile_synchronize
-(JNIEnv *env, jobject klass,
- jstring jname, jlong juser, jlong jhost)
-{
-    CFStringRef name = toCF(env, jname);
-    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
-    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
-    jboolean result = 0;
-
-    if (name) {
-        result = CFPreferencesSynchronize(name, user, host);
-        CFRelease(name);
-    }
-
-    return result;
-}
--- a/jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m	Tue Feb 11 12:40:16 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, 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.
- */
-
-#import <Cocoa/Cocoa.h>
-#import <JavaNativeFoundation/JavaNativeFoundation.h>
-#import <SystemConfiguration/SystemConfiguration.h>
-
-
-@interface JNFVectorCoercion : NSObject <JNFTypeCoercion> { }
-@end
-
-@implementation JNFVectorCoercion
-
-- (jobject) coerceNSObject:(id)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
-    static JNF_CLASS_CACHE(jc_Vector, "java/util/Vector");
-    static JNF_CTOR_CACHE(jm_Vector_ctor, jc_Vector, "(I)V");
-    static JNF_MEMBER_CACHE(jm_Vector_add, jc_Vector, "add", "(Ljava/lang/Object;)Z");
-
-    NSArray *nsArray = (NSArray *)obj;
-    jobject javaArray = JNFNewObject(env, jm_Vector_ctor, (jint)[nsArray count]);
-
-    for (id obj in nsArray) {
-        jobject jobj = [coercer coerceNSObject:obj withEnv:env usingCoercer:coercer];
-        JNFCallBooleanMethod(env, javaArray, jm_Vector_add, jobj);
-        if (jobj != NULL) (*env)->DeleteLocalRef(env, jobj);
-    }
-
-    return javaArray;
-}
-
-- (id) coerceJavaObject:(jobject)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
-    return nil;
-}
-
-@end
-
-
-@interface JNFHashtableCoercion : NSObject <JNFTypeCoercion> { }
-@end
-
-@implementation JNFHashtableCoercion
-
-- (jobject) coerceNSObject:(id)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
-    static JNF_CLASS_CACHE(jc_Hashtable, "java/util/Hashtable");
-    static JNF_CTOR_CACHE(jm_Hashtable_ctor, jc_Hashtable, "()V");
-    static JNF_MEMBER_CACHE(jm_Hashtable_put, jc_Hashtable, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
-
-    NSDictionary *nsDict = (NSDictionary *)obj;
-    NSEnumerator *keyEnum = [nsDict keyEnumerator];
-
-    jobject jHashTable = JNFNewObject(env, jm_Hashtable_ctor);
-
-    id key = nil;
-    while ((key = [keyEnum nextObject]) != nil) {
-        jobject jkey = [coercer coerceNSObject:key withEnv:env usingCoercer:coercer];
-
-        id value = [nsDict objectForKey:key];
-        jobject jvalue = [coercer coerceNSObject:value withEnv:env usingCoercer:coercer];
-
-        JNFCallObjectMethod(env, jHashTable, jm_Hashtable_put, jkey, jvalue);
-
-        if (jkey != NULL) (*env)->DeleteLocalRef(env, jkey);
-        if (jvalue != NULL) (*env)->DeleteLocalRef(env, jvalue);
-    }
-
-    return jHashTable;
-}
-
-- (id) coerceJavaObject:(jobject)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
-    return nil;
-}
-
-@end
-
-
-
-NSDictionary *realmConfigsForRealms(SCDynamicStoreRef store, NSArray *realms) {
-    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
-    for (NSString *realm in realms) {
-        CFTypeRef realmInfo = SCDynamicStoreCopyValue(store, (CFStringRef) [NSString stringWithFormat:@"Kerberos:%@", realm]);
-
-        if (CFGetTypeID(realmInfo) != CFDictionaryGetTypeID()) {
-            return nil;
-        }
-
-        [dict setObject:(NSArray *)realmInfo forKey:realm];
-        CFRelease(realmInfo);
-    }
-
-    return dict;
-}
-
-
-#define KERBEROS_DEFAULT_REALMS @"Kerberos-Default-Realms"
-#define KERBEROS_DEFAULT_REALM_MAPPINGS @"Kerberos-Domain-Realm-Mappings"
-
-void _SCDynamicStoreCallBack(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) {
-   NSArray *keys = (NSArray *)changedKeys;
-    if ([keys count] == 0) return;
-    if (![keys containsObject:KERBEROS_DEFAULT_REALMS] && ![keys containsObject:KERBEROS_DEFAULT_REALM_MAPPINGS]) return;
-
-    JNFPerformEnvBlock(JNFThreadDetachOnThreadDeath | JNFThreadSetSystemClassLoaderOnAttach | JNFThreadAttachAsDaemon, ^(JNIEnv *env) {
-        static JNF_CLASS_CACHE(jc_Config, "sun/security/krb5/Config");
-        static JNF_STATIC_MEMBER_CACHE(jm_Config_refresh, jc_Config, "refresh", "()V");
-        JNFCallStaticVoidMethod(env, jm_Config_refresh);
-    });
-}
-
-/*
- * Class:     sun_security_krb5_SCDynamicStoreConfig
- * Method:    installNotificationCallback
- */
-JNIEXPORT void JNICALL Java_sun_security_krb5_SCDynamicStoreConfig_installNotificationCallback(JNIEnv *env, jclass klass) {
-
-JNF_COCOA_ENTER(env);
-
-    SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java"), _SCDynamicStoreCallBack, NULL);
-    if (store == NULL) {
-        return;
-    }
-
-    NSArray *keys = [NSArray arrayWithObjects:KERBEROS_DEFAULT_REALMS, KERBEROS_DEFAULT_REALM_MAPPINGS, nil];
-    SCDynamicStoreSetNotificationKeys(store, (CFArrayRef) keys, NULL);
-
-    CFRunLoopSourceRef rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0);
-    if (rls != NULL) {
-        CFRunLoopAddSource(CFRunLoopGetMain(), rls, kCFRunLoopDefaultMode);
-        CFRelease(rls);
-    }
-
-    CFRelease(store);
-
-JNF_COCOA_EXIT(env);
-
-}
-
-/*
- * Class:     sun_security_krb5_SCDynamicStoreConfig
- * Method:    getKerberosConfig
- * Signature: ()Ljava/util/Hashtable;
- */
-JNIEXPORT jobject JNICALL Java_sun_security_krb5_SCDynamicStoreConfig_getKerberosConfig(JNIEnv *env, jclass klass) {
-    jobject jHashTable = NULL;
-
-JNF_COCOA_ENTER(env);
-
-    SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL);
-    if (store == NULL) {
-        return NULL;
-    }
-
-    CFTypeRef realms = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS);
-    if (realms == NULL || CFGetTypeID(realms) != CFArrayGetTypeID()) {
-        if (realms) CFRelease(realms);
-        CFRelease(store);
-        return NULL;
-    }
-
-    CFTypeRef realmMappings = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS);
-
-    if (realmMappings == NULL || CFGetTypeID(realmMappings) != CFArrayGetTypeID()) {
-        if (realmMappings) CFRelease(realmMappings);
-        CFRelease(realms);
-        CFRelease(store);
-        return NULL;
-    }
-
-    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
-    if (CFArrayGetCount(realms) > 0) {
-        NSDictionary *defaultRealmsDict = [NSDictionary dictionaryWithObject:[(NSArray *)realms objectAtIndex:0] forKey:@"default_realm"];
-        [dict setObject:defaultRealmsDict forKey:@"libdefaults"];
-
-        NSDictionary *realmConfigs = realmConfigsForRealms(store, (NSArray *)realms);
-        [dict setObject:realmConfigs forKey:@"realms"];
-    }
-    CFRelease(realms);
-    CFRelease(store);
-
-    if (CFArrayGetCount(realmMappings) > 0) {
-        [dict setObject:[(NSArray *)realmMappings objectAtIndex:0] forKey:@"domain_realm"];
-    }
-    CFRelease(realmMappings);
-
-
-    // create and load a coercer with all of the different coercions to convert each type of object
-    JNFTypeCoercer *coercer = [[[JNFTypeCoercer alloc] init] autorelease];
-    [JNFDefaultCoercions addStringCoercionTo:coercer];
-    [JNFDefaultCoercions addNumberCoercionTo:coercer];
-    [coercer addCoercion:[[[JNFHashtableCoercion alloc] init] autorelease] forNSClass:[NSDictionary class] javaClass:@"java/util/Map"];
-    [coercer addCoercion:[[[JNFVectorCoercion alloc] init] autorelease] forNSClass:[NSArray class] javaClass:@"java/util/List"];
-
-    // convert Cocoa graph to Java graph
-    jHashTable = [coercer coerceNSObject:dict withEnv:env];
-
-JNF_COCOA_EXIT(env);
-
-    return jHashTable;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/macosx/native/java/util/prefs/MacOSXPreferencesFile.m	Tue Feb 11 14:42:17 2014 -0800
@@ -0,0 +1,999 @@
+/*
+ * Copyright (c) 2011, 2012, 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.
+ */
+
+/*
+   Hierarchical storage layout:
+
+   <dict>
+     <key>/</key>
+     <dict>
+       <key>foo</key>
+       <string>/foo's value</string>
+       <key>foo/</key>
+       <dict>
+         <key>bar</key>
+         <string>/foo/bar's value</string>
+       </dict>
+     </dict>
+   </dict>
+
+   Java pref nodes are stored in several different files. Pref nodes
+   with at least three components in the node name (e.g. /com/MyCompany/MyApp/)
+   are stored in a CF prefs file with the first three components as the name.
+   This way, all preferences for MyApp end up in com.MyCompany.MyApp.plist .
+   Pref nodes with shorter names are stored in com.apple.java.util.prefs.plist
+
+   The filesystem is assumed to be case-insensitive (like HFS+).
+   Java pref node names are case-sensitive. If two pref node names differ
+   only in case, they may end up in the same pref file. This is ok
+   because the CF keys identifying the node span the entire absolute path
+   to the node and are case-sensitive.
+
+   Java node names may contain '.' . When mapping to the CF file name,
+   these dots are left as-is, even though '/' is mapped to '.' .
+   This is ok because the CF key contains the correct node name.
+*/
+
+
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include "jni_util.h"
+#include "jlong.h"
+#include "jvm.h"
+
+
+// Throw an OutOfMemoryError with the given message.
+static void throwOutOfMemoryError(JNIEnv *env, const char *msg)
+{
+    static jclass exceptionClass = NULL;
+    jclass c;
+
+    if (exceptionClass) {
+        c = exceptionClass;
+    } else {
+        c = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
+        if ((*env)->ExceptionOccurred(env)) return;
+        exceptionClass = (*env)->NewGlobalRef(env, c);
+    }
+
+    (*env)->ThrowNew(env, c, msg);
+}
+
+
+// throwIfNull macro
+// If var is NULL, throw an OutOfMemoryError and goto badvar.
+// var must be a variable. env must be the current JNIEnv.
+// fixme throw BackingStoreExceptions sometimes?
+#define throwIfNull(var, msg) \
+    do { \
+        if (var == NULL) { \
+            throwOutOfMemoryError(env, msg); \
+            goto bad##var; \
+        } \
+    } while (0)
+
+
+// Converts CFNumber, CFBoolean, CFString to CFString
+// returns NULL if value is of some other type
+// throws and returns NULL on memory error
+// result must be released (even if value was already a CFStringRef)
+// value must not be null
+static CFStringRef copyToCFString(JNIEnv *env, CFTypeRef value)
+{
+    CFStringRef result;
+    CFTypeID type;
+
+    type = CFGetTypeID(value);
+
+    if (type == CFStringGetTypeID()) {
+        result = (CFStringRef)CFRetain(value);
+    }
+    else if (type == CFBooleanGetTypeID()) {
+        // Java Preferences API expects "true" and "false" for boolean values.
+        result = CFStringCreateCopy(NULL, (value == kCFBooleanTrue) ? CFSTR("true") : CFSTR("false"));
+        throwIfNull(result, "copyToCFString failed");
+    }
+    else if (type == CFNumberGetTypeID()) {
+        CFNumberRef number = (CFNumberRef) value;
+        if (CFNumberIsFloatType(number)) {
+            double d;
+            CFNumberGetValue(number, kCFNumberDoubleType, &d);
+            result = CFStringCreateWithFormat(NULL, NULL, CFSTR("%g"), d);
+            throwIfNull(result, "copyToCFString failed");
+        }
+        else {
+            long l;
+            CFNumberGetValue(number, kCFNumberLongType, &l);
+            result = CFStringCreateWithFormat(NULL, NULL, CFSTR("%ld"), l);
+            throwIfNull(result, "copyToCFString failed");
+        }
+    }
+    else {
+        // unknown type - return NULL
+        result = NULL;
+    }
+
+ badresult:
+    return result;
+}
+
+
+// Create a Java string from the given CF string.
+// returns NULL if cfString is NULL
+// throws and returns NULL on memory error
+static jstring toJavaString(JNIEnv *env, CFStringRef cfString)
+{
+    if (cfString == NULL) {
+        return NULL;
+    } else {
+        jstring javaString = NULL;
+
+        CFIndex length = CFStringGetLength(cfString);
+        const UniChar *constchars = CFStringGetCharactersPtr(cfString);
+        if (constchars) {
+            javaString = (*env)->NewString(env, constchars, length);
+        } else {
+            UniChar *chars = malloc(length * sizeof(UniChar));
+            throwIfNull(chars, "toJavaString failed");
+            CFStringGetCharacters(cfString, CFRangeMake(0, length), chars);
+            javaString = (*env)->NewString(env, chars, length);
+            free(chars);
+        }
+    badchars:
+        return javaString;
+    }
+}
+
+
+
+// Create a CF string from the given Java string.
+// returns NULL if javaString is NULL
+// throws and returns NULL on memory error
+static CFStringRef toCF(JNIEnv *env, jstring javaString)
+{
+    if (javaString == NULL) {
+        return NULL;
+    } else {
+        CFStringRef result = NULL;
+        jsize length = (*env)->GetStringLength(env, javaString);
+        const jchar *chars = (*env)->GetStringChars(env, javaString, NULL);
+        throwIfNull(chars, "toCF failed");
+        result =
+            CFStringCreateWithCharacters(NULL, (const UniChar *)chars, length);
+        (*env)->ReleaseStringChars(env, javaString, chars);
+        throwIfNull(result, "toCF failed");
+    badchars:
+    badresult:
+        return result;
+    }
+}
+
+
+// Create an empty Java string array of the given size.
+// Throws and returns NULL on error.
+static jarray createJavaStringArray(JNIEnv *env, CFIndex count)
+{
+    static jclass stringClass = NULL;
+    jclass c;
+
+    if (stringClass) {
+        c = stringClass;
+    } else {
+        c = (*env)->FindClass(env, "java/lang/String");
+        if ((*env)->ExceptionOccurred(env)) return NULL;
+        stringClass = (*env)->NewGlobalRef(env, c);
+    }
+
+    return (*env)->NewObjectArray(env, count, c, NULL); // AWT_THREADING Safe (known object)
+}
+
+
+// Java accessors for CF constants.
+JNIEXPORT jlong JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_currentUser(JNIEnv *env,
+                                                       jobject klass)
+{
+    return ptr_to_jlong(kCFPreferencesCurrentUser);
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_anyUser(JNIEnv *env, jobject klass)
+{
+    return ptr_to_jlong(kCFPreferencesAnyUser);
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_currentHost(JNIEnv *env,
+                                                       jobject klass)
+{
+    return ptr_to_jlong(kCFPreferencesCurrentHost);
+}
+
+JNIEXPORT jlong JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_anyHost(JNIEnv *env, jobject klass)
+{
+    return ptr_to_jlong(kCFPreferencesAnyHost);
+}
+
+
+// Create an empty node.
+// Does not store the node in any prefs file.
+// returns NULL on memory error
+static CFMutableDictionaryRef createEmptyNode(void)
+{
+    return CFDictionaryCreateMutable(NULL, 0,
+                                     &kCFTypeDictionaryKeyCallBacks,
+                                     &kCFTypeDictionaryValueCallBacks);
+}
+
+
+// Create a string that consists of path minus its last component.
+// path must end with '/'
+// The result will end in '/' (unless path itself is '/')
+static CFStringRef copyParentOf(CFStringRef path)
+{
+    CFRange searchRange;
+    CFRange slashRange;
+    CFRange parentRange;
+    Boolean found;
+
+    searchRange = CFRangeMake(0, CFStringGetLength(path) - 1);
+    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange,
+                                    kCFCompareBackwards, &slashRange);
+    if (!found) return CFSTR("");
+    parentRange = CFRangeMake(0, slashRange.location + 1); // include '/'
+    return CFStringCreateWithSubstring(NULL, path, parentRange);
+}
+
+
+// Create a string that consists of path's last component.
+// path must end with '/'
+// The result will end in '/'.
+// The result will not start with '/' (unless path itself is '/')
+static CFStringRef copyChildOf(CFStringRef path)
+{
+    CFRange searchRange;
+    CFRange slashRange;
+    CFRange childRange;
+    Boolean found;
+    CFIndex length = CFStringGetLength(path);
+
+    searchRange = CFRangeMake(0, length - 1);
+    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange,
+                                    kCFCompareBackwards, &slashRange);
+    if (!found) return CFSTR("");
+    childRange = CFRangeMake(slashRange.location + 1,
+                             length - slashRange.location - 1); // skip '/'
+    return CFStringCreateWithSubstring(NULL, path, childRange);
+}
+
+
+// Return the first three components of path, with leading and trailing '/'.
+// If path does not have three components, return NULL.
+// path must begin and end in '/'
+static CFStringRef copyFirstThreeComponentsOf(CFStringRef path)
+{
+    CFRange searchRange;
+    CFRange slashRange;
+    CFRange prefixRange;
+    CFStringRef prefix;
+    Boolean found;
+    CFIndex length = CFStringGetLength(path);
+
+    searchRange = CFRangeMake(1, length - 1);  // skip leading '/'
+    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange, 0,
+                                    &slashRange);
+    if (!found) return NULL;  // no second slash!
+
+    searchRange = CFRangeMake(slashRange.location + 1,
+                              length - slashRange.location - 1);
+    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange, 0,
+                                    &slashRange);
+    if (!found) return NULL;  // no third slash!
+
+    searchRange = CFRangeMake(slashRange.location + 1,
+                              length - slashRange.location - 1);
+    found = CFStringFindWithOptions(path, CFSTR("/"), searchRange, 0,
+                                    &slashRange);
+    if (!found) return NULL;  // no fourth slash!
+
+    prefixRange = CFRangeMake(0, slashRange.location + 1); // keep last '/'
+    prefix = CFStringCreateWithSubstring(NULL, path, prefixRange);
+
+    return prefix;
+}
+
+
+// Copy the CFPreferences key and value at the base of path's tree.
+// path must end in '/'
+// topKey or topValue may be NULL
+// Returns NULL on error or if there is no tree for path in this file.
+static void copyTreeForPath(CFStringRef path, CFStringRef name,
+                            CFStringRef user, CFStringRef host,
+                            CFStringRef *topKey, CFDictionaryRef *topValue)
+{
+    CFStringRef key;
+    CFPropertyListRef value;
+
+    if (topKey) *topKey = NULL;
+    if (topValue) *topValue = NULL;
+
+    if (CFEqual(name, CFSTR("com.apple.java.util.prefs"))) {
+        // Top-level file. Only key "/" is an acceptable root.
+        key = (CFStringRef) CFRetain(CFSTR("/"));
+    } else {
+        // Second-level file. Key must be the first three components of path.
+        key = copyFirstThreeComponentsOf(path);
+        if (!key) return;
+    }
+
+    value = CFPreferencesCopyValue(key, name, user, host);
+    if (value) {
+        if (CFGetTypeID(value) == CFDictionaryGetTypeID()) {
+            // (key, value) is acceptable
+            if (topKey) *topKey = (CFStringRef)CFRetain(key);
+            if (topValue) *topValue = (CFDictionaryRef)CFRetain(value);
+        }
+        CFRelease(value);
+    }
+    CFRelease(key);
+}
+
+
+// Find the node for path in the given tree.
+// Returns NULL on error or if path doesn't have a node in this tree.
+// path must end in '/'
+static CFDictionaryRef copyNodeInTree(CFStringRef path, CFStringRef topKey,
+                                      CFDictionaryRef topValue)
+{
+    CFMutableStringRef p;
+    CFDictionaryRef result = NULL;
+
+    p = CFStringCreateMutableCopy(NULL, 0, path);
+    if (!p) return NULL;
+    CFStringDelete(p, CFRangeMake(0, CFStringGetLength(topKey)));
+    result = topValue;
+
+    while (CFStringGetLength(p) > 0) {
+        CFDictionaryRef child;
+        CFStringRef part = NULL;
+        CFRange slashRange = CFStringFind(p, CFSTR("/"), 0);
+        // guaranteed to succeed because path must end in '/'
+        CFRange partRange = CFRangeMake(0, slashRange.location + 1);
+        part = CFStringCreateWithSubstring(NULL, p, partRange);
+        if (!part) { result = NULL; break; }
+        CFStringDelete(p, partRange);
+
+        child = CFDictionaryGetValue(result, part);
+        CFRelease(part);
+        if (child  &&  CFGetTypeID(child) == CFDictionaryGetTypeID()) {
+            // continue search
+            result = child;
+        } else {
+            // didn't find target node
+            result = NULL;
+            break;
+        }
+    }
+
+    CFRelease(p);
+    if (result) return (CFDictionaryRef)CFRetain(result);
+    else return NULL;
+}
+
+
+// Return a retained copy of the node at path from the given file.
+// path must end in '/'
+// returns NULL if node doesn't exist.
+// returns NULL if the value for key "path" isn't a valid node.
+static CFDictionaryRef copyNodeIfPresent(CFStringRef path, CFStringRef name,
+                                         CFStringRef user, CFStringRef host)
+{
+    CFStringRef topKey;
+    CFDictionaryRef topValue;
+    CFDictionaryRef result;
+
+    copyTreeForPath(path, name, user, host, &topKey, &topValue);
+    if (!topKey) return NULL;
+
+    result = copyNodeInTree(path, topKey, topValue);
+
+    CFRelease(topKey);
+    if (topValue) CFRelease(topValue);
+    return result;
+}
+
+
+// Create a new tree that would store path in the given file.
+// Only the root of the tree is created, not all of the links leading to path.
+// returns NULL on error
+static void createTreeForPath(CFStringRef path, CFStringRef name,
+                              CFStringRef user, CFStringRef host,
+                              CFStringRef *outTopKey,
+                              CFMutableDictionaryRef *outTopValue)
+{
+    *outTopKey = NULL;
+    *outTopValue = NULL;
+
+    // if name is "com.apple.java.util.prefs" then create tree "/"
+    // else create tree "/foo/bar/baz/"
+    // "com.apple.java.util.prefs.plist" is also in MacOSXPreferences.java
+    if (CFEqual(name, CFSTR("com.apple.java.util.prefs"))) {
+        *outTopKey = CFSTR("/");
+        *outTopValue = createEmptyNode();
+    } else {
+        CFStringRef prefix = copyFirstThreeComponentsOf(path);
+        if (prefix) {
+            *outTopKey = prefix;
+            *outTopValue = createEmptyNode();
+        }
+    }
+}
+
+
+// Return a mutable copy of the tree containing path and the dict for
+//   path itself. *outTopKey and *outTopValue can be used to write the
+//   modified tree back to the prefs file.
+// *outTopKey and *outTopValue must be released iff the actual return
+//   value is not NULL.
+static CFMutableDictionaryRef
+copyMutableNode(CFStringRef path, CFStringRef name,
+                CFStringRef user, CFStringRef host,
+                CFStringRef *outTopKey,
+                CFMutableDictionaryRef *outTopValue)
+{
+    CFStringRef topKey = NULL;
+    CFDictionaryRef oldTopValue = NULL;
+    CFMutableDictionaryRef topValue;
+    CFMutableDictionaryRef result = NULL;
+    CFMutableStringRef p;
+
+    if (outTopKey) *outTopKey = NULL;
+    if (outTopValue) *outTopValue = NULL;
+
+    copyTreeForPath(path, name, user, host, &topKey, &oldTopValue);
+    if (!topKey) {
+        createTreeForPath(path, name, user, host, &topKey, &topValue);
+    } else {
+        topValue = (CFMutableDictionaryRef)
+            CFPropertyListCreateDeepCopy(NULL, (CFPropertyListRef)oldTopValue,
+                                         kCFPropertyListMutableContainers);
+    }
+    if (!topValue) goto badtopValue;
+
+    p = CFStringCreateMutableCopy(NULL, 0, path);
+    if (!p) goto badp;
+    CFStringDelete(p, CFRangeMake(0, CFStringGetLength(topKey)));
+    result = topValue;
+
+    while (CFStringGetLength(p) > 0) {
+        CFMutableDictionaryRef child;
+        CFStringRef part = NULL;
+        CFRange slashRange = CFStringFind(p, CFSTR("/"), 0);
+        // guaranteed to succeed because path must end in '/'
+        CFRange partRange = CFRangeMake(0, slashRange.location + 1);
+        part = CFStringCreateWithSubstring(NULL, p, partRange);
+        if (!part) { result = NULL; break; }
+        CFStringDelete(p, partRange);
+
+        child = (CFMutableDictionaryRef)CFDictionaryGetValue(result, part);
+        if (child  &&  CFGetTypeID(child) == CFDictionaryGetTypeID()) {
+            // continue search
+            result = child;
+        } else {
+            // didn't find target node - add it and continue
+            child = createEmptyNode();
+            if (!child) { CFRelease(part); result = NULL; break; }
+            CFDictionaryAddValue(result, part, child);
+            result = child;
+        }
+        CFRelease(part);
+    }
+
+    if (result) {
+        *outTopKey = (CFStringRef)CFRetain(topKey);
+        *outTopValue = (CFMutableDictionaryRef)CFRetain(topValue);
+        CFRetain(result);
+    }
+
+    CFRelease(p);
+ badp:
+    CFRelease(topValue);
+ badtopValue:
+    if (topKey) CFRelease(topKey);
+    if (oldTopValue) CFRelease(oldTopValue);
+    return result;
+}
+
+
+JNIEXPORT jboolean JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_addNode
+(JNIEnv *env, jobject klass, jobject jpath,
+ jobject jname, jlong juser, jlong jhost)
+{
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFDictionaryRef node = NULL;
+    jboolean neededNewNode = false;
+
+    if (!path  ||  !name) goto badparams;
+
+    node = copyNodeIfPresent(path, name, user, host);
+
+    if (node) {
+        neededNewNode = false;
+        CFRelease(node);
+    } else {
+        CFStringRef topKey = NULL;
+        CFMutableDictionaryRef topValue = NULL;
+
+        neededNewNode = true;
+
+        // copyMutableNode creates the node if necessary
+        node = copyMutableNode(path, name, user, host, &topKey, &topValue);
+        throwIfNull(node, "copyMutableNode failed");
+
+        CFPreferencesSetValue(topKey, topValue, name, user, host);
+
+        CFRelease(node);
+        if (topKey) CFRelease(topKey);
+        if (topValue) CFRelease(topValue);
+    }
+
+ badnode:
+ badparams:
+    if (path) CFRelease(path);
+    if (name) CFRelease(name);
+
+    return neededNewNode;
+}
+
+
+JNIEXPORT void JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_removeNode
+(JNIEnv *env, jobject klass, jobject jpath,
+ jobject jname, jlong juser, jlong jhost)
+{
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFStringRef parentName;
+    CFStringRef childName;
+    CFDictionaryRef constParent;
+
+    if (!path  ||  !name) goto badparams;
+
+    parentName = copyParentOf(path);
+    throwIfNull(parentName, "copyParentOf failed");
+    childName  = copyChildOf(path);
+    throwIfNull(childName, "copyChildOf failed");
+
+    // root node is not allowed to be removed, so parentName is never empty
+
+    constParent = copyNodeIfPresent(parentName, name, user, host);
+    if (constParent  &&  CFDictionaryContainsKey(constParent, childName)) {
+        CFStringRef topKey;
+        CFMutableDictionaryRef topValue;
+        CFMutableDictionaryRef parent;
+
+        parent = copyMutableNode(parentName, name, user, host,
+                                 &topKey, &topValue);
+        throwIfNull(parent, "copyMutableNode failed");
+
+        CFDictionaryRemoveValue(parent, childName);
+        CFPreferencesSetValue(topKey, topValue, name, user, host);
+
+        CFRelease(parent);
+        if (topKey) CFRelease(topKey);
+        if (topValue) CFRelease(topValue);
+    } else {
+        // might be trying to remove the root itself in a non-root file
+        CFStringRef topKey;
+        CFDictionaryRef topValue;
+        copyTreeForPath(path, name, user, host, &topKey, &topValue);
+        if (topKey) {
+            if (CFEqual(topKey, path)) {
+                CFPreferencesSetValue(topKey, NULL, name, user, host);
+            }
+
+            if (topKey) CFRelease(topKey);
+            if (topValue) CFRelease(topValue);
+        }
+    }
+
+
+ badparent:
+    if (constParent) CFRelease(constParent);
+    CFRelease(childName);
+ badchildName:
+    CFRelease(parentName);
+ badparentName:
+ badparams:
+    if (path) CFRelease(path);
+    if (name) CFRelease(name);
+}
+
+
+// child must end with '/'
+JNIEXPORT Boolean JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_addChildToNode
+(JNIEnv *env, jobject klass, jobject jpath, jobject jchild,
+ jobject jname, jlong juser, jlong jhost)
+{
+    // like addNode, but can put a three-level-deep dict into the root file
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef child = toCF(env, jchild);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFMutableDictionaryRef parent;
+    CFDictionaryRef node;
+    CFStringRef topKey;
+    CFMutableDictionaryRef topValue;
+    Boolean beforeAdd = false;
+
+    if (!path  ||  !child  ||  !name) goto badparams;
+
+    node = createEmptyNode();
+    throwIfNull(node, "createEmptyNode failed");
+
+    // copyMutableNode creates the node if necessary
+    parent = copyMutableNode(path, name, user, host, &topKey, &topValue);
+    throwIfNull(parent, "copyMutableNode failed");
+    beforeAdd = CFDictionaryContainsKey(parent, child);
+    CFDictionaryAddValue(parent, child, node);
+    if (!beforeAdd)
+        beforeAdd = CFDictionaryContainsKey(parent, child);
+    else
+        beforeAdd = false;
+    CFPreferencesSetValue(topKey, topValue, name, user, host);
+
+    CFRelease(parent);
+    if (topKey) CFRelease(topKey);
+    if (topValue) CFRelease(topValue);
+ badparent:
+    CFRelease(node);
+ badnode:
+ badparams:
+    if (path) CFRelease(path);
+    if (child) CFRelease(child);
+    if (name) CFRelease(name);
+    return beforeAdd;
+}
+
+
+JNIEXPORT void JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_removeChildFromNode
+(JNIEnv *env, jobject klass, jobject jpath, jobject jchild,
+ jobject jname, jlong juser, jlong jhost)
+{
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef child = toCF(env, jchild);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFDictionaryRef constParent;
+
+    if (!path  ||  !child  ||  !name) goto badparams;
+
+    constParent = copyNodeIfPresent(path, name, user, host);
+    if (constParent  &&  CFDictionaryContainsKey(constParent, child)) {
+        CFStringRef topKey;
+        CFMutableDictionaryRef topValue;
+        CFMutableDictionaryRef parent;
+
+        parent = copyMutableNode(path, name, user, host, &topKey, &topValue);
+        throwIfNull(parent, "copyMutableNode failed");
+
+        CFDictionaryRemoveValue(parent, child);
+        CFPreferencesSetValue(topKey, topValue, name, user, host);
+
+        CFRelease(parent);
+        if (topKey) CFRelease(topKey);
+        if (topValue) CFRelease(topValue);
+    }
+
+ badparent:
+    if (constParent) CFRelease(constParent);
+ badparams:
+    if (path) CFRelease(path);
+    if (child) CFRelease(child);
+    if (name) CFRelease(name);
+}
+
+
+
+JNIEXPORT void JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_addKeyToNode
+(JNIEnv *env, jobject klass, jobject jpath, jobject jkey, jobject jvalue,
+ jobject jname, jlong juser, jlong jhost)
+{
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef key = toCF(env, jkey);
+    CFStringRef value = toCF(env, jvalue);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFMutableDictionaryRef node = NULL;
+    CFStringRef topKey;
+    CFMutableDictionaryRef topValue;
+
+    if (!path  ||  !key  || !value  ||  !name) goto badparams;
+
+    // fixme optimization: check whether old value and new value are identical
+    node = copyMutableNode(path, name, user, host, &topKey, &topValue);
+    throwIfNull(node, "copyMutableNode failed");
+
+    CFDictionarySetValue(node, key, value);
+    CFPreferencesSetValue(topKey, topValue, name, user, host);
+
+    CFRelease(node);
+    if (topKey) CFRelease(topKey);
+    if (topValue) CFRelease(topValue);
+
+ badnode:
+ badparams:
+    if (path) CFRelease(path);
+    if (key) CFRelease(key);
+    if (value) CFRelease(value);
+    if (name) CFRelease(name);
+}
+
+
+JNIEXPORT void JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_removeKeyFromNode
+(JNIEnv *env, jobject klass, jobject jpath, jobject jkey,
+ jobject jname, jlong juser, jlong jhost)
+{
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef key = toCF(env, jkey);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFDictionaryRef constNode;
+
+    if (!path  ||  !key  ||  !name) goto badparams;
+
+    constNode = copyNodeIfPresent(path, name, user, host);
+    if (constNode  &&  CFDictionaryContainsKey(constNode, key)) {
+        CFStringRef topKey;
+        CFMutableDictionaryRef topValue;
+        CFMutableDictionaryRef node;
+
+        node = copyMutableNode(path, name, user, host, &topKey, &topValue);
+        throwIfNull(node, "copyMutableNode failed");
+
+        CFDictionaryRemoveValue(node, key);
+        CFPreferencesSetValue(topKey, topValue, name, user, host);
+
+        CFRelease(node);
+        if (topKey) CFRelease(topKey);
+        if (topValue) CFRelease(topValue);
+    }
+
+ badnode:
+    if (constNode) CFRelease(constNode);
+ badparams:
+    if (path) CFRelease(path);
+    if (key) CFRelease(key);
+    if (name) CFRelease(name);
+}
+
+
+// path must end in '/'
+JNIEXPORT jstring JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_getKeyFromNode
+(JNIEnv *env, jobject klass, jobject jpath, jobject jkey,
+ jobject jname, jlong juser, jlong jhost)
+{
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef key = toCF(env, jkey);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFPropertyListRef value;
+    CFDictionaryRef node;
+    jstring result = NULL;
+
+    if (!path  ||  !key  ||  !name) goto badparams;
+
+    node = copyNodeIfPresent(path, name, user, host);
+    if (node) {
+        value = (CFPropertyListRef)CFDictionaryGetValue(node, key);
+        if (!value) {
+            // key doesn't exist, or other error - no Java errors available
+            result = NULL;
+        } else {
+            CFStringRef cfString = copyToCFString(env, value);
+            if ((*env)->ExceptionOccurred(env)) {
+                // memory error in copyToCFString
+                result = NULL;
+            } else if (cfString == NULL) {
+                // bogus value type in prefs file - no Java errors available
+                result = NULL;
+            } else {
+                // good cfString
+                result = toJavaString(env, cfString);
+                CFRelease(cfString);
+            }
+        }
+        CFRelease(node);
+    }
+
+ badparams:
+    if (path) CFRelease(path);
+    if (key) CFRelease(key);
+    if (name) CFRelease(name);
+
+    return result;
+}
+
+
+typedef struct {
+    jarray result;
+    JNIEnv *env;
+    CFIndex used;
+    Boolean allowSlash;
+} BuildJavaArrayArgs;
+
+// CFDictionary applier function that builds an array of Java strings
+//   from a CFDictionary of CFPropertyListRefs.
+// If args->allowSlash, only strings that end in '/' are added to the array,
+//   with the slash removed. Otherwise, only strings that do not end in '/'
+//   are added.
+// args->result must already exist and be large enough to hold all
+//   strings from the dictionary.
+// After complete application, args->result may not be full because
+//   some of the dictionary values weren't convertible to string. In
+//   this case, args->used will be the count of used elements.
+static void BuildJavaArrayFn(const void *key, const void *value, void *context)
+{
+    BuildJavaArrayArgs *args = (BuildJavaArrayArgs *)context;
+    CFPropertyListRef propkey = (CFPropertyListRef)key;
+    CFStringRef cfString = NULL;
+    JNIEnv *env = args->env;
+
+    if ((*env)->ExceptionOccurred(env)) return; // already failed
+
+    cfString = copyToCFString(env, propkey);
+    if ((*env)->ExceptionOccurred(env)) {
+        // memory error in copyToCFString
+    } else if (!cfString) {
+        // bogus value type in prefs file - no Java errors available
+    } else if (args->allowSlash != CFStringHasSuffix(cfString, CFSTR("/"))) {
+        // wrong suffix - ignore
+    } else {
+        // good cfString
+        jstring javaString;
+        if (args->allowSlash) {
+            CFRange range = CFRangeMake(0, CFStringGetLength(cfString) - 1);
+            CFStringRef s = CFStringCreateWithSubstring(NULL, cfString, range);
+            CFRelease(cfString);
+            cfString = s;
+        }
+        if (CFStringGetLength(cfString) <= 0) goto bad; // ignore empty
+        javaString = toJavaString(env, cfString);
+        if ((*env)->ExceptionOccurred(env)) goto bad;
+        (*env)->SetObjectArrayElement(env, args->result,args->used,javaString);
+        if ((*env)->ExceptionOccurred(env)) goto bad;
+        args->used++;
+    }
+
+ bad:
+    if (cfString) CFRelease(cfString);
+}
+
+
+static jarray getStringsForNode(JNIEnv *env, jobject klass, jobject jpath,
+                                jobject jname, jlong juser, jlong jhost,
+                                Boolean allowSlash)
+{
+    CFStringRef path = toCF(env, jpath);
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    CFDictionaryRef node;
+    jarray result = NULL;
+    CFIndex count;
+
+    if (!path  ||  !name) goto badparams;
+
+    node = copyNodeIfPresent(path, name, user, host);
+    if (!node) {
+        result = createJavaStringArray(env, 0);
+    } else {
+        count = CFDictionaryGetCount(node);
+        result = createJavaStringArray(env, count);
+        if (result) {
+            BuildJavaArrayArgs args;
+            args.result = result;
+            args.env = env;
+            args.used = 0;
+            args.allowSlash = allowSlash;
+            CFDictionaryApplyFunction(node, BuildJavaArrayFn, &args);
+            if (!(*env)->ExceptionOccurred(env)) {
+                // array construction succeeded
+                if (args.used < count) {
+                    // finished array is smaller than expected.
+                    // Make a new array of precisely the right size.
+                    jarray newresult = createJavaStringArray(env, args.used);
+                    if (newresult) {
+                        JVM_ArrayCopy(env,0, result,0, newresult,0, args.used);
+                        result = newresult;
+                    }
+                }
+            }
+        }
+
+        CFRelease(node);
+    }
+
+ badparams:
+    if (path) CFRelease(path);
+    if (name) CFRelease(name);
+
+    return result;
+}
+
+
+JNIEXPORT jarray JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_getKeysForNode
+(JNIEnv *env, jobject klass, jobject jpath,
+ jobject jname, jlong juser, jlong jhost)
+{
+    return getStringsForNode(env, klass, jpath, jname, juser, jhost, false);
+}
+
+JNIEXPORT jarray JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_getChildrenForNode
+(JNIEnv *env, jobject klass, jobject jpath,
+ jobject jname, jlong juser, jlong jhost)
+{
+    return getStringsForNode(env, klass, jpath, jname, juser, jhost, true);
+}
+
+
+// Returns false on error instead of throwing.
+JNIEXPORT jboolean JNICALL
+Java_java_util_prefs_MacOSXPreferencesFile_synchronize
+(JNIEnv *env, jobject klass,
+ jstring jname, jlong juser, jlong jhost)
+{
+    CFStringRef name = toCF(env, jname);
+    CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
+    CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
+    jboolean result = 0;
+
+    if (name) {
+        result = CFPreferencesSynchronize(name, user, host);
+        CFRelease(name);
+    }
+
+    return result;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m	Tue Feb 11 14:42:17 2014 -0800
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2011, 2012, 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.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <JavaNativeFoundation/JavaNativeFoundation.h>
+#import <SystemConfiguration/SystemConfiguration.h>
+
+
+@interface JNFVectorCoercion : NSObject <JNFTypeCoercion> { }
+@end
+
+@implementation JNFVectorCoercion
+
+- (jobject) coerceNSObject:(id)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
+    static JNF_CLASS_CACHE(jc_Vector, "java/util/Vector");
+    static JNF_CTOR_CACHE(jm_Vector_ctor, jc_Vector, "(I)V");
+    static JNF_MEMBER_CACHE(jm_Vector_add, jc_Vector, "add", "(Ljava/lang/Object;)Z");
+
+    NSArray *nsArray = (NSArray *)obj;
+    jobject javaArray = JNFNewObject(env, jm_Vector_ctor, (jint)[nsArray count]);
+
+    for (id obj in nsArray) {
+        jobject jobj = [coercer coerceNSObject:obj withEnv:env usingCoercer:coercer];
+        JNFCallBooleanMethod(env, javaArray, jm_Vector_add, jobj);
+        if (jobj != NULL) (*env)->DeleteLocalRef(env, jobj);
+    }
+
+    return javaArray;
+}
+
+- (id) coerceJavaObject:(jobject)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
+    return nil;
+}
+
+@end
+
+
+@interface JNFHashtableCoercion : NSObject <JNFTypeCoercion> { }
+@end
+
+@implementation JNFHashtableCoercion
+
+- (jobject) coerceNSObject:(id)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
+    static JNF_CLASS_CACHE(jc_Hashtable, "java/util/Hashtable");
+    static JNF_CTOR_CACHE(jm_Hashtable_ctor, jc_Hashtable, "()V");
+    static JNF_MEMBER_CACHE(jm_Hashtable_put, jc_Hashtable, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
+
+    NSDictionary *nsDict = (NSDictionary *)obj;
+    NSEnumerator *keyEnum = [nsDict keyEnumerator];
+
+    jobject jHashTable = JNFNewObject(env, jm_Hashtable_ctor);
+
+    id key = nil;
+    while ((key = [keyEnum nextObject]) != nil) {
+        jobject jkey = [coercer coerceNSObject:key withEnv:env usingCoercer:coercer];
+
+        id value = [nsDict objectForKey:key];
+        jobject jvalue = [coercer coerceNSObject:value withEnv:env usingCoercer:coercer];
+
+        JNFCallObjectMethod(env, jHashTable, jm_Hashtable_put, jkey, jvalue);
+
+        if (jkey != NULL) (*env)->DeleteLocalRef(env, jkey);
+        if (jvalue != NULL) (*env)->DeleteLocalRef(env, jvalue);
+    }
+
+    return jHashTable;
+}
+
+- (id) coerceJavaObject:(jobject)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer {
+    return nil;
+}
+
+@end
+
+
+
+NSDictionary *realmConfigsForRealms(SCDynamicStoreRef store, NSArray *realms) {
+    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
+
+    for (NSString *realm in realms) {
+        CFTypeRef realmInfo = SCDynamicStoreCopyValue(store, (CFStringRef) [NSString stringWithFormat:@"Kerberos:%@", realm]);
+
+        if (CFGetTypeID(realmInfo) != CFDictionaryGetTypeID()) {
+            return nil;
+        }
+
+        [dict setObject:(NSArray *)realmInfo forKey:realm];
+        CFRelease(realmInfo);
+    }
+
+    return dict;
+}
+
+
+#define KERBEROS_DEFAULT_REALMS @"Kerberos-Default-Realms"
+#define KERBEROS_DEFAULT_REALM_MAPPINGS @"Kerberos-Domain-Realm-Mappings"
+
+void _SCDynamicStoreCallBack(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) {
+   NSArray *keys = (NSArray *)changedKeys;
+    if ([keys count] == 0) return;
+    if (![keys containsObject:KERBEROS_DEFAULT_REALMS] && ![keys containsObject:KERBEROS_DEFAULT_REALM_MAPPINGS]) return;
+
+    JNFPerformEnvBlock(JNFThreadDetachOnThreadDeath | JNFThreadSetSystemClassLoaderOnAttach | JNFThreadAttachAsDaemon, ^(JNIEnv *env) {
+        static JNF_CLASS_CACHE(jc_Config, "sun/security/krb5/Config");
+        static JNF_STATIC_MEMBER_CACHE(jm_Config_refresh, jc_Config, "refresh", "()V");
+        JNFCallStaticVoidMethod(env, jm_Config_refresh);
+    });
+}
+
+/*
+ * Class:     sun_security_krb5_SCDynamicStoreConfig
+ * Method:    installNotificationCallback
+ */
+JNIEXPORT void JNICALL Java_sun_security_krb5_SCDynamicStoreConfig_installNotificationCallback(JNIEnv *env, jclass klass) {
+
+JNF_COCOA_ENTER(env);
+
+    SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java"), _SCDynamicStoreCallBack, NULL);
+    if (store == NULL) {
+        return;
+    }
+
+    NSArray *keys = [NSArray arrayWithObjects:KERBEROS_DEFAULT_REALMS, KERBEROS_DEFAULT_REALM_MAPPINGS, nil];
+    SCDynamicStoreSetNotificationKeys(store, (CFArrayRef) keys, NULL);
+
+    CFRunLoopSourceRef rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0);
+    if (rls != NULL) {
+        CFRunLoopAddSource(CFRunLoopGetMain(), rls, kCFRunLoopDefaultMode);
+        CFRelease(rls);
+    }
+
+    CFRelease(store);
+
+JNF_COCOA_EXIT(env);
+
+}
+
+/*
+ * Class:     sun_security_krb5_SCDynamicStoreConfig
+ * Method:    getKerberosConfig
+ * Signature: ()Ljava/util/Hashtable;
+ */
+JNIEXPORT jobject JNICALL Java_sun_security_krb5_SCDynamicStoreConfig_getKerberosConfig(JNIEnv *env, jclass klass) {
+    jobject jHashTable = NULL;
+
+JNF_COCOA_ENTER(env);
+
+    SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL);
+    if (store == NULL) {
+        return NULL;
+    }
+
+    CFTypeRef realms = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS);
+    if (realms == NULL || CFGetTypeID(realms) != CFArrayGetTypeID()) {
+        if (realms) CFRelease(realms);
+        CFRelease(store);
+        return NULL;
+    }
+
+    CFTypeRef realmMappings = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS);
+
+    if (realmMappings == NULL || CFGetTypeID(realmMappings) != CFArrayGetTypeID()) {
+        if (realmMappings) CFRelease(realmMappings);
+        CFRelease(realms);
+        CFRelease(store);
+        return NULL;
+    }
+
+    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
+
+    if (CFArrayGetCount(realms) > 0) {
+        NSDictionary *defaultRealmsDict = [NSDictionary dictionaryWithObject:[(NSArray *)realms objectAtIndex:0] forKey:@"default_realm"];
+        [dict setObject:defaultRealmsDict forKey:@"libdefaults"];
+
+        NSDictionary *realmConfigs = realmConfigsForRealms(store, (NSArray *)realms);
+        [dict setObject:realmConfigs forKey:@"realms"];
+    }
+    CFRelease(realms);
+    CFRelease(store);
+
+    if (CFArrayGetCount(realmMappings) > 0) {
+        [dict setObject:[(NSArray *)realmMappings objectAtIndex:0] forKey:@"domain_realm"];
+    }
+    CFRelease(realmMappings);
+
+
+    // create and load a coercer with all of the different coercions to convert each type of object
+    JNFTypeCoercer *coercer = [[[JNFTypeCoercer alloc] init] autorelease];
+    [JNFDefaultCoercions addStringCoercionTo:coercer];
+    [JNFDefaultCoercions addNumberCoercionTo:coercer];
+    [coercer addCoercion:[[[JNFHashtableCoercion alloc] init] autorelease] forNSClass:[NSDictionary class] javaClass:@"java/util/Map"];
+    [coercer addCoercion:[[[JNFVectorCoercion alloc] init] autorelease] forNSClass:[NSArray class] javaClass:@"java/util/List"];
+
+    // convert Cocoa graph to Java graph
+    jHashTable = [coercer coerceNSObject:dict withEnv:env];
+
+JNF_COCOA_EXIT(env);
+
+    return jHashTable;
+}
--- a/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Tue Feb 11 14:42:17 2014 -0800
@@ -24,6 +24,7 @@
  */
 
 #include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h"
+#include "jni_util.h"
 #include <CoreFoundation/CoreFoundation.h>
 #include <stdio.h>
 
@@ -63,6 +64,10 @@
     localeString = getMacOSXLocale(posixCat);
     if (localeString == NULL) {
         localeString = getPosixLocale(posixCat);
+        if (localeString == NULL) {
+            JNU_ThrowOutOfMemoryError(env, NULL);
+            return NULL;
+        }
     }
     ret = (*env)->NewStringUTF(env, localeString);
     free(localeString);
@@ -127,6 +132,7 @@
 JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings
   (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) {
     CFLocaleRef cflocale = CFLocaleCopyCurrent();
+    jstring tmp_string;
     if (cflocale != NULL) {
         CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
                                                   cflocale,
@@ -138,13 +144,18 @@
             if (amStr != NULL) {
                 CFStringGetCString(amStr, buf, BUFLEN, kCFStringEncodingUTF8);
                 CFRelease(amStr);
-                (*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewStringUTF(env, buf));
+                tmp_string = (*env)->NewStringUTF(env, buf);
+                if (tmp_string != NULL) {
+                    (*env)->SetObjectArrayElement(env, ampms, 0, tmp_string);
+                }
             }
-            CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol);
-            if (pmStr != NULL) {
-                CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8);
-                CFRelease(pmStr);
-                (*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf));
+            if (!(*env)->ExceptionCheck(env)){
+                CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol);
+                if (pmStr != NULL) {
+                    CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8);
+                    CFRelease(pmStr);
+                    (*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf));
+                }
             }
             CFRelease(df);
         }
@@ -647,10 +658,16 @@
 
 static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count) {
     char buf[BUFLEN];
+    jstring tmp_string;
 
     for (; count > 0; sindex++, dindex++, count--) {
         CFStringGetCString(CFArrayGetValueAtIndex(cfarray, sindex), buf, BUFLEN, kCFStringEncodingUTF8);
-        (*env)->SetObjectArrayElement(env, jarray, dindex, (*env)->NewStringUTF(env, buf));
+        tmp_string = (*env)->NewStringUTF(env, buf);
+        if (tmp_string != NULL) {
+            (*env)->SetObjectArrayElement(env, jarray, dindex, tmp_string);
+        } else {
+            break;
+        }
     }
 }
 
--- a/jdk/src/share/back/ArrayTypeImpl.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/back/ArrayTypeImpl.c	Tue Feb 11 14:42:17 2014 -0800
@@ -112,7 +112,7 @@
     WITH_LOCAL_REFS(env, 1) {
 
         jarray array;
-        jclass componentClass;
+        jclass componentClass = NULL;
         jdwpError serror;
 
         serror = getComponentClass(env, arrayClass,
--- a/jdk/src/share/back/error_messages.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/back/error_messages.c	Tue Feb 11 14:42:17 2014 -0800
@@ -140,7 +140,7 @@
 const char *
 jvmtiErrorText(jvmtiError error)
 {
-    switch (error) {
+    switch ((int)error) {
         CASE_RETURN_TEXT(JVMTI_ERROR_NONE)
         CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD)
         CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD_GROUP)
--- a/jdk/src/share/back/util.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/back/util.c	Tue Feb 11 14:42:17 2014 -0800
@@ -2122,7 +2122,7 @@
 jdwpError
 map2jdwpError(jvmtiError error)
 {
-    switch ( error ) {
+    switch ( (int)error ) {
         case JVMTI_ERROR_NONE:
             return JDWP_ERROR(NONE);
         case AGENT_ERROR_INVALID_THREAD:
--- a/jdk/src/share/classes/java/awt/color/CMMException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/color/CMMException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -47,6 +47,7 @@
  */
 
 public class CMMException extends java.lang.RuntimeException {
+    private static final long serialVersionUID = 5775558044142994965L;
 
     /**
      *  Constructs a CMMException with the specified detail message.
--- a/jdk/src/share/classes/java/awt/color/ProfileDataException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/color/ProfileDataException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -31,6 +31,7 @@
  */
 
 public class ProfileDataException extends java.lang.RuntimeException {
+    private static final long serialVersionUID = 7286140888240322498L;
 
     /**
      *  Constructs a ProfileDataException with the specified detail message.
--- a/jdk/src/share/classes/java/awt/datatransfer/FlavorEvent.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/datatransfer/FlavorEvent.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -38,6 +38,8 @@
  * @since 1.5
  */
 public class FlavorEvent extends EventObject {
+    private static final long serialVersionUID = -5842664112252414548L;
+
     /**
      * Constructs a <code>FlavorEvent</code> object.
      *
--- a/jdk/src/share/classes/java/awt/geom/IllegalPathStateException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/geom/IllegalPathStateException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -35,6 +35,8 @@
  */
 
 public class IllegalPathStateException extends RuntimeException {
+    private static final long serialVersionUID = -5158084205220481094L;
+
     /**
      * Constructs an <code>IllegalPathStateException</code> with no
      * detail message.
--- a/jdk/src/share/classes/java/awt/geom/NoninvertibleTransformException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/geom/NoninvertibleTransformException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -33,6 +33,8 @@
  */
 
 public class NoninvertibleTransformException extends java.lang.Exception {
+    private static final long serialVersionUID = 6137225240503990466L;
+
     /**
      * Constructs an instance of
      * <code>NoninvertibleTransformException</code>
--- a/jdk/src/share/classes/java/awt/image/ImagingOpException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/image/ImagingOpException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -32,6 +32,7 @@
  * process the image.
  */
 public class ImagingOpException extends java.lang.RuntimeException {
+    private static final long serialVersionUID = 8026288481846276658L;
 
     /**
      * Constructs an <code>ImagingOpException</code> object with the
--- a/jdk/src/share/classes/java/awt/image/RasterFormatException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/image/RasterFormatException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -31,6 +31,7 @@
  * invalid layout information in the {@link Raster}.
  */
 public class RasterFormatException extends java.lang.RuntimeException {
+    private static final long serialVersionUID = 96598996116164315L;
 
     /**
      * Constructs a new <code>RasterFormatException</code> with the
--- a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -93,6 +93,8 @@
  * </pre>
  * */
 public class ParameterBlock implements Cloneable, Serializable {
+    private static final long serialVersionUID = -7577115551785240750L;
+
     /** A Vector of sources, stored as arbitrary Objects. */
     protected Vector<Object> sources = new Vector<Object>();
 
--- a/jdk/src/share/classes/java/awt/print/PrinterAbortException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/print/PrinterAbortException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -33,6 +33,7 @@
  */
 
 public class PrinterAbortException extends PrinterException {
+    private static final long serialVersionUID = 4725169026278854136L;
 
     /**
      * Constructs a new <code>PrinterAbortException</code> with no
--- a/jdk/src/share/classes/java/awt/print/PrinterException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/awt/print/PrinterException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -32,6 +32,7 @@
  */
 
 public class PrinterException extends Exception {
+    private static final long serialVersionUID = -3757589981158265819L;
 
     /**
      * Constructs a new <code>PrinterException</code> object
--- a/jdk/src/share/classes/java/io/FileInputStream.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/FileInputStream.java	Tue Feb 11 14:42:17 2014 -0800
@@ -51,6 +51,12 @@
     /* File Descriptor - handle to the open file */
     private final FileDescriptor fd;
 
+    /**
+     * The path of the referenced file
+     * (null if the stream is created with a file descriptor)
+     */
+    private final String path;
+
     private FileChannel channel = null;
 
     private final Object closeLock = new Object();
@@ -128,6 +134,7 @@
         }
         fd = new FileDescriptor();
         fd.attach(this);
+        path = name;
         open(name);
     }
 
@@ -164,6 +171,7 @@
             security.checkRead(fdObj);
         }
         fd = fdObj;
+        path = null;
 
         /*
          * FileDescriptor is being shared by streams.
@@ -186,7 +194,11 @@
      *             file is reached.
      * @exception  IOException  if an I/O error occurs.
      */
-    public native int read() throws IOException;
+    public int read() throws IOException {
+        return read0();
+    }
+
+    private native int read0() throws IOException;
 
     /**
      * Reads a subarray as a sequence of bytes.
@@ -345,7 +357,7 @@
     public FileChannel getChannel() {
         synchronized (this) {
             if (channel == null) {
-                channel = FileChannelImpl.open(fd, true, false, this);
+                channel = FileChannelImpl.open(fd, path, true, false, this);
             }
             return channel;
         }
--- a/jdk/src/share/classes/java/io/FileOutputStream.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/FileOutputStream.java	Tue Feb 11 14:42:17 2014 -0800
@@ -67,6 +67,12 @@
      */
     private FileChannel channel;
 
+    /**
+     * The path of the referenced file
+     * (null if the stream is created with a file descriptor)
+     */
+    private final String path;
+
     private final Object closeLock = new Object();
     private volatile boolean closed = false;
 
@@ -202,6 +208,7 @@
         this.fd = new FileDescriptor();
         fd.attach(this);
         this.append = append;
+        this.path = name;
 
         open(name, append);
     }
@@ -239,6 +246,7 @@
         }
         this.fd = fdObj;
         this.append = false;
+        this.path = null;
 
         fd.attach(this);
     }
@@ -376,7 +384,7 @@
     public FileChannel getChannel() {
         synchronized (this) {
             if (channel == null) {
-                channel = FileChannelImpl.open(fd, false, true, append, this);
+                channel = FileChannelImpl.open(fd, path, false, true, append, this);
             }
             return channel;
         }
--- a/jdk/src/share/classes/java/io/ObjectInputStream.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/ObjectInputStream.java	Tue Feb 11 14:42:17 2014 -0800
@@ -39,7 +39,6 @@
 import java.util.HashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicBoolean;
 import static java.io.ObjectStreamClass.processQueue;
 import sun.reflect.misc.ReflectUtil;
 
@@ -534,7 +533,7 @@
         if (ctx == null) {
             throw new NotActiveException("not in call to readObject");
         }
-        Object curObj = ctx.getObj();
+        ctx.checkAndSetUsed();
         ObjectStreamClass curDesc = ctx.getDesc();
         bin.setBlockDataMode(false);
         GetFieldImpl getField = new GetFieldImpl(curDesc);
@@ -1597,7 +1596,7 @@
         int descHandle = handles.assign(unshared ? unsharedMarker : desc);
         passHandle = NULL_HANDLE;
 
-        ObjectStreamClass readDesc = null;
+        ObjectStreamClass readDesc;
         try {
             readDesc = readClassDescriptor();
         } catch (ClassNotFoundException ex) {
@@ -1976,29 +1975,34 @@
         }
 
         int primDataSize = desc.getPrimDataSize();
-        if (primVals == null || primVals.length < primDataSize) {
-            primVals = new byte[primDataSize];
-        }
-        bin.readFully(primVals, 0, primDataSize, false);
-        if (obj != null) {
-            desc.setPrimFieldValues(obj, primVals);
-        }
-
-        int objHandle = passHandle;
-        ObjectStreamField[] fields = desc.getFields(false);
-        Object[] objVals = new Object[desc.getNumObjFields()];
-        int numPrimFields = fields.length - objVals.length;
-        for (int i = 0; i < objVals.length; i++) {
-            ObjectStreamField f = fields[numPrimFields + i];
-            objVals[i] = readObject0(f.isUnshared());
-            if (f.getField() != null) {
-                handles.markDependency(objHandle, passHandle);
+        if (primDataSize > 0) {
+            if (primVals == null || primVals.length < primDataSize) {
+                primVals = new byte[primDataSize];
+            }
+            bin.readFully(primVals, 0, primDataSize, false);
+            if (obj != null) {
+                desc.setPrimFieldValues(obj, primVals);
             }
         }
-        if (obj != null) {
-            desc.setObjFieldValues(obj, objVals);
+
+        int numObjFields = desc.getNumObjFields();
+        if (numObjFields > 0) {
+            int objHandle = passHandle;
+            ObjectStreamField[] fields = desc.getFields(false);
+            Object[] objVals = new Object[numObjFields];
+            int numPrimFields = fields.length - objVals.length;
+            for (int i = 0; i < objVals.length; i++) {
+                ObjectStreamField f = fields[numPrimFields + i];
+                objVals[i] = readObject0(f.isUnshared());
+                if (f.getField() != null) {
+                    handles.markDependency(objHandle, passHandle);
+                }
+            }
+            if (obj != null) {
+                desc.setObjFieldValues(obj, objVals);
+            }
+            passHandle = objHandle;
         }
-        passHandle = objHandle;
     }
 
     /**
--- a/jdk/src/share/classes/java/io/ObjectOutputStream.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java	Tue Feb 11 14:42:17 2014 -0800
@@ -35,7 +35,6 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import static java.io.ObjectStreamClass.processQueue;
-import java.io.SerialCallbackContext;
 import sun.reflect.misc.ReflectUtil;
 
 /**
@@ -458,7 +457,7 @@
             if (ctx == null) {
                 throw new NotActiveException("not in call to writeObject");
             }
-            Object curObj = ctx.getObj();
+            ctx.checkAndSetUsed();
             ObjectStreamClass curDesc = ctx.getDesc();
             curPut = new PutFieldImpl(curDesc);
         }
@@ -1527,29 +1526,34 @@
         desc.checkDefaultSerialize();
 
         int primDataSize = desc.getPrimDataSize();
-        if (primVals == null || primVals.length < primDataSize) {
-            primVals = new byte[primDataSize];
+        if (primDataSize > 0) {
+            if (primVals == null || primVals.length < primDataSize) {
+                primVals = new byte[primDataSize];
+            }
+            desc.getPrimFieldValues(obj, primVals);
+            bout.write(primVals, 0, primDataSize, false);
         }
-        desc.getPrimFieldValues(obj, primVals);
-        bout.write(primVals, 0, primDataSize, false);
 
-        ObjectStreamField[] fields = desc.getFields(false);
-        Object[] objVals = new Object[desc.getNumObjFields()];
-        int numPrimFields = fields.length - objVals.length;
-        desc.getObjFieldValues(obj, objVals);
-        for (int i = 0; i < objVals.length; i++) {
-            if (extendedDebugInfo) {
-                debugInfoStack.push(
-                    "field (class \"" + desc.getName() + "\", name: \"" +
-                    fields[numPrimFields + i].getName() + "\", type: \"" +
-                    fields[numPrimFields + i].getType() + "\")");
-            }
-            try {
-                writeObject0(objVals[i],
-                             fields[numPrimFields + i].isUnshared());
-            } finally {
+        int numObjFields = desc.getNumObjFields();
+        if (numObjFields > 0) {
+            ObjectStreamField[] fields = desc.getFields(false);
+            Object[] objVals = new Object[numObjFields];
+            int numPrimFields = fields.length - objVals.length;
+            desc.getObjFieldValues(obj, objVals);
+            for (int i = 0; i < objVals.length; i++) {
                 if (extendedDebugInfo) {
-                    debugInfoStack.pop();
+                    debugInfoStack.push(
+                        "field (class \"" + desc.getName() + "\", name: \"" +
+                        fields[numPrimFields + i].getName() + "\", type: \"" +
+                        fields[numPrimFields + i].getType() + "\")");
+                }
+                try {
+                    writeObject0(objVals[i],
+                                 fields[numPrimFields + i].isUnshared());
+                } finally {
+                    if (extendedDebugInfo) {
+                        debugInfoStack.pop();
+                    }
                 }
             }
         }
@@ -2464,7 +2468,9 @@
             StringBuilder buffer = new StringBuilder();
             if (!stack.isEmpty()) {
                 for(int i = stack.size(); i > 0; i-- ) {
-                    buffer.append(stack.get(i-1) + ((i != 1) ? "\n" : ""));
+                    buffer.append(stack.get(i - 1));
+                    if (i != 1)
+                        buffer.append('\n');
                 }
             }
             return buffer.toString();
--- a/jdk/src/share/classes/java/io/ObjectStreamClass.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1472,42 +1472,55 @@
     }
 
     /**
+     * Returns JVM type signature for given primitive.
+     */
+    private static String getPrimitiveSignature(Class<?> cl) {
+        if (cl == Integer.TYPE)
+            return "I";
+        else if (cl == Byte.TYPE)
+            return "B";
+        else if (cl == Long.TYPE)
+            return "J";
+        else if (cl == Float.TYPE)
+            return "F";
+        else if (cl == Double.TYPE)
+            return "D";
+        else if (cl == Short.TYPE)
+            return "S";
+        else if (cl == Character.TYPE)
+            return "C";
+        else if (cl == Boolean.TYPE)
+            return "Z";
+        else if (cl == Void.TYPE)
+            return "V";
+        else
+            throw new InternalError();
+    }
+
+    /**
      * Returns JVM type signature for given class.
      */
-    private static String getClassSignature(Class<?> cl) {
-        StringBuilder sbuf = new StringBuilder();
-        while (cl.isArray()) {
-            sbuf.append('[');
-            cl = cl.getComponentType();
-        }
-        if (cl.isPrimitive()) {
-            if (cl == Integer.TYPE) {
-                sbuf.append('I');
-            } else if (cl == Byte.TYPE) {
-                sbuf.append('B');
-            } else if (cl == Long.TYPE) {
-                sbuf.append('J');
-            } else if (cl == Float.TYPE) {
-                sbuf.append('F');
-            } else if (cl == Double.TYPE) {
-                sbuf.append('D');
-            } else if (cl == Short.TYPE) {
-                sbuf.append('S');
-            } else if (cl == Character.TYPE) {
-                sbuf.append('C');
-            } else if (cl == Boolean.TYPE) {
-                sbuf.append('Z');
-            } else if (cl == Void.TYPE) {
-                sbuf.append('V');
-            } else {
-                throw new InternalError();
-            }
-        } else {
-            sbuf.append('L' + cl.getName().replace('.', '/') + ';');
-        }
-        return sbuf.toString();
+    static String getClassSignature(Class<?> cl) {
+        if (cl.isPrimitive())
+            return getPrimitiveSignature(cl);
+        else
+            return appendClassSignature(new StringBuilder(), cl).toString();
     }
 
+    private static StringBuilder appendClassSignature(StringBuilder sbuf, Class<?> cl) {
+       while (cl.isArray()) {
+           sbuf.append('[');
+           cl = cl.getComponentType();
+       }
+
+       if (cl.isPrimitive())
+           sbuf.append(getPrimitiveSignature(cl));
+       else
+           sbuf.append('L').append(cl.getName().replace('.', '/')).append(';');
+
+       return sbuf;
+   }
+
     /**
      * Returns JVM type signature for given list of parameters and return type.
      */
@@ -1517,10 +1530,10 @@
         StringBuilder sbuf = new StringBuilder();
         sbuf.append('(');
         for (int i = 0; i < paramTypes.length; i++) {
-            sbuf.append(getClassSignature(paramTypes[i]));
+            appendClassSignature(sbuf, paramTypes[i]);
         }
         sbuf.append(')');
-        sbuf.append(getClassSignature(retType));
+        appendClassSignature(sbuf, retType);
         return sbuf.toString();
     }
 
--- a/jdk/src/share/classes/java/io/ObjectStreamField.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/ObjectStreamField.java	Tue Feb 11 14:42:17 2014 -0800
@@ -91,7 +91,7 @@
         this.name = name;
         this.type = type;
         this.unshared = unshared;
-        signature = getClassSignature(type).intern();
+        signature = ObjectStreamClass.getClassSignature(type).intern();
         field = null;
     }
 
@@ -137,7 +137,7 @@
         name = field.getName();
         Class<?> ftype = field.getType();
         type = (showType || ftype.isPrimitive()) ? ftype : Object.class;
-        signature = getClassSignature(ftype).intern();
+        signature = ObjectStreamClass.getClassSignature(ftype).intern();
     }
 
     /**
@@ -286,41 +286,4 @@
     String getSignature() {
         return signature;
     }
-
-    /**
-     * Returns JVM type signature for given class.
-     */
-    private static String getClassSignature(Class<?> cl) {
-        StringBuilder sbuf = new StringBuilder();
-        while (cl.isArray()) {
-            sbuf.append('[');
-            cl = cl.getComponentType();
-        }
-        if (cl.isPrimitive()) {
-            if (cl == Integer.TYPE) {
-                sbuf.append('I');
-            } else if (cl == Byte.TYPE) {
-                sbuf.append('B');
-            } else if (cl == Long.TYPE) {
-                sbuf.append('J');
-            } else if (cl == Float.TYPE) {
-                sbuf.append('F');
-            } else if (cl == Double.TYPE) {
-                sbuf.append('D');
-            } else if (cl == Short.TYPE) {
-                sbuf.append('S');
-            } else if (cl == Character.TYPE) {
-                sbuf.append('C');
-            } else if (cl == Boolean.TYPE) {
-                sbuf.append('Z');
-            } else if (cl == Void.TYPE) {
-                sbuf.append('V');
-            } else {
-                throw new InternalError();
-            }
-        } else {
-            sbuf.append('L' + cl.getName().replace('.', '/') + ';');
-        }
-        return sbuf.toString();
-    }
 }
--- a/jdk/src/share/classes/java/io/RandomAccessFile.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/RandomAccessFile.java	Tue Feb 11 14:42:17 2014 -0800
@@ -62,6 +62,12 @@
     private FileChannel channel = null;
     private boolean rw;
 
+    /**
+     * The path of the referenced file
+     * (null if the stream is created with a file descriptor)
+     */
+    private final String path;
+
     private Object closeLock = new Object();
     private volatile boolean closed = false;
 
@@ -233,6 +239,7 @@
         }
         fd = new FileDescriptor();
         fd.attach(this);
+        path = name;
         open(name, imode);
     }
 
@@ -272,7 +279,7 @@
     public final FileChannel getChannel() {
         synchronized (this) {
             if (channel == null) {
-                channel = FileChannelImpl.open(fd, true, rw, this);
+                channel = FileChannelImpl.open(fd, path, true, rw, this);
             }
             return channel;
         }
@@ -309,7 +316,11 @@
      * @exception  IOException  if an I/O error occurs. Not thrown if
      *                          end-of-file has been reached.
      */
-    public native int read() throws IOException;
+    public int read() throws IOException {
+        return read0();
+    }
+
+    private native int read0() throws IOException;
 
     /**
      * Reads a sub array as a sequence of bytes.
@@ -457,7 +468,11 @@
      * @param      b   the {@code byte} to be written.
      * @exception  IOException  if an I/O error occurs.
      */
-    public native void write(int b) throws IOException;
+    public void write(int b) throws IOException {
+        write0(b);
+    }
+
+    private native void write0(int b) throws IOException;
 
     /**
      * Writes a sub array as a sequence of bytes.
--- a/jdk/src/share/classes/java/io/SerialCallbackContext.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/io/SerialCallbackContext.java	Tue Feb 11 14:42:17 2014 -0800
@@ -60,7 +60,7 @@
         return desc;
     }
 
-    private void checkAndSetUsed() throws NotActiveException {
+    public void checkAndSetUsed() throws NotActiveException {
         if (thread != Thread.currentThread()) {
              throw new NotActiveException(
               "not in readObject invocation or fields already read");
--- a/jdk/src/share/classes/java/lang/String.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/lang/String.java	Tue Feb 11 14:42:17 2014 -0800
@@ -2549,87 +2549,88 @@
         if (locale == null) {
             throw new NullPointerException();
         }
-
-        int firstUpper;
+        int first;
+        boolean hasSurr = false;
         final int len = value.length;
 
-        /* Now check if there are any characters that need to be changed. */
-        scan: {
-            for (firstUpper = 0 ; firstUpper < len; ) {
-                char c = value[firstUpper];
-                if ((c >= Character.MIN_HIGH_SURROGATE)
-                        && (c <= Character.MAX_HIGH_SURROGATE)) {
-                    int supplChar = codePointAt(firstUpper);
-                    if (supplChar != Character.toLowerCase(supplChar)) {
-                        break scan;
-                    }
-                    firstUpper += Character.charCount(supplChar);
-                } else {
-                    if (c != Character.toLowerCase(c)) {
-                        break scan;
-                    }
-                    firstUpper++;
-                }
+        // Now check if there are any characters that need to be changed, or are surrogate
+        for (first = 0 ; first < len; first++) {
+            int cp = (int)value[first];
+            if (Character.isSurrogate((char)cp)) {
+                hasSurr = true;
+                break;
+            }
+            if (cp != Character.toLowerCase(cp)) {  // no need to check Character.ERROR
+                break;
             }
+        }
+        if (first == len)
             return this;
+        char[] result = new char[len];
+        System.arraycopy(value, 0, result, 0, first);  // Just copy the first few
+                                                       // lowerCase characters.
+        String lang = locale.getLanguage();
+        if (lang == "tr" || lang == "az" || lang == "lt") {
+            return toLowerCaseEx(result, first, locale, true);
+        }
+        if (hasSurr) {
+            return toLowerCaseEx(result, first, locale, false);
         }
-
-        char[] result = new char[len];
-        int resultOffset = 0;  /* result may grow, so i+resultOffset
-                                * is the write location in result */
-
-        /* Just copy the first few lowerCase characters. */
-        System.arraycopy(value, 0, result, 0, firstUpper);
+        for (int i = first; i < len; i++) {
+            int cp = (int)value[i];
+            if (cp == '\u03A3') {                       // GREEK CAPITAL LETTER SIGMA
+                return toLowerCaseEx(result, i, locale, false);
+            }
+            cp = Character.toLowerCase(cp);
+            if (!Character.isBmpCodePoint(cp)) {
+                return toLowerCaseEx(result, i, locale, false);
+            }
+            result[i] = (char)cp;
+        }
+        return new String(result, true);
+    }
 
-        String lang = locale.getLanguage();
-        boolean localeDependent =
-                (lang == "tr" || lang == "az" || lang == "lt");
-        char[] lowerCharArray;
-        int lowerChar;
-        int srcChar;
+    private String toLowerCaseEx(char[] result, int first, Locale locale, boolean localeDependent) {
+        int resultOffset = first;
         int srcCount;
-        for (int i = firstUpper; i < len; i += srcCount) {
-            srcChar = (int)value[i];
-            if ((char)srcChar >= Character.MIN_HIGH_SURROGATE
-                    && (char)srcChar <= Character.MAX_HIGH_SURROGATE) {
+        for (int i = first; i < value.length; i += srcCount) {
+            int srcChar = (int)value[i];
+            int lowerChar;
+            char[] lowerCharArray;
+            srcCount = 1;
+            if (Character.isSurrogate((char)srcChar)) {
                 srcChar = codePointAt(i);
                 srcCount = Character.charCount(srcChar);
-            } else {
-                srcCount = 1;
             }
             if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
                 lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale);
             } else {
                 lowerChar = Character.toLowerCase(srcChar);
             }
-            if ((lowerChar == Character.ERROR)
-                    || (lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
+            if (Character.isBmpCodePoint(lowerChar)) {    // Character.ERROR is not a bmp
+                result[resultOffset++] = (char)lowerChar;
+            } else {
                 if (lowerChar == Character.ERROR) {
-                    lowerCharArray =
-                            ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
+                    lowerCharArray = ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
                 } else if (srcCount == 2) {
-                    resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount;
+                    resultOffset += Character.toChars(lowerChar, result, resultOffset);
                     continue;
                 } else {
                     lowerCharArray = Character.toChars(lowerChar);
                 }
-
                 /* Grow result if needed */
                 int mapLen = lowerCharArray.length;
                 if (mapLen > srcCount) {
                     char[] result2 = new char[result.length + mapLen - srcCount];
-                    System.arraycopy(result, 0, result2, 0, i + resultOffset);
+                    System.arraycopy(result, 0, result2, 0, resultOffset);
                     result = result2;
                 }
                 for (int x = 0; x < mapLen; ++x) {
-                    result[i + resultOffset + x] = lowerCharArray[x];
+                    result[resultOffset++] = lowerCharArray[x];
                 }
-                resultOffset += (mapLen - srcCount);
-            } else {
-                result[i + resultOffset] = (char)lowerChar;
             }
         }
-        return new String(result, 0, len + resultOffset);
+        return new String(result, 0, resultOffset);
     }
 
     /**
@@ -2707,92 +2708,91 @@
         if (locale == null) {
             throw new NullPointerException();
         }
-
-        int firstLower;
+        int first;
+        boolean hasSurr = false;
         final int len = value.length;
 
-        /* Now check if there are any characters that need to be changed. */
-        scan: {
-            for (firstLower = 0 ; firstLower < len; ) {
-                int c = (int)value[firstLower];
-                int srcCount;
-                if ((c >= Character.MIN_HIGH_SURROGATE)
-                        && (c <= Character.MAX_HIGH_SURROGATE)) {
-                    c = codePointAt(firstLower);
-                    srcCount = Character.charCount(c);
-                } else {
-                    srcCount = 1;
-                }
-                int upperCaseChar = Character.toUpperCaseEx(c);
-                if ((upperCaseChar == Character.ERROR)
-                        || (c != upperCaseChar)) {
-                    break scan;
-                }
-                firstLower += srcCount;
+        // Now check if there are any characters that need to be changed, or are surrogate
+        for (first = 0 ; first < len; first++ ) {
+            int cp = (int)value[first];
+            if (Character.isSurrogate((char)cp)) {
+                hasSurr = true;
+                break;
             }
+            if (cp != Character.toUpperCaseEx(cp)) {   // no need to check Character.ERROR
+                break;
+            }
+        }
+        if (first == len) {
             return this;
         }
-
-        /* result may grow, so i+resultOffset is the write location in result */
-        int resultOffset = 0;
-        char[] result = new char[len]; /* may grow */
-
-        /* Just copy the first few upperCase characters. */
-        System.arraycopy(value, 0, result, 0, firstLower);
-
+        char[] result = new char[len];
+        System.arraycopy(value, 0, result, 0, first);  // Just copy the first few
+                                                       // upperCase characters.
         String lang = locale.getLanguage();
-        boolean localeDependent =
-                (lang == "tr" || lang == "az" || lang == "lt");
-        char[] upperCharArray;
-        int upperChar;
-        int srcChar;
+        if (lang == "tr" || lang == "az" || lang == "lt") {
+            return toUpperCaseEx(result, first, locale, true);
+        }
+        if (hasSurr) {
+            return toUpperCaseEx(result, first, locale, false);
+        }
+        for (int i = first; i < len; i++) {
+            int cp = Character.toUpperCaseEx((int)value[i]);
+            if (!Character.isBmpCodePoint(cp)) {    // Character.ERROR is not bmp
+                return toUpperCaseEx(result, i, locale, false);
+            }
+            result[i] = (char)cp;
+        }
+        return new String(result, true);
+    }
+
+    private String toUpperCaseEx(char[] result, int first, Locale locale,
+                                 boolean localeDependent) {
+        int resultOffset = first;
         int srcCount;
-        for (int i = firstLower; i < len; i += srcCount) {
-            srcChar = (int)value[i];
-            if ((char)srcChar >= Character.MIN_HIGH_SURROGATE &&
-                (char)srcChar <= Character.MAX_HIGH_SURROGATE) {
+        for (int i = first; i < value.length; i += srcCount) {
+            int srcChar = (int)value[i];
+            int upperChar;
+            char[] upperCharArray;
+            srcCount = 1;
+            if (Character.isSurrogate((char)srcChar)) {
                 srcChar = codePointAt(i);
                 srcCount = Character.charCount(srcChar);
-            } else {
-                srcCount = 1;
             }
             if (localeDependent) {
                 upperChar = ConditionalSpecialCasing.toUpperCaseEx(this, i, locale);
             } else {
                 upperChar = Character.toUpperCaseEx(srcChar);
             }
-            if ((upperChar == Character.ERROR)
-                    || (upperChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
+            if (Character.isBmpCodePoint(upperChar)) {
+                result[resultOffset++] = (char)upperChar;
+            } else {
                 if (upperChar == Character.ERROR) {
                     if (localeDependent) {
                         upperCharArray =
-                                ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale);
+                            ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale);
                     } else {
                         upperCharArray = Character.toUpperCaseCharArray(srcChar);
                     }
                 } else if (srcCount == 2) {
-                    resultOffset += Character.toChars(upperChar, result, i + resultOffset) - srcCount;
+                    resultOffset += Character.toChars(upperChar, result, resultOffset);
                     continue;
                 } else {
                     upperCharArray = Character.toChars(upperChar);
                 }
-
                 /* Grow result if needed */
                 int mapLen = upperCharArray.length;
                 if (mapLen > srcCount) {
                     char[] result2 = new char[result.length + mapLen - srcCount];
-                    System.arraycopy(result, 0, result2, 0, i + resultOffset);
+                    System.arraycopy(result, 0, result2, 0, resultOffset);
                     result = result2;
-                }
-                for (int x = 0; x < mapLen; ++x) {
-                    result[i + resultOffset + x] = upperCharArray[x];
-                }
-                resultOffset += (mapLen - srcCount);
-            } else {
-                result[i + resultOffset] = (char)upperChar;
+                 }
+                 for (int x = 0; x < mapLen; ++x) {
+                    result[resultOffset++] = upperCharArray[x];
+                 }
             }
         }
-        return new String(result, 0, len + resultOffset);
+        return new String(result, 0, resultOffset);
     }
 
     /**
--- a/jdk/src/share/classes/java/time/Clock.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/time/Clock.java	Tue Feb 11 14:42:17 2014 -0800
@@ -104,7 +104,7 @@
  * resolution clock if one is available.
  *
  * @implSpec
- * This abstract class must be implemented with care to ensure other operate correctly.
+ * This abstract class must be implemented with care to ensure other classes operate correctly.
  * All implementations that can be instantiated must be final, immutable and thread-safe.
  * <p>
  * The principal methods are defined to allow the throwing of an exception.
--- a/jdk/src/share/classes/java/time/Instant.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/time/Instant.java	Tue Feb 11 14:42:17 2014 -0800
@@ -100,11 +100,6 @@
  * This class models a single instantaneous point on the time-line.
  * This might be used to record event time-stamps in the application.
  * <p>
- * For practicality, the instant is stored with some constraints.
- * The measurable time-line is restricted to the number of seconds that can be held
- * in a {@code long}. This is greater than the current estimated age of the universe.
- * The instant is stored to nanosecond resolution.
- * <p>
  * The range of an instant requires the storage of a number larger than a {@code long}.
  * To achieve this, the class stores a {@code long} representing epoch-seconds and an
  * {@code int} representing nanosecond-of-second, which will always be between 0 and 999,999,999.
--- a/jdk/src/share/classes/java/time/format/DateTimeFormatter.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/time/format/DateTimeFormatter.java	Tue Feb 11 14:42:17 2014 -0800
@@ -344,10 +344,7 @@
  * <b>Fraction</b>: Outputs the nano-of-second field as a fraction-of-second.
  * The nano-of-second value has nine digits, thus the count of pattern letters
  * is from 1 to 9. If it is less than 9, then the nano-of-second value is
- * truncated, with only the most significant digits being output. When parsing
- * in strict mode, the number of parsed digits must match the count of pattern
- * letters. When parsing in lenient mode, the number of parsed digits must be at
- * least the count of pattern letters, up to 9 digits.
+ * truncated, with only the most significant digits being output.
  * <p>
  * <b>Year</b>: The count of letters determines the minimum field width below
  * which padding is used. If the count of letters is two, then a
--- a/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java	Tue Feb 11 14:42:17 2014 -0800
@@ -217,7 +217,7 @@
     default int get(TemporalField field) {
         ValueRange range = range(field);
         if (range.isIntValue() == false) {
-            throw new UnsupportedTemporalTypeException("Invalid field " + field + " + for get() method, use getLong() instead");
+            throw new UnsupportedTemporalTypeException("Invalid field " + field + " for get() method, use getLong() instead");
         }
         long value = getLong(field);
         if (range.isValidValue(value) == false) {
--- a/jdk/src/share/classes/java/util/Arrays.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/util/Arrays.java	Tue Feb 11 14:42:17 2014 -0800
@@ -50,7 +50,7 @@
  * if the specified array reference is null, except where noted.
  *
  * <p>The documentation for the methods contained in this class includes
- * briefs description of the <i>implementations</i>. Such descriptions should
+ * brief descriptions of the <i>implementations</i>. Such descriptions should
  * be regarded as <i>implementation notes</i>, rather than parts of the
  * <i>specification</i>. Implementors should feel free to substitute other
  * algorithms, so long as the specification itself is adhered to. (For
--- a/jdk/src/share/classes/java/util/Comparator.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/util/Comparator.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -235,7 +235,7 @@
      * @see #thenComparing(Comparator)
      * @since 1.8
      */
-    default <U extends Comparable<? super U>> Comparator<T> thenComparing(
+    default <U> Comparator<T> thenComparing(
             Function<? super T, ? extends U> keyExtractor,
             Comparator<? super U> keyComparator)
     {
--- a/jdk/src/share/classes/java/util/logging/FileHandler.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/java/util/logging/FileHandler.java	Tue Feb 11 14:42:17 2014 -0800
@@ -535,7 +535,7 @@
                     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 @@
             lastException = ex;
         }
     }
-
-    /**
-     * check if we are in a set UID program.
-     */
-    private static native boolean isSetUID();
 }
--- a/jdk/src/share/classes/javax/imageio/IIOException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/IIOException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -40,6 +40,7 @@
  *
  */
 public class IIOException extends IOException {
+    private static final long serialVersionUID = -3216210718638985251L;
 
     /**
      * Constructs an <code>IIOException</code> with a given message
--- a/jdk/src/share/classes/javax/imageio/metadata/IIOInvalidTreeException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/metadata/IIOInvalidTreeException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -44,6 +44,7 @@
  *
  */
 public class IIOInvalidTreeException extends IIOException {
+    private static final long serialVersionUID = -1314083172544132777L;
 
     /**
      * The <code>Node</code> that led to the parsing error, or
--- a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataNode.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataNode.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -41,6 +41,7 @@
 
 
 class IIODOMException extends DOMException {
+    private static final long serialVersionUID = -4369510142067447468L;
 
     public IIODOMException(short code, String message) {
         super(code, message);
--- a/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -40,6 +40,7 @@
  *
  */
 class DigraphNode implements Cloneable, Serializable {
+    private static final long serialVersionUID = 5308261378582246841L;
 
     /** The data associated with this node. */
     protected Object data;
--- a/jdk/src/share/classes/javax/print/DocFlavor.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/print/DocFlavor.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1045,6 +1045,7 @@
      * @author  Alan Kaminsky
      */
     public static class URL extends DocFlavor {
+        private static final long serialVersionUID = 2936725788144902062L;
 
         /**
          * Constructs a new doc flavor with the given MIME type and a print
--- a/jdk/src/share/classes/javax/print/PrintException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/print/PrintException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -33,7 +33,7 @@
  *
  */
 public class PrintException extends Exception {
-
+    private static final long serialVersionUID = -5932531546705242471L;
 
     /**
      * Construct a print exception with no detail message.
--- a/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -77,6 +77,7 @@
       */
     private static class UnmodifiableAttributeSet
         implements AttributeSet, Serializable {
+        private static final long serialVersionUID = -6131802583863447813L;
 
         private AttributeSet attrset;
 
@@ -147,6 +148,7 @@
     private static class UnmodifiableDocAttributeSet
         extends UnmodifiableAttributeSet
         implements DocAttributeSet, Serializable {
+        private static final long serialVersionUID = -6349408326066898956L;
 
         public UnmodifiableDocAttributeSet(DocAttributeSet attributeSet) {
 
@@ -161,6 +163,7 @@
         extends UnmodifiableAttributeSet
         implements PrintRequestAttributeSet, Serializable
     {
+        private static final long serialVersionUID = 7799373532614825073L;
         public UnmodifiablePrintRequestAttributeSet
             (PrintRequestAttributeSet attributeSet) {
 
@@ -175,6 +178,7 @@
         extends UnmodifiableAttributeSet
         implements PrintJobAttributeSet, Serializable
     {
+        private static final long serialVersionUID = -8002245296274522112L;
         public UnmodifiablePrintJobAttributeSet
             (PrintJobAttributeSet attributeSet) {
 
@@ -189,6 +193,7 @@
         extends UnmodifiableAttributeSet
         implements PrintServiceAttributeSet, Serializable
     {
+        private static final long serialVersionUID = -7112165137107826819L;
         public UnmodifiablePrintServiceAttributeSet
             (PrintServiceAttributeSet attributeSet) {
 
@@ -291,6 +296,7 @@
       */
     private static class SynchronizedAttributeSet
                         implements AttributeSet, Serializable {
+        private static final long serialVersionUID = 8365731020128564925L;
 
         private AttributeSet attrset;
 
@@ -357,6 +363,7 @@
     private static class SynchronizedDocAttributeSet
         extends SynchronizedAttributeSet
         implements DocAttributeSet, Serializable {
+        private static final long serialVersionUID = 6455869095246629354L;
 
         public SynchronizedDocAttributeSet(DocAttributeSet attributeSet) {
             super(attributeSet);
@@ -369,6 +376,7 @@
     private static class SynchronizedPrintRequestAttributeSet
         extends SynchronizedAttributeSet
         implements PrintRequestAttributeSet, Serializable {
+        private static final long serialVersionUID = 5671237023971169027L;
 
         public SynchronizedPrintRequestAttributeSet
             (PrintRequestAttributeSet attributeSet) {
@@ -382,6 +390,7 @@
     private static class SynchronizedPrintJobAttributeSet
         extends SynchronizedAttributeSet
         implements PrintJobAttributeSet, Serializable {
+        private static final long serialVersionUID = 2117188707856965749L;
 
         public SynchronizedPrintJobAttributeSet
             (PrintJobAttributeSet attributeSet) {
@@ -395,6 +404,8 @@
     private static class SynchronizedPrintServiceAttributeSet
         extends SynchronizedAttributeSet
         implements PrintServiceAttributeSet, Serializable {
+        private static final long serialVersionUID = -2830705374001675073L;
+
         public SynchronizedPrintServiceAttributeSet
             (PrintServiceAttributeSet attributeSet) {
             super(attributeSet);
--- a/jdk/src/share/classes/javax/print/attribute/UnmodifiableSetException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/print/attribute/UnmodifiableSetException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -33,6 +33,8 @@
  * @since   1.4
  */
 public class UnmodifiableSetException extends RuntimeException {
+    private static final long serialVersionUID = 2255250308571511731L;
+
     /**
      * Constructs an UnsupportedOperationException with no detail message.
      */
--- a/jdk/src/share/classes/javax/sound/midi/InvalidMidiDataException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/sound/midi/InvalidMidiDataException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -39,6 +39,7 @@
  * @author Kara Kytle
  */
 public class InvalidMidiDataException extends Exception {
+    private static final long serialVersionUID = 2780771756789932067L;
 
     /**
      * Constructs an <code>InvalidMidiDataException</code> with
@@ -49,7 +50,6 @@
         super();
     }
 
-
     /**
      *  Constructs an <code>InvalidMidiDataException</code> with the
      * specified detail message.
--- a/jdk/src/share/classes/javax/sound/midi/MidiUnavailableException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/sound/midi/MidiUnavailableException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -39,6 +39,7 @@
  * @author Kara Kytle
  */
 public class MidiUnavailableException extends Exception {
+    private static final long serialVersionUID = 6093809578628944323L;
 
     /**
      * Constructs a <code>MidiUnavailableException</code> that has
@@ -49,7 +50,6 @@
         super();
     }
 
-
     /**
      *  Constructs a <code>MidiUnavailableException</code> with the
      * specified detail message.
--- a/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -27,7 +27,6 @@
 
 import java.security.BasicPermission;
 
-
 /**
  * The <code>AudioPermission</code> class represents access rights to the audio
  * system resources.  An <code>AudioPermission</code> contains a target name
@@ -76,134 +75,8 @@
  * @author Kara Kytle
  * @since 1.3
  */
-/*
- * (OLD PERMISSIONS TAKEN OUT FOR 1.2 BETA)
- *
- * <tr>
- * <td>playback device access</td>
- * <td>Direct access to the audio playback device(s), including configuration of the
- * playback format, volume, and balance, explicit opening and closing of the device,
- * etc.</td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * <tr>
- * <td>playback device override</td>
- * <td>Manipulation of the audio playback device(s) in a way that directly conflicts
- * with use by other applications.  This includes closing the device while it is in
- * use by another application, changing the device format while another application
- * is using it, etc. </td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * <tr>
- * <td>record device access</td>
- * <td>Direct access to the audio recording device(s), including configuration of the
- * the record format, volume, and balance, explicit opening and closing of the device,
- * etc.</td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * <tr>
- * <td>record device override</td>
- * <td>Manipulation of the audio recording device(s) in a way that directly conflicts
- * with use by other applications.  This includes closing the device while it is in
- * use by another application, changing the device format while another application
- * is using it, etc. </td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * </table>
- *<p>
- *
- * @author Kara Kytle
- * @since 1.3
- */
-
-/*
- * The <code>AudioPermission</code> class represents access rights to the audio
- * system resources.  An <code>AudioPermission</code> contains a target name
- * but no actions list; you either have the named permission or you don't.
- * <p>
- * The target name is the name of the audio permission (see the table below).
- * The names follow the hierarchical property-naming convention. Also, an asterisk
- * can be used to represent all the audio permissions.
- * <p>
- * The following table lists all the possible AudioPermission target names.
- * For each name, the table provides a description of exactly what that permission
- * allows, as well as a discussion of the risks of granting code the permission.
- * <p>
- *
- * <table border=1 cellpadding=5>
- * <tr>
- * <th>Permission Target Name</th>
- * <th>What the Permission Allows</th>
- * <th>Risks of Allowing this Permission</th>
- * </tr>
- *
- * <tr>
- * <td>play</td>
- * <td>Audio playback through the audio device or devices on the system.</td>
- * <td>Allows the application to use a system device.  Can affect other applications,
- * because the result will be mixed with other audio being played on the system.</td>
- *</tr>
- *
- * <tr>
- * <td>record</td>
- * <td>Recording audio from the audio device or devices on the system,
- * commonly through a microphone.</td>
- * <td>Can enable an applet or application to eavesdrop on a user.</td>
- * </tr>
- *
- * <tr>
- * <td>playback device access</td>
- * <td>Direct access to the audio playback device(s), including configuration of the
- * playback format, volume, and balance, explicit opening and closing of the device,
- * etc.</td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * <tr>
- * <td>playback device override</td>
- * <td>Manipulation of the audio playback device(s) in a way that directly conflicts
- * with use by other applications.  This includes closing the device while it is in
- * use by another application, changing the device format while another application
- * is using it, etc. </td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * <tr>
- * <td>record device access</td>
- * <td>Direct access to the audio recording device(s), including configuration of the
- * the record format, volume, and balance, explicit opening and closing of the device,
- * etc.</td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * <tr>
- * <td>record device override</td>
- * <td>Manipulation of the audio recording device(s) in a way that directly conflicts
- * with use by other applications.  This includes closing the device while it is in
- * use by another application, changing the device format while another application
- * is using it, etc. </td>
- * <td>Changes the properties of a shared system device and therefore
- * can affect other applications.</td>
- * </tr>
- *
- * </table>
- *<p>
- *
- * @author Kara Kytle
- */
-
 public class AudioPermission extends BasicPermission {
+    private static final long serialVersionUID = -5518053473477801126L;
 
     /**
      * Creates a new <code>AudioPermission</code> object that has the specified
--- a/jdk/src/share/classes/javax/sound/sampled/LineEvent.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/sound/sampled/LineEvent.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -46,6 +46,7 @@
  * @serial exclude
  */
 public class LineEvent extends java.util.EventObject {
+    private static final long serialVersionUID = -1274246333383880410L;
 
     // INSTANCE VARIABLES
 
--- a/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -44,6 +44,7 @@
  */
 
 public class LineUnavailableException extends Exception {
+    private static final long serialVersionUID = -2046718279487432130L;
 
     /**
      * Constructs a <code>LineUnavailableException</code> that has
@@ -54,7 +55,6 @@
         super();
     }
 
-
     /**
      * Constructs a <code>LineUnavailableException</code> that has
      * the specified detail message.
--- a/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -33,15 +33,8 @@
  * @author Kara Kytle
  * @since 1.3
  */
-/*
- * An <code>UnsupportedAudioFileException</code> is an exception indicating that an
- * operation failed because a file did not contain valid data of a recognized file
- * type and format.
- *
- * @author Kara Kytle
- */
-
 public class UnsupportedAudioFileException extends Exception {
+    private static final long serialVersionUID = -139127412623160368L;
 
     /**
      * Constructs a <code>UnsupportedAudioFileException</code> that has
@@ -52,7 +45,6 @@
         super();
     }
 
-
     /**
      * Constructs a <code>UnsupportedAudioFileException</code> that has
      * the specified detail message.
--- a/jdk/src/share/classes/sun/misc/VM.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/sun/misc/VM.java	Tue Feb 11 14:42:17 2014 -0800
@@ -367,6 +367,11 @@
      */
     public static native ClassLoader latestUserDefinedLoader();
 
+    /**
+     * Returns {@code true} if we are in a set UID program.
+     */
+    public static native boolean isSetUID();
+
     static {
         initialize();
     }
--- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java	Tue Feb 11 14:42:17 2014 -0800
@@ -29,10 +29,20 @@
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
-import java.nio.channels.*;
+import java.nio.channels.ClosedByInterruptException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.FileLockInterruptionException;
+import java.nio.channels.NonReadableChannelException;
+import java.nio.channels.NonWritableChannelException;
+import java.nio.channels.OverlappingFileLockException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.List;
-import java.security.AccessController;
+
 import sun.misc.Cleaner;
 import sun.security.action.GetPropertyAction;
 
@@ -56,13 +66,17 @@
     // Required to prevent finalization of creating stream (immutable)
     private final Object parent;
 
+    // The path of the referenced file
+    // (null if the parent stream is created with a file descriptor)
+    private final String path;
+
     // Thread-safe set of IDs of native threads, for signalling
     private final NativeThreadSet threads = new NativeThreadSet(2);
 
     // Lock for operations involving position and size
     private final Object positionLock = new Object();
 
-    private FileChannelImpl(FileDescriptor fd, boolean readable,
+    private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
                             boolean writable, boolean append, Object parent)
     {
         this.fd = fd;
@@ -70,23 +84,24 @@
         this.writable = writable;
         this.append = append;
         this.parent = parent;
+        this.path = path;
         this.nd = new FileDispatcherImpl(append);
     }
 
     // Used by FileInputStream.getChannel() and RandomAccessFile.getChannel()
-    public static FileChannel open(FileDescriptor fd,
+    public static FileChannel open(FileDescriptor fd, String path,
                                    boolean readable, boolean writable,
                                    Object parent)
     {
-        return new FileChannelImpl(fd, readable, writable, false, parent);
+        return new FileChannelImpl(fd, path, readable, writable, false, parent);
     }
 
     // Used by FileOutputStream.getChannel
-    public static FileChannel open(FileDescriptor fd,
+    public static FileChannel open(FileDescriptor fd, String path,
                                    boolean readable, boolean writable,
                                    boolean append, Object parent)
     {
-        return new FileChannelImpl(fd, readable, writable, append, parent);
+        return new FileChannelImpl(fd, path, readable, writable, append, parent);
     }
 
     private void ensureOpen() throws IOException {
--- a/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java	Tue Feb 11 14:42:17 2014 -0800
@@ -42,7 +42,7 @@
                 public Boolean run() {
                     String osname = System.getProperty("os.name");
                     if (osname.contains("OS X")) {
-                        System.loadLibrary("osx");
+                        System.loadLibrary("osxkrb5");
                         return true;
                     }
                     return false;
--- a/jdk/src/share/native/common/jni_util.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/common/jni_util.c	Tue Feb 11 14:42:17 2014 -0800
@@ -626,10 +626,14 @@
 {
     jstring propname = 0;
     jstring enc = 0;
+    jclass strClazz = NULL;
 
     if ((*env)->EnsureLocalCapacity(env, 3) < 0)
         return;
 
+    strClazz = JNU_ClassString(env);
+    CHECK_NULL(strClazz);
+
     propname = (*env)->NewStringUTF(env, "sun.jnu.encoding");
     if (propname) {
         jboolean exc;
@@ -683,9 +687,10 @@
     (*env)->DeleteLocalRef(env, enc);
 
     /* Initialize method-id cache */
-    String_getBytes_ID = (*env)->GetMethodID(env, JNU_ClassString(env),
+    String_getBytes_ID = (*env)->GetMethodID(env, strClazz,
                                              "getBytes", "(Ljava/lang/String;)[B");
-    String_init_ID = (*env)->GetMethodID(env, JNU_ClassString(env),
+    CHECK_NULL(String_getBytes_ID);
+    String_init_ID = (*env)->GetMethodID(env, strClazz,
                                          "<init>", "([BLjava/lang/String;)V");
 }
 
@@ -714,46 +719,49 @@
 JNIEXPORT jstring JNICALL
 JNU_NewStringPlatform(JNIEnv *env, const char *str)
 {
-    jstring result;
-    result = nativeNewStringPlatform(env, str);
-    if (result == NULL) {
-        jbyteArray hab = 0;
-        int len;
+    jstring result = NULL;
+    jbyteArray hab = 0;
+    int len;
 
-        if (fastEncoding == NO_ENCODING_YET)
-            initializeEncoding(env);
+    if (fastEncoding == NO_ENCODING_YET) {
+        initializeEncoding(env);
+        JNU_CHECK_EXCEPTION_RETURN(env, NULL);
+    }
 
-        if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
-            return newString8859_1(env, str);
-        if (fastEncoding == FAST_646_US)
-            return newString646_US(env, str);
-        if (fastEncoding == FAST_CP1252)
-            return newStringCp1252(env, str);
+    if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
+        return newString8859_1(env, str);
+    if (fastEncoding == FAST_646_US)
+        return newString646_US(env, str);
+    if (fastEncoding == FAST_CP1252)
+        return newStringCp1252(env, str);
 
-        if ((*env)->EnsureLocalCapacity(env, 2) < 0)
-            return NULL;
+    if ((*env)->EnsureLocalCapacity(env, 2) < 0)
+        return NULL;
 
-        len = (int)strlen(str);
-        hab = (*env)->NewByteArray(env, len);
-        if (hab != 0) {
-            (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str);
-            if (jnuEncodingSupported(env)) {
-                result = (*env)->NewObject(env, JNU_ClassString(env),
-                                           String_init_ID, hab, jnuEncoding);
-            } else {
-                /*If the encoding specified in sun.jnu.encoding is not endorsed
-                  by "Charset.isSupported" we have to fall back to use String(byte[])
-                  explicitly here without specifying the encoding name, in which the
-                  StringCoding class will pickup the iso-8859-1 as the fallback
-                  converter for us.
-                 */
-                jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env),
-                                                    "<init>", "([B)V");
-                result = (*env)->NewObject(env, JNU_ClassString(env), mid, hab);
+    len = (int)strlen(str);
+    hab = (*env)->NewByteArray(env, len);
+    if (hab != 0) {
+        jclass strClazz = JNU_ClassString(env);
+        CHECK_NULL_RETURN(strClazz, 0);
+        (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str);
+        if (jnuEncodingSupported(env)) {
+            result = (*env)->NewObject(env, strClazz,
+                                       String_init_ID, hab, jnuEncoding);
+        } else {
+            /*If the encoding specified in sun.jnu.encoding is not endorsed
+              by "Charset.isSupported" we have to fall back to use String(byte[])
+              explicitly here without specifying the encoding name, in which the
+              StringCoding class will pickup the iso-8859-1 as the fallback
+              converter for us.
+             */
+            jmethodID mid = (*env)->GetMethodID(env, strClazz,
+                                                "<init>", "([B)V");
+            if (mid != NULL) {
+                result = (*env)->NewObject(env, strClazz, mid, hab);
             }
-            (*env)->DeleteLocalRef(env, hab);
-            return result;
         }
+        (*env)->DeleteLocalRef(env, hab);
+        return result;
     }
     return NULL;
 }
@@ -767,49 +775,53 @@
 JNIEXPORT const char * JNICALL
 JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy)
 {
-    char *result = nativeGetStringPlatformChars(env, jstr, isCopy);
-    if (result == NULL) {
-
-        jbyteArray hab = 0;
+    char *result = NULL;
+    jbyteArray hab = 0;
 
-        if (isCopy)
-            *isCopy = JNI_TRUE;
+    if (isCopy)
+        *isCopy = JNI_TRUE;
 
-        if (fastEncoding == NO_ENCODING_YET)
-            initializeEncoding(env);
+    if (fastEncoding == NO_ENCODING_YET) {
+        initializeEncoding(env);
+        JNU_CHECK_EXCEPTION_RETURN(env, 0);
+    }
 
-        if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
-            return getString8859_1Chars(env, jstr);
-        if (fastEncoding == FAST_646_US)
-            return getString646_USChars(env, jstr);
-        if (fastEncoding == FAST_CP1252)
-            return getStringCp1252Chars(env, jstr);
+    if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
+        return getString8859_1Chars(env, jstr);
+    if (fastEncoding == FAST_646_US)
+        return getString646_USChars(env, jstr);
+    if (fastEncoding == FAST_CP1252)
+        return getStringCp1252Chars(env, jstr);
+
+    if ((*env)->EnsureLocalCapacity(env, 2) < 0)
+        return 0;
 
-        if ((*env)->EnsureLocalCapacity(env, 2) < 0)
-            return 0;
-
-        if (jnuEncodingSupported(env)) {
-            hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding);
-        } else {
-            jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env),
-                                                "getBytes", "()[B");
+    if (jnuEncodingSupported(env)) {
+        hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding);
+    } else {
+        jmethodID mid;
+        jclass strClazz = JNU_ClassString(env);
+        CHECK_NULL_RETURN(strClazz, 0);
+        mid = (*env)->GetMethodID(env, strClazz,
+                                       "getBytes", "()[B");
+        if (mid != NULL) {
             hab = (*env)->CallObjectMethod(env, jstr, mid);
         }
+    }
 
-        if (!(*env)->ExceptionCheck(env)) {
-            jint len = (*env)->GetArrayLength(env, hab);
-            result = MALLOC_MIN4(len);
-            if (result == 0) {
-                JNU_ThrowOutOfMemoryError(env, 0);
-                (*env)->DeleteLocalRef(env, hab);
-                return 0;
-            }
-            (*env)->GetByteArrayRegion(env, hab, 0, len, (jbyte *)result);
-            result[len] = 0; /* NULL-terminate */
+    if (!(*env)->ExceptionCheck(env)) {
+        jint len = (*env)->GetArrayLength(env, hab);
+        result = MALLOC_MIN4(len);
+        if (result == 0) {
+            JNU_ThrowOutOfMemoryError(env, 0);
+            (*env)->DeleteLocalRef(env, hab);
+            return 0;
         }
+        (*env)->GetByteArrayRegion(env, hab, 0, len, (jbyte *)result);
+        result[len] = 0; /* NULL-terminate */
+    }
 
-        (*env)->DeleteLocalRef(env, hab);
-    }
+    (*env)->DeleteLocalRef(env, hab);
     return result;
 }
 
@@ -842,6 +854,7 @@
         if ((*env)->EnsureLocalCapacity(env, 1) < 0)
             return 0;
         c = (*env)->FindClass(env, "java/lang/String");
+        CHECK_NULL_RETURN(c, NULL);
         cls = (*env)->NewGlobalRef(env, c);
         (*env)->DeleteLocalRef(env, c);
     }
@@ -857,6 +870,7 @@
         if ((*env)->EnsureLocalCapacity(env, 1) < 0)
             return 0;
         c = (*env)->FindClass(env, "java/lang/Class");
+        CHECK_NULL_RETURN(c, NULL);
         cls = (*env)->NewGlobalRef(env, c);
         (*env)->DeleteLocalRef(env, c);
     }
@@ -872,6 +886,7 @@
         if ((*env)->EnsureLocalCapacity(env, 1) < 0)
             return 0;
         c = (*env)->FindClass(env, "java/lang/Object");
+        CHECK_NULL_RETURN(c, NULL);
         cls = (*env)->NewGlobalRef(env, c);
         (*env)->DeleteLocalRef(env, c);
     }
@@ -887,6 +902,7 @@
         if ((*env)->EnsureLocalCapacity(env, 1) < 0)
             return 0;
         c = (*env)->FindClass(env, "java/lang/Throwable");
+        CHECK_NULL_RETURN(c, NULL);
         cls = (*env)->NewGlobalRef(env, c);
         (*env)->DeleteLocalRef(env, c);
     }
@@ -936,8 +952,11 @@
 {
     static jmethodID mid = NULL;
     if (mid == NULL) {
-        mid = (*env)->GetMethodID(env, JNU_ClassObject(env), "equals",
+        jclass objClazz = JNU_ClassObject(env);
+        CHECK_NULL_RETURN(objClazz, JNI_FALSE);
+        mid = (*env)->GetMethodID(env, objClazz, "equals",
                                   "(Ljava/lang/Object;)Z");
+        CHECK_NULL_RETURN(mid, JNI_FALSE);
     }
     return (*env)->CallBooleanMethod(env, object1, mid, object2);
 }
@@ -1039,7 +1058,9 @@
     } else {
         jclass cls = (*env)->GetObjectClass(env, object);
         jstring clsName = JNU_ToString(env, cls);
-        JNU_PrintString(env, hdr, clsName);
+        if (clsName == NULL) {
+            JNU_PrintString(env, hdr, clsName);
+        }
         (*env)->DeleteLocalRef(env, cls);
         (*env)->DeleteLocalRef(env, clsName);
     }
--- a/jdk/src/share/native/common/jni_util.h	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/common/jni_util.h	Tue Feb 11 14:42:17 2014 -0800
@@ -363,10 +363,6 @@
     FAST_646_US                 /* US-ASCII : ISO646-US */
 };
 
-jstring nativeNewStringPlatform(JNIEnv *env, const char *str);
-
-char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
-
 int getFastEncoding();
 
 void initializeEncoding();
--- a/jdk/src/share/native/java/io/FileInputStream.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/java/io/FileInputStream.c	Tue Feb 11 14:42:17 2014 -0800
@@ -62,7 +62,7 @@
 }
 
 JNIEXPORT jint JNICALL
-Java_java_io_FileInputStream_read(JNIEnv *env, jobject this) {
+Java_java_io_FileInputStream_read0(JNIEnv *env, jobject this) {
     return readSingle(env, this, fis_fd);
 }
 
--- a/jdk/src/share/native/java/io/RandomAccessFile.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/java/io/RandomAccessFile.c	Tue Feb 11 14:42:17 2014 -0800
@@ -64,7 +64,7 @@
 }
 
 JNIEXPORT jint JNICALL
-Java_java_io_RandomAccessFile_read(JNIEnv *env, jobject this) {
+Java_java_io_RandomAccessFile_read0(JNIEnv *env, jobject this) {
     return readSingle(env, this, raf_fd);
 }
 
@@ -75,7 +75,7 @@
 }
 
 JNIEXPORT void JNICALL
-Java_java_io_RandomAccessFile_write(JNIEnv *env, jobject this, jint byte) {
+Java_java_io_RandomAccessFile_write0(JNIEnv *env, jobject this, jint byte) {
     writeSingle(env, this, byte, JNI_FALSE, raf_fd);
 }
 
--- a/jdk/src/share/native/java/net/net_util.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/java/net/net_util.c	Tue Feb 11 14:42:17 2014 -0800
@@ -108,7 +108,7 @@
     return (*env)->GetObjectField(env, holder, ia6_scopeifnameID);
 }
 
-int setInet6Address_scopeifname(JNIEnv *env, jobject iaObj, jobject scopeifname) {
+jboolean setInet6Address_scopeifname(JNIEnv *env, jobject iaObj, jobject scopeifname) {
     jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
     CHECK_NULL_RETURN(holder, JNI_FALSE);
     (*env)->SetObjectField(env, holder, ia6_scopeifnameID, scopeifname);
@@ -127,20 +127,18 @@
     return (*env)->GetIntField(env, holder, ia6_scopeidID);
 }
 
-int setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) {
+jboolean setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) {
     jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
     CHECK_NULL_RETURN(holder, JNI_FALSE);
     (*env)->SetIntField(env, holder, ia6_scopeidID, scopeid);
     if (scopeid > 0) {
-            (*env)->SetBooleanField(env, holder, ia6_scopeidsetID, JNI_TRUE);
+        (*env)->SetBooleanField(env, holder, ia6_scopeidsetID, JNI_TRUE);
     }
     return JNI_TRUE;
 }
 
-
-int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) {
+jboolean getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) {
     jobject holder, addr;
-    jbyteArray barr;
 
     holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
     CHECK_NULL_RETURN(holder, JNI_FALSE);
@@ -150,7 +148,7 @@
     return JNI_TRUE;
 }
 
-int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
+jboolean setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
     jobject holder;
     jbyteArray addr;
 
@@ -201,7 +199,6 @@
     jobject iaObj;
 #ifdef AF_INET6
     if (him->sa_family == AF_INET6) {
-        jbyteArray ipaddress;
 #ifdef WIN32
         struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
 #else
@@ -217,11 +214,12 @@
             setInetAddress_family(env, iaObj, IPv4);
         } else {
             jint scope;
-            int ret;
+            jboolean ret;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
             CHECK_NULL_RETURN(iaObj, NULL);
             ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr));
-            CHECK_NULL_RETURN(ret, NULL);
+            if (ret == JNI_FALSE)
+                return NULL;
             setInetAddress_family(env, iaObj, IPv6);
             scope = getScopeID(him);
             setInet6Address_scopeid(env, iaObj, scope);
@@ -268,7 +266,6 @@
                 return JNI_FALSE;
             }
         } else {
-            jbyteArray ipaddress;
             jbyte caddrCur[16];
             int scope;
 
--- a/jdk/src/share/native/java/net/net_util.h	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/java/net/net_util.h	Tue Feb 11 14:42:17 2014 -0800
@@ -63,12 +63,12 @@
  * get_ methods that return objects return NULL on error.
  */
 extern jobject getInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj);
-extern int setInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj, jobject scopeifname);
+extern jboolean setInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj, jobject scopeifname);
 extern int getInet6Address_scopeid_set(JNIEnv *env, jobject ia6Obj);
 extern int getInet6Address_scopeid(JNIEnv *env, jobject ia6Obj);
-extern int setInet6Address_scopeid(JNIEnv *env, jobject ia6Obj, int scopeid);
-extern int getInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *dest);
-extern int setInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *address);
+extern jboolean setInet6Address_scopeid(JNIEnv *env, jobject ia6Obj, int scopeid);
+extern jboolean getInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *dest);
+extern jboolean setInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *address);
 
 extern void setInetAddress_addr(JNIEnv *env, jobject iaObj, int address);
 extern void setInetAddress_family(JNIEnv *env, jobject iaObj, int family);
--- a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c	Tue Feb 11 14:42:17 2014 -0800
@@ -28,6 +28,7 @@
 #include "NativeFunc.h"
 #include "jlong.h"
 #include <jni.h>
+#include "jni_util.h"
 
 /* Throws a Java Exception by name */
 
@@ -65,6 +66,12 @@
     }
 
     libName = (*env)->GetStringUTFChars(env, jlibName, NULL);
+    if (libName == NULL) {
+        if (!(*env)->ExceptionCheck(env)) {
+            throwOutOfMemoryError(env, NULL);
+        }
+        return JNI_FALSE;
+    }
     sprintf(debugBuf, "[GSSLibStub_init] libName=%s", libName);
     debug(env, debugBuf);
 
@@ -110,6 +117,8 @@
         }
       }
       (*env)->ReleaseByteArrayElements(env, jbytes, bytes, 0);
+    } else {
+      JNU_CHECK_EXCEPTION_RETURN(env, jlong_zero);
     }
     if (found != JNI_TRUE) {
       checkStatus(env, NULL, GSS_S_BAD_MECH, 0, "[GSSLibStub_getMechPtr]");
@@ -147,7 +156,9 @@
     cb->initiator_addrtype = GSS_C_AF_INET;
     value = (*env)->CallObjectMethod(env, jinetAddr,
                                      MID_InetAddress_getAddr);
-    initGSSBuffer(env, value, &(cb->initiator_address));
+    if (!initGSSBuffer(env, value, &(cb->initiator_address))) {
+        return NULL;
+    }
   } else {
     cb->initiator_addrtype = GSS_C_AF_NULLADDR;
     cb->initiator_address.length = 0;
@@ -161,7 +172,9 @@
     cb->acceptor_addrtype = GSS_C_AF_INET;
     value = (*env)->CallObjectMethod(env, jinetAddr,
                                      MID_InetAddress_getAddr);
-    initGSSBuffer(env, value, &(cb->acceptor_address));
+    if (!initGSSBuffer(env, value, &(cb->acceptor_address))) {
+        return NULL;
+    }
   } else {
     cb->acceptor_addrtype = GSS_C_AF_NULLADDR;
     cb->acceptor_address.length = 0;
@@ -171,7 +184,9 @@
   value = (*env)->CallObjectMethod(env, jcb,
                                    MID_ChannelBinding_getAppData);
   if (value != NULL) {
-    initGSSBuffer(env, value, &(cb->application_data));
+    if (!initGSSBuffer(env, value, &(cb->application_data))) {
+        return NULL;
+    }
   } else {
     cb->application_data.length = 0;
     cb->application_data.value = NULL;
@@ -230,6 +245,7 @@
     isUnseq = ((suppInfo & GSS_S_UNSEQ_TOKEN) != 0);
     hasGap = ((suppInfo & GSS_S_GAP_TOKEN) != 0);
     minorMsg = getMinorMessage(env, jstub, minor);
+    CHECK_NULL(minorMsg);
     (*env)->CallVoidMethod(env, jprop, MID_MessageProp_setSupplementaryStates,
                            isDuplicate, isOld, isUnseq, hasGap, minor,
                            minorMsg);
@@ -277,6 +293,7 @@
   /* release intermediate buffers */
   deleteGSSOIDSet(nameTypes);
 
+  CHECK_NULL_RETURN(result, NULL);
   checkStatus(env, jobj, major, minor, "[GSSLibStub_inquireNamesForMech]");
   return result;
   } else return NULL;
@@ -326,7 +343,9 @@
 
   debug(env, "[GSSLibStub_importName]");
 
-  initGSSBuffer(env, jnameVal, &nameVal);
+  if (!initGSSBuffer(env, jnameVal, &nameVal)) {
+    return jlong_zero;
+  }
   nameType = newGSSOID(env, jnameType);
   if ((*env)->ExceptionCheck(env)) {
     deleteGSSOID(nameType);
@@ -501,9 +520,14 @@
 
   /* release intermediate buffers */
   jname = getJavaString(env, &outNameBuf);
+  if (jname == NULL && !(*env)->ExceptionCheck(env)) {
+    throwOutOfMemoryError(env, NULL);
+    return NULL;
+  }
 
   jtype = getJavaOID(env, outNameType);
   jresult = (*env)->NewObjectArray(env, 2, CLS_Object, NULL);
+  CHECK_NULL_RETURN(jresult, NULL);
 
   /* return immediately if an exception has occurred */
   if ((*env)->ExceptionCheck(env)) {
@@ -738,7 +762,9 @@
   debug(env, "[GSSLibStub_importContext]");
 
   contextHdl = GSS_C_NO_CONTEXT;
-  initGSSBuffer(env, jctxtToken, &ctxtToken);
+  if (!initGSSBuffer(env, jctxtToken, &ctxtToken)) {
+    return NULL;
+  }
 
   /* gss_import_sec_context(...) => GSS_S_NO_CONTEXT, GSS_S_DEFECTIVE_TOKEN,
      GSS_S_UNAVAILABLE, GSS_S_UNAUTHORIZED */
@@ -829,7 +855,9 @@
     return NULL;
   }
 
-  initGSSBuffer(env, jinToken, &inToken);
+  if (!initGSSBuffer(env, jinToken, &inToken)) {
+    return NULL;
+  }
 
   sprintf(debugBuf,
           "[GSSLibStub_initContext] before: pCred=%ld, pContext=%ld",
@@ -927,7 +955,9 @@
   contextHdl = (gss_ctx_id_t)jlong_to_ptr(
     (*env)->GetLongField(env, jcontextSpi, FID_NativeGSSContext_pContext));
   credHdl = (gss_cred_id_t) jlong_to_ptr(pCred);
-  initGSSBuffer(env, jinToken, &inToken);
+  if (!initGSSBuffer(env, jinToken, &inToken)) {
+    return NULL;
+  }
   cb = getGSSCB(env, jcb);
   if ((*env)->ExceptionCheck(env)) {
     free(cb);
@@ -1102,6 +1132,7 @@
   result[5] = (jlong) getJavaTime(time);
 
   jresult = (*env)->NewLongArray(env, 6);
+  CHECK_NULL_RETURN(jresult, NULL);
   (*env)->SetLongArrayRegion(env, jresult, 0, 6, result);
 
   /* release intermediate buffers */
@@ -1335,7 +1366,9 @@
   }
   contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
   qop = (gss_qop_t) jqop;
-  initGSSBuffer(env, jmsg, &msg);
+  if (!initGSSBuffer(env, jmsg, &msg)) {
+    return NULL;
+  }
 
   /* gss_get_mic(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!),
      GSS_S_BAD_QOP */
@@ -1379,8 +1412,12 @@
         "[GSSLibStub_verifyMic]");
     return;
   }
-  initGSSBuffer(env, jmsg, &msg);
-  initGSSBuffer(env, jmsgToken, &msgToken);
+
+  if (!initGSSBuffer(env, jmsg, &msg) ||
+      !initGSSBuffer(env, jmsgToken, &msgToken)) {
+    return;
+  }
+
   qop = (gss_qop_t) (*env)->CallIntMethod(env, jprop, MID_MessageProp_getQOP);
   /* gss_verify_mic(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC,
      GSS_S_CONTEXT_EXPIRED, GSS_S_DUPLICATE_TOKEN(!), GSS_S_OLD_TOKEN(!),
@@ -1433,7 +1470,9 @@
     (*env)->CallBooleanMethod(env, jprop, MID_MessageProp_getPrivacy);
   qop = (gss_qop_t)
     (*env)->CallIntMethod(env, jprop, MID_MessageProp_getQOP);
-  initGSSBuffer(env, jmsg, &msg);
+  if (!initGSSBuffer(env, jmsg, &msg)) {
+    return NULL;
+  }
   /* gss_wrap(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!),
      GSS_S_BAD_QOP */
   major = (*ftab->wrap)(&minor, contextHdl, confFlag, qop, &msg, &confState,
@@ -1479,7 +1518,9 @@
     checkStatus(env, jobj, GSS_S_CONTEXT_EXPIRED, 0, "[GSSLibStub_unwrap]");
     return NULL;
   }
-  initGSSBuffer(env, jmsgToken, &msgToken);
+  if (!initGSSBuffer(env, jmsgToken, &msgToken)) {
+    return NULL;
+  }
   confState = 0;
   qop = GSS_C_QOP_DEFAULT;
   /* gss_unwrap(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC,
--- a/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.c	Tue Feb 11 14:42:17 2014 -0800
@@ -27,6 +27,7 @@
 #include "NativeFunc.h"
 #include "jlong.h"
 #include <jni.h>
+#include "jni_util.h"
 
 extern void throwOutOfMemoryError(JNIEnv *env, const char *message);
 
@@ -495,6 +496,9 @@
                              &messageContext, &statusString);
   /* release intermediate buffers */
   msg = getJavaString(env, &statusString);
+  if (msg == NULL && !(*env)->ExceptionCheck(env)) {
+    throwOutOfMemoryError(env, NULL);
+  }
   (*ftab->releaseBuffer)(&minor, &statusString);
   return msg;
 }
@@ -529,6 +533,7 @@
     jmsg = NULL;
     if (minor != 0) {
       jmsg = getMinorMessage(env, jstub, minor);
+      CHECK_NULL(jmsg);
     }
     gssEx = (*env)->NewObject(env, CLS_GSSException,
                               MID_GSSException_ctor3,
@@ -545,28 +550,41 @@
     }
     jmajor = 13; /* use GSSException.FAILURE for now */
     jmsg = (*env)->NewStringUTF(env, msg);
+    CHECK_NULL(jmsg);
     gssEx = (*env)->NewObject(env, CLS_GSSException,
                               MID_GSSException_ctor3,
                               jmajor, jminor, jmsg);
+    CHECK_NULL(gssEx);
     (*env)->Throw(env, gssEx);
   }
 }
+
 /*
  * Utility routine for initializing gss_buffer_t structure
  * with the byte[] in the specified jbyteArray object.
  * NOTE: need to call resetGSSBuffer(...) to free up
  * the resources.
+ * Return JNI_TRUE if GetByteArrayElements() returns ok, JNI_FALSE otherwise
+ * If JNI_FALSE returned, then an exception has been thrown.
  */
-void initGSSBuffer(JNIEnv *env, jbyteArray jbytes,
+int initGSSBuffer(JNIEnv *env, jbyteArray jbytes,
                    gss_buffer_t cbytes) {
   if (jbytes != NULL) {
     cbytes->length = (*env)->GetArrayLength(env, jbytes);
     cbytes->value = (*env)->GetByteArrayElements(env, jbytes, NULL);
+    if (cbytes->value == NULL) {
+        if (!(*env)->ExceptionCheck(env)) {
+            throwOutOfMemoryError(env, NULL);
+        }
+        return JNI_FALSE;
+    }
   } else {
     cbytes->length = 0;
     cbytes->value = NULL;
   }
+  return JNI_TRUE;
 }
+
 /*
  * Utility routine for unpinning/releasing the byte[]
  * associated with the specified jbyteArray object.
@@ -593,7 +611,8 @@
   if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER) &&
       (cbytes->length != 0)) {
     result = (*env)->NewByteArray(env, cbytes->length);
-    (*env)->SetByteArrayRegion(env, result, 0, cbytes->length,
+    if (result != NULL)
+        (*env)->SetByteArrayRegion(env, result, 0, cbytes->length,
                                cbytes->value);
     (*ftab->releaseBuffer)(&minor, cbytes);
     return result;
@@ -616,6 +635,7 @@
     if ((*env)->ExceptionCheck(env)) {
       gssEx = (*env)->ExceptionOccurred(env);
       (*env)->Throw(env, gssEx);
+      return GSS_C_NO_OID;
     }
     cOid = malloc(sizeof(struct gss_OID_desc_struct));
     if (cOid == NULL) {
@@ -665,13 +685,12 @@
   oidHdr[0] = 6;
   oidHdr[1] = cLen;
   jbytes = (*env)->NewByteArray(env, cLen+2);
+  CHECK_NULL_RETURN(jbytes, NULL);
   (*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr);
   (*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements);
 
   result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes);
-  if ((*env)->ExceptionCheck(env)) {
-    (*env)->Throw(env, (*env)->ExceptionOccurred(env));
-  }
+  JNU_CHECK_EXCEPTION_RETURN(env, NULL);
   (*env)->DeleteLocalRef(env, jbytes);
   return result;
 }
@@ -722,6 +741,9 @@
   if (cOidSet != NULL && cOidSet != GSS_C_NO_OID_SET) {
     numOfOids = cOidSet->count;
     jOidSet = (*env)->NewObjectArray(env, numOfOids, CLS_Oid, NULL);
+    if (jOidSet == NULL) {
+      return NULL;
+    }
     if (jOidSet != NULL) {
       for (i = 0; i < numOfOids; i++) {
         jOid = getJavaOID(env, &(cOidSet->elements[i]));
@@ -736,6 +758,7 @@
 
 void debug(JNIEnv *env, char *msg) {
   jstring jmsg = (*env)->NewStringUTF(env, msg);
+  CHECK_NULL(jmsg);
   (*env)->CallStaticVoidMethod(env, CLS_SunNativeProvider,
                                MID_SunNativeProvider_debug, jmsg);
   (*env)->DeleteLocalRef(env, jmsg);
--- a/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h	Tue Feb 11 14:42:17 2014 -0800
@@ -37,7 +37,7 @@
   extern OM_uint32 getGSSTime(jint);
   extern void checkStatus(JNIEnv *, jobject, OM_uint32, OM_uint32, char*);
   extern jint checkTime(OM_uint32);
-  extern void initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t);
+  extern jint initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t);
   extern void resetGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t);
 
   extern gss_OID newGSSOID(JNIEnv *, jobject);
--- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Tue Feb 11 14:42:17 2014 -0800
@@ -48,6 +48,15 @@
  * @since   1.4
  */
 class FileSystemPreferences extends AbstractPreferences {
+
+    static {
+        PrivilegedAction<Void> load = () -> {
+            System.loadLibrary("prefs");
+            return null;
+        };
+        AccessController.doPrivileged(load);
+    }
+
     /**
      * Sync interval in seconds.
      */
@@ -868,7 +877,7 @@
 
     /**
      * 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) != '_')
--- a/jdk/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java	Tue Feb 11 14:42:17 2014 -0800
@@ -149,7 +149,7 @@
                 int afd = openat(fd, nameAsBytes(file,name), (O_RDONLY|O_XATTR), 0);
 
                 // wrap with channel
-                FileChannel fc = UnixChannelFactory.newFileChannel(afd, true, false);
+                FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), true, false);
 
                 // read to EOF (nothing we can do if I/O error occurs)
                 try {
@@ -190,7 +190,7 @@
                                  UnixFileModeAttribute.ALL_PERMISSIONS);
 
                 // wrap with channel
-                FileChannel fc = UnixChannelFactory.newFileChannel(afd, false, true);
+                FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), false, true);
 
                 // write value (nothing we can do if I/O error occurs)
                 try {
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java	Tue Feb 11 14:42:17 2014 -0800
@@ -100,10 +100,10 @@
     /**
      * Constructs a file channel from an existing (open) file descriptor
      */
-    static FileChannel newFileChannel(int fd, boolean reading, boolean writing) {
+    static FileChannel newFileChannel(int fd, String path, boolean reading, boolean writing) {
         FileDescriptor fdObj = new FileDescriptor();
         fdAccess.set(fdObj, fd);
-        return FileChannelImpl.open(fdObj, reading, writing, null);
+        return FileChannelImpl.open(fdObj, path, reading, writing, null);
     }
 
     /**
@@ -134,7 +134,7 @@
             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 
         FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
-        return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);
+        return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null);
     }
 
     /**
--- a/jdk/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -25,100 +25,10 @@
 
 package sun.util.locale.provider;
 
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.text.spi.DateFormatProvider;
-import java.util.Locale;
-
 /**
  * LocaleProviderAdapter implementation for the Unix locale data
  *
  * @author Naoto Sato
  */
 public class HostLocaleProviderAdapterImpl {
-    static Locale[] supported = {Locale.getDefault(Locale.Category.FORMAT)};
-
-    public static DateFormatProvider getDateFormatProvider() {
-        return new DateFormatProvider() {
-            String posixPattern;
-
-            @Override
-            public Locale[] getAvailableLocales() {
-                // not implemented yet
-                return new Locale[0];
-            }
-            @Override
-            public DateFormat getDateInstance(int style, Locale locale) {
-                posixPattern = getPattern(style, -1, locale.toLanguageTag());
-                return new SimpleDateFormat(convertPosixToJava(posixPattern), locale);
-            }
-            @Override
-            public DateFormat getTimeInstance(int style, Locale locale) {
-                posixPattern = getPattern(-1, style, locale.toLanguageTag());
-                return new SimpleDateFormat(convertPosixToJava(posixPattern), locale);
-            }
-            @Override
-            public DateFormat getDateTimeInstance(int dateStyle,
-                    int timeStyle, Locale locale) {
-                posixPattern = getPattern(dateStyle, timeStyle, locale.toLanguageTag());
-                return new SimpleDateFormat(convertPosixToJava(posixPattern), locale);
-            }
-        };
-    }
-
-    private static String convertPosixToJava(String posixPattern) {
-        StringBuilder sb = new StringBuilder();
-        boolean conversion = false;
-
-        for (int index = 0; index < posixPattern.length(); index++) {
-            char c = posixPattern.charAt(index);
-            if (conversion) {
-                switch (c) {
-                case 'a':
-                    sb.append("EEE");
-                    break;
-                case 'b':
-                    sb.append("MMM");
-                    break;
-                case 'e':
-                    sb.append("dd");
-                    break;
-                case 'H':
-                    sb.append("kk");
-                    break;
-                case 'M':
-                    sb.append("mm");
-                    break;
-                case 'S':
-                    sb.append("ss");
-                    break;
-                case 'Y':
-                    sb.append("yyyy");
-                    break;
-                case 'm':
-                    sb.append("MM");
-                    break;
-                case 'd':
-                    sb.append("dd");
-                    break;
-                case 'r':
-                    sb.append("hh:mm:ss aa");
-                    break;
-                case 'Z':
-                    sb.append("zzz");
-                    break;
-                }
-                conversion = false;
-            } else {
-                if (c == '%') {
-                    conversion = true;
-                } else {
-                    sb.append(c);
-                }
-            }
-        }
-        return sb.toString();
-    }
-
-    private static native String getPattern(int dateStyle, int timeStyle, String langtag);
 }
--- a/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c	Tue Feb 11 14:42:17 2014 -0800
@@ -32,6 +32,12 @@
 #include <string.h>
 #include <pwd.h>
 
+static void throwIllegalArgumentException(JNIEnv *env, const char *msg) {
+    jclass clazz = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+    if (clazz != NULL)
+        (*env)->ThrowNew(env, clazz, msg);
+}
+
 JNIEXPORT void JNICALL
 Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo
                                                 (JNIEnv *env, jobject obj) {
@@ -51,7 +57,7 @@
 
     if (groups == NULL) {
         jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
-        if(cls != 0)
+        if (cls != NULL)
             (*env)->ThrowNew(env, cls, NULL);
         return;
     }
@@ -67,15 +73,14 @@
          */
         fid = (*env)->GetFieldID(env, cls, "username", "Ljava/lang/String;");
         if (fid == 0) {
-            jclass newExcCls =
-                (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-            if (newExcCls == 0) {
-                /* Unable to find the new exception class, give up. */
-                return;
-            }
-            (*env)->ThrowNew(env, newExcCls, "invalid field: username");
+            (*env)->ExceptionClear(env);
+            throwIllegalArgumentException(env, "invalid field: username");
+            goto cleanupAndReturn;
         }
         jstr = (*env)->NewStringUTF(env, pwd.pw_name);
+        if (jstr == NULL) {
+            goto cleanupAndReturn;
+        }
         (*env)->SetObjectField(env, obj, fid, jstr);
 
         /*
@@ -83,13 +88,9 @@
          */
         fid = (*env)->GetFieldID(env, cls, "uid", "J");
         if (fid == 0) {
-            jclass newExcCls =
-                (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-            if (newExcCls == 0) {
-                /* Unable to find the new exception class, give up. */
-                return;
-            }
-            (*env)->ThrowNew(env, newExcCls, "invalid field: username");
+            (*env)->ExceptionClear(env);
+            throwIllegalArgumentException(env, "invalid field: uid");
+            goto cleanupAndReturn;
         }
         (*env)->SetLongField(env, obj, fid, pwd.pw_uid);
 
@@ -98,13 +99,9 @@
          */
         fid = (*env)->GetFieldID(env, cls, "gid", "J");
         if (fid == 0) {
-            jclass newExcCls =
-                (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-            if (newExcCls == 0) {
-                /* Unable to find the new exception class, give up. */
-                return;
-            }
-            (*env)->ThrowNew(env, newExcCls, "invalid field: username");
+            (*env)->ExceptionClear(env);
+            throwIllegalArgumentException(env, "invalid field: gid");
+            goto cleanupAndReturn;
         }
         (*env)->SetLongField(env, obj, fid, pwd.pw_gid);
 
@@ -113,21 +110,26 @@
          */
         fid = (*env)->GetFieldID(env, cls, "groups", "[J");
         if (fid == 0) {
-            jclass newExcCls =
-                (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-            if (newExcCls == 0) {
-                /* Unable to find the new exception class, give up. */
-                return;
-            }
-            (*env)->ThrowNew(env, newExcCls, "invalid field: username");
+            (*env)->ExceptionClear(env);
+            throwIllegalArgumentException(env, "invalid field: groups");
+            goto cleanupAndReturn;
         }
 
         jgroups = (*env)->NewLongArray(env, numSuppGroups);
+        if (jgroups == NULL) {
+            goto cleanupAndReturn;
+        }
         jgroupsAsArray = (*env)->GetLongArrayElements(env, jgroups, 0);
+        if (jgroupsAsArray == NULL) {
+            goto cleanupAndReturn;
+        }
         for (i = 0; i < numSuppGroups; i++)
             jgroupsAsArray[i] = groups[i];
         (*env)->ReleaseLongArrayElements(env, jgroups, jgroupsAsArray, 0);
         (*env)->SetObjectField(env, obj, fid, jgroups);
     }
+cleanupAndReturn:
+    free(groups);
+
     return;
 }
--- a/jdk/src/solaris/native/com/sun/security/auth/module/Unix.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/native/com/sun/security/auth/module/Unix.c	Tue Feb 11 14:42:17 2014 -0800
@@ -60,7 +60,7 @@
     groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t));
     if (groups == NULL) {
         jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError");
-        if(cls != 0)
+        if (cls != NULL)
             (*env)->ThrowNew(env, cls, NULL);
         return;
     }
@@ -90,6 +90,8 @@
             goto cleanUpAndReturn;
 
         jstr = (*env)->NewStringUTF(env, pwd->pw_name);
+        if (jstr == NULL)
+            goto cleanUpAndReturn;
         (*env)->SetObjectField(env, obj, userNameID, jstr);
 
         (*env)->SetLongField(env, obj, userID, pwd->pw_uid);
@@ -97,7 +99,11 @@
         (*env)->SetLongField(env, obj, groupID, pwd->pw_gid);
 
         jgroups = (*env)->NewLongArray(env, numSuppGroups);
+        if (jgroups == NULL)
+            goto cleanUpAndReturn;
         jgroupsAsArray = (*env)->GetLongArrayElements(env, jgroups, 0);
+        if (jgroupsAsArray == NULL)
+            goto cleanUpAndReturn;
         for (i = 0; i < numSuppGroups; i++)
             jgroupsAsArray[i] = groups[i];
         (*env)->ReleaseLongArrayElements(env, jgroups, jgroupsAsArray, 0);
--- a/jdk/src/solaris/native/common/jni_util_md.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/native/common/jni_util_md.c	Tue Feb 11 14:42:17 2014 -0800
@@ -29,14 +29,6 @@
 #include "jni_util.h"
 #include "dlfcn.h"
 
-jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
-    return NULL;
-}
-
-char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
-    return NULL;
-}
-
 void* getProcessHandle() {
     static void *procHandle = NULL;
     if (procHandle != NULL) {
--- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c	Tue Feb 11 14:42:17 2014 -0800
@@ -66,27 +66,27 @@
  */
 JNIEXPORT jstring JNICALL
 Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
+    int ret;
     char hostname[NI_MAXHOST+1];
 
     hostname[0] = '\0';
-    if (JVM_GetHostName(hostname, sizeof(hostname))) {
+    ret = JVM_GetHostName(hostname, sizeof(hostname));
+    if (ret) {
         /* Something went wrong, maybe networking is not setup? */
         strcpy(hostname, "localhost");
     } else {
         // ensure null-terminated
         hostname[NI_MAXHOST] = '\0';
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
-        /* On Linux/FreeBSD gethostname() says "host.domain.sun.com".  On
-         * Solaris gethostname() says "host", so extra work is needed.
-         */
-#else
+    }
+
+#if defined(__solaris__) && defined(AF_INET6)
+    if (ret == 0) {
         /* Solaris doesn't want to give us a fully qualified domain name.
          * We do a reverse lookup to try and get one.  This works
          * if DNS occurs before NIS in /etc/resolv.conf, but fails
          * if NIS comes first (it still gets only a partial name).
          * We use thread-safe system calls.
          */
-#ifdef AF_INET6
         struct addrinfo  hints, *res;
         int error;
 
@@ -111,9 +111,9 @@
 
             freeaddrinfo(res);
         }
-#endif /* AF_INET6 */
-#endif /* __linux__ || _ALLBSD_SOURCE */
     }
+#endif
+
     return (*env)->NewStringUTF(env, hostname);
 }
 
@@ -402,7 +402,7 @@
         }
 
         while (iterator != NULL) {
-            int ret1;
+            jboolean ret1;
             if (iterator->ai_family == AF_INET) {
                 jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
                 if (IS_NULL(iaObj)) {
@@ -422,7 +422,7 @@
                     goto cleanupAndReturn;
                 }
                 ret1 = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
-                if (!ret1) {
+                if (ret1 == JNI_FALSE) {
                     ret = NULL;
                     goto cleanupAndReturn;
                 }
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c	Tue Feb 11 14:42:17 2014 -0800
@@ -677,7 +677,7 @@
             int scope=0;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
             if (iaObj) {
-                int ret = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr));
+                jboolean ret = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr));
                 if (ret == JNI_FALSE) {
                     return NULL;
                 }
--- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Tue Feb 11 14:42:17 2014 -0800
@@ -506,6 +506,7 @@
     }
     if (IS_NULL(addressObj)) {
         JNU_ThrowNullPointerException(env, "Null address in peek()");
+        return -1;
     }
     if (timeout) {
         int ret = NET_Timeout(fd, timeout);
@@ -1419,7 +1420,7 @@
         default :
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                 "Socket option not supported by PlainDatagramSocketImp");
-            break;
+            return;
 
     }
 
@@ -1833,6 +1834,7 @@
 #ifdef AF_INET6
 #ifdef __linux__
     setTTL(env, fd, ttl);
+    JNU_CHECK_EXCEPTION(env);
     if (ipv6_available()) {
         setHopLimit(env, fd, ttl);
     }
@@ -2120,6 +2122,7 @@
                     else
                         NET_ThrowCurrent(env, "setsockopt IP_DROP_MEMBERSHIP failed");
                 }
+                return;
             }
         }
 
@@ -2156,7 +2159,7 @@
             caddr[14] = ((address >> 8) & 0xff);
             caddr[15] = (address & 0xff);
         } else {
-            getInet6Address_ipaddress(env, iaObj, caddr);
+            getInet6Address_ipaddress(env, iaObj, (char*)caddr);
         }
 
         memcpy((void *)&(mname6.ipv6mr_multiaddr), caddr, sizeof(struct in6_addr));
--- a/jdk/src/solaris/native/java/util/FileSystemPreferences.c	Tue Feb 11 12:40:16 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-/*
- * Solaris/Linux platform specific code to support the Prefs API.
- */
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <utime.h>
-#include "jni_util.h"
-
-JNIEXPORT jint JNICALL
-Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env,
-                       jclass thisclass, jstring java_fname, jint permission) {
-    const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
-    int result = -1;
-    if (fname) {
-        result =  chmod(fname, permission);
-        if (result != 0)
-            result = errno;
-        JNU_ReleaseStringPlatformChars(env, java_fname, fname);
-    }
-    return (jint) result;
-}
-
-#if defined(_ALLBSD_SOURCE)
-typedef struct flock FLOCK;
-#else
-typedef struct flock64 FLOCK;
-#endif
-
-/**
- * Try to open a named lock file.
- * The result is a cookie that can be used later to unlock the file.
- * On failure the result is zero.
- */
-JNIEXPORT jintArray JNICALL
-Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env,
-    jclass thisclass, jstring java_fname, jint permission, jboolean shared) {
-    const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
-    int fd, rc;
-    int result[2];
-    jintArray javaResult = NULL;
-    int old_umask;
-    FLOCK fl;
-
-    if (!fname)
-        return javaResult;
-
-    fl.l_whence = SEEK_SET;
-    fl.l_len = 0;
-    fl.l_start = 0;
-    if (shared == JNI_TRUE) {
-        fl.l_type = F_RDLCK;
-    } else {
-        fl.l_type = F_WRLCK;
-    }
-
-    if (shared == JNI_TRUE) {
-        fd = open(fname, O_RDONLY, 0);
-    } else {
-        old_umask = umask(0);
-        fd = open(fname, O_WRONLY|O_CREAT, permission);
-        result[1] = errno;
-        umask(old_umask);
-    }
-
-    if (fd < 0) {
-        result[0] = 0;
-    } else {
-#if defined(_ALLBSD_SOURCE)
-        rc = fcntl(fd, F_SETLK, &fl);
-#else
-        rc = fcntl(fd, F_SETLK64, &fl);
-#endif
-        result[1] = errno;
-        if (rc < 0) {
-            result[0]= 0;
-            close(fd);
-        } else {
-          result[0] = fd;
-        }
-    }
-    JNU_ReleaseStringPlatformChars(env, java_fname, fname);
-    javaResult = (*env)->NewIntArray(env,2);
-    if (javaResult)
-        (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result);
-    return javaResult;
-}
-
-
-/**
- * Try to unlock a lock file, using a cookie returned by lockFile.
- */
-JNIEXPORT jint JNICALL
-Java_java_util_prefs_FileSystemPreferences_unlockFile0(JNIEnv *env,
-                                      jclass thisclass, jint fd) {
-
-    int rc;
-    FLOCK fl;
-    fl.l_whence = SEEK_SET;
-    fl.l_len = 0;
-    fl.l_start = 0;
-    fl.l_type = F_UNLCK;
-
-#if defined(_ALLBSD_SOURCE)
-    rc = fcntl(fd, F_SETLK, &fl);
-#else
-    rc = fcntl(fd, F_SETLK64, &fl);
-#endif
-
-    if (rc < 0) {
-        close(fd);
-        return (jint)errno;
-    }
-    rc = close(fd);
-    if (rc < 0) {
-        return (jint) errno;
-    }
-    return 0;
-}
--- a/jdk/src/solaris/native/java/util/logging.c	Tue Feb 11 12:40:16 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2001, 2004, 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.
- */
-
-/*
- * Solaris/Linux specific code to support logging.
- */
-
-#include <unistd.h>
-#include "jni_util.h"
-
-
-JNIEXPORT jboolean JNICALL
-Java_java_util_logging_FileHandler_isSetUID(JNIEnv *env, jclass thisclass) {
-
-    /* Return true if we are in a set UID or set GID process. */
-    if (getuid() != geteuid() || getgid() != getegid()) {
-        return JNI_TRUE;
-    }
-    return JNI_FALSE;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/java/util/prefs/FileSystemPreferences.c	Tue Feb 11 14:42:17 2014 -0800
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2001, 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.
+ */
+
+/*
+ * Solaris/Linux platform specific code to support the Prefs API.
+ */
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <utime.h>
+#include "jni_util.h"
+
+JNIEXPORT jint JNICALL
+Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env,
+                       jclass thisclass, jstring java_fname, jint permission) {
+    const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
+    int result = -1;
+    if (fname) {
+        result =  chmod(fname, permission);
+        if (result != 0)
+            result = errno;
+        JNU_ReleaseStringPlatformChars(env, java_fname, fname);
+    }
+    return (jint) result;
+}
+
+#if defined(_ALLBSD_SOURCE)
+typedef struct flock FLOCK;
+#else
+typedef struct flock64 FLOCK;
+#endif
+
+/**
+ * Try to open a named lock file.
+ * The result is a cookie that can be used later to unlock the file.
+ * On failure the result is zero.
+ */
+JNIEXPORT jintArray JNICALL
+Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env,
+    jclass thisclass, jstring java_fname, jint permission, jboolean shared) {
+    const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
+    int fd, rc;
+    int result[2];
+    jintArray javaResult = NULL;
+    int old_umask;
+    FLOCK fl;
+
+    if (!fname)
+        return javaResult;
+
+    fl.l_whence = SEEK_SET;
+    fl.l_len = 0;
+    fl.l_start = 0;
+    if (shared == JNI_TRUE) {
+        fl.l_type = F_RDLCK;
+    } else {
+        fl.l_type = F_WRLCK;
+    }
+
+    if (shared == JNI_TRUE) {
+        fd = open(fname, O_RDONLY, 0);
+    } else {
+        old_umask = umask(0);
+        fd = open(fname, O_WRONLY|O_CREAT, permission);
+        result[1] = errno;
+        umask(old_umask);
+    }
+
+    if (fd < 0) {
+        result[0] = 0;
+    } else {
+#if defined(_ALLBSD_SOURCE)
+        rc = fcntl(fd, F_SETLK, &fl);
+#else
+        rc = fcntl(fd, F_SETLK64, &fl);
+#endif
+        result[1] = errno;
+        if (rc < 0) {
+            result[0]= 0;
+            close(fd);
+        } else {
+          result[0] = fd;
+        }
+    }
+    JNU_ReleaseStringPlatformChars(env, java_fname, fname);
+    javaResult = (*env)->NewIntArray(env,2);
+    if (javaResult)
+        (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result);
+    return javaResult;
+}
+
+
+/**
+ * Try to unlock a lock file, using a cookie returned by lockFile.
+ */
+JNIEXPORT jint JNICALL
+Java_java_util_prefs_FileSystemPreferences_unlockFile0(JNIEnv *env,
+                                      jclass thisclass, jint fd) {
+
+    int rc;
+    FLOCK fl;
+    fl.l_whence = SEEK_SET;
+    fl.l_len = 0;
+    fl.l_start = 0;
+    fl.l_type = F_UNLCK;
+
+#if defined(_ALLBSD_SOURCE)
+    rc = fcntl(fd, F_SETLK, &fl);
+#else
+    rc = fcntl(fd, F_SETLK64, &fl);
+#endif
+
+    if (rc < 0) {
+        close(fd);
+        return (jint)errno;
+    }
+    rc = close(fd);
+    if (rc < 0) {
+        return (jint) errno;
+    }
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/misc/VM_md.c	Tue Feb 11 14:42:17 2014 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2001, 2004, 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 <unistd.h>
+#include "jni_util.h"
+
+
+JNIEXPORT jboolean JNICALL
+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()) {
+        return JNI_TRUE;
+    }
+    return JNI_FALSE;
+}
--- a/jdk/src/solaris/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Tue Feb 11 12:40:16 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2012, 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 "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h"
-#include <gdefs.h>
-#include <string.h>
-#include <langinfo.h>
-#include <locale.h>
-
-#define BUFLEN 64
-
-/*
- * Class:     sun_util_locale_provider_HostLocaleProviderAdapterImpl
- * Method:    getPattern
- * Signature: (IILjava/lang/String;)Ljava/lang/String;
- */
-JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPattern
-  (JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) {
-
-    // TEMPORARY!
-    char locale[BUFLEN];
-    char * pch;
-    char * old;
-    char * ret;
-    const char *langtag = (*env)->GetStringUTFChars(env, jlangtag, JNI_FALSE);
-
-    strcpy(locale, langtag);
-    pch = strchr(locale, '-');
-    if (pch != NULL) {
-        *pch = '_';
-    }
-    pch = strchr(locale, '-');
-    if (pch != NULL) {
-        *pch = '\0';
-    }
-    strcat(locale, ".UTF-8");
-    old = setlocale(LC_TIME, "");
-    setlocale(LC_TIME, locale);
-
-    if (dateStyle != (-1) && timeStyle != (-1)) {
-        ret = nl_langinfo(D_T_FMT);
-    } else if (dateStyle != (-1)) {
-        ret = nl_langinfo(D_FMT);
-    } else if (timeStyle != (-1)) {
-        ret = nl_langinfo(T_FMT);
-    } else {
-        ret = "yyyy/MM/dd";
-    }
-
-    setlocale(LC_TIME, old);
-
-    (*env)->ReleaseStringUTFChars(env, jlangtag, langtag);
-
-    return (*env)->NewStringUTF(env, ret);
-}
--- a/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java	Tue Feb 11 14:42:17 2014 -0800
@@ -29,6 +29,9 @@
 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 @@
 
 class WindowsPreferences extends AbstractPreferences{
 
+    static {
+        PrivilegedAction<Void> load = () -> {
+            System.loadLibrary("prefs");
+            return null;
+        };
+        AccessController.doPrivileged(load);
+    }
+
     /**
      * Logger for error messages
      */
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java	Tue Feb 11 14:42:17 2014 -0800
@@ -25,19 +25,22 @@
 
 package sun.nio.fs;
 
-import java.nio.file.*;
-import java.nio.channels.*;
 import java.io.FileDescriptor;
 import java.io.IOException;
-import java.util.*;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.FileChannel;
+import java.nio.file.LinkOption;
+import java.nio.file.OpenOption;
+import java.nio.file.StandardOpenOption;
+import java.util.Set;
 
 import com.sun.nio.file.ExtendedOpenOption;
 
+import sun.misc.JavaIOFileDescriptorAccess;
+import sun.misc.SharedSecrets;
 import sun.nio.ch.FileChannelImpl;
 import sun.nio.ch.ThreadPool;
 import sun.nio.ch.WindowsAsynchronousFileChannelImpl;
-import sun.misc.SharedSecrets;
-import sun.misc.JavaIOFileDescriptorAccess;
 
 import static sun.nio.fs.WindowsNativeDispatcher.*;
 import static sun.nio.fs.WindowsConstants.*;
@@ -157,7 +160,7 @@
             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 
         FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
-        return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);
+        return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null);
     }
 
     /**
--- a/jdk/src/windows/native/com/sun/security/auth/module/nt.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/com/sun/security/auth/module/nt.c	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -43,6 +43,12 @@
 BOOL getTextualSid(PSID pSid, LPTSTR TextualSid, LPDWORD lpdwBufferLen);
 void DisplayErrorText(DWORD dwLastError);
 
+static void throwIllegalArgumentException(JNIEnv *env, const char *msg) {
+    jclass clazz = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+    if (clazz != NULL)
+        (*env)->ThrowNew(env, clazz, msg);
+}
+
 JNIEXPORT jlong JNICALL
 Java_com_sun_security_auth_module_NTSystem_getImpersonationToken0
         (JNIEnv *env, jobject obj) {
@@ -62,7 +68,6 @@
 
     long i, j = 0;
     HANDLE tokenHandle = INVALID_HANDLE_VALUE;
-    BOOL systemError = FALSE;
 
     LPTSTR userName = NULL;             // user name
     LPTSTR userSid = NULL;              // user sid
@@ -116,70 +121,59 @@
 
     fid = (*env)->GetFieldID(env, cls, "userName", "Ljava/lang/String;");
     if (fid == 0) {
-        jclass newExcCls =
-            (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-        if (newExcCls == 0) {
-            // Unable to find exception class
-            systemError = TRUE;
-            goto out;
-        }
-        (*env)->ThrowNew(env, newExcCls, "invalid field: userName");
+        (*env)->ExceptionClear(env);
+        throwIllegalArgumentException(env, "invalid field: userName");
+        goto cleanup;
     }
     jstr = (*env)->NewStringUTF(env, userName);
+    if (jstr == NULL)
+        goto cleanup;
     (*env)->SetObjectField(env, obj, fid, jstr);
 
     fid = (*env)->GetFieldID(env, cls, "userSID", "Ljava/lang/String;");
     if (fid == 0) {
-        jclass newExcCls =
-            (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-        if (newExcCls == 0) {
-            systemError = TRUE;
-            goto out;
-        }
-        (*env)->ThrowNew(env, newExcCls, "invalid field: userSID");
+        (*env)->ExceptionClear(env);
+        throwIllegalArgumentException(env, "invalid field: userSID");
+        goto cleanup;
     }
     jstr = (*env)->NewStringUTF(env, userSid);
+    if (jstr == NULL)
+        goto cleanup;
     (*env)->SetObjectField(env, obj, fid, jstr);
 
     fid = (*env)->GetFieldID(env, cls, "domain", "Ljava/lang/String;");
     if (fid == 0) {
-        jclass newExcCls =
-            (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-        if (newExcCls == 0) {
-            systemError = TRUE;
-            goto out;
-        }
-        (*env)->ThrowNew(env, newExcCls, "invalid field: domain");
+        (*env)->ExceptionClear(env);
+        throwIllegalArgumentException(env, "invalid field: domain");
+        goto cleanup;
     }
     jstr = (*env)->NewStringUTF(env, domainName);
+    if (jstr == NULL)
+        goto cleanup;
     (*env)->SetObjectField(env, obj, fid, jstr);
 
     if (domainSid != NULL) {
         fid = (*env)->GetFieldID(env, cls, "domainSID", "Ljava/lang/String;");
         if (fid == 0) {
-            jclass newExcCls =
-                (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-            if (newExcCls == 0) {
-                systemError = TRUE;
-                goto out;
-            }
-            (*env)->ThrowNew(env, newExcCls, "invalid field: domainSID");
+            (*env)->ExceptionClear(env);
+            throwIllegalArgumentException(env, "invalid field: domainSID");
+            goto cleanup;
         }
         jstr = (*env)->NewStringUTF(env, domainSid);
+        if (jstr == NULL)
+            goto cleanup;
         (*env)->SetObjectField(env, obj, fid, jstr);
     }
 
     fid = (*env)->GetFieldID(env, cls, "primaryGroupID", "Ljava/lang/String;");
     if (fid == 0) {
-        jclass newExcCls =
-            (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-        if (newExcCls == 0) {
-            systemError = TRUE;
-            goto out;
-        }
-        (*env)->ThrowNew(env, newExcCls, "invalid field: PrimaryGroupID");
+        (*env)->ExceptionClear(env);
+        throwIllegalArgumentException(env, "invalid field: PrimaryGroupID");
+        goto cleanup;
     }
     jstr = (*env)->NewStringUTF(env, primaryGroup);
+    if (jstr == NULL)
+        goto cleanup;
     (*env)->SetObjectField(env, obj, fid, jstr);
 
     // primary group may or may not be part of supplementary groups
@@ -204,19 +198,14 @@
 
         fid = (*env)->GetFieldID(env, cls, "groupIDs", "[Ljava/lang/String;");
         if (fid == 0) {
-            jclass newExcCls =
-                (*env)->FindClass(env, "java/lang/IllegalArgumentException");
-            if (newExcCls == 0) {
-                systemError = TRUE;
-                goto out;
-            }
-            (*env)->ThrowNew(env, newExcCls, "invalid field: groupIDs");
+            (*env)->ExceptionClear(env);
+            throwIllegalArgumentException(env, "groupIDs");
+            goto cleanup;
         }
 
         stringClass = (*env)->FindClass(env, "java/lang/String");
-        if (stringClass == 0) {
-            goto out;
-        }
+        if (stringClass == NULL)
+            goto cleanup;
 
         if (pIndex == -1) {
             // primary group not in groups array
@@ -226,6 +215,8 @@
             // allocate one less array entry and do not add into new array
             jgroups = (*env)->NewObjectArray(env, numGroups-1, stringClass, 0);
         }
+        if (jgroups == NULL)
+            goto cleanup;
 
         for (i = 0, j = 0; i < (long)numGroups; i++) {
             if (pIndex == i) {
@@ -233,12 +224,14 @@
                 continue;
             }
             jstr = (*env)->NewStringUTF(env, groups[i]);
+            if (jstr == NULL)
+                goto cleanup;
             (*env)->SetObjectArrayElement(env, jgroups, j++, jstr);
         }
         (*env)->SetObjectField(env, obj, fid, jgroups);
     }
 
-out:
+cleanup:
     if (userName != NULL) {
         HeapFree(GetProcessHeap(), 0, userName);
     }
@@ -264,11 +257,6 @@
     }
     CloseHandle(tokenHandle);
 
-    if (systemError && debug) {
-        printf("  [getCurrent] System Error: ");
-        printf("unable to find IllegalArgumentException class\n");
-    }
-
     return;
 }
 
@@ -336,7 +324,7 @@
             DisplayErrorText(GetLastError());
         }
         error = TRUE;
-        goto out;
+        goto cleanup;
     }
 
     if (debug) {
@@ -369,7 +357,7 @@
             DisplayErrorText(GetLastError());
         }
         error = TRUE;
-        goto out;
+        goto cleanup;
     }
 
     if (debug) {
@@ -411,7 +399,7 @@
             DisplayErrorText(GetLastError());
         }
         // ok not to have a domain SID (no error)
-        goto out;
+        goto cleanup;
     }
 
     bufSize = 0;
@@ -422,7 +410,7 @@
         printf("  [getUser] domainSid: %s\n", *domainSid);
     }
 
-out:
+cleanup:
     if (tokenUserInfo != NULL) {
         HeapFree(GetProcessHeap(), 0, tokenUserInfo);
     }
@@ -466,7 +454,7 @@
             DisplayErrorText(GetLastError());
         }
         error = TRUE;
-        goto out;
+        goto cleanup;
     }
 
     if (debug) {
@@ -481,7 +469,7 @@
         printf("  [getPrimaryGroup] primaryGroup: %s\n", *primaryGroup);
     }
 
-out:
+cleanup:
     if (tokenGroupInfo != NULL) {
         HeapFree(GetProcessHeap(), 0, tokenGroupInfo);
     }
@@ -519,7 +507,7 @@
             DisplayErrorText(GetLastError());
         }
         error = TRUE;
-        goto out;
+        goto cleanup;
     }
 
     if (debug) {
@@ -528,7 +516,7 @@
 
     if (tokenGroupInfo->GroupCount == 0) {
         // no groups
-        goto out;
+        goto cleanup;
     }
 
     // return group info
@@ -545,7 +533,7 @@
         }
     }
 
-out:
+cleanup:
     if (tokenGroupInfo != NULL) {
         HeapFree(GetProcessHeap(), 0, tokenGroupInfo);
     }
@@ -589,7 +577,8 @@
     CloseHandle(dupToken);
 
     if (debug) {
-        printf("  [getImpersonationToken] token = %d\n", *impersonationToken);
+        printf("  [getImpersonationToken] token = %p\n",
+            (void *)*impersonationToken);
     }
     return TRUE;
 }
--- a/jdk/src/windows/native/common/jni_util_md.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/common/jni_util_md.c	Tue Feb 11 14:42:17 2014 -0800
@@ -42,102 +42,6 @@
     *lastSlash = 0;
 }
 
-BOOL useNativeConverter(JNIEnv *env) {
-    static BOOL initialized;
-    static BOOL useNative;
-    if (!initialized) {
-        HMODULE jvm = GetModuleHandle("jvm");
-        useNative = FALSE;
-        if (jvm != NULL) {
-            TCHAR *jvmPath = NULL;
-            int bufferSize = MAX_PATH;
-            while (jvmPath == NULL) {
-                DWORD result;
-                jvmPath = malloc(bufferSize);
-                if (jvmPath == NULL)
-                    return FALSE;
-                result = GetModuleFileName(jvm, jvmPath, bufferSize);
-                if (result == 0)
-                    return FALSE;
-                if (result == bufferSize) { // didn't fit
-                    bufferSize += MAX_PATH; // increase buffer size, try again
-                    free(jvmPath);
-                    jvmPath = NULL;
-                }
-            }
-
-            getParent(jvmPath, jvmPath);
-            useNative = (!strcmp("kernel", jvmPath + strlen(jvmPath) -
-                    strlen("kernel"))); // true if jvm.dll lives in "kernel"
-            if (useNative)
-                setlocale(LC_ALL, "");
-            free(jvmPath);
-        }
-        initialized = TRUE;
-    }
-    return useNative;
-}
-
-jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
-    static jmethodID String_char_constructor;
-    if (useNativeConverter(env)) {
-        // use native Unicode conversion so Kernel isn't required during
-        // System.initProperties
-        jcharArray chars = 0;
-        wchar_t *utf16;
-        int len;
-        jstring result = NULL;
-
-        if (getFastEncoding() == NO_ENCODING_YET)
-            initializeEncoding(env);
-
-        len = mbstowcs(NULL, str, strlen(str));
-        if (len == -1)
-            return NULL;
-        utf16 = calloc(len + 1, 2);
-        if (mbstowcs(utf16, str, len) == -1)
-            return NULL;
-        chars = (*env)->NewCharArray(env, len);
-        if (chars == NULL)
-            return NULL;
-        (*env)->SetCharArrayRegion(env, chars, 0, len, utf16);
-        if (String_char_constructor == NULL)
-            String_char_constructor = (*env)->GetMethodID(env,
-                    JNU_ClassString(env), "<init>", "([C)V");
-        result = (*env)->NewObject(env, JNU_ClassString(env),
-                String_char_constructor, chars);
-        free(utf16);
-        return result;
-    }
-    else
-        return NULL;
-}
-
-
-char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
-    if (useNativeConverter(env)) {
-        // use native Unicode conversion so Kernel isn't required during
-        // System.initProperties
-        char *result = NULL;
-        size_t len;
-        const jchar* utf16 = (*env)->GetStringChars(env, jstr, NULL);
-        len = wcstombs(NULL, utf16, (*env)->GetStringLength(env, jstr) * 4) + 1;
-        if (len == -1)
-            return NULL;
-        result = (char*) malloc(len);
-        if (result != NULL) {
-            if (wcstombs(result, utf16, len) == -1)
-                return NULL;
-            (*env)->ReleaseStringChars(env, jstr, utf16);
-            if (isCopy)
-                *isCopy = JNI_TRUE;
-        }
-        return result;
-    }
-    else
-        return NULL;
-}
-
 void* getProcessHandle() {
     return (void*)GetModuleHandle(NULL);
 }
--- a/jdk/src/windows/native/java/lang/java_props_md.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/java/lang/java_props_md.c	Tue Feb 11 14:42:17 2014 -0800
@@ -28,6 +28,9 @@
 #define _WIN32_WINNT 0x0601
 #endif
 
+#include "jni.h"
+#include "jni_util.h"
+
 #include <windows.h>
 #include <shlobj.h>
 #include <objidl.h>
@@ -51,7 +54,7 @@
 #endif
 
 typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
-static void SetupI18nProps(LCID lcid, char** language, char** script, char** country,
+static boolean SetupI18nProps(LCID lcid, char** language, char** script, char** country,
                char** variant, char** encoding);
 
 #define PROPSIZE 9      // eight-letter + null terminator
@@ -60,8 +63,11 @@
 static char *
 getEncodingInternal(LCID lcid)
 {
+    int codepage;
     char * ret = malloc(16);
-    int codepage;
+    if (ret == NULL) {
+        return NULL;
+    }
 
     if (GetLocaleInfo(lcid,
                       LOCALE_IDEFAULTANSICODEPAGE,
@@ -132,7 +138,11 @@
 static char* getConsoleEncoding()
 {
     char* buf = malloc(16);
-    int cp = GetConsoleCP();
+    int cp;
+    if (buf == NULL) {
+        return NULL;
+    }
+    cp = GetConsoleCP();
     if (cp >= 874 && cp <= 950)
         sprintf(buf, "ms%d", cp);
     else
@@ -152,25 +162,33 @@
 getJavaIDFromLangID(LANGID langID)
 {
     char * elems[5]; // lang, script, ctry, variant, encoding
-    char * ret = malloc(SNAMESIZE);
+    char * ret;
     int index;
 
-    SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
-                   &(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]));
-
-    // there always is the "language" tag
-    strcpy(ret, elems[0]);
-
-    // append other elements, if any
-    for (index = 1; index < 4; index++) {
-        if ((elems[index])[0] != '\0') {
-            strcat(ret, "-");
-            strcat(ret, elems[index]);
-        }
+    ret = malloc(SNAMESIZE);
+    if (ret == NULL) {
+        return NULL;
     }
 
-    for (index = 0; index < 5; index++) {
-        free(elems[index]);
+    if (SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
+                   &(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]))) {
+
+        // there always is the "language" tag
+        strcpy(ret, elems[0]);
+
+        // append other elements, if any
+        for (index = 1; index < 4; index++) {
+            if ((elems[index])[0] != '\0') {
+                strcat(ret, "-");
+                strcat(ret, elems[index]);
+            }
+        }
+
+        for (index = 0; index < 5; index++) {
+            free(elems[index]);
+        }
+    } else {
+        ret = NULL;
     }
 
     return ret;
@@ -259,12 +277,15 @@
     return NULL;
 }
 
-static void
+static boolean
 SetupI18nProps(LCID lcid, char** language, char** script, char** country,
                char** variant, char** encoding) {
     /* script */
     char tmp[SNAMESIZE];
     *script = malloc(PROPSIZE);
+    if (*script == NULL) {
+        return FALSE;
+    }
     if (GetLocaleInfo(lcid,
                       LOCALE_SNAME, tmp, SNAMESIZE) == 0 ||
         sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 ||
@@ -274,6 +295,9 @@
 
     /* country */
     *country = malloc(PROPSIZE);
+    if (*country == NULL) {
+        return FALSE;
+    }
     if (GetLocaleInfo(lcid,
                       LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 &&
         GetLocaleInfo(lcid,
@@ -283,6 +307,9 @@
 
     /* language */
     *language = malloc(PROPSIZE);
+    if (*language == NULL) {
+        return FALSE;
+    }
     if (GetLocaleInfo(lcid,
                       LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 &&
         GetLocaleInfo(lcid,
@@ -294,6 +321,9 @@
 
     /* variant */
     *variant = malloc(PROPSIZE);
+    if (*variant == NULL) {
+        return FALSE;
+    }
     (*variant)[0] = '\0';
 
     /* handling for Norwegian */
@@ -308,6 +338,10 @@
 
     /* encoding */
     *encoding = getEncodingInternal(lcid);
+    if (*encoding == NULL) {
+        return FALSE;
+    }
+    return TRUE;
 }
 
 java_props_t *
--- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c	Tue Feb 11 14:42:17 2014 -0800
@@ -221,14 +221,14 @@
               (*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
                 inetIndex ++;
             } else if (iterator->ai_family == AF_INET6) {
-              jint scope = 0, ret1;
+              jint scope = 0;
+              jboolean ret1;
               jobject iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
               if (IS_NULL(iaObj)) {
                 ret = NULL;
                 goto cleanupAndReturn;
               }
               ret1 = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
-
               if (ret1 == JNI_FALSE) {
                 ret = NULL;
                 goto cleanupAndReturn;
--- a/jdk/src/windows/native/java/net/NetworkInterface.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/java/net/NetworkInterface.c	Tue Feb 11 14:42:17 2014 -0800
@@ -614,7 +614,7 @@
             int scope;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
             if (iaObj) {
-                int ret = setInet6Address_ipaddress(env, iaObj,  (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
+                jboolean ret = setInet6Address_ipaddress(env, iaObj,  (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
                 if (ret == JNI_FALSE) {
                     return NULL;
                 }
--- a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c	Tue Feb 11 14:42:17 2014 -0800
@@ -549,7 +549,7 @@
             int scope;
             iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
             if (iaObj) {
-                int ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
+                jboolean ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
                 if (ret == JNI_FALSE) {
                     return NULL;
                 }
--- a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c	Tue Feb 11 14:42:17 2014 -0800
@@ -1646,6 +1646,7 @@
 }
 
 static int isAdapterIpv6Enabled(JNIEnv *env, int index) {
+  extern int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP);
   netif *ifList, *curr;
   int ipv6Enabled = 0;
   if (getAllInterfacesAndAddresses (env, &ifList) < 0) {
--- a/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c	Tue Feb 11 14:42:17 2014 -0800
@@ -575,7 +575,6 @@
 {
     /* fields on this */
     jint port;
-    jint scope;
     jint timeout = (*env)->GetIntField(env, this, psi_timeoutID);
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
     jobject fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID);
@@ -750,7 +749,7 @@
             NET_SocketClose(fd);
             return;
         }
-        setInet6Address_ipaddress(env, socketAddressObj, (const char *)&him.him6.sin6_addr);
+        setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.him6.sin6_addr);
         setInetAddress_family(env, socketAddressObj, IPv6);
         setInet6Address_scopeid(env, socketAddressObj, him.him6.sin6_scope_id);
 
--- a/jdk/src/windows/native/java/util/WindowsPreferences.c	Tue Feb 11 12:40:16 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, 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 <stdlib.h>
-#include <jni.h>
-#include <windows.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegOpenKey
-               (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey, jint securityMask) {
-        HKEY handle;
-        char* str;
-        int tmp[2];
-        int errorCode=-1;
-        jintArray result;
-        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
-        errorCode =  RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle);
-        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
-        tmp[0]= (int) handle;
-        tmp[1]= errorCode;
-        result = (*env)->NewIntArray(env,2);
-        (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
-        return result;
-    }
-
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCloseKey
-               (JNIEnv* env, jclass this_class, jint hKey) {
-        return (jint) RegCloseKey((HKEY) hKey);
-    };
-
-    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCreateKeyEx
-               (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) {
-        HKEY handle;
-        char* str;
-        int tmp[3];
-        DWORD lpdwDisposition;
-        int errorCode;
-        jintArray result;
-        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
-        errorCode =  RegCreateKeyEx((HKEY)hKey, str, 0, NULL,
-                      REG_OPTION_NON_VOLATILE, KEY_READ,
-                      NULL, &handle, &lpdwDisposition);
-        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
-        tmp[0]= (int) handle;
-        tmp[1]= errorCode;
-        tmp[2]= lpdwDisposition;
-        result = (*env)->NewIntArray(env,3);
-        (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
-        return result;
-    }
-
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteKey
-              (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) {
-        char* str;
-        int result;
-        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
-        result = RegDeleteKey((HKEY)hKey, str);
-        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
-        return  result;
-
-    };
-
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegFlushKey
-        (JNIEnv* env, jclass this_class, jint hKey) {
-        return RegFlushKey ((HKEY)hKey);
-        }
-
-    JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryValueEx
-         (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) {
-        char* valueNameStr;
-        char* buffer;
-        jbyteArray result;
-        DWORD valueType;
-        DWORD valueSize;
-        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
-        if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL,
-                                                 &valueSize) != ERROR_SUCCESS) {
-        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return NULL;
-        }
-
-        buffer = (char*)malloc(valueSize);
-
-        if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
-            &valueSize) != ERROR_SUCCESS) {
-            free(buffer);
-            (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return NULL;
-        }
-
-        if (valueType == REG_SZ) {
-        result = (*env)->NewByteArray(env, valueSize);
-        (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
-        } else {
-        result = NULL;
-        }
-        free(buffer);
-        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return result;
-    }
-
-
-
-
-    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegSetValueEx
-    (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName, jbyteArray data) {
-        char* valueNameStr;
-        char* dataStr;
-        int size = -1;
-        int nameSize = -1;
-        int error_code = -1;
-        if ((valueName == NULL)||(data == NULL)) {return -1;}
-        size = (*env)->GetArrayLength(env, data);
-        dataStr = (*env)->GetByteArrayElements(env, data, NULL);
-        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
-        error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
-                                                        REG_SZ, dataStr, size);
-        (*env)->ReleaseByteArrayElements(env, data, dataStr, 0);
-        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return error_code;
-    }
-
-     JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteValue
-            (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) {
-        char* valueNameStr;
-        int error_code = -1;
-        if (valueName == NULL) {return -1;}
-        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
-        error_code = RegDeleteValue((HKEY)hKey, valueNameStr);
-        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return error_code;
-     }
-
-    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey
-                                  (JNIEnv* env, jclass this_class, jint hKey) {
-        jintArray result;
-        int tmp[5];
-        int valuesNumber = -1;
-        int maxValueNameLength = -1;
-        int maxSubKeyLength = -1;
-        int subKeysNumber = -1;
-        int errorCode = -1;
-        errorCode = RegQueryInfoKey((HKEY)hKey, NULL, NULL, NULL,
-                 &subKeysNumber, &maxSubKeyLength, NULL,
-                 &valuesNumber, &maxValueNameLength,
-                 NULL, NULL, NULL);
-        tmp[0]= subKeysNumber;
-        tmp[1]= (int)errorCode;
-        tmp[2]= valuesNumber;
-        tmp[3]= maxSubKeyLength;
-        tmp[4]= maxValueNameLength;
-        result = (*env)->NewIntArray(env,5);
-        (*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
-        return result;
-    }
-
-     JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegEnumKeyEx
-     (JNIEnv* env, jclass this_class, jint hKey , jint subKeyIndex, jint maxKeyLength) {
-        int size = maxKeyLength;
-        jbyteArray result;
-        char* buffer = NULL;
-        buffer = (char*)malloc(maxKeyLength);
-        if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL,
-                                                 NULL, NULL) != ERROR_SUCCESS){
-        free(buffer);
-        return NULL;
-        }
-        result = (*env)->NewByteArray(env, size + 1);
-        (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
-        free(buffer);
-        return result;
-     }
-
-     JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegEnumValue
-          (JNIEnv* env, jclass this_class, jint hKey , jint valueIndex, jint maxValueNameLength){
-          int size = maxValueNameLength;
-          jbyteArray result;
-          char* buffer = NULL;
-          int error_code;
-          buffer = (char*)malloc(maxValueNameLength);
-          error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer,
-                                             &size, NULL, NULL, NULL, NULL);
-          if (error_code!= ERROR_SUCCESS){
-            free(buffer);
-            return NULL;
-          }
-          result = (*env)->NewByteArray(env, size + 1);
-          (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
-          free(buffer);
-          return result;
-     }
-
-
-#ifdef __cplusplus
-}
-#endif
--- a/jdk/src/windows/native/java/util/logging.c	Tue Feb 11 12:40:16 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-/*
- * Win32 specific code to support logging.
- */
-
-#include "jni_util.h"
-
-
-JNIEXPORT jboolean JNICALL
-Java_java_util_logging_FileHandler_isSetUID(JNIEnv *env, jclass thisclass) {
-
-    /* There is no set UID on Windows. */
-    return JNI_FALSE;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/java/util/prefs/WindowsPreferences.c	Tue Feb 11 14:42:17 2014 -0800
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2000, 2002, 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 <stdlib.h>
+#include <jni.h>
+#include <windows.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegOpenKey
+               (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey, jint securityMask) {
+        HKEY handle;
+        char* str;
+        int tmp[2];
+        int errorCode=-1;
+        jintArray result;
+        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+        errorCode =  RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle);
+        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
+        tmp[0]= (int) handle;
+        tmp[1]= errorCode;
+        result = (*env)->NewIntArray(env,2);
+        (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
+        return result;
+    }
+
+    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCloseKey
+               (JNIEnv* env, jclass this_class, jint hKey) {
+        return (jint) RegCloseKey((HKEY) hKey);
+    };
+
+    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegCreateKeyEx
+               (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) {
+        HKEY handle;
+        char* str;
+        int tmp[3];
+        DWORD lpdwDisposition;
+        int errorCode;
+        jintArray result;
+        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+        errorCode =  RegCreateKeyEx((HKEY)hKey, str, 0, NULL,
+                      REG_OPTION_NON_VOLATILE, KEY_READ,
+                      NULL, &handle, &lpdwDisposition);
+        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
+        tmp[0]= (int) handle;
+        tmp[1]= errorCode;
+        tmp[2]= lpdwDisposition;
+        result = (*env)->NewIntArray(env,3);
+        (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
+        return result;
+    }
+
+    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteKey
+              (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey) {
+        char* str;
+        int result;
+        str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+        result = RegDeleteKey((HKEY)hKey, str);
+        (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
+        return  result;
+
+    };
+
+    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegFlushKey
+        (JNIEnv* env, jclass this_class, jint hKey) {
+        return RegFlushKey ((HKEY)hKey);
+        }
+
+    JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryValueEx
+         (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) {
+        char* valueNameStr;
+        char* buffer;
+        jbyteArray result;
+        DWORD valueType;
+        DWORD valueSize;
+        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+        if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL,
+                                                 &valueSize) != ERROR_SUCCESS) {
+        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+        return NULL;
+        }
+
+        buffer = (char*)malloc(valueSize);
+
+        if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
+            &valueSize) != ERROR_SUCCESS) {
+            free(buffer);
+            (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+        return NULL;
+        }
+
+        if (valueType == REG_SZ) {
+        result = (*env)->NewByteArray(env, valueSize);
+        (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
+        } else {
+        result = NULL;
+        }
+        free(buffer);
+        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+        return result;
+    }
+
+
+
+
+    JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegSetValueEx
+    (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName, jbyteArray data) {
+        char* valueNameStr;
+        char* dataStr;
+        int size = -1;
+        int nameSize = -1;
+        int error_code = -1;
+        if ((valueName == NULL)||(data == NULL)) {return -1;}
+        size = (*env)->GetArrayLength(env, data);
+        dataStr = (*env)->GetByteArrayElements(env, data, NULL);
+        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+        error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
+                                                        REG_SZ, dataStr, size);
+        (*env)->ReleaseByteArrayElements(env, data, dataStr, 0);
+        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+        return error_code;
+    }
+
+     JNIEXPORT jint JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegDeleteValue
+            (JNIEnv* env, jclass this_class, jint hKey, jbyteArray valueName) {
+        char* valueNameStr;
+        int error_code = -1;
+        if (valueName == NULL) {return -1;}
+        valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+        error_code = RegDeleteValue((HKEY)hKey, valueNameStr);
+        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+        return error_code;
+     }
+
+    JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey
+                                  (JNIEnv* env, jclass this_class, jint hKey) {
+        jintArray result;
+        int tmp[5];
+        int valuesNumber = -1;
+        int maxValueNameLength = -1;
+        int maxSubKeyLength = -1;
+        int subKeysNumber = -1;
+        int errorCode = -1;
+        errorCode = RegQueryInfoKey((HKEY)hKey, NULL, NULL, NULL,
+                 &subKeysNumber, &maxSubKeyLength, NULL,
+                 &valuesNumber, &maxValueNameLength,
+                 NULL, NULL, NULL);
+        tmp[0]= subKeysNumber;
+        tmp[1]= (int)errorCode;
+        tmp[2]= valuesNumber;
+        tmp[3]= maxSubKeyLength;
+        tmp[4]= maxValueNameLength;
+        result = (*env)->NewIntArray(env,5);
+        (*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
+        return result;
+    }
+
+     JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegEnumKeyEx
+     (JNIEnv* env, jclass this_class, jint hKey , jint subKeyIndex, jint maxKeyLength) {
+        int size = maxKeyLength;
+        jbyteArray result;
+        char* buffer = NULL;
+        buffer = (char*)malloc(maxKeyLength);
+        if (RegEnumKeyEx((HKEY) hKey, subKeyIndex, buffer, &size, NULL, NULL,
+                                                 NULL, NULL) != ERROR_SUCCESS){
+        free(buffer);
+        return NULL;
+        }
+        result = (*env)->NewByteArray(env, size + 1);
+        (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+        free(buffer);
+        return result;
+     }
+
+     JNIEXPORT jbyteArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegEnumValue
+          (JNIEnv* env, jclass this_class, jint hKey , jint valueIndex, jint maxValueNameLength){
+          int size = maxValueNameLength;
+          jbyteArray result;
+          char* buffer = NULL;
+          int error_code;
+          buffer = (char*)malloc(maxValueNameLength);
+          error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer,
+                                             &size, NULL, NULL, NULL, NULL);
+          if (error_code!= ERROR_SUCCESS){
+            free(buffer);
+            return NULL;
+          }
+          result = (*env)->NewByteArray(env, size + 1);
+          (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+          free(buffer);
+          return result;
+     }
+
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/misc/VM_md.c	Tue Feb 11 14:42:17 2014 -0800
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2001, 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_util.h"
+
+
+JNIEXPORT jboolean JNICALL
+Java_sun_misc_VM_isSetUID(JNIEnv *env, jclass thisclass) {
+
+    /* There is no set UID on Windows. */
+    return JNI_FALSE;
+}
--- a/jdk/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Tue Feb 11 14:42:17 2014 -0800
@@ -24,6 +24,7 @@
  */
 
 #include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h"
+#include "jni_util.h"
 #include <windows.h>
 #include <gdefs.h>
 #include <stdlib.h>
@@ -197,8 +198,13 @@
     }
 
     localeString = (char *)getJavaIDFromLangID(langid);
-    ret = (*env)->NewStringUTF(env, localeString);
-    free(localeString);
+    if (localeString != NULL) {
+        ret = (*env)->NewStringUTF(env, localeString);
+        free(localeString);
+    } else {
+        JNU_ThrowOutOfMemoryError(env, "memory allocation error");
+        ret = NULL;
+    }
     return ret;
 }
 
@@ -211,6 +217,7 @@
   (JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) {
     WCHAR pattern[BUFLEN];
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, NULL);
 
     pattern[0] = L'\0';
 
@@ -238,8 +245,11 @@
  */
 JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarID
   (JNIEnv *env, jclass cls, jstring jlangtag) {
-    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    jint ret = getCalendarID(langtag);
+    const jchar *langtag;
+    jint ret;
+    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, 0);
+    ret = getCalendarID(langtag);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
     return ret;
 }
@@ -252,10 +262,13 @@
 JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings
   (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) {
     WCHAR buf[BUFLEN];
-    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    const jchar *langtag;
 
     // AM
-    int got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN);
+    int got;
+    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, NULL);
+    got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN);
     if (got) {
         (*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewString(env, buf, wcslen(buf)));
     }
@@ -280,6 +293,7 @@
   (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray eras) {
     WCHAR ad[BUFLEN];
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, eras);
 
     getCalendarInfoWrapper(langtag, getCalendarID(langtag), NULL,
                       CAL_SERASTRING, ad, BUFLEN, NULL);
@@ -347,10 +361,14 @@
  */
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNumberPattern
   (JNIEnv *env, jclass cls, jint numberStyle, jstring jlangtag) {
-    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    const jchar *langtag;
     jstring ret;
+    WCHAR * pattern;
 
-    WCHAR * pattern = getNumberPattern(langtag, numberStyle);
+    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, NULL);
+    pattern = getNumberPattern(langtag, numberStyle);
+    CHECK_NULL_RETURN(pattern, NULL);
 
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
     ret = (*env)->NewString(env, pattern, wcslen(pattern));
@@ -367,8 +385,10 @@
 JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_isNativeDigit
   (JNIEnv *env, jclass cls, jstring jlangtag) {
     DWORD num;
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag,
+    CHECK_NULL_RETURN(langtag, JNI_FALSE);
+    got = getLocaleInfoWrapper(langtag,
         LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER,
         (LPWSTR)&num, sizeof(num));
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
@@ -384,8 +404,10 @@
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SCURRENCY, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, currencySymbol);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SCURRENCY, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -403,8 +425,10 @@
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SDECIMAL, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, decimalSeparator);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SDECIMAL, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -422,8 +446,10 @@
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_STHOUSAND, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, groupingSeparator);
+    got = getLocaleInfoWrapper(langtag, LOCALE_STHOUSAND, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -441,8 +467,10 @@
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SPOSINFINITY, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, infinity);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SPOSINFINITY, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -460,8 +488,10 @@
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SINTLSYMBOL, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, internationalCurrencySymbol);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SINTLSYMBOL, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -479,8 +509,10 @@
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SNEGATIVESIGN, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, minusSign);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SNEGATIVESIGN, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -498,8 +530,10 @@
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SMONDECIMALSEP, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, monetaryDecimalSeparator);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SMONDECIMALSEP, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -517,8 +551,10 @@
 JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN
   (JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SNAN, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, nan);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SNAN, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -536,8 +572,10 @@
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) {
     WCHAR buf[BUFLEN];
+    int got;
     const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SPERCENT, buf, BUFLEN);
+    CHECK_NULL_RETURN(langtag, percent);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SPERCENT, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -555,8 +593,12 @@
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) {
     WCHAR buf[BUFLEN];
-    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SPERMILLE, buf, BUFLEN);
+    const jchar *langtag;
+    int got;
+    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, perMill);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SPERMILLE, buf, BUFLEN);
+
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -574,8 +616,12 @@
 JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit
   (JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) {
     WCHAR buf[BUFLEN];
-    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int got = getLocaleInfoWrapper(langtag, LOCALE_SNATIVEDIGITS, buf, BUFLEN);
+    const jchar *langtag;
+    int got;
+    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, zeroDigit);
+    got = getLocaleInfoWrapper(langtag, LOCALE_SNATIVEDIGITS, buf, BUFLEN);
+
     (*env)->ReleaseStringChars(env, jlangtag, langtag);
 
     if (got) {
@@ -593,9 +639,11 @@
 JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDataValue
   (JNIEnv *env, jclass cls, jstring jlangtag, jint type) {
     DWORD num;
-    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    const jchar *langtag;
     int got = 0;
 
+    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL_RETURN(langtag, -1);
     switch (type) {
     case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK:
         got = getLocaleInfoWrapper(langtag,
@@ -648,6 +696,7 @@
     }
 
     pjChar = (*env)->GetStringChars(env, jStr, JNI_FALSE);
+    CHECK_NULL_RETURN(pjChar, NULL);
     got = getLocaleInfoWrapper(pjChar, lcType, buf, BUFLEN);
     (*env)->ReleaseStringChars(env, jStr, pjChar);
 
@@ -705,8 +754,11 @@
 
 void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) {
     WCHAR name[BUFLEN];
-    const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
-    int calid = getCalendarID(langtag);
+    const jchar *langtag;
+    int calid;
+    langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
+    CHECK_NULL(langtag);
+    calid = getCalendarID(langtag);
 
     if (calid != -1) {
         int i;
--- a/jdk/test/com/sun/jdi/ExclusiveBind.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/com/sun/jdi/ExclusiveBind.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -25,57 +25,28 @@
  * @bug 4531526
  * @summary Test that more than one debuggee cannot bind to same port
  *          at the same time.
+ * @library /lib/testlibrary
  *
+ * @build jdk.testlibrary.ProcessTools jdk.testlibrary.JDKToolLauncher jdk.testlibrary.Utils
  * @build VMConnection ExclusiveBind HelloWorld
  * @run main ExclusiveBind
  */
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
 import java.net.ServerSocket;
 import com.sun.jdi.Bootstrap;
 import com.sun.jdi.VirtualMachine;
 import com.sun.jdi.connect.Connector;
 import com.sun.jdi.connect.AttachingConnector;
+
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.List;
 import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.Utils;
 
 public class ExclusiveBind {
-
-    /*
-     * Helper class to direct process output to the parent
-     * System.out
-     */
-    static class IOHandler implements Runnable {
-        InputStream in;
-
-        IOHandler(InputStream in) {
-            this.in = in;
-        }
-
-        static void handle(InputStream in) {
-            IOHandler handler = new IOHandler(in);
-            Thread thr = new Thread(handler);
-            thr.setDaemon(true);
-            thr.start();
-        }
-
-        public void run() {
-            try {
-                byte b[] = new byte[100];
-                for (;;) {
-                    int n = in.read(b);
-                    if (n < 0) return;
-                    for (int i=0; i<n; i++) {
-                        System.out.print((char)b[i]);
-                    }
-                }
-            } catch (IOException ioe) { }
-        }
-
-    }
-
     /*
      * Find a connector by name
      */
@@ -95,25 +66,23 @@
      * Launch (in server mode) a debuggee with the given address and
      * suspend mode.
      */
-    private static Process launch(String address, boolean suspend, String class_name) throws IOException {
-        String exe = System.getProperty("java.home") + File.separator + "bin" +
-            File.separator + "java";
-        String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
-            " -agentlib:jdwp=transport=dt_socket,server=y,suspend=";
-        if (suspend) {
-            cmd += "y";
-        } else {
-            cmd += "n";
+    private static ProcessBuilder prepareLauncher(String address, boolean suspend, String class_name) throws Exception {
+        List<String> args = new ArrayList<>();
+        for(String dbgOption : VMConnection.getDebuggeeVMOptions().split(" ")) {
+            args.add(dbgOption);
         }
-        cmd += ",address=" + address + " " + class_name;
-
-        System.out.println("Starting: " + cmd);
+        String lib = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=";
+        if (suspend) {
+            lib += "y";
+        } else {
+            lib += "n";
+        }
+        lib += ",address=" + address;
 
-        Process p = Runtime.getRuntime().exec(cmd);
-        IOHandler.handle(p.getInputStream());
-        IOHandler.handle(p.getErrorStream());
+        args.add(lib);
+        args.add(class_name);
 
-        return p;
+        return ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()]));
     }
 
     /*
@@ -132,16 +101,21 @@
         String address = String.valueOf(port);
 
         // launch the first debuggee
-        Process process1 = launch(address, true, "HelloWorld");
-
-        // give first debuggee time to suspend
-        Thread.currentThread().sleep(5000);
+        ProcessBuilder process1 = prepareLauncher(address, true, "HelloWorld");
+        // start the debuggee and wait for the "ready" message
+        Process p = ProcessTools.startProcess(
+                "process1",
+                process1,
+                line -> line.equals("Listening for transport dt_socket at address: " + address),
+                Math.round(5000 * Utils.TIMEOUT_FACTOR),
+                TimeUnit.MILLISECONDS
+        );
 
         // launch a second debuggee with the same address
-        Process process2 = launch(address, false, "HelloWorld");
+        ProcessBuilder process2 = prepareLauncher(address, false, "HelloWorld");
 
         // get exit status from second debuggee
-        int exitCode = process2.waitFor();
+        int exitCode = ProcessTools.startProcess("process2", process2).waitFor();
 
         // clean-up - attach to first debuggee and resume it
         AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
--- a/jdk/test/java/lang/ClassLoader/Assert.sh	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/lang/ClassLoader/Assert.sh	Tue Feb 11 14:42:17 2014 -0800
@@ -23,6 +23,21 @@
 
 #
 
+OS=`uname -s`
+case "$OS" in
+  SunOS | Linux | Darwin )
+    FS="/"
+    CHMOD="${FS}bin${FS}chmod"
+    ;;
+  Windows* | CYGWIN* )
+    CHMOD="chmod"
+    ;;
+  * )
+    echo "Unrecognized system!"
+    exit 1;
+    ;;
+esac
+
 if [ "${TESTSRC}" = "" ]
 then
   echo "TESTSRC not set.  Test cannot execute.  Failed."
@@ -50,6 +65,7 @@
 cp ${TESTSRC}/Assert.java .
 cp -R ${TESTSRC}/package1 .
 cp -R ${TESTSRC}/package2 .
+${CHMOD} -R u+w *
 
 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} Assert.java 
 
--- a/jdk/test/java/lang/String/ToLowerCase.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/lang/String/ToLowerCase.java	Tue Feb 11 14:42:17 2014 -0800
@@ -23,7 +23,7 @@
 
 /*
     @test
-    @bug 4217441 4533872 4900935 8020037
+    @bug 4217441 4533872 4900935 8020037 8032012
     @summary toLowerCase should lower-case Greek Sigma correctly depending
              on the context (final/non-final).  Also it should handle
              Locale specific (lt, tr, and az) lowercasings and supplementary
@@ -104,6 +104,22 @@
         // invalid code point tests:
         test("\uD800\uD800\uD801A\uDC00\uDC00\uDC00B", Locale.US, "\uD800\uD800\uD801a\uDC00\uDC00\uDC00b");
 
+        // test bmp + supp1
+        StringBuilder src = new StringBuilder(0x20000);
+        StringBuilder exp = new StringBuilder(0x20000);
+        for (int cp = 0; cp < 0x20000; cp++) {
+            if (cp >= Character.MIN_HIGH_SURROGATE && cp <= Character.MAX_HIGH_SURROGATE) {
+                continue;
+            }
+            int lowerCase = Character.toLowerCase(cp);
+            if (lowerCase == -1) {    //Character.ERROR
+                continue;
+            }
+            src.appendCodePoint(cp);
+            exp.appendCodePoint(lowerCase);
+        }
+        test(src.toString(), Locale.US, exp.toString());
+
     }
 
     static void test(String in, Locale locale, String expected) {
--- a/jdk/test/java/nio/file/Files/InterruptCopy.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/nio/file/Files/InterruptCopy.java	Tue Feb 11 14:42:17 2014 -0800
@@ -25,7 +25,6 @@
  * @bug 4313887 6993267
  * @summary Unit test for Sun-specific ExtendedCopyOption.INTERRUPTIBLE option
  * @library ..
- * @run main/othervm -XX:-UseVMInterruptibleIO InterruptCopy
  */
 
 import java.nio.file.*;
--- a/jdk/test/java/rmi/registry/readTest/readTest.sh	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/rmi/registry/readTest/readTest.sh	Tue Feb 11 14:42:17 2014 -0800
@@ -37,11 +37,13 @@
   SunOS | Linux | Darwin | AIX )
     PS=":"
     FS="/"
+    CHMOD="${FS}bin${FS}chmod"
     FILEURL="file:"
     ;;
   Windows* )
     PS=";"
     FS="\\"
+    CHMOD="chmod"
     FILEURL="file:/"
     if [ "$VER" -eq "5" ]; then
         ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
@@ -51,6 +53,7 @@
   CYGWIN* )
     PS=";"
     FS="/"
+    CHMOD="chmod"
     FILEURL="file:/"
     if [ "$VER" -eq "5" ]; then
         ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000"
@@ -65,6 +68,7 @@
 
 TEST_CLASSPATH=.$PS${TESTCLASSPATH:-$TESTCLASSES}
 cp -r ${TESTSRC}${FS}* .
+${CHMOD} -R u+w *
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} testPkg${FS}*java
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -cp $TEST_CLASSPATH readTest.java
 
--- a/jdk/test/java/util/Comparator/TypeTest.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/util/Comparator/TypeTest.java	Tue Feb 11 14:42:17 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -24,6 +24,7 @@
 /**
  * @test
  * @summary Comparator API narrowing type test
+ * @bug 8009736 8033590
  * @run testng TypeTest
  */
 
@@ -33,6 +34,8 @@
 import java.util.Comparator;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.assertTrue;
+
 @Test(groups = "unit")
 public class TypeTest {
     static class Person {
@@ -66,6 +69,24 @@
         }
     }
 
+    static class Department {
+        Manager mgr;
+        String hr_code;
+
+        Department(Manager mgr, String hr) {
+            this.mgr = mgr;
+            this.hr_code = hr;
+        }
+
+        Manager getManager() {
+            return mgr;
+        }
+
+        String getHR() {
+            return hr_code;
+        }
+    }
+
     static <T> void assertOrder(T o1, T o2, Comparator<? super T> cmp) {
         if (cmp.compare(o1, o2) > 0) {
             System.out.println("Fail!!");
@@ -75,6 +96,8 @@
         }
     }
 
+    // Type tests just to make sure the code can compile and build
+    // Not necessarily need a meaningful result
     public void testOrder() {
         Manager m1 = new Manager("Manager", 2, 2000);
         Manager m2 = new Manager("Manager", 4, 1300);
@@ -93,4 +116,23 @@
         Map<String, Integer> map = new TreeMap<>();
         map.entrySet().stream().sorted(Map.Entry.comparingByKey(String.CASE_INSENSITIVE_ORDER));
     }
+
+    public void testJDK8033590() {
+        Manager a = new Manager("John Doe", 1234, 16);
+        Manager b = new Manager("Jane Roe", 2468, 16);
+        Department da = new Department(a, "X");
+        Department db = new Department(b, "X");
+
+        Comparator<Department> cmp = Comparator.comparing(Department::getHR)
+                .thenComparing(Department::getManager, Employee.C);
+        assertTrue(cmp.compare(da, db) < 0);
+
+        cmp = Comparator.comparing(Department::getHR)
+                .thenComparing(Department::getManager, Manager.C);
+        assertTrue(cmp.compare(da, db) == 0);
+
+        cmp = Comparator.comparing(Department::getHR)
+                .thenComparing(Department::getManager, Person.C);
+        assertTrue(cmp.compare(da, db) > 0);
+    }
 }
--- a/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java	Tue Feb 11 14:42:17 2014 -0800
@@ -25,7 +25,6 @@
  * @test
  * @bug 6384064
  * @summary Check proper handling of interrupts
- * @run main/othervm -XX:-UseVMInterruptibleIO Interrupt
  * @author Martin Buchholz
  */
 
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java	Tue Feb 11 14:42:17 2014 -0800
@@ -25,7 +25,6 @@
  * @test
  * @bug 6450200 6450205 6450207 6450211
  * @summary Test proper handling of tasks that terminate abruptly
- * @run main/othervm -XX:-UseVMInterruptibleIO ThrowingTasks
  * @author Martin Buchholz
  */
 
--- a/jdk/test/java/util/logging/SimpleLogManager.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/util/logging/SimpleLogManager.java	Tue Feb 11 14:42:17 2014 -0800
@@ -98,16 +98,14 @@
             return false;
         }
         CustomLogger newLogger = new CustomLogger(logger);
-        super.addLogger(newLogger);
-        return true;
+        return super.addLogger(newLogger);
     }
 
     public class CustomLogger extends Logger {
+        final Logger keepRef; // keep a strong reference to avoid GC.
         CustomLogger(Logger logger) {
             super(logger.getName(), logger.getResourceBundleName());
-        }
-        CustomLogger(String name) {
-            super(name, null);
+            keepRef = logger;
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/TestGetLoggerNPE.java	Tue Feb 11 14:42:17 2014 -0800
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013, 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.
+ *
+ * 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.
+ */
+import java.io.PrintStream;
+import java.security.Permission;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import sun.misc.JavaAWTAccess;
+import sun.misc.SharedSecrets;
+
+/*
+ * @test
+ * @bug 8025512
+ *
+ * @summary NPE with logging while launching webstart
+ *
+ * @build TestGetLoggerNPE
+ * @run main/othervm TestGetLoggerNPE getLogger
+ * @run main/othervm TestGetLoggerNPE getLogManager
+ */
+public class TestGetLoggerNPE {
+    static volatile Throwable thrown = null;
+    public static void main(String[] args) throws Exception {
+        final String testCase = args.length == 0 ? "getLogger" : args[0];
+        final JavaAWTAccessStub access = new JavaAWTAccessStub();
+        SharedSecrets.setJavaAWTAccess(access);
+        final ThreadGroup tg = new ThreadGroup("TestGroup");
+        Thread t = new Thread(tg, "test") {
+            public void run() {
+                try {
+                    access.setContext(Context.ONE);
+                    final PrintStream out = System.out;
+                    System.setOut(null);
+                    try {
+                        if ("getLogger".equals(testCase)) {
+                           Logger.getLogger("sun.plugin");
+                        } else {
+                           LogManager.getLogManager();
+                        }
+                    } finally {
+                        System.setOut(out);
+                    }
+
+                    System.out.println(Logger.global);
+                } catch (Throwable x) {
+                    x.printStackTrace();
+                    thrown = x;
+                }
+            }
+        };
+        Policy.setPolicy(new Policy() {
+             public boolean implies(ProtectionDomain domain,
+                                    Permission permission) {
+                 return true; // all permissions
+             }
+        });
+        System.setSecurityManager(new SecurityManager());
+        t.start();
+        t.join();
+        if (thrown == null) {
+            System.out.println("PASSED: " + testCase);
+        } else {
+            System.err.println("FAILED: " + testCase);
+            throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
+        }
+
+    }
+
+    static enum Context { ONE, TWO };
+
+    static final class JavaAWTAccessStub implements JavaAWTAccess {
+        private static final InheritableThreadLocal<Context> context = new InheritableThreadLocal<>();
+
+
+        public void setContext(Context context) {
+            JavaAWTAccessStub.context.set(context);
+        }
+
+        @Override
+        public Object getAppletContext() {
+            return context.get();
+        }
+
+     }
+
+}
--- a/jdk/test/java/util/zip/ZipFile/ReadZip.java	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/java/util/zip/ZipFile/ReadZip.java	Tue Feb 11 14:42:17 2014 -0800
@@ -63,6 +63,8 @@
         Files.copy(Paths.get(System.getProperty("test.src", ""), "input.zip"),
                    newZip.toPath(), StandardCopyOption.REPLACE_EXISTING);
 
+        newZip.setWritable(true);
+
         // pad some bytes
         try (OutputStream os = Files.newOutputStream(newZip.toPath(),
                                                      StandardOpenOption.APPEND)) {
--- a/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh	Tue Feb 11 12:40:16 2014 -0800
+++ b/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh	Tue Feb 11 14:42:17 2014 -0800
@@ -34,14 +34,17 @@
   SunOS | Linux | Darwin | AIX )
     PS=":"
     FS="/"
+    CHMOD="${FS}bin${FS}chmod"
     ;;
   Windows* )
     PS=";"
     FS="\\"
+    CHMOD="chmod"
     ;;
   CYGWIN* )
     PS=";"
     FS="/"
+    CHMOD="chmod"
     #
     # javac does not like /cygdrive produced by `pwd`.
     #
@@ -59,6 +62,7 @@
 mkdir -p ${DEST}${FS}jar1
 cd ${TESTSRC}${FS}etc${FS}jar1
 cp -r . ${DEST}${FS}jar1
+${CHMOD} -R u+w ${DEST}${FS}jar1
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \
     ${TESTSRC}${FS}src${FS}jar1${FS}LoadResourceBundle.java
 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \