Merge
authorprr
Mon, 24 Mar 2014 10:43:59 -0700
changeset 23698 df595f006056
parent 23697 e556a715949f (current diff)
parent 23572 0b4b0e183619 (diff)
child 23699 fa664c1f28c1
Merge
--- a/jdk/make/Tools.gmk	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/make/Tools.gmk	Mon Mar 24 10:43:59 2014 -0700
@@ -71,6 +71,7 @@
     build.tools.generatecharacter.CharacterName
 
 TOOL_DTDBUILDER = $(JAVA_SMALL) -Ddtd_home=$(JDK_TOPDIR)/make/data/dtdbuilder \
+    -Djava.awt.headless=true \
     -cp $(JDK_OUTPUTDIR)/btclasses build.tools.dtdbuilder.DTDBuilder
 
 TOOL_GENERATEBREAKITERATORDATA = $(JAVA_SMALL) \
--- a/jdk/make/lib/CoreLibraries.gmk	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/make/lib/CoreLibraries.gmk	Mon Mar 24 10:43:59 2014 -0700
@@ -305,7 +305,7 @@
     LDFLAGS_SUFFIX_linux := -ljvm -ljava, \
     LDFLAGS_SUFFIX_solaris := -ljvm -ljava -lc, \
     LDFLAGS_SUFFIX_aix := -ljvm -ljava, \
-    LDFLAGS_SUFFIX_windows := advapi32.lib, \
+    LDFLAGS_SUFFIX_windows := advapi32.lib jvm.lib $(WIN_JAVA_LIB), \
     LDFLAGS_SUFFIX_macosx := -ljvm -framework CoreFoundation, \
     VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
     RC_FLAGS := $(RC_FLAGS) \
--- a/jdk/make/lib/ServiceabilityLibraries.gmk	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/make/lib/ServiceabilityLibraries.gmk	Mon Mar 24 10:43:59 2014 -0700
@@ -49,7 +49,7 @@
     EXCLUDE_FILES := $(LIBATTACH_EXCLUDE_FILES), \
     LANG := C, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB), \
+    CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS), \
     CFLAGS_windows := /Gy, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \
     VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
@@ -79,7 +79,7 @@
         $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket, \
     LANG := C, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
+    CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_CFLAGS_WARNINGS_ARE_ERRORS) -DUSE_MMAP \
         -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
         -I$(JDK_TOPDIR)/src/share/transport/socket \
         -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/socket \
@@ -115,7 +115,7 @@
           $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem, \
       LANG := C, \
       OPTIMIZATION := LOW, \
-      CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
+      CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) -DUSE_MMAP \
           -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \
           -I$(JDK_TOPDIR)/src/share/transport/shmem \
           -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/transport/shmem \
@@ -144,7 +144,7 @@
     SRC := $(JDK_TOPDIR)/src/share/back $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/back, \
     LANG := C, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB) -DJDWP_LOGGING \
+    CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) -DJDWP_LOGGING \
         -I$(JDK_TOPDIR)/src/share/transport/export \
         -I$(JDK_TOPDIR)/src/share/back/export \
         -I$(JDK_TOPDIR)/src/share/npt \
@@ -179,7 +179,7 @@
         $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/tracing/dtrace, \
     LANG := C, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB) \
+    CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
         -I$(JDK_TOPDIR)/src/share/native/sun/tracing/dtrace, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjsdt/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
@@ -248,7 +248,7 @@
     INCLUDE_FILES := $(LIBINSTRUMENT_FILES), \
     LANG := C, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(LIBINSTRUMENT_CFLAGS), \
+    CFLAGS := $(LIBINSTRUMENT_CFLAGS) $(CFLAGS_WARNINGS_ARE_ERRORS), \
     CFLAGS_debug := -DJPLIS_LOGGING, \
     CFLAGS_release := -DNO_JPLIS_LOGGING, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libinstrument/mapfile-vers, \
@@ -316,7 +316,7 @@
     EXCLUDE_FILES := $(BUILD_LIBMANAGEMENT_EXCLUDES), \
     LANG := C, \
     OPTIMIZATION := $(LIBMANAGEMENT_OPTIMIZATION), \
-    CFLAGS := $(CFLAGS_JDKLIB) $(BUILD_LIBMANAGEMENT_CFLAGS), \
+    CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) $(BUILD_LIBMANAGEMENT_CFLAGS), \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libmanagement/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -364,7 +364,7 @@
     SRC := $(BUILD_LIBHPROF_SRC), \
     LANG := C, \
     OPTIMIZATION := $(LIBHPROF_OPTIMIZATION), \
-    CFLAGS := $(CFLAGS_JDKLIB) \
+    CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
         $(BUILD_LIBHPROF_CFLAGS), \
     CFLAGS_debug := -DHPROF_LOGGING, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libhprof/mapfile-vers, \
@@ -392,7 +392,7 @@
     SRC := $(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo, \
     LANG := C, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB) \
+    CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
         -I$(JDK_TOPDIR)/src/share/demo/jvmti/java_crw_demo, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava_crw_demo/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
@@ -419,7 +419,7 @@
         SRC := $(JDK_TOPDIR)/src/closed/share/native/oracle/jfr, \
         LANG := C, \
         OPTIMIZATION := LOW, \
-        CFLAGS := $(CFLAGS_JDKLIB) \
+        CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
             -I$(JDK_TOPDIR)/src/closed/share/javavm/export, \
         MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjfr/mapfile-vers, \
         LDFLAGS := $(LDFLAGS_JDKLIB) \
--- a/jdk/src/share/back/SDE.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/back/SDE.c	Mon Mar 24 10:43:59 2014 -0700
@@ -48,8 +48,6 @@
 #define BASE_STRATUM_NAME "Java"
 
 #define null NULL
-#define true JNI_TRUE
-#define false JNI_FALSE
 #define String char *
 #define private static
 
@@ -147,7 +145,7 @@
             defaultStratumId = null;
             defaultStratumIndex = -1;
             baseStratumIndex = -2; /* so as not to match -1 above */
-            sourceMapIsValid = false;
+            sourceMapIsValid = JNI_FALSE;
 
             if (getSourceDebugExtension(clazz, &sourceDebugExtension) ==
                 JVMTI_ERROR_NONE) {
@@ -667,7 +665,7 @@
         jplsFilename = readLine();
         defaultStratumId = readLine();
         createJavaStratum();
-        while (true) {
+        while (1) {
             if (sdeRead() != '*') {
                 syntax("expected '*'");
             }
@@ -684,7 +682,7 @@
                 case 'E':
                     /* set end points */
                     storeStratum("*terminator*");
-                    sourceMapIsValid = true;
+                    sourceMapIsValid = JNI_TRUE;
                     return;
                 default:
                     ignoreSection();
--- a/jdk/src/share/back/eventHandler.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/back/eventHandler.c	Mon Mar 24 10:43:59 2014 -0700
@@ -1682,7 +1682,7 @@
 eventHandler_createPermanentInternal(EventIndex ei, HandlerFunction func)
 {
     return createInternal(ei, func, NULL,
-                          NULL, NULL, (jlocation)NULL, JNI_TRUE);
+                          NULL, NULL, 0, JNI_TRUE);
 }
 
 HandlerNode *
@@ -1691,7 +1691,7 @@
                                       jthread thread)
 {
     return createInternal(ei, func, thread,
-                          NULL, NULL, (jlocation)NULL, JNI_FALSE);
+                          NULL, NULL, 0, JNI_FALSE);
 }
 
 HandlerNode *
--- a/jdk/src/share/back/log_messages.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/back/log_messages.c	Mon Mar 24 10:43:59 2014 -0700
@@ -56,17 +56,24 @@
 static void
 get_time_stamp(char *tbuf, size_t ltbuf)
 {
-    char format[MAXLEN_TIMESTAMP+1];
+    char timestamp_prefix[MAXLEN_TIMESTAMP+1];
+    char timestamp_postfix[MAXLEN_TIMESTAMP+1];
     unsigned millisecs = 0;
     time_t t = 0;
 
     GETMILLSECS(millisecs);
-    if ( time(&t) == (time_t)(-1) )
+    if ( time(&t) == (time_t)(-1) ) {
         t = 0;
-    (void)strftime(format, sizeof(format),
-                /* Break this string up for SCCS's sake */
-                "%" "d.%" "m.%" "Y %" "T.%%.3d %" "Z", localtime(&t));
-    (void)snprintf(tbuf, ltbuf, format, (int)(millisecs));
+    }
+    /* Break this up so that the format strings are string literals
+       and we avoid a compiler warning. */
+    (void)strftime(timestamp_prefix, sizeof(timestamp_prefix),
+                "%d.%m.%Y %T", localtime(&t));
+    (void)strftime(timestamp_postfix, sizeof(timestamp_postfix),
+                "%Z", localtime(&t));
+    (void)snprintf(tbuf, ltbuf,
+                   "%s.%.3d %s", timestamp_prefix,
+                   (int)(millisecs), timestamp_postfix);
 }
 
 /* Get basename of filename */
@@ -175,7 +182,7 @@
                         "LOC=%s;PID=%d;THR=t@%d",
                         location_stamp,
                         (int)processPid,
-                        (int)tid);
+                        (int)(intptr_t)tid);
 
             /* Construct message string. */
             va_start(ap, format);
--- a/jdk/src/share/classes/java/util/Spliterators.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/classes/java/util/Spliterators.java	Mon Mar 24 10:43:59 2014 -0700
@@ -384,7 +384,7 @@
      */
     private static void checkFromToBounds(int arrayLength, int origin, int fence) {
         if (origin > fence) {
-            throw new IllegalArgumentException(
+            throw new ArrayIndexOutOfBoundsException(
                     "origin(" + origin + ") > fence(" + fence + ")");
         }
         if (origin < 0) {
--- a/jdk/src/share/classes/javax/sql/rowset/package.html	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/classes/javax/sql/rowset/package.html	Mon Mar 24 10:43:59 2014 -0700
@@ -295,14 +295,13 @@
 
 <h3><a name="relspec">4.0 Related Specifications</a></h3>
 <ul>
-<li><a href="http://java.sun.com/products/jdbc">JDBC 3.0 Specification</a>
+<li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.2 Specification</a>
 <li><a href="http://www.w3.org/XML/Schema">XML Schema</a>
-<li><a href="http://www.syncml.org">SyncML</a>
 </ul>
 
 <h3><a name="reldocs">5.0 Related Documentation</a></h3>
 <ul>
-<li><a href="http://java.sun.com/developer/Books/JDBCTutorial/chapter5.html">
+<li><a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/rowset.html">
 JDBC RowSet Tutorial</a>      
 </ul>
 </body>
--- a/jdk/src/share/classes/sun/security/pkcs11/SessionManager.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs11/SessionManager.java	Mon Mar 24 10:43:59 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, 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
@@ -34,6 +34,9 @@
 import sun.security.pkcs11.wrapper.*;
 import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
 
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.atomic.AtomicInteger;
+
 /**
  * Session manager. There is one session manager object per PKCS#11
  * provider. It allows code to checkout a session, release it
@@ -77,7 +80,7 @@
     private final int maxSessions;
 
     // total number of active sessions
-    private int activeSessions;
+    private AtomicInteger activeSessions = new AtomicInteger();
 
     // pool of available object sessions
     private final Pool objSessions;
@@ -118,7 +121,7 @@
         return (maxSessions <= DEFAULT_MAX_SESSIONS);
     }
 
-    synchronized Session getObjSession() throws PKCS11Exception {
+    Session getObjSession() throws PKCS11Exception {
         Session session = objSessions.poll();
         if (session != null) {
             return ensureValid(session);
@@ -131,7 +134,7 @@
         return ensureValid(session);
     }
 
-    synchronized Session getOpSession() throws PKCS11Exception {
+    Session getOpSession() throws PKCS11Exception {
         Session session = opSessions.poll();
         if (session != null) {
             return ensureValid(session);
@@ -139,7 +142,7 @@
         // create a new session rather than re-using an obj session
         // that avoids potential expensive cancels() for Signatures & RSACipher
         if (maxSessions == Integer.MAX_VALUE ||
-                activeSessions < maxSessions) {
+                activeSessions.get() < maxSessions) {
             session = openSession();
             return ensureValid(session);
         }
@@ -155,20 +158,20 @@
         return session;
     }
 
-    synchronized Session killSession(Session session) {
+    Session killSession(Session session) {
         if ((session == null) || (token.isValid() == false)) {
             return null;
         }
         if (debug != null) {
             String location = new Exception().getStackTrace()[2].toString();
             System.out.println("Killing session (" + location + ") active: "
-                + activeSessions);
+                + activeSessions.get());
         }
         closeSession(session);
         return null;
     }
 
-    synchronized Session releaseSession(Session session) {
+    Session releaseSession(Session session) {
         if ((session == null) || (token.isValid() == false)) {
             return null;
         }
@@ -181,13 +184,13 @@
         return null;
     }
 
-    synchronized void demoteObjSession(Session session) {
+    void demoteObjSession(Session session) {
         if (token.isValid() == false) {
             return;
         }
         if (debug != null) {
             System.out.println("Demoting session, active: " +
-                activeSessions);
+                activeSessions.get());
         }
         boolean present = objSessions.remove(session);
         if (present == false) {
@@ -200,18 +203,21 @@
 
     private Session openSession() throws PKCS11Exception {
         if ((maxSessions != Integer.MAX_VALUE) &&
-                (activeSessions >= maxSessions)) {
+                (activeSessions.get() >= maxSessions)) {
             throw new ProviderException("No more sessions available");
         }
+
         long id = token.p11.C_OpenSession
                     (token.provider.slotID, openSessionFlags, null, null);
         Session session = new Session(token, id);
-        activeSessions++;
+        activeSessions.incrementAndGet();
         if (debug != null) {
-            if (activeSessions > maxActiveSessions) {
-                maxActiveSessions = activeSessions;
-                if (maxActiveSessions % 10 == 0) {
-                    System.out.println("Open sessions: " + maxActiveSessions);
+            synchronized(this) {
+                if (activeSessions.get() > maxActiveSessions) {
+                    maxActiveSessions = activeSessions.get();
+                    if (maxActiveSessions % 10 == 0) {
+                        System.out.println("Open sessions: " + maxActiveSessions);
+                    }
                 }
             }
         }
@@ -220,18 +226,18 @@
 
     private void closeSession(Session session) {
         session.close();
-        activeSessions--;
+        activeSessions.decrementAndGet();
     }
 
-    private static final class Pool {
+    public static final class Pool {
 
         private final SessionManager mgr;
 
-        private final List<Session> pool;
+        private final ConcurrentLinkedDeque<Session> pool;
 
         Pool(SessionManager mgr) {
-            this.mgr = mgr;
-            pool = new ArrayList<Session>();
+           this.mgr = mgr;
+           pool = new ConcurrentLinkedDeque<Session>();
         }
 
         boolean remove(Session session) {
@@ -239,45 +245,40 @@
         }
 
         Session poll() {
-            int n = pool.size();
-            if (n == 0) {
-                return null;
-            }
-            Session session = pool.remove(n - 1);
-            return session;
+            return pool.pollLast();
         }
 
         void release(Session session) {
-            pool.add(session);
-            // if there are idle sessions, close them
+            pool.offer(session);
             if (session.hasObjects()) {
                 return;
             }
+
             int n = pool.size();
             if (n < 5) {
                 return;
             }
-            Session oldestSession = pool.get(0);
+
+            Session oldestSession;
             long time = System.currentTimeMillis();
-            if (session.isLive(time) && oldestSession.isLive(time)) {
-                return;
-            }
-            Collections.sort(pool);
             int i = 0;
-            while (i < n - 1) { // always keep at least 1 session open
-                oldestSession = pool.get(i);
-                if (oldestSession.isLive(time)) {
+            // Check if the session head is too old and continue through queue
+            // until only one is left.
+            do {
+                oldestSession = pool.peek();
+                if (oldestSession == null || oldestSession.isLive(time) ||
+                        !pool.remove(oldestSession)) {
                     break;
                 }
+
                 i++;
                 mgr.closeSession(oldestSession);
-            }
+            } while ((n - i) > 1);
+
             if (debug != null) {
                 System.out.println("Closing " + i + " idle sessions, active: "
                         + mgr.activeSessions);
             }
-            List<Session> subList = pool.subList(0, i);
-            subList.clear();
         }
 
     }
--- a/jdk/src/share/classes/sun/tools/jinfo/JInfo.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/classes/sun/tools/jinfo/JInfo.java	Mon Mar 24 10:43:59 2014 -0700
@@ -78,8 +78,16 @@
         }
 
         if (useSA) {
+            // SA only supports -flags or -sysprops
+            if (args[0].startsWith("-")) {
+                if (!(args[0].equals("-flags") || args[0].equals("-sysprops"))) {
+                    usage(1);
+                }
+            }
+
             // invoke SA which does it's own argument parsing
             runTool(args);
+
         } else {
             // Now we can parse arguments for the non-SA case
             String pid = null;
--- a/jdk/src/share/instrument/InvocationAdapter.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/instrument/InvocationAdapter.c	Mon Mar 24 10:43:59 2014 -0700
@@ -359,7 +359,7 @@
          * class name. The manifest is in UTF8 so need to convert to
          * modified UTF8 (see JNI spec).
          */
-        oldLen = strlen(agentClass);
+        oldLen = (int)strlen(agentClass);
         newLen = modifiedUtf8LengthOfUtf8(agentClass, oldLen);
         if (newLen == oldLen) {
             agentClass = strdup(agentClass);
--- a/jdk/src/share/instrument/PathCharsValidator.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/share/instrument/PathCharsValidator.c	Mon Mar 24 10:43:59 2014 -0700
@@ -46,9 +46,9 @@
 
 /* Compute the low-order mask for the characters in the given string */
 static jlong lowMask(char* s) {
-    int n = strlen(s);
+    size_t n = strlen(s);
     jlong m = 0;
-    int i;
+    size_t i;
     for (i = 0; i < n; i++) {
         int c = (int)s[i];
         if (c < 64)
@@ -59,9 +59,9 @@
 
 /* Compute the high-order mask for the characters in the given string */
 static jlong highMask(char* s) {
-    int n = strlen(s);
+    size_t n = strlen(s);
     jlong m = 0;
-    int i;
+    size_t i;
     for (i = 0; i < n; i++) {
         int c = (int)s[i];
         if ((c >= 64) && (c < 128))
@@ -168,7 +168,7 @@
  * illegal characters. Returns 0 if only validate characters are present.
  */
 int validatePathChars(const char* path) {
-    int i, n;
+    size_t i, n;
 
     /* initialize on first usage */
     if (L_HEX == 0) {
--- a/jdk/src/solaris/back/util_md.h	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/solaris/back/util_md.h	Mon Mar 24 10:43:59 2014 -0700
@@ -62,13 +62,13 @@
                    (((UNSIGNED_JINT)(x & 0xff000000)) >> 24))
 #define HOST_TO_JAVA_LONG(x)                                            \
                   ((x << 56) |                                          \
-                   ((x & 0x000000000000ff00) << 40) |                   \
-                   ((x & 0x0000000000ff0000) << 24) |                   \
-                   ((x & 0x00000000ff000000) << 8) |                    \
-                   ((x & 0x000000ff00000000) >> 8) |                    \
-                   ((x & 0x0000ff0000000000) >> 24) |                   \
-                   ((x & 0x00ff000000000000) >> 40) |                   \
-                   (((UNSIGNED_JLONG)(x & 0xff00000000000000)) >> 56))
+                   ((x & 0x000000000000ff00LL) << 40) |                 \
+                   ((x & 0x0000000000ff0000LL) << 24) |                 \
+                   ((x & 0x00000000ff000000LL) << 8) |                  \
+                   ((x & 0x000000ff00000000LL) >> 8) |                  \
+                   ((x & 0x0000ff0000000000LL) >> 24) |                 \
+                   ((x & 0x00ff000000000000LL) >> 40) |                 \
+                   (((UNSIGNED_JLONG)(x & 0xff00000000000000ULL)) >> 56))
 #define HOST_TO_JAVA_FLOAT(x) stream_encodeFloat(x)
 #define HOST_TO_JAVA_DOUBLE(x) stream_encodeDouble(x)
 
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixPath.java	Mon Mar 24 10:43:59 2014 -0700
@@ -482,7 +482,7 @@
     @Override
     public Path normalize() {
         final int count = getNameCount();
-        if (count == 0)
+        if (count == 0 || isEmpty())
             return this;
 
         boolean[] ignore = new boolean[count];      // true => ignore name
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c	Mon Mar 24 10:43:59 2014 -0700
@@ -231,7 +231,11 @@
     }
 
     name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
-
+    if (name_utf == NULL) {
+       if (!(*env)->ExceptionCheck(env))
+           JNU_ThrowOutOfMemoryError(env, NULL);
+       return NULL;
+    }
     /*
      * Search the list of interface based on name
      */
@@ -499,7 +503,11 @@
     const char* name_utf;
 
     name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
-
+    if (name_utf == NULL) {
+       if (!(*env)->ExceptionCheck(env))
+           JNU_ThrowOutOfMemoryError(env, NULL);
+       return NULL;
+    }
     if ((sock =openSocketWithFallback(env, name_utf)) < 0) {
        (*env)->ReleaseStringUTFChars(env, name, name_utf);
        return JNI_FALSE;
@@ -546,6 +554,11 @@
     const char* name_utf;
 
     name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
+    if (name_utf == NULL) {
+       if (!(*env)->ExceptionCheck(env))
+           JNU_ThrowOutOfMemoryError(env, NULL);
+       return ret;
+    }
 
     if ((sock =openSocketWithFallback(env, name_utf)) < 0) {
        (*env)->ReleaseStringUTFChars(env, name, name_utf);
@@ -569,7 +582,11 @@
     int flags = 0;
 
     name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
-
+    if (name_utf == NULL) {
+       if (!(*env)->ExceptionCheck(env))
+           JNU_ThrowOutOfMemoryError(env, NULL);
+       return -1;
+    }
     if ((sock = openSocketWithFallback(env, name_utf)) < 0) {
         (*env)->ReleaseStringUTFChars(env, name, name_utf);
         return -1;
@@ -613,10 +630,9 @@
      * Create a NetworkInterface object and populate it
      */
     netifObj = (*env)->NewObject(env, ni_class, ni_ctrID);
+    CHECK_NULL_RETURN(netifObj, NULL);
     name = (*env)->NewStringUTF(env, ifs->name);
-    if (netifObj == NULL || name == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(name, NULL);
     (*env)->SetObjectField(env, netifObj, ni_nameID, name);
     (*env)->SetObjectField(env, netifObj, ni_descID, name);
     (*env)->SetIntField(env, netifObj, ni_indexID, ifs->index);
@@ -655,6 +671,8 @@
             iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
             if (iaObj) {
                  setInetAddress_addr(env, iaObj, htonl(((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr));
+            } else {
+                return NULL;
             }
             ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
             if (ibObj) {
@@ -665,10 +683,14 @@
                     if (ia2Obj) {
                        setInetAddress_addr(env, ia2Obj, htonl(((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr));
                        (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj);
+                    } else {
+                        return NULL;
                     }
                  }
                  (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask);
                  (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj);
+            } else {
+                return NULL;
             }
         }
 
@@ -688,20 +710,20 @@
                     setInet6Address_scopeid(env, iaObj, scope);
                     setInet6Address_scopeifname(env, iaObj, netifObj);
                 }
+            } else {
+                return NULL;
             }
             ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
             if (ibObj) {
                 (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj);
                 (*env)->SetShortField(env, ibObj, ni_ib4maskID, addrP->mask);
                 (*env)->SetObjectArrayElement(env, bindArr, bind_index++, ibObj);
+            } else {
+                return NULL;
             }
         }
 #endif
 
-        if (iaObj == NULL) {
-            return NULL;
-        }
-
         (*env)->SetObjectArrayElement(env, addrArr, addr_index++, iaObj);
         addrP = addrP->next;
     }
@@ -893,9 +915,14 @@
        // Deal with broadcast addr & subnet mask
        struct sockaddr * brdcast_to = (struct sockaddr *) ((char *) addrP + sizeof(netaddr) + addr_size);
        addrP->brdcast = getBroadcast(env, sock, name,  brdcast_to );
-
-       if ((mask = getSubnet(env, sock, name)) != -1)
+       if ((*env)->ExceptionCheck(env) == JNI_TRUE) {
+           return ifs;
+       }
+       if ((mask = getSubnet(env, sock, name)) != -1) {
            addrP->mask = mask;
+       } else if((*env)->ExceptionCheck(env)) {
+           return ifs;
+       }
      }
 
     /**
@@ -1377,6 +1404,7 @@
     nddp = (struct kinfo_ndd *)malloc(size);
 
     if (!nddp) {
+        JNU_ThrowOutOfMemoryError(env, "Network interface getMacAddress native buffer allocation failed");
         return -1;
     }
 
--- a/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/solaris/native/sun/management/MacosxOperatingSystem.c	Mon Mar 24 10:43:59 2014 -0700
@@ -29,6 +29,7 @@
 #include <mach/mach.h>
 #include <mach/task_info.h>
 
+#include "jvm.h"
 
 JNIEXPORT jdouble JNICALL
 Java_sun_management_OperatingSystemImpl_getSystemCpuLoad0
--- a/jdk/src/windows/back/linker_md.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/back/linker_md.c	Mon Mar 24 10:43:59 2014 -0700
@@ -33,6 +33,7 @@
 #include <string.h>
 #include <errno.h>
 #include <io.h>
+#include <stdlib.h>
 
 #include "sys.h"
 
--- a/jdk/src/windows/back/proc_md.h	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/back/proc_md.h	Mon Mar 24 10:43:59 2014 -0700
@@ -27,6 +27,7 @@
 
 #include <process.h>
 #include <time.h>
+#include <Windows.h>
 
 #define MUTEX_T         int
 #define MUTEX_INIT      0
@@ -40,4 +41,4 @@
 
 #define popen   _popen
 #define pclose  _pclose
-#define sleep   _sleep
+#define sleep(s)  Sleep((s)*1000)
--- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c	Mon Mar 24 10:43:59 2014 -0700
@@ -85,7 +85,7 @@
  * Retrieves the fully resolved (final) path for the given path or NULL
  * if the function fails.
  */
-static WCHAR* getFinalPath(const WCHAR *path)
+static WCHAR* getFinalPath(JNIEnv *env, const WCHAR *path)
 {
     HANDLE h;
     WCHAR *result;
@@ -121,6 +121,7 @@
                 len = (*GetFinalPathNameByHandle_func)(h, result, len, 0);
             } else {
                 len = 0;
+                JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
             }
         }
 
@@ -141,6 +142,7 @@
                 /* copy result without prefix into new buffer */
                 WCHAR *tmp = (WCHAR*)malloc(resultLen * sizeof(WCHAR));
                 if (tmp == NULL) {
+                    JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
                     len = 0;
                 } else {
                     WCHAR *p = result;
@@ -164,6 +166,8 @@
             free(result);
             result = NULL;
         }
+    } else {
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
     }
 
     error = GetLastError();
@@ -257,6 +261,8 @@
                     rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
                 }
                 free(cp);
+            } else {
+                JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
             }
         } else if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) {
             rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath));
@@ -288,6 +294,8 @@
                       rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
                     }
                     free(cp);
+                } else {
+                    JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
                 }
             } else if (wcanonicalizeWithPrefix(canonicalPrefix,
                                                pathWithCanonicalPrefix,
@@ -433,7 +441,7 @@
     if ((a != INVALID_FILE_ATTRIBUTES) &&
         ((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0))
     {
-        WCHAR *fp = getFinalPath(pathbuf);
+        WCHAR *fp = getFinalPath(env, pathbuf);
         if (fp == NULL) {
             a = INVALID_FILE_ATTRIBUTES;
         } else {
@@ -628,6 +636,7 @@
     if (search_path == 0) {
         free (pathbuf);
         errno = ENOMEM;
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation faiuled");
         return NULL;
     }
     wcscpy(search_path, pathbuf);
@@ -803,7 +812,7 @@
     if ((a != INVALID_FILE_ATTRIBUTES) &&
         ((a & FILE_ATTRIBUTE_REPARSE_POINT) != 0))
     {
-        WCHAR *fp = getFinalPath(pathbuf);
+        WCHAR *fp = getFinalPath(env, pathbuf);
         if (fp == NULL) {
             a = INVALID_FILE_ATTRIBUTES;
         } else {
--- a/jdk/src/windows/native/java/io/io_util_md.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/java/io/io_util_md.c	Mon Mar 24 10:43:59 2014 -0700
@@ -165,6 +165,9 @@
                      pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
                      if (pathbuf != 0) {
                          wcscpy(pathbuf, ps);
+                     } else {
+                         JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+                         return NULL;
                      }
                  }
             } else {
@@ -188,6 +191,9 @@
                     pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
                     if (pathbuf != 0) {
                         wcscpy(pathbuf, ps);
+                    } else {
+                        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+                        return NULL;
                     }
                 }
             }
@@ -196,11 +202,18 @@
 
     if (pathlen == 0) {
         if (throwFNFE == JNI_TRUE) {
-            throwFileNotFoundException(env, path);
+            if (!(*env)->ExceptionCheck(env)) {
+                throwFileNotFoundException(env, path);
+            }
             return NULL;
         } else {
             pathbuf = (WCHAR*)malloc(sizeof(WCHAR));
-            pathbuf[0] = L'\0';
+            if (pathbuf != NULL) {
+                pathbuf[0] = L'\0';
+            } else {
+                JNU_ThrowOutOfMemoryError(env, 0);
+                return NULL;
+            }
         }
     }
     if (pathbuf == 0) {
--- a/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c	Mon Mar 24 10:43:59 2014 -0700
@@ -35,9 +35,13 @@
     jmethodID String_init_ID;
     jbyteArray bytes;
     jbyte *blockA;
+    jclass string_class;
+
+    string_class = JNU_ClassString(env);
+    CHECK_NULL_RETURN(string_class, NULL);
 
     String_init_ID =
-        (*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V");
+        (*env)->GetMethodID(env, string_class, "<init>", "([B)V");
     CHECK_NULL_RETURN(String_init_ID, NULL);
 
     blockA = (jbyte *) GetEnvironmentStringsA();
@@ -54,10 +58,13 @@
         while (blockA[i++])
             ;
 
-    if ((bytes = (*env)->NewByteArray(env, i)) == NULL) return NULL;
+    if ((bytes = (*env)->NewByteArray(env, i)) == NULL) {
+        FreeEnvironmentStringsA(blockA);
+        return NULL;
+    }
     (*env)->SetByteArrayRegion(env, bytes, 0, i, blockA);
     FreeEnvironmentStringsA(blockA);
-    return (*env)->NewObject(env, JNU_ClassString(env),
+    return (*env)->NewObject(env, string_class,
                              String_init_ID, bytes);
 }
 
--- a/jdk/src/windows/native/java/lang/ProcessImpl_md.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/java/lang/ProcessImpl_md.c	Mon Mar 24 10:43:59 2014 -0700
@@ -359,24 +359,28 @@
             const jchar *penvBlock = (envBlock != NULL)
                 ? (*env)->GetStringChars(env, envBlock, NULL)
                 : NULL;
-            const jchar *pdir = (dir != NULL)
-                ? (*env)->GetStringChars(env, dir, NULL)
-                : NULL;
-            jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL);
-            if (handles != NULL) {
-                ret = processCreate(
-                    env,
-                    pcmd,
-                    penvBlock,
-                    pdir,
-                    handles,
-                    redirectErrorStream);
-                (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0);
+            if (!(*env)->ExceptionCheck(env)) {
+                const jchar *pdir = (dir != NULL)
+                    ? (*env)->GetStringChars(env, dir, NULL)
+                    : NULL;
+                if (!(*env)->ExceptionCheck(env)) {
+                    jlong *handles = (*env)->GetLongArrayElements(env, stdHandles, NULL);
+                    if (handles != NULL) {
+                        ret = processCreate(
+                            env,
+                            pcmd,
+                            penvBlock,
+                            pdir,
+                            handles,
+                            redirectErrorStream);
+                        (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0);
+                    }
+                    if (pdir != NULL)
+                        (*env)->ReleaseStringChars(env, dir, pdir);
+                }
+                if (penvBlock != NULL)
+                    (*env)->ReleaseStringChars(env, envBlock, penvBlock);
             }
-            if (pdir != NULL)
-                (*env)->ReleaseStringChars(env, dir, pdir);
-            if (penvBlock != NULL)
-                (*env)->ReleaseStringChars(env, envBlock, penvBlock);
             (*env)->ReleaseStringChars(env, cmd, pcmd);
         }
     }
@@ -448,7 +452,7 @@
 JNIEXPORT jboolean JNICALL
 Java_java_lang_ProcessImpl_closeHandle(JNIEnv *env, jclass ignored, jlong handle)
 {
-    return CloseHandle((HANDLE) handle);
+    return (jboolean) CloseHandle((HANDLE) handle);
 }
 
 /**
--- a/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Mon Mar 24 10:43:59 2014 -0700
@@ -384,15 +384,19 @@
         if (packetAddress == NULL) {
             packetAddress = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa,
                                                       &port);
-            /* stuff the new Inetaddress into the packet */
-            (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+            if (packetAddress != NULL) {
+                /* stuff the new Inetaddress into the packet */
+                (*env)->SetObjectField(env, dpObj, dp_addressID, packetAddress);
+            }
         }
 
-        /* populate the packet */
-        (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
+        if (!(*env)->ExceptionCheck(env)) {
+            /* populate the packet */
+            (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, rv,
                                    (jbyte *)fullPacket);
-        (*env)->SetIntField(env, dpObj, dp_portID, port);
-        (*env)->SetIntField(env, dpObj, dp_lengthID, rv);
+            (*env)->SetIntField(env, dpObj, dp_portID, port);
+            (*env)->SetIntField(env, dpObj, dp_lengthID, rv);
+        }
     }
 
     if (packetBufferLen > MAX_BUFFER_LEN) {
--- a/jdk/src/windows/native/java/net/NetworkInterface.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/java/net/NetworkInterface.c	Mon Mar 24 10:43:59 2014 -0700
@@ -543,16 +543,16 @@
      * Create a NetworkInterface object and populate it
      */
     netifObj = (*env)->NewObject(env, ni_class, ni_ctor);
+    CHECK_NULL_RETURN(netifObj, NULL);
     name = (*env)->NewStringUTF(env, ifs->name);
+    CHECK_NULL_RETURN(name, NULL);
     if (ifs->dNameIsUnicode) {
         displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName,
                                        (jsize)wcslen ((PWCHAR)ifs->displayName));
     } else {
         displayName = (*env)->NewStringUTF(env, ifs->displayName);
     }
-    if (netifObj == NULL || name == NULL || displayName == NULL) {
-        return NULL;
-    }
+    CHECK_NULL_RETURN(displayName, NULL);
     (*env)->SetObjectField(env, netifObj, ni_nameID, name);
     (*env)->SetObjectField(env, netifObj, ni_displayNameID, displayName);
     (*env)->SetIntField(env, netifObj, ni_indexID, ifs->index);
@@ -682,24 +682,29 @@
 
     /* get the name as a C string */
     name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
+    if (name_utf != NULL) {
 
-    /* Search by name */
-    curr = ifList;
-    while (curr != NULL) {
-        if (strcmp(name_utf, curr->name) == 0) {
-            break;
+        /* Search by name */
+        curr = ifList;
+        while (curr != NULL) {
+            if (strcmp(name_utf, curr->name) == 0) {
+                break;
+            }
+            curr = curr->next;
         }
-        curr = curr->next;
+
+        /* if found create a NetworkInterface */
+        if (curr != NULL) {;
+            netifObj = createNetworkInterface(env, curr, -1, NULL);
+        }
+
+        /* release the UTF string */
+        (*env)->ReleaseStringUTFChars(env, name, name_utf);
+    } else {
+        if (!(*env)->ExceptionCheck(env))
+            JNU_ThrowOutOfMemoryError(env, NULL);
     }
 
-    /* if found create a NetworkInterface */
-    if (curr != NULL) {;
-        netifObj = createNetworkInterface(env, curr, -1, NULL);
-    }
-
-    /* release the UTF string */
-    (*env)->ReleaseStringUTFChars(env, name, name_utf);
-
     /* release the interface list */
     free_netif(ifList);
 
--- a/jdk/src/windows/native/java/util/prefs/WindowsPreferences.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/java/util/prefs/WindowsPreferences.c	Mon Mar 24 10:43:59 2014 -0700
@@ -24,8 +24,10 @@
  */
 
 #include <stdlib.h>
-#include <jni.h>
 #include <windows.h>
+#include "jni.h"
+#include "jni_util.h"
+#include "jvm.h"
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -37,12 +39,15 @@
         int errorCode=-1;
         jintArray result;
         str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+        CHECK_NULL_RETURN(str, 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);
+        if (result != NULL) {
+            (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
+        }
         return result;
     }
 
@@ -58,8 +63,9 @@
         int tmp[3];
         DWORD lpdwDisposition;
         int errorCode;
-        jintArray result;
+        jintArray result = NULL;
         str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+        CHECK_NULL_RETURN(str, NULL);
         errorCode =  RegCreateKeyEx((HKEY)hKey, str, 0, NULL,
                       REG_OPTION_NON_VOLATILE, KEY_READ,
                       NULL, &handle, &lpdwDisposition);
@@ -68,7 +74,9 @@
         tmp[1]= errorCode;
         tmp[2]= lpdwDisposition;
         result = (*env)->NewIntArray(env,3);
-        (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
+        if (result != NULL) {
+            (*env)->SetIntArrayRegion(env, result, 0, 3, tmp);
+        }
         return result;
     }
 
@@ -77,6 +85,7 @@
         char* str;
         int result;
         str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+        CHECK_NULL_RETURN(str, -1);
         result = RegDeleteKey((HKEY)hKey, str);
         (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
         return  result;
@@ -96,6 +105,7 @@
         DWORD valueType;
         DWORD valueSize;
         valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+        CHECK_NULL_RETURN(valueNameStr, NULL);
         if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, NULL,
                                                  &valueSize) != ERROR_SUCCESS) {
         (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
@@ -103,19 +113,26 @@
         }
 
         buffer = (char*)malloc(valueSize);
-
-        if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
-            &valueSize) != ERROR_SUCCESS) {
-            free(buffer);
+        if (buffer != NULL) {
+            if (RegQueryValueEx((HKEY)hKey, valueNameStr, NULL, &valueType, buffer,
+                &valueSize) != ERROR_SUCCESS) {
+                free(buffer);
+                (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+                return NULL;
+            }
+        } else {
+            JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
             (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
-        return NULL;
+            return NULL;
         }
 
         if (valueType == REG_SZ) {
-        result = (*env)->NewByteArray(env, valueSize);
-        (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
+            result = (*env)->NewByteArray(env, valueSize);
+            if (result != NULL) {
+                (*env)->SetByteArrayRegion(env, result, 0, valueSize, buffer);
+            }
         } else {
-        result = NULL;
+            result = NULL;
         }
         free(buffer);
         (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
@@ -135,11 +152,14 @@
         if ((valueName == NULL)||(data == NULL)) {return -1;}
         size = (*env)->GetArrayLength(env, data);
         dataStr = (*env)->GetByteArrayElements(env, data, NULL);
+        CHECK_NULL_RETURN(dataStr, -1);
         valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
-        error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
+        if (valueNameStr != NULL) {
+            error_code = RegSetValueEx((HKEY)hKey, valueNameStr, 0,
                                                         REG_SZ, dataStr, size);
+            (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
+        }
         (*env)->ReleaseByteArrayElements(env, data, dataStr, 0);
-        (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
         return error_code;
     }
 
@@ -149,6 +169,7 @@
         int error_code = -1;
         if (valueName == NULL) {return -1;}
         valueNameStr = (*env)->GetByteArrayElements(env, valueName, NULL);
+        CHECK_NULL_RETURN(valueNameStr, -1);
         error_code = RegDeleteValue((HKEY)hKey, valueNameStr);
         (*env)->ReleaseByteArrayElements(env, valueName, valueNameStr, 0);
         return error_code;
@@ -156,7 +177,7 @@
 
     JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegQueryInfoKey
                                   (JNIEnv* env, jclass this_class, jint hKey) {
-        jintArray result;
+        jintArray result = NULL;
         int tmp[5];
         int valuesNumber = -1;
         int maxValueNameLength = -1;
@@ -173,7 +194,9 @@
         tmp[3]= maxSubKeyLength;
         tmp[4]= maxValueNameLength;
         result = (*env)->NewIntArray(env,5);
-        (*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
+        if (result != NULL) {
+            (*env)->SetIntArrayRegion(env, result, 0, 5, tmp);
+        }
         return result;
     }
 
@@ -183,13 +206,19 @@
         jbyteArray result;
         char* buffer = NULL;
         buffer = (char*)malloc(maxKeyLength);
+        if (buffer == NULL) {
+            JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+            return NULL;
+        }
         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);
+        if (result != NULL) {
+            (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+        }
         free(buffer);
         return result;
      }
@@ -201,6 +230,10 @@
           char* buffer = NULL;
           int error_code;
           buffer = (char*)malloc(maxValueNameLength);
+          if (buffer == NULL) {
+              JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+              return NULL;
+          }
           error_code = RegEnumValue((HKEY) hKey, valueIndex, buffer,
                                              &size, NULL, NULL, NULL, NULL);
           if (error_code!= ERROR_SUCCESS){
@@ -208,7 +241,9 @@
             return NULL;
           }
           result = (*env)->NewByteArray(env, size + 1);
-          (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+          if (result != NULL) {
+              (*env)->SetByteArrayRegion(env, result, 0, size + 1, buffer);
+          }
           free(buffer);
           return result;
      }
--- a/jdk/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c	Mon Mar 24 10:43:59 2014 -0700
@@ -39,6 +39,7 @@
 #define STS_NO_CONFIG       0x0             /* no configuration found */
 #define STS_SL_FOUND        0x1             /* search list found */
 #define STS_NS_FOUND        0x2             /* name servers found */
+#define STS_ERROR           -1              /* error return  lodConfig failed memory allccation failure*/
 
 #define IS_SL_FOUND(sts)    (sts & STS_SL_FOUND)
 #define IS_NS_FOUND(sts)    (sts & STS_NS_FOUND)
@@ -123,14 +124,14 @@
     size = sizeof(IP_ADAPTER_INFO);
     adapterP = (IP_ADAPTER_INFO *)malloc(size);
     if (adapterP == NULL) {
-        return -1;
+        return STS_ERROR;
     }
     ret = GetAdaptersInfo(adapterP, &size);
     if (ret == ERROR_BUFFER_OVERFLOW) {
         IP_ADAPTER_INFO *newAdapterP = (IP_ADAPTER_INFO *)realloc(adapterP, size);
         if (newAdapterP == NULL) {
             free(adapterP);
-            return -1;
+            return STS_ERROR;
         }
         adapterP = newAdapterP;
 
@@ -239,6 +240,7 @@
 {
     searchlistID = (*env)->GetStaticFieldID(env, cls, "os_searchlist",
                                       "Ljava/lang/String;");
+    CHECK_NULL(searchlistID);
     nameserversID = (*env)->GetStaticFieldID(env, cls, "os_nameservers",
                                       "Ljava/lang/String;");
 }
@@ -258,16 +260,21 @@
     searchlist[0] = '\0';
     nameservers[0] = '\0';
 
-    loadConfig(searchlist, nameservers);
+    if (loadConfig(searchlist, nameservers) != STS_ERROR) {
 
-    /*
-     * Populate static fields in sun.net.DefaultResolverConfiguration
-     */
-    obj = (*env)->NewStringUTF(env, searchlist);
-    (*env)->SetStaticObjectField(env, cls, searchlistID, obj);
+        /*
+         * Populate static fields in sun.net.DefaultResolverConfiguration
+         */
+        obj = (*env)->NewStringUTF(env, searchlist);
+        CHECK_NULL(obj);
+        (*env)->SetStaticObjectField(env, cls, searchlistID, obj);
 
-    obj = (*env)->NewStringUTF(env, nameservers);
-    (*env)->SetStaticObjectField(env, cls, nameserversID, obj);
+        obj = (*env)->NewStringUTF(env, nameservers);
+        CHECK_NULL(obj);
+        (*env)->SetStaticObjectField(env, cls, nameserversID, obj);
+    } else {
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+    }
 }
 
 
--- a/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c	Mon Mar 24 10:43:59 2014 -0700
@@ -53,7 +53,9 @@
 (JNIEnv *env, jclass authseq_clazz, jclass status_clazz)
 {
     ntlm_ctxHandleID = (*env)->GetFieldID(env, authseq_clazz, "ctxHandle", "J");
+    CHECK_NULL(ntlm_ctxHandleID);
     ntlm_crdHandleID = (*env)->GetFieldID(env, authseq_clazz, "crdHandle", "J");
+    CHECK_NULL(ntlm_crdHandleID);
     status_seqCompleteID = (*env)->GetFieldID(env, status_clazz, "sequenceComplete", "Z");
 }
 
@@ -100,6 +102,16 @@
         }
     }
     pCred = (CredHandle *)malloc(sizeof (CredHandle));
+    if (pCred == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+        if (pUser != NULL)
+            JNU_ReleaseStringPlatformChars(env, user, pUser);
+        if (pPassword != NULL)
+            JNU_ReleaseStringPlatformChars(env, password, pPassword);
+        if (pDomain != NULL)
+            JNU_ReleaseStringPlatformChars(env, domain, pDomain);
+        return NULL;
+    }
 
     if ( ((pUser != NULL) || (pPassword != NULL)) || (pDomain != NULL)) {
         pAuthId = &AuthId;
@@ -177,7 +189,12 @@
     pCtx = (CtxtHandle *) (*env)->GetLongField (env, this, ntlm_ctxHandleID);
     if (pCtx == 0) { /* first call */
         newContext = (CtxtHandle *)malloc(sizeof(CtxtHandle));
-        (*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext);
+        if (newContext != NULL) {
+            (*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext);
+        } else {
+            JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+            return NULL;
+        }
     } else {
         newContext = pCtx;
     }
@@ -198,6 +215,7 @@
     if (lastToken != 0)
     {
         pInput = (VOID *)(*env)->GetByteArrayElements(env, lastToken, &isCopy);
+        CHECK_NULL_RETURN(pInput, NULL);
         inputLen = (*env)->GetArrayLength(env, lastToken);
 
         InBuffDesc.ulVersion = 0;
@@ -240,8 +258,10 @@
 
     if ( OutSecBuff.cbBuffer > 0 ) {
         jbyteArray ret = (*env)->NewByteArray(env, OutSecBuff.cbBuffer);
-        (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
-                OutSecBuff.pvBuffer);
+        if (ret != NULL) {
+            (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
+                    OutSecBuff.pvBuffer);
+        }
         if (lastToken != 0) // 2nd stage
             endSequence (pCred, pCtx, env, status);
         result = ret;
--- a/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c	Mon Mar 24 10:43:59 2014 -0700
@@ -1123,11 +1123,13 @@
                     JNU_ThrowInternalError(env, "GetFullPathNameW failed");
                 }
                 free(lpBuf);
+            } else {
+                JNU_ThrowOutOfMemoryError(env, "native memory allocation failure");
             }
         }
+    } else {
+        throwWindowsException(env, GetLastError());
     }
-    if (len == 0)
-        throwWindowsException(env, GetLastError());
 
     return rv;
 }
@@ -1162,13 +1164,13 @@
                     JNU_ThrowInternalError(env, "GetFinalPathNameByHandleW failed");
                 }
                 free(lpBuf);
+            } else {
+                JNU_ThrowOutOfMemoryError(env, "native memory allocation failure");
             }
         }
+    } else {
+        throwWindowsException(env, GetLastError());
     }
-
-    if (len == 0)
-        throwWindowsException(env, GetLastError());
-
     return rv;
 }
 
--- a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c	Mon Mar 24 10:43:59 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -273,7 +273,9 @@
           NULL);                        // default security attribute
 
     if (hPipe == INVALID_HANDLE_VALUE) {
-        JNU_ThrowIOExceptionWithLastError(env, "CreateNamedPipe failed");
+        char msg[256];
+        _snprintf(msg, sizeof(msg), "CreateNamedPipe failed: %d", GetLastError());
+        JNU_ThrowIOExceptionWithLastError(env, msg);
     }
     return (jlong)hPipe;
 }
--- a/jdk/test/com/sun/corba/cachedSocket/7056731.sh	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/com/sun/corba/cachedSocket/7056731.sh	Mon Mar 24 10:43:59 2014 -0700
@@ -102,7 +102,7 @@
 sleep 5 # give time for Client to throw exception
 
 # JVM_PROC should have exited but just in case, include it.
-kill -9 $ORB_PROC $JVM_PROC
+kill -9 $ORB_PROC $JVM_PROC $SERVER_PROC
 
 grep "ORBUtilSystemException.writeErrorSend" client.$$
 result=$?
--- a/jdk/test/java/lang/Runtime/exec/ConcurrentRead.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/ConcurrentRead.java	Mon Mar 24 10:43:59 2014 -0700
@@ -30,21 +30,19 @@
 
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.File;
-import java.io.IOException;
 
 public class ConcurrentRead {
 
     static volatile Exception savedException;
-    static final String TEE = "/usr/bin/tee";
 
     public static void main(String[] args) throws Exception {
+        if (! UnixCommands.isUnix) {
+            System.out.println("For UNIX only");
+            return;
+        }
+        UnixCommands.ensureCommandsAvailable("tee");
 
-        if (File.separatorChar == '\\' ||                // Windows
-                                !new File(TEE).exists()) // no tee
-            return;
-
-        Process p = Runtime.getRuntime().exec(TEE);
+        Process p = Runtime.getRuntime().exec(UnixCommands.tee());
         OutputStream out = p.getOutputStream();
         InputStream in = p.getInputStream();
         Thread t1 = new WriterThread(out, in);
--- a/jdk/test/java/lang/Runtime/exec/ExecWithDir.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/ExecWithDir.java	Mon Mar 24 10:43:59 2014 -0700
@@ -28,21 +28,25 @@
  *          directory is specified
  */
 
-import java.io.*;
+import java.io.File;
 
 public class ExecWithDir {
 
-    private static final String CMD = "/bin/true";
     private static final int N = 500;
 
     public static void main(String args[]) throws Exception {
-        if (! new File(CMD).canExecute())
+        if (! UnixCommands.isUnix) {
+            System.out.println("For UNIX only");
             return;
+        }
+        UnixCommands.ensureCommandsAvailable("true");
+
+        final String trueCmd = UnixCommands.findCommand("true");
         File dir = new File(".");
         for (int i = 1; i <= N; i++) {
             System.out.print(i);
             System.out.print(" e");
-            Process p = Runtime.getRuntime().exec(CMD, null, dir);
+            Process p = Runtime.getRuntime().exec(trueCmd, null, dir);
             System.out.print('w');
             int s = p.waitFor();
             System.out.println("x " + s);
--- a/jdk/test/java/lang/Runtime/exec/ExecWithInput.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/ExecWithInput.java	Mon Mar 24 10:43:59 2014 -0700
@@ -39,7 +39,6 @@
 
 public class ExecWithInput {
 
-    private static final String CAT = "/bin/cat";
     private static final int N = 200;
 
     static int go(int i) throws Exception {
@@ -50,8 +49,7 @@
          * program exits. Under 1.4.1, cat sometimes gets stuck on a pipe
          * read and never terminates.
          */
-        //Process p = Runtime.getRuntime().exec(new String[] { CAT } );
-        Process p = Runtime.getRuntime().exec(CAT);
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
 
         String input = i + ": line 1\n" + i + ": line 2\n";
         StringBufferInputStream in = new StringBufferInputStream(input);
@@ -65,12 +63,12 @@
     }
 
     public static void main(String[] args) throws Exception {
-        if (!System.getProperty("os.name").equals("Linux"))
-            return;
-        if (File.separatorChar == '\\') {
-            // no /bin/cat on windows
+        if (! UnixCommands.isLinux) {
+            System.out.println("For Linux only");
             return;
         }
+        UnixCommands.ensureCommandsAvailable("cat");
+
         for (int i = 0; i < N; i++)
             go(i);
     }
@@ -93,7 +91,6 @@
 
         public void run() {
             try {
-                int c;
                 byte[] buf = new byte[8192];
                 int n;
                 while ((n = in.read(buf)) != -1) {
--- a/jdk/test/java/lang/Runtime/exec/ExitValue.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/ExitValue.java	Mon Mar 24 10:43:59 2014 -0700
@@ -68,13 +68,18 @@
                                                 int expectedExitValue)
         throws Exception
     {
-        checkExitValue(new String[] { "/bin/sh", "-c", posixShellProgram },
+        checkExitValue(new String[] { UnixCommands.sh(), "-c", posixShellProgram },
                        expectedExitValue);
     }
 
     final static int EXIT_CODE = 5;
 
     public static void main(String[] args) throws Exception {
+        if (! UnixCommands.isUnix) {
+            System.out.println("For UNIX only");
+            return;
+        }
+        UnixCommands.ensureCommandsAvailable("sh", "true", "kill");
 
         String java = join(File.separator, new String []
             { System.getProperty("java.home"), "bin", "java" });
@@ -85,17 +90,14 @@
               "ExitValue$Run", String.valueOf(EXIT_CODE)
             }, EXIT_CODE);
 
-        checkExitValue(new String[] { "/bin/true" }, 0);
+        checkExitValue(new String[] { UnixCommands.findCommand("true") }, 0);
 
         checkPosixShellExitValue("exit", 0);
 
         checkPosixShellExitValue("exit 7", 7);
 
-        if (new File("/bin/kill").exists()) {
-            int sigoffset =
-                System.getProperty("os.name").equals("SunOS") ? 0 : 128;
-            checkPosixShellExitValue("/bin/kill -9 $$", sigoffset+9);
-        }
+        int sigoffset = UnixCommands.isSunOS ? 0 : 128;
+        checkPosixShellExitValue(UnixCommands.kill() + " -9 $$", sigoffset+9);
     }
 
     public static class Run {
--- a/jdk/test/java/lang/Runtime/exec/LotsOfDestroys.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/LotsOfDestroys.java	Mon Mar 24 10:43:59 2014 -0700
@@ -28,19 +28,19 @@
  * @author kladko
  */
 
-import java.io.File;
-
 public class LotsOfDestroys {
     static final int RUNS = 400;
-    static final String ECHO = "/usr/bin/echo";
 
     public static void main(String[] args) throws Exception {
-        if (File.separatorChar == '\\' ||                // Windows
-                                !new File(ECHO).exists()) // no echo
+        if (! UnixCommands.isUnix) {
+            System.out.println("For UNIX only");
             return;
+        }
+        UnixCommands.ensureCommandsAvailable("echo");
 
-        for (int i = 0; i<= RUNS; i++) {
-            Process process = Runtime.getRuntime().exec(ECHO + " x");
+        for (int i = 0; i <= RUNS; i++) {
+            Process process = Runtime.getRuntime().exec(
+                    UnixCommands.echo() + " x");
             process.destroy();
         }
     }
--- a/jdk/test/java/lang/Runtime/exec/LotsOfOutput.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/LotsOfOutput.java	Mon Mar 24 10:43:59 2014 -0700
@@ -28,16 +28,16 @@
  * @author kladko
  */
 
-import java.io.File;
-
 public class LotsOfOutput {
-    static final String CAT = "/usr/bin/cat";
 
-    public static void main(String[] args) throws Exception{
-        if (File.separatorChar == '\\' ||                // Windows
-                                !new File(CAT).exists()) // no cat
+    public static void main(String[] args) throws Exception {
+        if (! UnixCommands.isUnix) {
+            System.out.println("For UNIX only");
             return;
-        Process p = Runtime.getRuntime().exec(CAT + " /dev/zero");
+        }
+        UnixCommands.ensureCommandsAvailable("cat");
+
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat() + " /dev/zero");
         long initMemory = Runtime.getRuntime().totalMemory();
         for (int i=1; i< 10; i++) {
             Thread.sleep(100);
--- a/jdk/test/java/lang/Runtime/exec/SleepyCat.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/SleepyCat.java	Mon Mar 24 10:43:59 2014 -0700
@@ -73,8 +73,8 @@
         // slower, making the child more likely to win the race!
         int iterations = 20;
         int timeout = 30;
-        String[] catArgs   = new String[] {"/bin/cat"};
-        String[] sleepArgs = new String[] {"/bin/sleep",
+        String[] catArgs   = new String[] {UnixCommands.cat()};
+        String[] sleepArgs = new String[] {UnixCommands.sleep(),
                                             String.valueOf(timeout+1)};
         Process[] cats   = new Process[iterations];
         Process[] sleeps = new Process[iterations];
@@ -126,8 +126,9 @@
         timer.schedule(sleeperExecutioner, timeout * 1000);
         byte[] buffer = new byte[10];
         String[] args =
-            new String[] {"/bin/sh", "-c",
-                          "exec sleep " + (timeout+1) + " >/dev/null"};
+            new String[] {UnixCommands.sh(), "-c",
+                          "exec " + UnixCommands.sleep() + " "
+                                  + (timeout+1) + " >/dev/null"};
 
         for (int i = 0;
              i < backgroundSleepers.length && !sleeperExecutioner.timedOut();
@@ -153,12 +154,13 @@
     }
 
     public static void main (String[] args) throws Exception {
-        try {
-            if (hang1() | hang2())
-                throw new Exception("Read from closed pipe hangs");
-        } catch (IOException e) {
-            // We will get here on non-Posix systems,
-            // which don't have cat and sleep and sh.
+        if (! UnixCommands.isUnix) {
+            System.out.println("For UNIX only");
+            return;
         }
+        UnixCommands.ensureCommandsAvailable("sh", "cat", "sleep");
+
+        if (hang1() | hang2())
+            throw new Exception("Read from closed pipe hangs");
     }
 }
--- a/jdk/test/java/lang/Runtime/exec/Status.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/Status.java	Mon Mar 24 10:43:59 2014 -0700
@@ -35,10 +35,15 @@
     public static void main(String args[])
         throws Exception
     {
-        if (!System.getProperty("os.name").equals("Linux"))
+        if (!System.getProperty("os.name").equals("Linux")) {
+            System.out.println("Only for Linux");
             return;
+        }
+        UnixCommands.ensureCommandsAvailable("false");
+
+        final String falseCmd = UnixCommands.findCommand("false");
         for (int i = 0; i < N; i++) {
-            Process p = Runtime.getRuntime().exec("false");
+            Process p = Runtime.getRuntime().exec(falseCmd);
             int s = p.waitFor();
             System.out.print(s);
             System.out.print(' ');
--- a/jdk/test/java/lang/Runtime/exec/StreamsSurviveDestroy.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/lang/Runtime/exec/StreamsSurviveDestroy.java	Mon Mar 24 10:43:59 2014 -0700
@@ -102,7 +102,7 @@
         CountDownLatch latch = new CountDownLatch(2);
 
         System.err.println("test");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 false, false, latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -122,7 +122,7 @@
         CountDownLatch latch = new CountDownLatch(2);
 
         System.err.println("testCloseBeforeDestroy");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 true, false, latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -143,7 +143,7 @@
     static void testCloseAfterDestroy() throws Exception {
         CountDownLatch latch = new CountDownLatch(2);
         System.err.println("testCloseAfterDestroy");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 true, false,latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -165,7 +165,7 @@
     static void testInterrupt() throws Exception {
         CountDownLatch latch = new CountDownLatch(2);
         System.err.println("testInterrupt");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 false, true, latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
@@ -186,10 +186,13 @@
 
     public static void main(String[] args) throws Exception {
 
-        // Applies only to Solaris; Linux and Windows
-        // behave a little differently
-        if (!System.getProperty("os.name").equals("SunOS"))
+        // Applies only to Solaris;
+        // Linux and Windows behave a little differently
+        if (! UnixCommands.isSunOS) {
+            System.out.println("For SunOS only");
             return;
+        }
+        UnixCommands.ensureCommandsAvailable("cat");
 
         test();
         testCloseBeforeDestroy();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Runtime/exec/UnixCommands.java	Mon Mar 24 10:43:59 2014 -0700
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ *
+ * 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.File;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Utility class for finding the command on the current system
+ */
+public class UnixCommands {
+
+    public static final boolean isUnix = ! System.getProperty("os.name").startsWith("Windows");
+    public static final boolean isLinux = System.getProperty("os.name").startsWith("Linux");
+    public static final boolean isSunOS = System.getProperty("os.name").equals("SunOS");
+
+    private static final String[] paths = {"/bin", "/usr/bin"};
+
+    private static Map<String,String> nameToCommand = new HashMap<>(16);
+
+    /**
+     * Throws Error unless every listed command is available on the system
+     */
+    public static void ensureCommandsAvailable(String... commands) {
+        for (String command : commands) {
+            if (findCommand(command) == null) {
+                throw new Error("Command '" + command + "' not found; bailing out");
+            }
+        }
+    }
+
+    /**
+     * If the path to the command could be found, returns the command with the full path.
+     * Otherwise, returns null.
+     */
+    public static String cat()   { return findCommand("cat"); }
+    public static String sh()    { return findCommand("sh"); }
+    public static String kill()  { return findCommand("kill"); }
+    public static String sleep() { return findCommand("sleep"); }
+    public static String tee()   { return findCommand("tee"); }
+    public static String echo()  { return findCommand("echo"); }
+
+    public static String findCommand(String name) {
+        if (nameToCommand.containsKey(name)) {
+            return nameToCommand.get(name);
+        }
+        String command = findCommand0(name);
+        nameToCommand.put(name, command);
+        return command;
+    }
+
+    private static String findCommand0(String name) {
+        for (String path : paths) {
+            File file = new File(path, name);
+            if (file.canExecute()) {
+                return file.getPath();
+            }
+        }
+        return null;
+    }
+}
--- a/jdk/test/java/nio/file/Path/PathOps.java	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/java/nio/file/Path/PathOps.java	Mon Mar 24 10:43:59 2014 -0700
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 6838333 6925932 7006126
+ * @bug 4313887 6838333 6925932 7006126 8037945
  * @summary Unit test for java.nio.file.Path path operations
  */
 
@@ -899,6 +899,8 @@
             .normalize("foo");
         test("/foo")
             .normalize("/foo");
+        test("")
+            .normalize("");
         test(".")
             .normalize("");
         test("..")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Arrays/StreamAndSpliterator.java	Mon Mar 24 10:43:59 2014 -0700
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test 8037857
+ * @summary tests for stream and spliterator factory methods
+ * @run testng StreamAndSpliterator
+ */
+
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Spliterators;
+
+import static org.testng.Assert.assertNotNull;
+
+public class StreamAndSpliterator {
+    @Test
+    public void testStreamNPEs() {
+        assertThrowsNPE(() -> Arrays.stream((int[]) null, 0, 0));
+        assertThrowsNPE(() -> Arrays.stream((long[]) null, 0, 0));
+        assertThrowsNPE(() -> Arrays.stream((double[]) null, 0, 0));
+        assertThrowsNPE(() -> Arrays.stream((String[]) null, 0, 0));
+    }
+
+    @Test
+    public void testStreamAIOBEs() {
+        // origin > fence
+        assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 1, 0));
+        assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 1, 0));
+        assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 1, 0));
+        assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 1, 0));
+
+        // bad origin
+        assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, -1, 0));
+        assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, -1, 0));
+        assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, -1, 0));
+        assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, -1, 0));
+
+        // bad fence
+        assertThrowsAIOOB(() -> Arrays.stream(new int[]{}, 0, 1));
+        assertThrowsAIOOB(() -> Arrays.stream(new long[]{}, 0, 1));
+        assertThrowsAIOOB(() -> Arrays.stream(new double[]{}, 0, 1));
+        assertThrowsAIOOB(() -> Arrays.stream(new String[]{}, 0, 1));
+    }
+
+
+    @Test
+    public void testSpliteratorNPEs() {
+        assertThrowsNPE(() -> Arrays.spliterator((int[]) null, 0, 0));
+        assertThrowsNPE(() -> Arrays.spliterator((long[]) null, 0, 0));
+        assertThrowsNPE(() -> Arrays.spliterator((double[]) null, 0, 0));
+        assertThrowsNPE(() -> Arrays.spliterator((String[]) null, 0, 0));
+    }
+
+    @Test
+    public void testSpliteratorAIOBEs() {
+        // origin > fence
+        assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 1, 0));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 1, 0));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 1, 0));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 1, 0));
+
+        // bad origin
+        assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, -1, 0));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, -1, 0));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, -1, 0));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, -1, 0));
+
+        // bad fence
+        assertThrowsAIOOB(() -> Arrays.spliterator(new int[]{}, 0, 1));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new long[]{}, 0, 1));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new double[]{}, 0, 1));
+        assertThrowsAIOOB(() -> Arrays.spliterator(new String[]{}, 0, 1));
+    }
+
+
+    @Test
+    public void testSpliteratorNPEsFromSpliterators() {
+        assertThrowsNPE(() -> Spliterators.spliterator((int[]) null, 0, 0, 0));
+        assertThrowsNPE(() -> Spliterators.spliterator((long[]) null, 0, 0, 0));
+        assertThrowsNPE(() -> Spliterators.spliterator((double[]) null, 0, 0, 0));
+        assertThrowsNPE(() -> Spliterators.spliterator((String[]) null, 0, 0, 0));
+    }
+
+    @Test
+    public void testSpliteratorAIOBEsFromSpliterators() {
+        // origin > fence
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 1, 0, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 1, 0, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 1, 0, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 1, 0, 0));
+
+        // bad origin
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, -1, 0, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, -1, 0, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, -1, 0, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, -1, 0, 0));
+
+        // bad fence
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new int[]{}, 0, 1, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new long[]{}, 0, 1, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new double[]{}, 0, 1, 0));
+        assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 0, 1, 0));
+    }
+
+    void assertThrowsNPE(Runnable r) {
+        NullPointerException caught = null;
+        try {
+            r.run();
+        }
+        catch (NullPointerException e) {
+            caught = e;
+        }
+        assertNotNull(caught, "NullPointerException not thrown");
+    }
+
+    void assertThrowsAIOOB(Runnable r) {
+        ArrayIndexOutOfBoundsException caught = null;
+        try {
+            r.run();
+        }
+        catch (ArrayIndexOutOfBoundsException e) {
+            caught = e;
+        }
+        assertNotNull(caught, "ArrayIndexOutOfBoundsException not thrown");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/jaxp/XPath/8035577/Regex.java	Mon Mar 24 10:43:59 2014 -0700
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+/*
+ * @test
+ * @bug 8035577
+ * @summary Tests for xpath regular expression methods.
+ * @run main Regex
+ * @author david.x.li@oracle.com
+ */
+
+import com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression;
+import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
+
+public class Regex {
+
+    public static void main(String[] args) {
+        testIntersect();
+    }
+
+    static void testIntersect() {
+        // The use of intersection operator & is not allowed in
+        // XML schema.  Consequently, the intersection operator
+        // can never be called except for internal API usage.
+        // Following test illustrates this.
+        try{
+            new RegularExpression("(?[b-d]&[a-r])", "X");
+            throw new RuntimeException ("Xerces XPath Regex: " +
+                "intersection not allowed in XML schema mode, " +
+                "exception expected above.");
+        }
+        catch (ParseException e) {
+            // Empty, expecting an exception
+        }
+
+        // Bug 8035577: verifying a typo fix in RangeToken.intersectRanges.
+        // Note: Each test case has a diagram showing the ranges being tested.
+        // Following test case will trigger the typo.
+        // o-----o
+        //    o-----o
+        RegularExpression ce = new RegularExpression("(?[a-e]&[c-r])");
+        if (!(ce.matches("c") && ce.matches("d") && ce.matches("e"))) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[c-e] expected to match c,d,e.");
+        }
+
+        if (ce.matches("b") || ce.matches("f")) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[c-e] not expected to match b or f.");
+        }
+
+        // Test the expected behavior after fixing the typo.
+        //    o------o
+        // o-------------o
+        RegularExpression bd = new RegularExpression("(?[b-d]&[a-r])");
+        if (!(bd.matches("b") && bd.matches("c") && bd.matches("d"))) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[b-d] expected to match b,c,d.");
+        }
+
+        if (bd.matches("e") || bd.matches("a")) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[b-d] not expected to match a or e.");
+        }
+
+        // Bug fix for first range ends later than second range.
+        // o--------o
+        //    o--o
+        RegularExpression bd2 = new RegularExpression("(?[a-r]&[b-d])");
+        if (!(bd.matches("b") && bd.matches("c") && bd.matches("d"))) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[b-d] expected to match b,c,d, test 2.");
+        }
+
+        if (bd2.matches("e") || bd2.matches("a")) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[b-d] not expected to match a or e, test 2.");
+        }
+
+        //    o-----o
+        // o----o
+        RegularExpression dh = new RegularExpression("(?[d-z]&[a-h])");
+        if (!(dh.matches("d") && dh.matches("e") && dh.matches("h"))) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[d-h] expected to match d,e,h.");
+        }
+
+        if (dh.matches("c") || bd2.matches("i")) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[d-h] not expected to match c or i.");
+        }
+
+        // Test code improvement, addition of src2+=2 to one of the
+        // conditions.  In this case, src1 leftover from matching
+        // first portion of src2 is re-used to match against the next
+        // portion of src2.
+        // o--------------o
+        //   o--o  o--o
+        RegularExpression dfhk = new RegularExpression("(?[b-r]&[d-fh-k])");
+        if (!(dfhk.matches("d") && dfhk.matches("f") && dfhk.matches("h") && dfhk.matches("k"))) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[d-fh-k] expected to match d,f,h,k.");
+        }
+
+        if (dfhk.matches("c") || dfhk.matches("g") || dfhk.matches("l")) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[d-fh-k] not expected to match c,g,l.");
+        }
+
+        // random tests
+        //    o------------o
+        // o-----o  o--o
+        RegularExpression cfhk = new RegularExpression("(?[c-r]&[b-fh-k])");
+        if (!(cfhk.matches("c") && cfhk.matches("f") && cfhk.matches("h") && cfhk.matches("k"))) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[c-fh-k] expected to match c,f,h,k.");
+        }
+
+        if (cfhk.matches("b") || cfhk.matches("g") || cfhk.matches("l")) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[c-fh-k] not expected to match b,g,l.");
+        }
+
+        // o----------o
+        //    o-----------o
+        //  o----o  o---o
+        RegularExpression ekor = new RegularExpression("(?[a-r]&[e-z]&[c-ko-s])");
+        if (!(ekor.matches("e") && ekor.matches("k") && ekor.matches("o") && ekor.matches("r"))) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[e-ko-r] expected to match e,k,o,r.");
+        }
+
+        if (ekor.matches("d") || ekor.matches("l") || ekor.matches("s")) {
+            throw new RuntimeException("Xerces XPath Regex Error: " +
+                "[e-ko-r] not expected to match d,l,s.");
+        }
+
+    }
+
+}
--- a/jdk/test/sun/tools/jinfo/Basic.sh	Sun Mar 23 13:49:48 2014 -0700
+++ b/jdk/test/sun/tools/jinfo/Basic.sh	Mon Mar 24 10:43:59 2014 -0700
@@ -40,6 +40,7 @@
 
 # all return statuses are checked in this test
 set +e
+set -x
 
 failed=0
 
@@ -71,16 +72,6 @@
     # no option
     ${JINFO} -J-XX:+UsePerfData -F $appJavaPid
     if [ $? != 0 ]; then failed=1; fi
-
-    # -flag option
-    ${JINFO} -J-XX:+UsePerfData -F -flag +PrintGC $appJavaPid
-    if [ $? != 0 ]; then failed=1; fi 
-
-    ${JINFO} -J-XX:+UsePerfData -F -flag -PrintGC $appJavaPid
-    if [ $? != 0 ]; then failed=1; fi
-
-    ${JINFO} -J-XX:+UsePerfData -F -flag PrintGC $appJavaPid
-    if [ $? != 0 ]; then failed=1; fi
 fi
 
 # -sysprops option