diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 4748a943834bc6d4785016ad84a64b1c0b316a37..519f598b86e2fb7cac0b0ac1246eaa091c923fea 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -266,3 +266,4 @@ ee4fd72b2ec3d92497f37163352f294aa695c6fb jdk9-b20
 9052803f4d01feda28b3d65f2b64dd457d21c7b6 jdk9-b21
 8e4bdab4c362aadde2d321f968cd503a2f779e2f jdk9-b22
 88567461a2cd9b7fb431fee6440005a694df1f47 jdk9-b23
+1d4a293fbec19dc2d5790bbb2c7dd0ed8f265484 jdk9-b24
diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
index 57465032e7744c3d5b1297103e9939cbbb74af83..39216b544a693a0116ca20b081b37aea92dc6f17 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -4311,7 +4311,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++"
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1404942241
+DATE_WHEN_GENERATED=1405336663
 
 ###############################################################################
 #
@@ -14548,7 +14548,7 @@ $as_echo "$with_jvm_variants" >&6; }
   if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then
     INCLUDE_SA=false
   fi
-  if test "x$VAR_CPU" = xppc64 ; then
+  if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
 
diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4
index b012aa756b487cf69b1c168e243cd91833d9de4c..75affdeeeef1721745f1f1254daa03fd66a71148 100644
--- a/common/autoconf/jdk-options.m4
+++ b/common/autoconf/jdk-options.m4
@@ -158,7 +158,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JVM_VARIANTS],
   if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then
     INCLUDE_SA=false
   fi
-  if test "x$VAR_CPU" = xppc64 ; then
+  if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
   AC_SUBST(INCLUDE_SA)
diff --git a/corba/.hgtags b/corba/.hgtags
index a6c27d443ef01fa71664a5805e46040b619c8dca..25bbe5d05c0c245ec60fc0b8a9d17fffef67580e 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -266,3 +266,4 @@ eecc1b6adc7e193d00a0641eb0963add5a4c06e8 jdk9-b19
 3615a4e7f0542ca7552ad6454b742c73ee211d8e jdk9-b21
 ddc07abf4307855c0dc904cc5c96cc764023a930 jdk9-b22
 57735d66face054440a63ce99789eac5a5ee1dfd jdk9-b23
+8a44142bb7fc8118f70f91a1b97c12dfc50563ee jdk9-b24
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 41a4099fc84141bc5b8a37fd7f7ab028b130048f..63e06453ec99ddd12a4a31d6e83258b7b33e9365 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -426,3 +426,4 @@ c1af79d122ec9f715fa29312b5e91763f3a4dfc4 jdk9-b20
 17b4a5e831b398738feedb0afe75245744510153 jdk9-b21
 518d1fcc0799494f013e00e0a94a91b6f212d54f jdk9-b22
 dd472cdacc32e3afc7c5bfa7ef16ea0e0befb7fa jdk9-b23
+dde2d03b0ea46a27650839e3a1d212c7c1f7b4c8 jdk9-b24
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java
index c963350591da2066db6201364eeb1207ded186ab..36fb55066602f5e144c1e12e4e2cef161fe46058 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, 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,6 +33,7 @@ import sun.jvm.hotspot.debugger.DebuggerException;
 import sun.jvm.hotspot.debugger.JVMDebugger;
 import sun.jvm.hotspot.debugger.MachineDescription;
 import sun.jvm.hotspot.debugger.MachineDescriptionAMD64;
+import sun.jvm.hotspot.debugger.MachineDescriptionPPC64;
 import sun.jvm.hotspot.debugger.MachineDescriptionIA64;
 import sun.jvm.hotspot.debugger.MachineDescriptionIntelX86;
 import sun.jvm.hotspot.debugger.MachineDescriptionSPARC32Bit;
@@ -588,6 +589,8 @@ public class HotSpotAgent {
             machDesc = new MachineDescriptionIA64();
         } else if (cpu.equals("amd64")) {
             machDesc = new MachineDescriptionAMD64();
+        } else if (cpu.equals("ppc64")) {
+            machDesc = new MachineDescriptionPPC64();
         } else if (cpu.equals("sparc")) {
             if (LinuxDebuggerLocal.getAddressSize()==8) {
                     machDesc = new MachineDescriptionSPARC64Bit();
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionPPC64.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionPPC64.java
new file mode 100644
index 0000000000000000000000000000000000000000..070ac8d42d625a7f693c048df2b0a9a633fb2aa1
--- /dev/null
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionPPC64.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ */
+
+package sun.jvm.hotspot.debugger;
+
+public class MachineDescriptionPPC64 extends MachineDescriptionTwosComplement implements MachineDescription {
+  public long getAddressSize() {
+    return 8;
+  }
+
+  public boolean isLP64() {
+    return true;
+  }
+
+  public boolean isBigEndian() {
+    return true;
+  }
+}
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java
index afe81ef578d2346e1110853c496754f8d9ef79c4..c1c76c73ac76703750981d28512fc8fede6e165c 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, 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
@@ -61,7 +61,7 @@ public class PlatformInfo {
       return "x86";
     } else if (cpu.equals("sparc") || cpu.equals("sparcv9")) {
       return "sparc";
-    } else if (cpu.equals("ia64") || cpu.equals("amd64") || cpu.equals("x86_64")) {
+    } else if (cpu.equals("ia64") || cpu.equals("amd64") || cpu.equals("x86_64") || cpu.equals("ppc64")) {
       return cpu;
     } else {
       try {
diff --git a/hotspot/make/aix/makefiles/buildtree.make b/hotspot/make/aix/makefiles/buildtree.make
index eb8fc24e637073a7caa2a9894687a0f208aaf9f8..ddeb64c0a34b76bec7a95bd181ad563646d79eaf 100644
--- a/hotspot/make/aix/makefiles/buildtree.make
+++ b/hotspot/make/aix/makefiles/buildtree.make
@@ -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.
 # Copyright 2012, 2013 SAP AG. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
@@ -274,6 +274,8 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 	echo; \
 	[ -n "$(SPEC)" ] && \
 	    echo "include $(SPEC)"; \
+	echo "CP ?= cp"; \
+	echo "MV ?= mv"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 	echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
diff --git a/hotspot/make/aix/makefiles/jsig.make b/hotspot/make/aix/makefiles/jsig.make
index 301aa84195b6f7a11e8e7b5f716b2ade150be053..08657fc6db213804d6bbff4fccb4bcf4d5f026c9 100644
--- a/hotspot/make/aix/makefiles/jsig.make
+++ b/hotspot/make/aix/makefiles/jsig.make
@@ -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.
 # Copyright 2012, 2013 SAP AG. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
@@ -20,7 +20,7 @@
 # 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.
-#  
+#
 #
 
 # Rules to build signal interposition library, used by vm.make
@@ -40,8 +40,8 @@ DEST_JSIG_DIZ       = $(JDK_LIBDIR)/$(LIBJSIG_DIZ)
 
 LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
 
-# On Linux we really dont want a mapfile, as this library is small 
-# and preloaded using LD_PRELOAD, making functions private will 
+# On Linux we really dont want a mapfile, as this library is small
+# and preloaded using LD_PRELOAD, making functions private will
 # cause problems with interposing. See CR: 6466665
 # LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
 
@@ -79,9 +79,9 @@ $(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
 install_jsig: $(LIBJSIG)
 	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
 	$(QUIETLY) test -f $(LIBJSIG_DEBUGINFO) && \
-	    cp -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
+	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
 	$(QUIETLY) test -f $(LIBJSIG_DIZ) && \
-	    cp -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
+	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
 
 .PHONY: install_jsig
diff --git a/hotspot/make/aix/makefiles/rules.make b/hotspot/make/aix/makefiles/rules.make
index 33898f5c85893b0fa2c82836107cfcebe823daba..c6f32c218064ff1fe958b4a9326d7cd08743a057 100644
--- a/hotspot/make/aix/makefiles/rules.make
+++ b/hotspot/make/aix/makefiles/rules.make
@@ -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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Common rules/macros for the vm, adlc.
@@ -28,7 +28,7 @@
 .SUFFIXES: .cpp $(SUFFIXES)
 
 DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
+DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
 
 # $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
 CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
diff --git a/hotspot/make/aix/makefiles/sa.make b/hotspot/make/aix/makefiles/sa.make
index b711afb4024e577c8c23368c8beb62e24e52e4a8..02ce87c6c68099f328a1a608f31a39169770c40a 100644
--- a/hotspot/make/aix/makefiles/sa.make
+++ b/hotspot/make/aix/makefiles/sa.make
@@ -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.
 # Copyright 2012, 2013 SAP AG. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
@@ -98,11 +98,11 @@ $(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
 	$(QUIETLY) $(REMOTE) $(COMPILE.RMIC)  -classpath $(SA_CLASSDIR) -d $(SA_CLASSDIR) sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer
 	$(QUIETLY) echo "$(SA_BUILD_VERSION_PROP)" > $(SA_PROPERTIES)
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql/sa.js
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
 	$(QUIETLY) mkdir -p $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/*
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
-	$(QUIETLY) cp -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
+	$(QUIETLY) $(CP) -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
 	$(QUIETLY) $(REMOTE) $(RUN.JAR) cf $@ -C $(SA_CLASSDIR)/ .
 	$(QUIETLY) $(REMOTE) $(RUN.JAR) uf $@ -C $(AGENT_SRC_DIR) META-INF/services/com.sun.jdi.connect.Connector
 	$(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.x86.X86ThreadContext
diff --git a/hotspot/make/aix/makefiles/saproc.make b/hotspot/make/aix/makefiles/saproc.make
index a7f28914a3d7fce0ce248dcc9fa99f9bdbd33cef..cd8019c22e8be25e9e4af185e15cb1fcdb56132d 100644
--- a/hotspot/make/aix/makefiles/saproc.make
+++ b/hotspot/make/aix/makefiles/saproc.make
@@ -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.
 # Copyright 2012, 2013 SAP AG. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
@@ -20,7 +20,7 @@
 # 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 $(GAMMADIR)/make/defs.make
 
@@ -108,10 +108,10 @@ install_saproc: $(BUILDLIBSAPROC)
 	$(QUIETLY) if [ -e $(LIBSAPROC) ] ; then             \
 	  echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)";     \
 	  test -f $(LIBSAPROC_DEBUGINFO) &&                  \
-	    cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
+	    $(CP) -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
 	  test -f $(LIBSAPROC_DIZ) &&                  \
-	    cp -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ); \
-	  cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";  \
+	    $(CP) -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ); \
+	  $(CP) -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";  \
 	fi
 
 .PHONY: install_saproc
diff --git a/hotspot/make/aix/makefiles/top.make b/hotspot/make/aix/makefiles/top.make
index 95e6e6856e81a13eea2aef8a9398902cd3dd5803..4fc96b5fd746d1f598cf58d2d2d4653acd4f23f6 100644
--- a/hotspot/make/aix/makefiles/top.make
+++ b/hotspot/make/aix/makefiles/top.make
@@ -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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # top.make is included in the Makefile in the build directories.
@@ -45,10 +45,10 @@ TOPDIR      = $(shell echo `pwd`)
 GENERATED   = $(TOPDIR)/../generated
 VM          = $(GAMMADIR)/src/share/vm
 Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED); 
+CDG         = cd $(GENERATED);
 
 ifneq ($(USE_PRECOMPILED_HEADER),0)
-UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) 
+UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS)
 else
 UpdatePCH = \# precompiled header is not used
 endif
@@ -84,7 +84,7 @@ vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) trace_stu
 	@# We need a null action here, so implicit rules don't get consulted.
 
 $(Cached_plat): $(Plat_File)
-	$(CDG) cp $(Plat_File) $(Cached_plat)
+	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
 
 # make AD files as necessary
 ad_stuff: $(Cached_plat) $(adjust-mflags)
@@ -125,12 +125,12 @@ install gamma: the_vm
 # next rules support "make foo.[ois]"
 
 %.o %.i %.s:
-	$(UpdatePCH) 
+	$(UpdatePCH)
 	$(MAKE) -f vm.make $(MFLAGS) $@
 	#$(MAKE) -f vm.make $@
 
 # this should force everything to be rebuilt
-clean: 
+clean:
 	rm -f $(GENERATED)/*.class
 	$(MAKE) -f vm.make $(MFLAGS) clean
 
diff --git a/hotspot/make/aix/makefiles/vm.make b/hotspot/make/aix/makefiles/vm.make
index 1170b0477d65595f6057c1cf4f1dd604980a8177..4177591e2bb8e76e894f70a34e5c6aaa0c631644 100644
--- a/hotspot/make/aix/makefiles/vm.make
+++ b/hotspot/make/aix/makefiles/vm.make
@@ -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.
 # Copyright 2012, 2013 SAP AG. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
@@ -346,10 +346,10 @@ DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
 install_jvm: $(LIBJVM)
 	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
 	$(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \
-	    cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
+	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
 	$(QUIETLY) test -f $(LIBJVM_DIZ) && \
-	    cp -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
+	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
 
 #----------------------------------------------------------------------
 # Other files
diff --git a/hotspot/make/bsd/makefiles/buildtree.make b/hotspot/make/bsd/makefiles/buildtree.make
index 1ed146c729bd74dd0b479f920e8a70381f253358..3a7efca537dfe0c521323c9a3536b3546b325257 100644
--- a/hotspot/make/bsd/makefiles/buildtree.make
+++ b/hotspot/make/bsd/makefiles/buildtree.make
@@ -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
@@ -278,6 +278,8 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 	echo; \
 	[ -n "$(SPEC)" ] && \
 	    echo "include $(SPEC)"; \
+	echo "CP ?= cp"; \
+	echo "MV ?= mv"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 	echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
diff --git a/hotspot/make/bsd/makefiles/jsig.make b/hotspot/make/bsd/makefiles/jsig.make
index 220a5d091f606d114308308ee317e92b5ac60fab..df03f9c75ea44d37d520bb58ff51f6de7d815567 100644
--- a/hotspot/make/bsd/makefiles/jsig.make
+++ b/hotspot/make/bsd/makefiles/jsig.make
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Rules to build signal interposition library, used by vm.make
@@ -47,8 +47,8 @@ DEST_JSIG_DIZ       = $(JDK_LIBDIR)/$(LIBJSIG_DIZ)
 
 LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
 
-# On Bsd we really dont want a mapfile, as this library is small 
-# and preloaded using LD_PRELOAD, making functions private will 
+# On Bsd we really dont want a mapfile, as this library is small
+# and preloaded using LD_PRELOAD, making functions private will
 # cause problems with interposing. See CR: 6466665
 # LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
 
@@ -92,13 +92,13 @@ install_jsig: $(LIBJSIG)
 	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
 ifeq ($(OS_VENDOR), Darwin)
 	$(QUIETLY) test ! -d $(LIBJSIG_DEBUGINFO) || \
-	    cp -f -r $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
+	    $(CP) -f -r $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
 else
 	$(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \
-	    cp -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
+	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
 endif
 	$(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \
-	    cp -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
+	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
 
 .PHONY: install_jsig
diff --git a/hotspot/make/bsd/makefiles/rules.make b/hotspot/make/bsd/makefiles/rules.make
index d40b88d5ed02f31dc12d2afbd4b43213d275a7a1..c6f32c218064ff1fe958b4a9326d7cd08743a057 100644
--- a/hotspot/make/bsd/makefiles/rules.make
+++ b/hotspot/make/bsd/makefiles/rules.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2012, 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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Common rules/macros for the vm, adlc.
@@ -28,7 +28,7 @@
 .SUFFIXES: .cpp $(SUFFIXES)
 
 DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
+DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
 
 # $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
 CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
diff --git a/hotspot/make/bsd/makefiles/sa.make b/hotspot/make/bsd/makefiles/sa.make
index 83b9b7954beaebb48c4964490bce96f885f972fb..417a748f2eac775bfc47f1e872496c529f00e40a 100644
--- a/hotspot/make/bsd/makefiles/sa.make
+++ b/hotspot/make/bsd/makefiles/sa.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2012, 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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # This makefile (sa.make) is included from the sa.make in the
@@ -71,7 +71,7 @@ SA_PROPERTIES = $(SA_CLASSDIR)/sa.properties
 # if $(AGENT_DIR) does not exist, we don't build SA
 # also, we don't build SA on Itanium, PowerPC, ARM or zero.
 
-all: 
+all:
 	if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" \
              -a "$(SRCARCH)" != "arm" \
              -a "$(SRCARCH)" != "ppc" \
@@ -112,11 +112,11 @@ $(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
 	$(QUIETLY) $(REMOTE) $(COMPILE.RMIC)  -classpath $(SA_CLASSDIR) -d $(SA_CLASSDIR) sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer
 	$(QUIETLY) echo "$(SA_BUILD_VERSION_PROP)" > $(SA_PROPERTIES)
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql/sa.js
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
 	$(QUIETLY) mkdir -p $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/*
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
-	$(QUIETLY) cp -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
+	$(QUIETLY) $(CP) -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
 	$(QUIETLY) $(REMOTE) $(RUN.JAR) cf $@ -C $(SA_CLASSDIR)/ .
 	$(QUIETLY) $(REMOTE) $(RUN.JAR) uf $@ -C $(AGENT_SRC_DIR) META-INF/services/com.sun.jdi.connect.Connector
 	$(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.x86.X86ThreadContext
diff --git a/hotspot/make/bsd/makefiles/saproc.make b/hotspot/make/bsd/makefiles/saproc.make
index 1b0d5d603e860c7a48ff10f673a53327251a4901..80993afbeceff0b5f66707567a573eca616b7d82 100644
--- a/hotspot/make/bsd/makefiles/saproc.make
+++ b/hotspot/make/bsd/makefiles/saproc.make
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Rules to build serviceability agent library, used by vm.make
@@ -83,7 +83,7 @@ else
     endif
   else
     SASRCFILES = $(SASRCDIR)/StubDebuggerLocal.c
-    SALIBS = 
+    SALIBS =
     SAARCH = $(ARCHFLAG)
   endif
 endif
@@ -163,13 +163,13 @@ install_saproc: $(BUILDLIBSAPROC)
 	@echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)"
 ifeq ($(OS_VENDOR), Darwin)
 	$(QUIETLY) test ! -d $(LIBSAPROC_DEBUGINFO) || \
-	    cp -f -r $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO)
+	    $(CP) -f -r $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO)
 else
 	$(QUIETLY) test ! -f $(LIBSAPROC_DEBUGINFO) || \
-	    cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO)
+	    $(CP) -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO)
 endif
 	$(QUIETLY) test ! -f $(LIBSAPROC_DIZ) || \
-	    cp -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ)
-	$(QUIETLY) cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done"
+	    $(CP) -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done"
 
 .PHONY: install_saproc
diff --git a/hotspot/make/bsd/makefiles/top.make b/hotspot/make/bsd/makefiles/top.make
index 6094e83c8412fa4e72de0efceaa8418c5fc02691..fd0dc57dbb0c50c37d5a7b1e5c02b0cd8abaabed 100644
--- a/hotspot/make/bsd/makefiles/top.make
+++ b/hotspot/make/bsd/makefiles/top.make
@@ -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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # top.make is included in the Makefile in the build directories.
@@ -45,10 +45,10 @@ TOPDIR      = $(shell echo `pwd`)
 GENERATED   = $(TOPDIR)/../generated
 VM          = $(GAMMADIR)/src/share/vm
 Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED); 
+CDG         = cd $(GENERATED);
 
 ifneq ($(USE_PRECOMPILED_HEADER),0)
-UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) 
+UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS)
 else
 UpdatePCH = \# precompiled header is not used
 endif
@@ -84,7 +84,7 @@ vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stu
 	@# We need a null action here, so implicit rules don't get consulted.
 
 $(Cached_plat): $(Plat_File)
-	$(CDG) cp $(Plat_File) $(Cached_plat)
+	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
 
 # make AD files as necessary
 ad_stuff: $(Cached_plat) $(adjust-mflags)
@@ -134,12 +134,12 @@ install : the_vm
 # next rules support "make foo.[ois]"
 
 %.o %.i %.s:
-	$(UpdatePCH) 
+	$(UpdatePCH)
 	$(MAKE) -f vm.make $(MFLAGS) $@
 	#$(MAKE) -f vm.make $@
 
 # this should force everything to be rebuilt
-clean: 
+clean:
 	rm -f $(GENERATED)/*.class
 	$(MAKE) -f vm.make $(MFLAGS) clean
 
diff --git a/hotspot/make/bsd/makefiles/vm.make b/hotspot/make/bsd/makefiles/vm.make
index 3a658ab13738813a38ccd99827935a4b40dc4afe..8c5d281ffc007a36173c5b1f008ee39d62156e3b 100644
--- a/hotspot/make/bsd/makefiles/vm.make
+++ b/hotspot/make/bsd/makefiles/vm.make
@@ -360,14 +360,14 @@ install_jvm: $(LIBJVM)
 	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
 ifeq ($(OS_VENDOR), Darwin)
 	$(QUIETLY) test ! -d $(LIBJVM_DEBUGINFO) || \
-	    cp -f -r $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
+	    $(CP) -f -r $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
 else
 	$(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \
-	    cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
+	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
 endif
 	$(QUIETLY) test ! -f $(LIBJVM_DIZ) || \
-	    cp -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
+	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
 
 #----------------------------------------------------------------------
 # Other files
diff --git a/hotspot/make/jprt.properties b/hotspot/make/jprt.properties
index eea0ef533911a0b4b961460d9b4ef780de69eef3..22c7b05ad6d31d750dc0ce01bc085874c0a587b7 100644
--- a/hotspot/make/jprt.properties
+++ b/hotspot/make/jprt.properties
@@ -350,21 +350,25 @@ jprt.make.rule.test.targets.standard.internalvmtests = \
   ${jprt.my.windows.i586}-fastdebug-c2-internalvmtests, \
   ${jprt.my.windows.x64}-fastdebug-c2-internalvmtests
 
-jprt.make.rule.test.targets.standard.wbapi = \
-  ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-wbapitest, \
-  ${jprt.my.solaris.x64}-{product|fastdebug}-c2-wbapitest, \
-  ${jprt.my.linux.i586}-{product|fastdebug}-c2-wbapitest, \
-  ${jprt.my.linux.x64}-{product|fastdebug}-c2-wbapitest, \
-  ${jprt.my.windows.i586}-{product|fastdebug}-c2-wbapitest, \
-  ${jprt.my.windows.x64}-{product|fastdebug}-c2-wbapitest, \
-  ${jprt.my.linux.i586}-{product|fastdebug}-c1-wbapitest, \
-  ${jprt.my.windows.i586}-{product|fastdebug}-c1-wbapitest
+jprt.make.rule.test.targets.standard.reg.group = \
+  ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GROUP, \
+  ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GROUP, \
+  ${jprt.my.linux.i586}-{product|fastdebug}-c2-GROUP, \
+  ${jprt.my.linux.x64}-{product|fastdebug}-c2-GROUP, \
+  ${jprt.my.windows.i586}-{product|fastdebug}-c2-GROUP, \
+  ${jprt.my.windows.x64}-{product|fastdebug}-c2-GROUP, \
+  ${jprt.my.linux.i586}-{product|fastdebug}-c1-GROUP, \
+  ${jprt.my.windows.i586}-{product|fastdebug}-c1-GROUP
 
 jprt.make.rule.test.targets.standard = \
   ${jprt.make.rule.test.targets.standard.client}, \
   ${jprt.make.rule.test.targets.standard.server}, \
   ${jprt.make.rule.test.targets.standard.internalvmtests}, \
-  ${jprt.make.rule.test.targets.standard.wbapi}
+  ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_wbapitest}, \
+  ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_compiler}, \
+  ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_gc}, \
+  ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_runtime}, \
+  ${jprt.make.rule.test.targets.standard.reg.group:GROUP=hotspot_serviceability}
 
 jprt.make.rule.test.targets.embedded = \
   ${jprt.make.rule.test.targets.standard.client}
diff --git a/hotspot/make/linux/makefiles/buildtree.make b/hotspot/make/linux/makefiles/buildtree.make
index d9c053e50cdfd8352724d1ccafbefeef2dc10f53..091c752ce5d38f21647a1061fdb129d3b21851ac 100644
--- a/hotspot/make/linux/makefiles/buildtree.make
+++ b/hotspot/make/linux/makefiles/buildtree.make
@@ -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
@@ -277,6 +277,8 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 	echo; \
 	[ -n "$(SPEC)" ] && \
 	    echo "include $(SPEC)"; \
+	echo "CP ?= cp"; \
+	echo "MV ?= mv"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 	echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
diff --git a/hotspot/make/linux/makefiles/defs.make b/hotspot/make/linux/makefiles/defs.make
index a3ba3fbb4d221da42791b6da5315153a7b825c68..373ad7cf95af925164a0beb9665f83e28cab75c0 100644
--- a/hotspot/make/linux/makefiles/defs.make
+++ b/hotspot/make/linux/makefiles/defs.make
@@ -297,27 +297,23 @@ ifeq ($(JVM_VARIANT_MINIMAL1),true)
 endif
 
 # Serviceability Binaries
-# No SA Support for PPC, IA64, ARM or zero
-ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
-                        $(EXPORT_LIB_DIR)/sa-jdi.jar
-ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
-                        $(EXPORT_LIB_DIR)/sa-jdi.jar
+
+ADD_SA_BINARIES/DEFAULT = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
+                          $(EXPORT_LIB_DIR)/sa-jdi.jar
+
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
   ifeq ($(ZIP_DEBUGINFO_FILES),1)
-    ADD_SA_BINARIES/x86   += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz
-    ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz
+    ADD_SA_BINARIES/DEFAULT += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.diz
   else
-    ADD_SA_BINARIES/x86   += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo
-    ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo
+    ADD_SA_BINARIES/DEFAULT += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo
   endif
 endif
-ADD_SA_BINARIES/ppc   =
-ADD_SA_BINARIES/ia64  =
-ADD_SA_BINARIES/arm   =
+
+ADD_SA_BINARIES/$(HS_ARCH) = $(ADD_SA_BINARIES/DEFAULT)
+
+# No SA Support for zero
 ADD_SA_BINARIES/zero  =
 
 -include $(HS_ALT_MAKE)/linux/makefiles/defs.make
 
 EXPORT_LIST += $(ADD_SA_BINARIES/$(HS_ARCH))
-
-
diff --git a/hotspot/make/linux/makefiles/jsig.make b/hotspot/make/linux/makefiles/jsig.make
index 8295cbbe6ec2d2b1888d5b9814d6138cc5da0837..208a5e58cd83af5697cc52ee7bc78602028b59da 100644
--- a/hotspot/make/linux/makefiles/jsig.make
+++ b/hotspot/make/linux/makefiles/jsig.make
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Rules to build signal interposition library, used by vm.make
@@ -39,8 +39,8 @@ DEST_JSIG_DIZ       = $(JDK_LIBDIR)/$(LIBJSIG_DIZ)
 
 LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
 
-# On Linux we really dont want a mapfile, as this library is small 
-# and preloaded using LD_PRELOAD, making functions private will 
+# On Linux we really dont want a mapfile, as this library is small
+# and preloaded using LD_PRELOAD, making functions private will
 # cause problems with interposing. See CR: 6466665
 # LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
 
@@ -75,9 +75,9 @@ endif
 install_jsig: $(LIBJSIG)
 	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
 	$(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \
-	    cp -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
+	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
 	$(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \
-	    cp -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
+	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
 
 .PHONY: install_jsig
diff --git a/hotspot/make/linux/makefiles/rules.make b/hotspot/make/linux/makefiles/rules.make
index d40b88d5ed02f31dc12d2afbd4b43213d275a7a1..c6f32c218064ff1fe958b4a9326d7cd08743a057 100644
--- a/hotspot/make/linux/makefiles/rules.make
+++ b/hotspot/make/linux/makefiles/rules.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2012, 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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Common rules/macros for the vm, adlc.
@@ -28,7 +28,7 @@
 .SUFFIXES: .cpp $(SUFFIXES)
 
 DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
+DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
 
 # $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
 CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
diff --git a/hotspot/make/linux/makefiles/sa.make b/hotspot/make/linux/makefiles/sa.make
index 66a7b9457377454aec48a80ca88013538d766128..0dab937874d229d0474dc2ef2a373285001f3f4f 100644
--- a/hotspot/make/linux/makefiles/sa.make
+++ b/hotspot/make/linux/makefiles/sa.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2012, 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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # This makefile (sa.make) is included from the sa.make in the
@@ -60,7 +60,7 @@ SA_PROPERTIES = $(SA_CLASSDIR)/sa.properties
 # if $(AGENT_DIR) does not exist, we don't build SA
 # also, we don't build SA on Itanium or zero.
 
-all: 
+all:
 	if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" \
              -a "$(SRCARCH)" != "zero" ] ; then \
 	   $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \
@@ -99,11 +99,11 @@ $(GENERATED)/sa-jdi.jar:: $(AGENT_FILES)
 	$(QUIETLY) $(REMOTE) $(COMPILE.RMIC)  -classpath $(SA_CLASSDIR) -d $(SA_CLASSDIR) sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer
 	$(QUIETLY) echo "$(SA_BUILD_VERSION_PROP)" > $(SA_PROPERTIES)
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql/sa.js
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
 	$(QUIETLY) mkdir -p $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/*
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
-	$(QUIETLY) cp -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
+	$(QUIETLY) $(CP) -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
 	$(QUIETLY) $(REMOTE) $(RUN.JAR) cf $@ -C $(SA_CLASSDIR)/ .
 	$(QUIETLY) $(REMOTE) $(RUN.JAR) uf $@ -C $(AGENT_SRC_DIR) META-INF/services/com.sun.jdi.connect.Connector
 	$(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.x86.X86ThreadContext
diff --git a/hotspot/make/linux/makefiles/saproc.make b/hotspot/make/linux/makefiles/saproc.make
index c2397491d43ea65113860dd4d6a65274c83c8f1d..caa16e3e7384270c83195c9f1375a76a73c39387 100644
--- a/hotspot/make/linux/makefiles/saproc.make
+++ b/hotspot/make/linux/makefiles/saproc.make
@@ -19,7 +19,7 @@
 # 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 $(GAMMADIR)/make/defs.make
 include $(GAMMADIR)/make/altsrc.make
@@ -116,10 +116,10 @@ install_saproc: $(BUILDLIBSAPROC)
 	$(QUIETLY) if [ -e $(LIBSAPROC) ] ; then                   \
 	  echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)";           \
 	  test ! -f $(LIBSAPROC_DEBUGINFO) ||                      \
-	    cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
+	    $(CP) -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
 	  test ! -f $(LIBSAPROC_DIZ) ||                            \
-	    cp -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ);             \
-	  cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";        \
+	    $(CP) -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ);             \
+	  $(CP) -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";        \
 	fi
 
 .PHONY: install_saproc
diff --git a/hotspot/make/linux/makefiles/top.make b/hotspot/make/linux/makefiles/top.make
index aca73c6eb6cb2bfeb8cb20022ade136f98b25378..294400c844ed04f9085889c94d042a0711d34cba 100644
--- a/hotspot/make/linux/makefiles/top.make
+++ b/hotspot/make/linux/makefiles/top.make
@@ -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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # top.make is included in the Makefile in the build directories.
@@ -45,10 +45,10 @@ TOPDIR      = $(shell echo `pwd`)
 GENERATED   = $(TOPDIR)/../generated
 VM          = $(GAMMADIR)/src/share/vm
 Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED); 
+CDG         = cd $(GENERATED);
 
 ifneq ($(USE_PRECOMPILED_HEADER),0)
-UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) 
+UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS)
 else
 UpdatePCH = \# precompiled header is not used
 endif
@@ -84,7 +84,7 @@ vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) trace_stu
 	@# We need a null action here, so implicit rules don't get consulted.
 
 $(Cached_plat): $(Plat_File)
-	$(CDG) cp $(Plat_File) $(Cached_plat)
+	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
 
 # make AD files as necessary
 ad_stuff: $(Cached_plat) $(adjust-mflags)
@@ -128,12 +128,12 @@ install: the_vm
 # next rules support "make foo.[ois]"
 
 %.o %.i %.s:
-	$(UpdatePCH) 
+	$(UpdatePCH)
 	$(MAKE) -f vm.make $(MFLAGS) $@
 	#$(MAKE) -f vm.make $@
 
 # this should force everything to be rebuilt
-clean: 
+clean:
 	rm -f $(GENERATED)/*.class
 	$(MAKE) -f vm.make $(MFLAGS) clean
 
diff --git a/hotspot/make/linux/makefiles/vm.make b/hotspot/make/linux/makefiles/vm.make
index 7e3e5f0f65c54fc0c62e1b81438d651b13790569..fd299ceba53fc4807b3d713ec8e16f1e24b1b022 100644
--- a/hotspot/make/linux/makefiles/vm.make
+++ b/hotspot/make/linux/makefiles/vm.make
@@ -362,10 +362,10 @@ DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
 install_jvm: $(LIBJVM)
 	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
 	$(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \
-	    cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
+	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
 	$(QUIETLY) test ! -f $(LIBJVM_DIZ) || \
-	    cp -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
+	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
 
 #----------------------------------------------------------------------
 # Other files
diff --git a/hotspot/make/solaris/makefiles/buildtree.make b/hotspot/make/solaris/makefiles/buildtree.make
index 2627dbf040a676b2324dd02a06d194e9db939d92..3c068b8c2b5205138aaf190e78156e673b376e23 100644
--- a/hotspot/make/solaris/makefiles/buildtree.make
+++ b/hotspot/make/solaris/makefiles/buildtree.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2013, 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
@@ -265,6 +265,8 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 	echo; \
 	[ -n "$(SPEC)" ] && \
 	    echo "include $(SPEC)"; \
+	echo "CP ?= cp"; \
+	echo "MV ?= mv"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
 	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
 	) > $@
diff --git a/hotspot/make/solaris/makefiles/jsig.make b/hotspot/make/solaris/makefiles/jsig.make
index 0087fe958d8c50f9c10f97e7d5176c0d601728d7..5afc405e7e009b8bbc09921a337851abe400c2bd 100644
--- a/hotspot/make/solaris/makefiles/jsig.make
+++ b/hotspot/make/solaris/makefiles/jsig.make
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Rules to build signal interposition library, used by vm.make
@@ -80,9 +80,9 @@ endif
 install_jsig: $(LIBJSIG)
 	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
 	$(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \
-	    cp -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
+	    $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
 	$(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \
-	    cp -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
-	$(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
+	    $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
 
 .PHONY: install_jsig
diff --git a/hotspot/make/solaris/makefiles/rules.make b/hotspot/make/solaris/makefiles/rules.make
index b7006f5836e018d115c28c07a221b8675a31efe6..159143a6391b996d2e71a64c615e85546f02ec42 100644
--- a/hotspot/make/solaris/makefiles/rules.make
+++ b/hotspot/make/solaris/makefiles/rules.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2012, 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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Common rules/macros for the vm, adlc.
@@ -28,7 +28,7 @@
 .SUFFIXES: .cpp $(SUFFIXES)
 
 DEMANGLER       = c++filt
-DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
+DEMANGLE        = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@
 
 # $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
 CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
diff --git a/hotspot/make/solaris/makefiles/sa.make b/hotspot/make/solaris/makefiles/sa.make
index 546e2630ce4162d800f59edf0434a9457a9780c0..ab5385dd91458cadd365eba0b8338ce0c881a3d7 100644
--- a/hotspot/make/solaris/makefiles/sa.make
+++ b/hotspot/make/solaris/makefiles/sa.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2012, 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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # This makefile (sa.make) is included from the sa.make in the
@@ -52,7 +52,7 @@ SA_BUILD_VERSION_PROP = "sun.jvm.hotspot.runtime.VM.saBuildVersion=$(SA_BUILD_VE
 SA_PROPERTIES = $(SA_CLASSDIR)/sa.properties
 
 # if $(AGENT_DIR) does not exist, we don't build SA.
-all: 
+all:
 	$(QUIETLY) if [ -d $(AGENT_DIR) ] ; then \
 	   $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \
 	fi
@@ -90,11 +90,11 @@ $(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
 	$(QUIETLY) $(COMPILE.RMIC)  -classpath $(SA_CLASSDIR) -d $(SA_CLASSDIR) sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer
 	$(QUIETLY) echo "$(SA_BUILD_VERSION_PROP)" > $(SA_PROPERTIES)
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql/sa.js
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
 	$(QUIETLY) mkdir -p $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/*
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
-	$(QUIETLY) cp -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
+	$(QUIETLY) $(CP) -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
 	$(QUIETLY) $(RUN.JAR) cf $@ -C $(SA_CLASSDIR)/ .
 	$(QUIETLY) $(RUN.JAR) uf $@ -C $(AGENT_SRC_DIR) META-INF/services/com.sun.jdi.connect.Connector
 	$(QUIETLY) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.proc.ProcDebuggerLocal
diff --git a/hotspot/make/solaris/makefiles/saproc.make b/hotspot/make/solaris/makefiles/saproc.make
index 9721b8c065d6e2ea63358a244015d70680087316..bfa38c5d854a047a9e752d929deb8f9e1503aab7 100644
--- a/hotspot/make/solaris/makefiles/saproc.make
+++ b/hotspot/make/solaris/makefiles/saproc.make
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # Rules to build serviceability agent library, used by vm.make
@@ -119,7 +119,7 @@ $(SADISOBJ): $(SADISSRCFILES)
 	           $(SOLARIS_11_B159_OR_LATER)                          \
 	           $(SADISSRCFILES)                                     \
 	           -c -o $(SADISOBJ)
-	
+
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
 # Clear the SHF_ALLOC flag (if set) from empty section headers.
@@ -150,10 +150,10 @@ install_saproc: $(BULDLIBSAPROC)
 	$(QUIETLY) if [ -f $(LIBSAPROC) ] ; then                   \
 	  echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)";           \
 	  test ! -f $(LIBSAPROC_DEBUGINFO) ||                      \
-	    cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
+	    $(CP) -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
 	  test ! -f $(LIBSAPROC_DIZ) ||                            \
-	    cp -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ);             \
-	  cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";        \
+	    $(CP) -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ);             \
+	  $(CP) -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";        \
 	fi
 
 .PHONY: install_saproc
diff --git a/hotspot/make/solaris/makefiles/top.make b/hotspot/make/solaris/makefiles/top.make
index c211151b09ff0afc1a99263a7b8763d0d5c54470..70113e6c0bf70f9b1b326a40d5f4c4d7a603f5a2 100644
--- a/hotspot/make/solaris/makefiles/top.make
+++ b/hotspot/make/solaris/makefiles/top.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2013, 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
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # top.make is included in the Makefile in the build directories.
@@ -44,7 +44,7 @@ include $(GAMMADIR)/make/altsrc.make
 GENERATED   = ../generated
 VM          = $(GAMMADIR)/src/share/vm
 Plat_File   = $(Platform_file)
-CDG         = cd $(GENERATED); 
+CDG         = cd $(GENERATED);
 
 Cached_plat = $(GENERATED)/platform.current
 
@@ -77,7 +77,7 @@ vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stu
 	@# We need a null action here, so implicit rules don't get consulted.
 
 $(Cached_plat): $(Plat_File)
-	$(CDG) cp $(Plat_File) $(Cached_plat)
+	$(CDG) $(CP) $(Plat_File) $(Cached_plat)
 
 # make AD files as necessary
 ad_stuff: $(Cached_plat) $(adjust-mflags)
@@ -87,7 +87,7 @@ ad_stuff: $(Cached_plat) $(adjust-mflags)
 jvmti_stuff: $(Cached_plat) $(adjust-mflags)
 	@$(MAKE) -f jvmti.make $(MFLAGS-adjusted)
 
-# generate trace files 
+# generate trace files
 trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags)
 	@$(MAKE) -f trace.make $(MFLAGS-adjusted)
 
@@ -124,7 +124,7 @@ install: the_vm
 	#$(MAKE) -f vm.make $@
 
 # this should force everything to be rebuilt
-clean: 
+clean:
 	rm -f $(GENERATED)/*.class
 	$(MAKE) -f vm.make $(MFLAGS) clean
 
diff --git a/hotspot/make/solaris/makefiles/vm.make b/hotspot/make/solaris/makefiles/vm.make
index e0176bf66c2090af140781bffad9794331197136..609a76e1930554f47ee74d60bfee2f31d8a20127 100644
--- a/hotspot/make/solaris/makefiles/vm.make
+++ b/hotspot/make/solaris/makefiles/vm.make
@@ -336,10 +336,10 @@ DEST_JVM_DIZ       = $(DEST_SUBDIR)/$(LIBJVM_DIZ)
 install_jvm: $(LIBJVM)
 	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
 	$(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \
-	    cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
+	    $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
 	$(QUIETLY) test ! -f $(LIBJVM_DIZ) || \
-	    cp -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
-	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
+	    $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ)
+	$(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done"
 
 #----------------------------------------------------------------------
 # Other files
diff --git a/hotspot/make/windows/build.make b/hotspot/make/windows/build.make
index 62943b5abfe7582f861095c55ee0d5a65cf0dfdd..cd4ae4fa938552c6588458658a774e5896cd4a83 100644
--- a/hotspot/make/windows/build.make
+++ b/hotspot/make/windows/build.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2013, 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
@@ -300,6 +300,8 @@ $(variantDir)\local.make: checks
 	@ if "$(ENABLE_FULL_DEBUG_SYMBOLS)" NEQ "" echo ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) >> $@
 	@ if "$(ZIP_DEBUGINFO_FILES)" NEQ "" echo ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) >> $@
 	@ if "$(RM)" NEQ "" echo RM=$(RM)                       >> $@
+	@ if "$(CP)" NEQ "" echo CP=$(CP)                       >> $@
+	@ if "$(MV)" NEQ "" echo MV=$(MV)                       >> $@
 	@ if "$(ZIPEXE)" NEQ "" echo ZIPEXE=$(ZIPEXE)           >> $@
 
 checks: checkVariant checkWorkSpace checkSA
diff --git a/hotspot/make/windows/makefiles/defs.make b/hotspot/make/windows/makefiles/defs.make
index 9b22e37a30184e0f95cbda5278452374df608959..d45dae17d82b181408ce0f235e3c0a781cf6471f 100644
--- a/hotspot/make/windows/makefiles/defs.make
+++ b/hotspot/make/windows/makefiles/defs.make
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -156,6 +156,9 @@ endif
 
 MAKE_ARGS += RM="$(RM)"
 MAKE_ARGS += ZIPEXE=$(ZIPEXE)
+MAKE_ARGS += CP="${CP}"
+MAKE_ARGS += MV="${MV}"
+
 
 # On 32 bit windows we build server and client, on 64 bit just server.
 ifeq ($(JVM_VARIANTS),)
diff --git a/hotspot/make/windows/makefiles/sa.make b/hotspot/make/windows/makefiles/sa.make
index 4ac5d89f5fa2193410f83b47cb60b5e306ad15ed..0ecb3278b1509c574cbcdefd9137c1624733daa7 100644
--- a/hotspot/make/windows/makefiles/sa.make
+++ b/hotspot/make/windows/makefiles/sa.make
@@ -19,7 +19,7 @@
 # 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.
-#  
+#
 #
 
 # This makefile is used to build Serviceability Agent code
@@ -76,16 +76,16 @@ $(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
 	$(COMPILE_RMIC) -classpath $(SA_CLASSDIR) -d $(SA_CLASSDIR) sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer
 	$(QUIETLY) echo $(SA_BUILD_VERSION_PROP)> $(SA_PROPERTIES)
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql/sa.js
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
 	$(QUIETLY) rm -rf $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
 	$(QUIETLY) mkdir $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
-	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
-	$(QUIETLY) cp -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)
+	$(QUIETLY) $(CP) $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
+	$(QUIETLY) $(CP) -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)
 	$(RUN_JAR) cf $@ -C $(SA_CLASSDIR) .
 	$(RUN_JAR) uf $@ -C $(AGENT_SRC_DIR) META-INF/services/com.sun.jdi.connect.Connector
 	$(RUN_JAVAH) -classpath $(SA_CLASSDIR) -jni sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal
-	$(RUN_JAVAH) -classpath $(SA_CLASSDIR) -jni sun.jvm.hotspot.debugger.x86.X86ThreadContext 
-	$(RUN_JAVAH) -classpath $(SA_CLASSDIR) -jni sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext 
+	$(RUN_JAVAH) -classpath $(SA_CLASSDIR) -jni sun.jvm.hotspot.debugger.x86.X86ThreadContext
+	$(RUN_JAVAH) -classpath $(SA_CLASSDIR) -jni sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
 	$(RUN_JAVAH) -classpath $(SA_CLASSDIR) -jni sun.jvm.hotspot.asm.Disassembler
 
 
@@ -105,7 +105,7 @@ SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN
 !elseif "$(BUILDARCH)" == "amd64"
 SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -c
 !else
-SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -RTC1 -c 
+SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -RTC1 -c
 !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
 SA_CFLAGS = $(SA_CFLAGS) -ZI
 !endif
@@ -116,7 +116,7 @@ SA_LD_FLAGS = -manifest $(SA_LD_FLAGS)
 
 SASRCFILES = $(AGENT_DIR)/src/os/win32/windbg/sawindbg.cpp \
 		$(AGENT_DIR)/src/share/native/sadis.c
-		            
+
 SA_LFLAGS = $(SA_LD_FLAGS) -nologo -subsystem:console -machine:$(MACHINE)
 !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
 SA_LFLAGS = $(SA_LFLAGS) -map -debug
@@ -136,7 +136,7 @@ SA_CFLAGS = $(SA_CFLAGS) $(MP_FLAG)
 $(SAWINDBG): $(SASRCFILES)
 	set INCLUDE=$(SA_INCLUDE)$(INCLUDE)
 	$(CXX) @<<
-	  -I"$(BootStrapDir)/include" -I"$(BootStrapDir)/include/win32" 
+	  -I"$(BootStrapDir)/include" -I"$(BootStrapDir)/include/win32"
 	  -I"$(GENERATED)" $(SA_CFLAGS)
 	  $(SASRCFILES)
 	  -out:$*.obj
diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
index adeb338d3f1771f16d795691bc7117a0297e8d4e..79bf7139a1282a9305c80d166bbee6c1ac15c22b 100644
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
@@ -251,6 +251,49 @@ void VM_Version::initialize() {
   // buf is started with ", " or is empty
   _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf);
 
+  // There are three 64-bit SPARC families that do not overlap, e.g.,
+  // both is_ultra3() and is_sparc64() cannot be true at the same time.
+  // Within these families, there can be more than one chip, e.g.,
+  // is_T4() and is_T7() machines are also is_niagara().
+  if (is_ultra3()) {
+    assert(_L1_data_cache_line_size == 0, "overlap with Ultra3 family");
+    // Ref: UltraSPARC III Cu Processor
+    _L1_data_cache_line_size = 64;
+  }
+  if (is_niagara()) {
+    assert(_L1_data_cache_line_size == 0, "overlap with niagara family");
+    // All Niagara's are sun4v's, but not all sun4v's are Niagaras, e.g.,
+    // Fujitsu SPARC64 is sun4v, but we don't want it in this block.
+    //
+    // Ref: UltraSPARC T1 Supplement to the UltraSPARC Architecture 2005
+    // Appendix F.1.3.1 Cacheable Accesses
+    // -> 16-byte L1 cache line size
+    //
+    // Ref: UltraSPARC T2: A Highly-Threaded, Power-Efficient, SPARC SOC
+    // Section III: SPARC Processor Core
+    // -> 16-byte L1 cache line size
+    //
+    // Ref: Oracle's SPARC T4-1, SPARC T4-2, SPARC T4-4, and SPARC T4-1B Server Architecture
+    // Section SPARC T4 Processor Cache Architecture
+    // -> 32-byte L1 cache line size (no longer see that info on this ref)
+    //
+    // XXX - still need a T7 reference here
+    //
+    if (is_T7()) {  // T7 or newer
+      _L1_data_cache_line_size = 64;
+    } else if (is_T4()) {  // T4 or newer (until T7)
+      _L1_data_cache_line_size = 32;
+    } else {  // T1 or newer (until T4)
+      _L1_data_cache_line_size = 16;
+    }
+  }
+  if (is_sparc64()) {
+    guarantee(_L1_data_cache_line_size == 0, "overlap with SPARC64 family");
+    // Ref: Fujitsu SPARC64 VII Processor
+    // Section 4 Cache System
+    _L1_data_cache_line_size = 64;
+  }
+
   // UseVIS is set to the smallest of what hardware supports and what
   // the command line requires.  I.e., you cannot set UseVIS to 3 on
   // older UltraSparc which do not support it.
@@ -356,6 +399,7 @@ void VM_Version::initialize() {
 
 #ifndef PRODUCT
   if (PrintMiscellaneous && Verbose) {
+    tty->print_cr("L1 data cache line size: %u", L1_data_cache_line_size());
     tty->print("Allocation");
     if (AllocatePrefetchStyle <= 0) {
       tty->print_cr(": no prefetching");
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
index f37004ffed9f5e6e7d63849f455f91d2ee8f1692..57a1545166ad95be27eb754d89e288dc248d389d 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
@@ -394,6 +394,8 @@ void VM_Version::get_processor_features() {
   _stepping = 0;
   _cpuFeatures = 0;
   _logical_processors_per_package = 1;
+  // i486 internal cache is both I&D and has a 16-byte line size
+  _L1_data_cache_line_size = 16;
 
   if (!Use486InstrsOnly) {
     // Get raw processor info
@@ -412,6 +414,7 @@ void VM_Version::get_processor_features() {
       // Logical processors are only available on P4s and above,
       // and only if hyperthreading is available.
       _logical_processors_per_package = logical_processor_count();
+      _L1_data_cache_line_size = L1_line_size();
     }
   }
 
@@ -924,6 +927,7 @@ void VM_Version::get_processor_features() {
   if (PrintMiscellaneous && Verbose) {
     tty->print_cr("Logical CPUs per core: %u",
                   logical_processors_per_package());
+    tty->print_cr("L1 data cache line size: %u", L1_data_cache_line_size());
     tty->print("UseSSE=%d", (int) UseSSE);
     if (UseAVX > 0) {
       tty->print("  UseAVX=%d", (int) UseAVX);
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
index 51f6e4f2f4a30ea0933451c2a840d41191e15571..20c384c3722b6e60935912a185f116f0fca1cfb6 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
@@ -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
@@ -581,7 +581,7 @@ public:
     return result;
   }
 
-  static intx prefetch_data_size()  {
+  static intx L1_line_size()  {
     intx result = 0;
     if (is_intel()) {
       result = (_cpuid_info.dcp_cpuid4_ebx.bits.L1_line_size + 1);
@@ -593,6 +593,10 @@ public:
     return result;
   }
 
+  static intx prefetch_data_size()  {
+    return L1_line_size();
+  }
+
   //
   // Feature identification
   //
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
index 50704c3512e5ca092f97a21fb41e88c8edfeb8f2..47d625e12cf912413dc6f14c0040a801747491e3 100644
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
@@ -478,9 +478,17 @@ public class LogParser extends DefaultHandler implements ErrorHandler, Constants
                 } else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) {
                     scopes.push(scopes.peek().last(-2));
                 } else {
-                    System.out.println(site.getMethod());
-                    System.out.println(m);
-                    throw new InternalError("call site and parse don't match");
+                    // C1 prints multiple method tags during inlining when it narrows method being inlinied.
+                    // Example:
+                    //   ...
+                    //   <method id="813" holder="694" name="toString" return="695" flags="1" bytes="36" iicount="1"/>
+                    //   <call method="813" instr="invokevirtual"/>
+                    //   <inline_success reason="receiver is statically known"/>
+                    //   <method id="814" holder="792" name="toString" return="695" flags="1" bytes="5" iicount="3"/>
+                    //   <parse method="814">
+                    //   ...
+                    site.setMethod(m);
+                    scopes.push(site);
                 }
             }
         } else if (qname.equals("parse_done")) {
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index b571778b91f123de6a3ee9e6c7165aa4511c4e54..838e08d799c36ffd05e6f5fca196f3b8eff337eb 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -1573,6 +1573,7 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
         default:
           constant = new Constant(as_ValueType(field_val));
         }
+        // Stable static fields are checked for non-default values in ciField::initialize_from().
       }
       if (constant != NULL) {
         push(type, append(constant));
@@ -1614,6 +1615,10 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
             default:
               constant = new Constant(as_ValueType(field_val));
             }
+            if (FoldStableValues && field->is_stable() && field_val.is_null_or_zero()) {
+              // Stable field with default value can't be constant.
+              constant = NULL;
+            }
           } else {
             // For CallSite objects treat the target field as a compile time constant.
             if (const_oop->is_call_site()) {
@@ -3959,10 +3964,15 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, Bytecode
   // Clear out bytecode stream
   scope_data()->set_stream(NULL);
 
+  CompileLog* log = compilation()->log();
+  if (log != NULL) log->head("parse method='%d'", log->identify(callee));
+
   // Ready to resume parsing in callee (either in the same block we
   // were in before or in the callee's start block)
   iterate_all_blocks(callee_start_block == NULL);
 
+  if (log != NULL) log->done("parse");
+
   // If we bailed out during parsing, return immediately (this is bad news)
   if (bailed_out())
       return false;
diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp
index 18cf9add331dcc9e75d22f102d8777814e0c2366..310b4c2a4071f245d40de5ca43676cdca5dc07c3 100644
--- a/hotspot/src/share/vm/ci/ciEnv.cpp
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp
@@ -1125,9 +1125,6 @@ int ciEnv::num_inlined_bytecodes() const {
 // ------------------------------------------------------------------
 // ciEnv::record_failure()
 void ciEnv::record_failure(const char* reason) {
-  if (log() != NULL) {
-    log()->elem("failure reason='%s'", reason);
-  }
   if (_failure_reason == NULL) {
     // Record the first failure reason.
     _failure_reason = reason;
diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp
index 71bcad2b445cbb9e6881c2804b9172bfb48908e0..1b2bd8a26b183e61ab0684bd968a2f2ff145011b 100644
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp
@@ -777,11 +777,22 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure) {
   // unneeded entries.
   bool has_redefined_a_class = JvmtiExport::has_redefined_a_class();
   MetadataOnStackMark md_on_stack;
-  while (data != NULL) {
-    if (data->is_alive(is_alive_closure)) {
-      if (has_redefined_a_class) {
+  if (has_redefined_a_class) {
+    // purge_previous_versions also cleans weak method links. Because
+    // one method's MDO can reference another method from another
+    // class loader, we need to first clean weak method links for all
+    // class loaders here. Below, we can then free redefined methods
+    // for all class loaders.
+    while (data != NULL) {
+      if (data->is_alive(is_alive_closure)) {
         data->classes_do(InstanceKlass::purge_previous_versions);
       }
+      data = data->next();
+    }
+  }
+  data = _head;
+  while (data != NULL) {
+    if (data->is_alive(is_alive_closure)) {
       data->free_deallocate_list();
       prev = data;
       data = data->next();
diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp
index 8ada113ffaa57e4cb85277bdc6d37e6e7d6babdb..cd313d277574b6aaad1e455f9e65ab7aa3e09b01 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp
@@ -1239,6 +1239,16 @@ oop java_lang_Throwable::message(Handle throwable) {
 }
 
 
+// Return Symbol for detailed_message or NULL
+Symbol* java_lang_Throwable::detail_message(oop throwable) {
+  PRESERVE_EXCEPTION_MARK;  // Keep original exception
+  oop detailed_message = java_lang_Throwable::message(throwable);
+  if (detailed_message != NULL) {
+    return java_lang_String::as_symbol(detailed_message, THREAD);
+  }
+  return NULL;
+}
+
 void java_lang_Throwable::set_message(oop throwable, oop value) {
   throwable->obj_field_put(detailMessage_offset, value);
 }
diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp
index 88b747fdcc178de4052aec4c6cfe7055ff64c4d1..aeafbfbf8b1ffa6747d6b6089d92dee5dafae7df 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp
@@ -520,6 +520,7 @@ class java_lang_Throwable: AllStatic {
   static oop message(oop throwable);
   static oop message(Handle throwable);
   static void set_message(oop throwable, oop value);
+  static Symbol* detail_message(oop throwable);
   static void print_stack_element(outputStream *st, Handle mirror, int method,
                                   int version, int bci);
   static void print_stack_element(outputStream *st, methodHandle method, int bci);
diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp
index 9fb79021009e285a37470c3cd827bca9586a1227..37098b1f4e6ee56bbc1fec7ed0fa90607d8d9240 100644
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp
@@ -297,6 +297,7 @@ void CompileTask::initialize(int compile_id,
   _hot_count = hot_count;
   _time_queued = 0;  // tidy
   _comment = comment;
+  _failure_reason = NULL;
 
   if (LogCompilation) {
     _time_queued = os::elapsed_counter();
@@ -566,6 +567,11 @@ void CompileTask::log_task_done(CompileLog* log) {
   methodHandle method(thread, this->method());
   ResourceMark rm(thread);
 
+  if (!_is_success) {
+    const char* reason = _failure_reason != NULL ? _failure_reason : "unknown";
+    log->elem("failure reason='%s'", reason);
+  }
+
   // <task_done ... stamp='1.234'>  </task>
   nmethod* nm = code();
   log->begin_elem("task_done success='%d' nmsize='%d' count='%d'",
@@ -733,6 +739,7 @@ void CompileQueue::purge_stale_tasks() {
       for (CompileTask* task = head; task != NULL; ) {
         CompileTask* next_task = task->next();
         CompileTaskWrapper ctw(task); // Frees the task
+        task->set_failure_reason("stale task");
         task = next_task;
       }
     }
@@ -1786,6 +1793,7 @@ void CompileBroker::compiler_thread_loop() {
       } else {
         // After compilation is disabled, remove remaining methods from queue
         method->clear_queued_for_compilation();
+        task->set_failure_reason("compilation is disabled");
       }
     }
   }
@@ -1973,6 +1981,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
     compilable = ci_env.compilable();
 
     if (ci_env.failing()) {
+      task->set_failure_reason(ci_env.failure_reason());
       const char* retry_message = ci_env.retry_message();
       if (_compilation_log != NULL) {
         _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
diff --git a/hotspot/src/share/vm/compiler/compileBroker.hpp b/hotspot/src/share/vm/compiler/compileBroker.hpp
index d3a25dddcc450a20a59c40dbc8f53b9df0d90a88..7a381cd3addfb778b54ac1830558ba2ed5d726e4 100644
--- a/hotspot/src/share/vm/compiler/compileBroker.hpp
+++ b/hotspot/src/share/vm/compiler/compileBroker.hpp
@@ -64,6 +64,7 @@ class CompileTask : public CHeapObj<mtCompiler> {
   jobject      _hot_method_holder;
   int          _hot_count;    // information about its invocation counter
   const char*  _comment;      // more info about the task
+  const char*  _failure_reason;
 
  public:
   CompileTask() {
@@ -138,6 +139,10 @@ public:
   void         log_task_queued();
   void         log_task_start(CompileLog* log);
   void         log_task_done(CompileLog* log);
+
+  void         set_failure_reason(const char* reason) {
+    _failure_reason = reason;
+  }
 };
 
 // CompilerCounters
diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp
index 439256140a636cc75941363956c56408d5dac144..bb7028ec9c14d40dea664d89f35860db159525fe 100644
--- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp
+++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp
@@ -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
@@ -197,28 +197,29 @@ void VM_GenCollectFull::doit() {
 
 bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() {
 #if INCLUDE_ALL_GCS
-  if (UseConcMarkSweepGC || UseG1GC) {
-    if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) {
-      MetaspaceGC::set_should_concurrent_collect(true);
-    } else if (UseG1GC) {
-      G1CollectedHeap* g1h = G1CollectedHeap::heap();
-      g1h->g1_policy()->set_initiate_conc_mark_if_possible();
+  if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) {
+    MetaspaceGC::set_should_concurrent_collect(true);
+    return true;
+  }
 
-      GCCauseSetter x(g1h, _gc_cause);
+  if (UseG1GC) {
+    G1CollectedHeap* g1h = G1CollectedHeap::heap();
+    g1h->g1_policy()->set_initiate_conc_mark_if_possible();
 
-      // At this point we are supposed to start a concurrent cycle. We
-      // will do so if one is not already in progress.
-      bool should_start = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause);
+    GCCauseSetter x(g1h, _gc_cause);
 
-      if (should_start) {
-        double pause_target = g1h->g1_policy()->max_pause_time_ms();
-        g1h->do_collection_pause_at_safepoint(pause_target);
-      }
-    }
+    // At this point we are supposed to start a concurrent cycle. We
+    // will do so if one is not already in progress.
+    bool should_start = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause);
 
+    if (should_start) {
+      double pause_target = g1h->g1_policy()->max_pause_time_ms();
+      g1h->do_collection_pause_at_safepoint(pause_target);
+    }
     return true;
   }
 #endif
+
   return false;
 }
 
diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
index c795b11db2347dcd27df129e083c48b63dc9e088..5f1894033de4bad6d8c7337fa926b72f493e77a5 100644
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
@@ -430,9 +430,18 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea
 
     // tracing
     if (TraceExceptions) {
-      ttyLocker ttyl;
       ResourceMark rm(thread);
-      tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", h_exception->print_value_string(), (address)h_exception());
+      Symbol* message = java_lang_Throwable::detail_message(h_exception());
+      ttyLocker ttyl;  // Lock after getting the detail message
+      if (message != NULL) {
+        tty->print_cr("Exception <%s: %s> (" INTPTR_FORMAT ")",
+                      h_exception->print_value_string(), message->as_C_string(),
+                      (address)h_exception());
+      } else {
+        tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")",
+                      h_exception->print_value_string(),
+                      (address)h_exception());
+      }
       tty->print_cr(" thrown in interpreter method <%s>", h_method->print_value_string());
       tty->print_cr(" at bci %d for thread " INTPTR_FORMAT, current_bci, thread);
     }
diff --git a/hotspot/src/share/vm/interpreter/oopMapCache.cpp b/hotspot/src/share/vm/interpreter/oopMapCache.cpp
index e3d41a3c4a9a5427baaa20bb4d5e7a8c3fdb25da..d3f188863ae979fc3ed4728906efdfb9cbc344fd 100644
--- a/hotspot/src/share/vm/interpreter/oopMapCache.cpp
+++ b/hotspot/src/share/vm/interpreter/oopMapCache.cpp
@@ -244,10 +244,8 @@ void InterpreterOopMap::print() const {
   method()->print_value();
   tty->print(" @ %d = [%d] { ", bci(), n);
   for (int i = 0; i < n; i++) {
-#ifdef ENABLE_ZAP_DEAD_LOCALS
     if (is_dead(i)) tty->print("%d+ ", i);
     else
-#endif
     if (is_oop(i)) tty->print("%d ", i);
   }
   tty->print_cr("}");
@@ -402,13 +400,11 @@ void OopMapCacheEntry::set_mask(CellTypeState *vars, CellTypeState *stack, int s
       value |= (mask << oop_bit_number );
     }
 
-  #ifdef ENABLE_ZAP_DEAD_LOCALS
     // set dead bit
     if (!cell->is_live()) {
       value |= (mask << dead_bit_number);
       assert(!cell->is_reference(), "dead value marked as oop");
     }
-  #endif
   }
 
   // make sure last word is stored
diff --git a/hotspot/src/share/vm/interpreter/oopMapCache.hpp b/hotspot/src/share/vm/interpreter/oopMapCache.hpp
index a56dcb8d4184bd1ce0bda04201bc2f2eadcbe1e8..dbdd4cb1a88236945194646a1cddcd3cbb47a747 100644
--- a/hotspot/src/share/vm/interpreter/oopMapCache.hpp
+++ b/hotspot/src/share/vm/interpreter/oopMapCache.hpp
@@ -66,19 +66,15 @@ class InterpreterOopMap: ResourceObj {
 
  public:
   enum {
-    N                = 2,                // the number of words reserved
+    N                = 4,                // the number of words reserved
                                          // for inlined mask storage
     small_mask_limit = N * BitsPerWord,  // the maximum number of bits
                                          // available for small masks,
                                          // small_mask_limit can be set to 0
                                          // for testing bit_mask allocation
 
-#ifdef ENABLE_ZAP_DEAD_LOCALS
     bits_per_entry   = 2,
     dead_bit_number  = 1,
-#else
-    bits_per_entry   = 1,
-#endif
     oop_bit_number   = 0
   };
 
@@ -119,10 +115,6 @@ class InterpreterOopMap: ResourceObj {
 
   void set_expression_stack_size(int sz)         { _expression_stack_size = sz; }
 
-#ifdef ENABLE_ZAP_DEAD_LOCALS
-  bool is_dead(int offset) const                 { return (entry_at(offset) & (1 << dead_bit_number)) != 0; }
-#endif
-
   // Lookup
   bool match(methodHandle method, int bci) const { return _method == method() && _bci == bci; }
   bool is_empty() const;
@@ -144,6 +136,7 @@ class InterpreterOopMap: ResourceObj {
   void print() const;
 
   int number_of_entries() const                  { return mask_size() / bits_per_entry; }
+  bool is_dead(int offset) const                 { return (entry_at(offset) & (1 << dead_bit_number)) != 0; }
   bool is_oop (int offset) const                 { return (entry_at(offset) & (1 << oop_bit_number )) != 0; }
 
   int expression_stack_size() const              { return _expression_stack_size; }
diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp
index 111d55b3af7ecdc43f79d0d8c3b8dfefde8a83ac..f26c0d4318abdfbca9b508caeeb9e1b38b111ca3 100644
--- a/hotspot/src/share/vm/oops/constantPool.cpp
+++ b/hotspot/src/share/vm/oops/constantPool.cpp
@@ -520,13 +520,9 @@ bool ConstantPool::resolve_class_constants(TRAPS) {
 
 Symbol* ConstantPool::exception_message(constantPoolHandle this_cp, int which, constantTag tag, oop pending_exception) {
   // Dig out the detailed message to reuse if possible
-  Symbol* message = NULL;
-  oop detailed_message = java_lang_Throwable::message(pending_exception);
-  if (detailed_message != NULL) {
-     message = java_lang_String::as_symbol_or_null(detailed_message);
-     if (message != NULL) {
-       return message;
-     }
+  Symbol* message = java_lang_Throwable::detail_message(pending_exception);
+  if (message != NULL) {
+    return message;
   }
 
   // Return specific message for the tag
diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp
index 4549c68871f0e17b1956cf6581b5ae7a70884dd9..83ac9591aa289e292ca0286b122b7a3fe282577b 100644
--- a/hotspot/src/share/vm/oops/method.cpp
+++ b/hotspot/src/share/vm/oops/method.cpp
@@ -729,8 +729,8 @@ void Method::print_made_not_compilable(int comp_level, bool is_osr, bool report,
   }
   if ((TraceDeoptimization || LogCompilation) && (xtty != NULL)) {
     ttyLocker ttyl;
-    xtty->begin_elem("make_not_%scompilable thread='" UINTX_FORMAT "'",
-                     is_osr ? "osr_" : "", os::current_thread_id());
+    xtty->begin_elem("make_not_compilable thread='" UINTX_FORMAT "' osr='%d' level='%d'",
+                     os::current_thread_id(), is_osr, comp_level);
     if (reason != NULL) {
       xtty->print(" reason=\'%s\'", reason);
     }
diff --git a/hotspot/src/share/vm/oops/methodData.cpp b/hotspot/src/share/vm/oops/methodData.cpp
index 2975462fbbf172a1be1c21df4b03c99c815e3a91..40dfee7fbea051b7daf8562f7f8ea152a75614aa 100644
--- a/hotspot/src/share/vm/oops/methodData.cpp
+++ b/hotspot/src/share/vm/oops/methodData.cpp
@@ -1556,7 +1556,7 @@ class CleanExtraDataMethodClosure : public CleanExtraDataClosure {
 public:
   CleanExtraDataMethodClosure() {}
   bool is_live(Method* m) {
-    return m->on_stack();
+    return !m->is_old() || m->on_stack();
   }
 };
 
diff --git a/hotspot/src/share/vm/opto/bytecodeInfo.cpp b/hotspot/src/share/vm/opto/bytecodeInfo.cpp
index c4ee166a20c116811bddb4b268a6e56c90e82a1d..ae8da0fcd9c8ee6b3bdfee8ac70406be97f1849e 100644
--- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp
+++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp
@@ -107,7 +107,7 @@ bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
                                int caller_bci, ciCallProfile& profile,
                                WarmCallInfo* wci_result) {
   // Allows targeted inlining
-  if(callee_method->should_inline()) {
+  if (callee_method->should_inline()) {
     *wci_result = *(WarmCallInfo::always_hot());
     if (C->print_inlining() && Verbose) {
       CompileTask::print_inline_indent(inline_level());
@@ -118,6 +118,12 @@ bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
     return true;
   }
 
+  if (callee_method->force_inline()) {
+      set_msg("force inline by annotation");
+      _forced_inline = true;
+      return true;
+  }
+
 #ifndef PRODUCT
   int inline_depth = inline_level()+1;
   if (ciReplay::should_inline(C->replay_inline_data(), callee_method, caller_bci, inline_depth)) {
@@ -244,6 +250,11 @@ bool InlineTree::should_not_inline(ciMethod *callee_method,
   }
 #endif
 
+  if (callee_method->force_inline()) {
+    set_msg("force inline by annotation");
+    return false;
+  }
+
   // Now perform checks which are heuristic
 
   if (is_unboxing_method(callee_method, C)) {
@@ -251,12 +262,10 @@ bool InlineTree::should_not_inline(ciMethod *callee_method,
     return false;
   }
 
-  if (!callee_method->force_inline()) {
-    if (callee_method->has_compiled_code() &&
-        callee_method->instructions_size() > InlineSmallCode) {
-      set_msg("already compiled into a big method");
-      return true;
-    }
+  if (callee_method->has_compiled_code() &&
+      callee_method->instructions_size() > InlineSmallCode) {
+    set_msg("already compiled into a big method");
+    return true;
   }
 
   // don't inline exception code unless the top method belongs to an
@@ -349,7 +358,7 @@ bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,
       // Escape Analysis stress testing when running Xcomp or CTW:
       // inline constructors even if they are not reached.
     } else if (forced_inline()) {
-      // Inlining was forced by CompilerOracle or ciReplay
+      // Inlining was forced by CompilerOracle, ciReplay or annotation
     } else if (profile.count() == 0) {
       // don't inline unreached call sites
        set_msg("call site not reached");
diff --git a/hotspot/src/share/vm/opto/machnode.cpp b/hotspot/src/share/vm/opto/machnode.cpp
index 985dbfcc93a0e320dd51f7fdbd3670ea946fd841..69139e104f7944cbd1a6ec627f100bfd04bbefe8 100644
--- a/hotspot/src/share/vm/opto/machnode.cpp
+++ b/hotspot/src/share/vm/opto/machnode.cpp
@@ -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
@@ -639,7 +639,6 @@ void MachCallNode::dump_spec(outputStream *st) const {
 }
 #endif
 
-
 bool MachCallNode::return_value_is_used() const {
   if (tf()->range()->cnt() == TypeFunc::Parms) {
     // void return
@@ -657,6 +656,14 @@ bool MachCallNode::return_value_is_used() const {
   return false;
 }
 
+// Similar to cousin class CallNode::returns_pointer
+// Because this is used in deoptimization, we want the type info, not the data
+// flow info; the interpreter will "use" things that are dead to the optimizer.
+bool MachCallNode::returns_pointer() const {
+  const TypeTuple *r = tf()->range();
+  return (r->cnt() > TypeFunc::Parms &&
+          r->field_at(TypeFunc::Parms)->isa_ptr());
+}
 
 //------------------------------Registers--------------------------------------
 const RegMask &MachCallNode::in_RegMask(uint idx) const {
diff --git a/hotspot/src/share/vm/opto/machnode.hpp b/hotspot/src/share/vm/opto/machnode.hpp
index 1e2f22e9ef711705a2544b1e072d656ca9099fa3..78ab196b3a5ef5445aa3d9c8468ea8c33fa0e13e 100644
--- a/hotspot/src/share/vm/opto/machnode.hpp
+++ b/hotspot/src/share/vm/opto/machnode.hpp
@@ -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
@@ -842,6 +842,10 @@ public:
 
   bool returns_long() const { return tf()->return_type() == T_LONG; }
   bool return_value_is_used() const;
+
+  // Similar to cousin class CallNode::returns_pointer
+  bool returns_pointer() const;
+
 #ifndef PRODUCT
   virtual void dump_spec(outputStream *st) const;
 #endif
diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp
index a484a10b435abf04afa29a83fa7f5933ae39e184..c8e6b9736c29b517941bd0305ee043d85503fd40 100644
--- a/hotspot/src/share/vm/opto/output.cpp
+++ b/hotspot/src/share/vm/opto/output.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, 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
@@ -854,8 +854,7 @@ void Compile::Process_OopMap_Node(MachNode *mach, int current_offset) {
     }
 
     // Check if a call returns an object.
-    if (mcall->return_value_is_used() &&
-        mcall->tf()->range()->field_at(TypeFunc::Parms)->isa_ptr()) {
+    if (mcall->returns_pointer()) {
       return_oop = true;
     }
     safepoint_pc_offset += mcall->ret_addr_offset();
diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp
index 34c4eb4b045340b7d6ebbe04fe8c3486f6bcc5d8..ab05a633ae14057dc4c94e9c59230879d23c914a 100644
--- a/hotspot/src/share/vm/opto/parse.hpp
+++ b/hotspot/src/share/vm/opto/parse.hpp
@@ -142,7 +142,7 @@ public:
 
   void print_value_on(outputStream* st) const PRODUCT_RETURN;
 
-  bool        _forced_inline;     // Inlining was forced by CompilerOracle or ciReplay
+  bool        _forced_inline;     // Inlining was forced by CompilerOracle, ciReplay or annotation
   bool        forced_inline()     const { return _forced_inline; }
   // Count number of nodes in this subtree
   int         count() const;
diff --git a/hotspot/src/share/vm/opto/replacednodes.cpp b/hotspot/src/share/vm/opto/replacednodes.cpp
index bf647e964811ec84b5d522e80e47a5602397d9ee..d4cb3b1e260010b37f93db903a0fa16cbfd5f2be 100644
--- a/hotspot/src/share/vm/opto/replacednodes.cpp
+++ b/hotspot/src/share/vm/opto/replacednodes.cpp
@@ -185,11 +185,11 @@ void ReplacedNodes::apply(Compile* C, Node* ctl) {
 
 void ReplacedNodes::dump(outputStream *st) const {
   if (!is_empty()) {
-    tty->print("replaced nodes: ");
+    st->print("replaced nodes: ");
     for (int i = 0; i < _replaced_nodes->length(); i++) {
-      tty->print("%d->%d", _replaced_nodes->at(i).initial()->_idx, _replaced_nodes->at(i).improved()->_idx);
+      st->print("%d->%d", _replaced_nodes->at(i).initial()->_idx, _replaced_nodes->at(i).improved()->_idx);
       if (i < _replaced_nodes->length()-1) {
-        tty->print(",");
+        st->print(",");
       }
     }
   }
diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp
index 8c32be348c7f3b315a12dec823ac72b3ba232083..51548acdba343aa84e6efd2e2a20d5fe399919b1 100644
--- a/hotspot/src/share/vm/prims/jni.cpp
+++ b/hotspot/src/share/vm/prims/jni.cpp
@@ -247,15 +247,6 @@ void jfieldIDWorkaround::verify_instance_jfieldID(Klass* k, jfieldID id) {
       "Bug in native code: jfieldID offset must address interior of object");
 }
 
-// Pick a reasonable higher bound for local capacity requested
-// for EnsureLocalCapacity and PushLocalFrame.  We don't want it too
-// high because a test (or very unusual application) may try to allocate
-// that many handles and run out of swap space.  An implementation is
-// permitted to allocate more handles than the ensured capacity, so this
-// value is set high enough to prevent compatibility problems.
-const int MAX_REASONABLE_LOCAL_CAPACITY = 4*K;
-
-
 // Wrapper to trace JNI functions
 
 #ifdef ASSERT
@@ -741,7 +732,8 @@ JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity))
   HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY(env, capacity);
 
   //%note jni_11
-  if (capacity < 0 || capacity > MAX_REASONABLE_LOCAL_CAPACITY) {
+  if (capacity < 0 ||
+      ((MaxJNILocalCapacity > 0) && (capacity > MaxJNILocalCapacity))) {
     HOTSPOT_JNI_PUSHLOCALFRAME_RETURN((uint32_t)JNI_ERR);
     return JNI_ERR;
   }
@@ -844,7 +836,8 @@ JNI_LEAF(jint, jni_EnsureLocalCapacity(JNIEnv *env, jint capacity))
   HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY(env, capacity);
 
   jint ret;
-  if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) {
+  if (capacity >= 0 &&
+      ((MaxJNILocalCapacity <= 0) || (capacity <= MaxJNILocalCapacity))) {
     ret = JNI_OK;
   } else {
     ret = JNI_ERR;
@@ -3893,6 +3886,7 @@ void execute_internal_vm_tests() {
     run_unit_test(TestKlass_test());
     run_unit_test(TestBitMap_test());
     run_unit_test(TestAsUtf8());
+    run_unit_test(ObjectMonitor::sanity_checks());
 #if INCLUDE_VM_STRUCTS
     run_unit_test(VMStructs::test());
 #endif
diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp
index cdce2643775b8346e13f37e03fa5470f93c736bc..4ffa3d491d08e306805cbfd1996dec0555a7a8c7 100644
--- a/hotspot/src/share/vm/prims/jniCheck.cpp
+++ b/hotspot/src/share/vm/prims/jniCheck.cpp
@@ -185,6 +185,9 @@ static void NativeReportJNIWarning(JavaThread* thr, const char *msg) {
  * throw an ArrayIndexOutOfBoundsException or ArrayStoreException.
  *
  * In all other cases, a non-error return value guarantees that no exceptions have been thrown.
+ *
+ * Programmers often defend against ArrayIndexOutOfBoundsException, so warning
+ * for these functions would be pedantic.
  */
 static inline void
 check_pending_exception(JavaThread* thr) {
@@ -201,6 +204,16 @@ check_pending_exception(JavaThread* thr) {
   }
 }
 
+/**
+ * Add to the planned number of handles. I.e. plus current live & warning threshold
+ */
+static inline void
+add_planned_handle_capacity(JNIHandleBlock* handles, size_t capacity) {
+  handles->set_planned_capacity(capacity +
+                                handles->get_number_of_live_handles() +
+                                CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
+}
+
 
 static inline void
 functionEnterCritical(JavaThread* thr)
@@ -243,7 +256,7 @@ functionExit(JavaThread* thr)
       thr->print_stack();
     )
     // Complain just the once, reset to current + warn threshold
-    handles->set_planned_capacity(live_handles + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
+    add_planned_handle_capacity(handles, 0);
   }
 }
 
@@ -720,7 +733,7 @@ JNI_ENTRY_CHECKED(jint,
       NativeReportJNIFatalError(thr, "negative capacity");
     jint result = UNCHECKED()->PushLocalFrame(env, capacity);
     if (result == JNI_OK) {
-      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
+      add_planned_handle_capacity(thr->active_handles(), capacity);
     }
     functionExit(thr);
     return result;
@@ -824,7 +837,7 @@ JNI_ENTRY_CHECKED(jint,
     }
     jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
     if (result == JNI_OK) {
-      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
+      add_planned_handle_capacity(thr->active_handles(), capacity);
     }
     functionExit(thr);
     return result;
@@ -1628,7 +1641,6 @@ JNI_ENTRY_CHECKED(jobject,
       check_is_obj_array(thr, array);
     )
     jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
-    thr->set_pending_jni_exception_check("GetObjectArrayElement");
     functionExit(thr);
     return result;
 JNI_END
@@ -1643,7 +1655,6 @@ JNI_ENTRY_CHECKED(void,
       check_is_obj_array(thr, array);
     )
     UNCHECKED()->SetObjectArrayElement(env,array,index,val);
-    thr->set_pending_jni_exception_check("SetObjectArrayElement");
     functionExit(thr);
 JNI_END
 
@@ -1733,7 +1744,6 @@ JNI_ENTRY_CHECKED(void,  \
       check_primitive_array_type(thr, array, ElementTag); \
     ) \
     UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \
-    thr->set_pending_jni_exception_check("Get"#Result"ArrayRegion"); \
     functionExit(thr); \
 JNI_END
 
@@ -1758,7 +1768,6 @@ JNI_ENTRY_CHECKED(void,  \
       check_primitive_array_type(thr, array, ElementTag); \
     ) \
     UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \
-    thr->set_pending_jni_exception_check("Set"#Result"ArrayRegion"); \
     functionExit(thr); \
 JNI_END
 
@@ -1835,7 +1844,6 @@ JNI_ENTRY_CHECKED(void,
       checkString(thr, str);
     )
     UNCHECKED()->GetStringRegion(env, str, start, len, buf);
-    thr->set_pending_jni_exception_check("GetStringRegion");
     functionExit(thr);
 JNI_END
 
@@ -1850,7 +1858,6 @@ JNI_ENTRY_CHECKED(void,
       checkString(thr, str);
     )
     UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf);
-    thr->set_pending_jni_exception_check("GetStringUTFRegion");
     functionExit(thr);
 JNI_END
 
diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp
index 328e9d869affbb9051c25d3f6cf8080164b6bce7..55aec25613e200404729f42d72ab8a9361056a84 100644
--- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "interpreter/interpreter.hpp"
+#include "interpreter/oopMapCache.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/instanceKlass.hpp"
@@ -744,6 +745,13 @@ bool VM_GetOrSetLocal::doit_prologue() {
 }
 
 void VM_GetOrSetLocal::doit() {
+  InterpreterOopMap oop_mask;
+  _jvf->method()->mask_for(_jvf->bci(), &oop_mask);
+  if (oop_mask.is_dead(_index)) {
+    // The local can be invalid and uninitialized in the scope of current bci
+    _result = JVMTI_ERROR_INVALID_SLOT;
+    return;
+  }
   if (_set) {
     // Force deoptimization of frame if compiled because it's
     // possible the compiler emitted some locals as constant values,
diff --git a/hotspot/src/share/vm/runtime/atomic.hpp b/hotspot/src/share/vm/runtime/atomic.hpp
index b2b561713624d050876fb7a46bd7509c9b8f2387..52e122fce481d837d4076de6737e9316890c6580 100644
--- a/hotspot/src/share/vm/runtime/atomic.hpp
+++ b/hotspot/src/share/vm/runtime/atomic.hpp
@@ -35,6 +35,18 @@ class Atomic : AllStatic {
   // can provide an alternative action if not - see supports_cx8() for
   // a means to test availability.
 
+  // The memory operations that are mentioned with each of the atomic
+  // function families come from src/share/vm/runtime/orderAccess.hpp,
+  // e.g., <fence> is described in that file and is implemented by the
+  // OrderAccess::fence() function. See that file for the gory details
+  // on the Memory Access Ordering Model.
+
+  // All of the atomic operations that imply a read-modify-write action
+  // guarantee a two-way memory barrier across that operation. Historically
+  // these semantics reflect the strength of atomic operations that are
+  // provided on SPARC/X86. We assume that strength is necessary unless
+  // we can prove that a weaker form is sufficiently safe.
+
   // Atomically store to a location
   inline static void store    (jbyte    store_value, jbyte*    dest);
   inline static void store    (jshort   store_value, jshort*   dest);
@@ -55,7 +67,8 @@ class Atomic : AllStatic {
   // See comment above about using jlong atomics on 32-bit platforms
   inline static jlong load(volatile jlong* src);
 
-  // Atomically add to a location, return updated value
+  // Atomically add to a location. Returns updated value. add*() provide:
+  // <fence> add-value-to-dest <membar StoreLoad|StoreStore>
   inline static jint     add    (jint     add_value, volatile jint*     dest);
   inline static size_t   add    (size_t   add_value, volatile size_t*   dest);
   inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
@@ -63,30 +76,35 @@ class Atomic : AllStatic {
   // See comment above about using jlong atomics on 32-bit platforms
          static jlong    add    (jlong    add_value, volatile jlong*    dest);
 
-  // Atomically increment location
+  // Atomically increment location. inc*() provide:
+  // <fence> increment-dest <membar StoreLoad|StoreStore>
   inline static void inc    (volatile jint*     dest);
          static void inc    (volatile jshort*   dest);
   inline static void inc    (volatile size_t*   dest);
   inline static void inc_ptr(volatile intptr_t* dest);
   inline static void inc_ptr(volatile void*     dest);
 
-  // Atomically decrement a location
+  // Atomically decrement a location. dec*() provide:
+  // <fence> decrement-dest <membar StoreLoad|StoreStore>
   inline static void dec    (volatile jint*     dest);
          static void dec    (volatile jshort*    dest);
   inline static void dec    (volatile size_t*   dest);
   inline static void dec_ptr(volatile intptr_t* dest);
   inline static void dec_ptr(volatile void*     dest);
 
-  // Performs atomic exchange of *dest with exchange_value.  Returns old prior value of *dest.
+  // Performs atomic exchange of *dest with exchange_value. Returns old
+  // prior value of *dest. xchg*() provide:
+  // <fence> exchange-value-with-dest <membar StoreLoad|StoreStore>
   inline static jint         xchg(jint         exchange_value, volatile jint*         dest);
          static unsigned int xchg(unsigned int exchange_value, volatile unsigned int* dest);
 
   inline static intptr_t xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest);
   inline static void*    xchg_ptr(void*    exchange_value, volatile void*   dest);
 
-  // Performs atomic compare of *dest and compare_value, and exchanges *dest with exchange_value
-  // if the comparison succeeded.  Returns prior value of *dest.  Guarantees a two-way memory
-  // barrier across the cmpxchg.  I.e., it's really a 'fence_cmpxchg_acquire'.
+  // Performs atomic compare of *dest and compare_value, and exchanges
+  // *dest with exchange_value if the comparison succeeded. Returns prior
+  // value of *dest. cmpxchg*() provide:
+  // <fence> compare-and-exchange <membar StoreLoad|StoreStore>
          static jbyte    cmpxchg    (jbyte    exchange_value, volatile jbyte*    dest, jbyte    compare_value);
   inline static jint     cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value);
   // See comment above about using jlong atomics on 32-bit platforms
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index 7d3267b4bc324fb4190fe9de4274f2ba7a93d50b..2d1805e2fb61aec5af1de362d7a9d22d55330a85 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -1216,6 +1216,11 @@ class CommandLineFlags {
   product(bool, UseFastJNIAccessors, true,                                  \
           "Use optimized versions of Get<Primitive>Field")                  \
                                                                             \
+  product(intx, MaxJNILocalCapacity, 65536,                                 \
+          "Maximum allowable local JNI handle capacity to "                 \
+          "EnsureLocalCapacity() and PushLocalFrame(), "                    \
+          "where <= 0 is unlimited, default: 65536")                        \
+                                                                            \
   product(bool, EagerXrunInit, false,                                       \
           "Eagerly initialize -Xrun libraries; allows startup profiling, "  \
           "but not all -Xrun libraries may support the state of the VM "    \
diff --git a/hotspot/src/share/vm/runtime/objectMonitor.cpp b/hotspot/src/share/vm/runtime/objectMonitor.cpp
index d763a84e07bf32d6cc3a108242b79a89bd064a3f..186154e5e4841fbbde689611c82d445dd1b814a3 100644
--- a/hotspot/src/share/vm/runtime/objectMonitor.cpp
+++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp
@@ -2497,6 +2497,10 @@ void ObjectMonitor::DeferredInitialize() {
   SETKNOB(FastHSSEC);
   #undef SETKNOB
 
+  if (Knob_Verbose) {
+    sanity_checks();
+  }
+
   if (os::is_MP()) {
      BackOffMask = (1 << Knob_SpinBackOff) - 1;
      if (Knob_ReportSettings) ::printf("BackOffMask=%X\n", BackOffMask);
@@ -2517,6 +2521,66 @@ void ObjectMonitor::DeferredInitialize() {
   InitDone = 1;
 }
 
+void ObjectMonitor::sanity_checks() {
+  int error_cnt = 0;
+  int warning_cnt = 0;
+  bool verbose = Knob_Verbose != 0 NOT_PRODUCT(|| VerboseInternalVMTests);
+
+  if (verbose) {
+    tty->print_cr("INFO: sizeof(ObjectMonitor)=" SIZE_FORMAT,
+                  sizeof(ObjectMonitor));
+  }
+
+  uint cache_line_size = VM_Version::L1_data_cache_line_size();
+  if (verbose) {
+    tty->print_cr("INFO: L1_data_cache_line_size=%u", cache_line_size);
+  }
+
+  ObjectMonitor dummy;
+  u_char *addr_begin  = (u_char*)&dummy;
+  u_char *addr_header = (u_char*)&dummy._header;
+  u_char *addr_owner  = (u_char*)&dummy._owner;
+
+  uint offset_header = (uint)(addr_header - addr_begin);
+  if (verbose) tty->print_cr("INFO: offset(_header)=%u", offset_header);
+
+  uint offset_owner = (uint)(addr_owner - addr_begin);
+  if (verbose) tty->print_cr("INFO: offset(_owner)=%u", offset_owner);
+
+  if ((uint)(addr_header - addr_begin) != 0) {
+    tty->print_cr("ERROR: offset(_header) must be zero (0).");
+    error_cnt++;
+  }
+
+  if (cache_line_size != 0) {
+    // We were able to determine the L1 data cache line size so
+    // do some cache line specific sanity checks
+
+    if ((offset_owner - offset_header) < cache_line_size) {
+      tty->print_cr("WARNING: the _header and _owner fields are closer "
+                    "than a cache line which permits false sharing.");
+      warning_cnt++;
+    }
+
+    if ((sizeof(ObjectMonitor) % cache_line_size) != 0) {
+      tty->print_cr("WARNING: ObjectMonitor size is not a multiple of "
+                    "a cache line which permits false sharing.");
+      warning_cnt++;
+    }
+  }
+
+  ObjectSynchronizer::sanity_checks(verbose, cache_line_size, &error_cnt,
+                                    &warning_cnt);
+
+  if (verbose || error_cnt != 0 || warning_cnt != 0) {
+    tty->print_cr("INFO: error_cnt=%d", error_cnt);
+    tty->print_cr("INFO: warning_cnt=%d", warning_cnt);
+  }
+
+  guarantee(error_cnt == 0,
+            "Fatal error(s) found in ObjectMonitor::sanity_checks()");
+}
+
 #ifndef PRODUCT
 void ObjectMonitor::verify() {
 }
diff --git a/hotspot/src/share/vm/runtime/objectMonitor.hpp b/hotspot/src/share/vm/runtime/objectMonitor.hpp
index c7c6886a2ba160259c6bec57d279485a08f1cdec..655211a0b1f5433a3d4e7e11dc368aef11745ec2 100644
--- a/hotspot/src/share/vm/runtime/objectMonitor.hpp
+++ b/hotspot/src/share/vm/runtime/objectMonitor.hpp
@@ -189,6 +189,8 @@ public:
   bool      check(TRAPS);       // true if the thread owns the monitor.
   void      check_slow(TRAPS);
   void      clear();
+  static void sanity_checks();  // public for -XX:+ExecuteInternalVMTests
+                                // in PRODUCT for -XX:SyncKnobs=Verbose=1
 #ifndef PRODUCT
   void      verify();
   void      print();
@@ -234,8 +236,6 @@ public:
 
   // WARNING: this must be the very first word of ObjectMonitor
   // This means this class can't use any virtual member functions.
-  // TODO-FIXME: assert that offsetof(_header) is 0 or get rid of the
-  // implicit 0 offset in emitted code.
 
   volatile markOop   _header;       // displaced object header word - mark
   void*     volatile _object;       // backward object pointer - strong root
diff --git a/hotspot/src/share/vm/runtime/synchronizer.cpp b/hotspot/src/share/vm/runtime/synchronizer.cpp
index fbdda196980df3403f2b0cefafa02ec8f56351ea..8a4d386321ec1462037193150cded5c8180be9d5 100644
--- a/hotspot/src/share/vm/runtime/synchronizer.cpp
+++ b/hotspot/src/share/vm/runtime/synchronizer.cpp
@@ -392,19 +392,22 @@ void ObjectSynchronizer::notifyall(Handle obj, TRAPS) {
 // Hash Code handling
 //
 // Performance concern:
-// OrderAccess::storestore() calls release() which STs 0 into the global volatile
-// OrderAccess::Dummy variable.  This store is unnecessary for correctness.
-// Many threads STing into a common location causes considerable cache migration
-// or "sloshing" on large SMP system.  As such, I avoid using OrderAccess::storestore()
-// until it's repaired.  In some cases OrderAccess::fence() -- which incurs local
-// latency on the executing processor -- is a better choice as it scales on SMP
-// systems.  See http://blogs.sun.com/dave/entry/biased_locking_in_hotspot for a
-// discussion of coherency costs.  Note that all our current reference platforms
-// provide strong ST-ST order, so the issue is moot on IA32, x64, and SPARC.
+// OrderAccess::storestore() calls release() which at one time stored 0
+// into the global volatile OrderAccess::dummy variable. This store was
+// unnecessary for correctness. Many threads storing into a common location
+// causes considerable cache migration or "sloshing" on large SMP systems.
+// As such, I avoided using OrderAccess::storestore(). In some cases
+// OrderAccess::fence() -- which incurs local latency on the executing
+// processor -- is a better choice as it scales on SMP systems.
+//
+// See http://blogs.oracle.com/dave/entry/biased_locking_in_hotspot for
+// a discussion of coherency costs. Note that all our current reference
+// platforms provide strong ST-ST order, so the issue is moot on IA32,
+// x64, and SPARC.
 //
 // As a general policy we use "volatile" to control compiler-based reordering
-// and explicit fences (barriers) to control for architectural reordering performed
-// by the CPU(s) or platform.
+// and explicit fences (barriers) to control for architectural reordering
+// performed by the CPU(s) or platform.
 
 struct SharedGlobals {
     // These are highly shared mostly-read variables.
@@ -1596,7 +1599,55 @@ void ObjectSynchronizer::release_monitors_owned_by_thread(TRAPS) {
 }
 
 //------------------------------------------------------------------------------
-// Non-product code
+// Debugging code
+
+void ObjectSynchronizer::sanity_checks(const bool verbose,
+                                       const uint cache_line_size,
+                                       int *error_cnt_ptr,
+                                       int *warning_cnt_ptr) {
+  u_char *addr_begin      = (u_char*)&GVars;
+  u_char *addr_stwRandom  = (u_char*)&GVars.stwRandom;
+  u_char *addr_hcSequence = (u_char*)&GVars.hcSequence;
+
+  if (verbose) {
+    tty->print_cr("INFO: sizeof(SharedGlobals)=" SIZE_FORMAT,
+                  sizeof(SharedGlobals));
+  }
+
+  uint offset_stwRandom = (uint)(addr_stwRandom - addr_begin);
+  if (verbose) tty->print_cr("INFO: offset(stwRandom)=%u", offset_stwRandom);
+
+  uint offset_hcSequence = (uint)(addr_hcSequence - addr_begin);
+  if (verbose) {
+    tty->print_cr("INFO: offset(_hcSequence)=%u", offset_hcSequence);
+  }
+
+  if (cache_line_size != 0) {
+    // We were able to determine the L1 data cache line size so
+    // do some cache line specific sanity checks
+
+    if (offset_stwRandom < cache_line_size) {
+      tty->print_cr("WARNING: the SharedGlobals.stwRandom field is closer "
+                    "to the struct beginning than a cache line which permits "
+                    "false sharing.");
+      (*warning_cnt_ptr)++;
+    }
+
+    if ((offset_hcSequence - offset_stwRandom) < cache_line_size) {
+      tty->print_cr("WARNING: the SharedGlobals.stwRandom and "
+                    "SharedGlobals.hcSequence fields are closer than a cache "
+                    "line which permits false sharing.");
+      (*warning_cnt_ptr)++;
+    }
+
+    if ((sizeof(SharedGlobals) - offset_hcSequence) < cache_line_size) {
+      tty->print_cr("WARNING: the SharedGlobals.hcSequence field is closer "
+                    "to the struct end than a cache line which permits false "
+                    "sharing.");
+      (*warning_cnt_ptr)++;
+    }
+  }
+}
 
 #ifndef PRODUCT
 
diff --git a/hotspot/src/share/vm/runtime/synchronizer.hpp b/hotspot/src/share/vm/runtime/synchronizer.hpp
index 07af7e325ef429171fec8e87d1d5934441a7a04b..ceb4a725ae62b08e70b4b1827bbfd0204b021f91 100644
--- a/hotspot/src/share/vm/runtime/synchronizer.hpp
+++ b/hotspot/src/share/vm/runtime/synchronizer.hpp
@@ -121,6 +121,9 @@ class ObjectSynchronizer : AllStatic {
   static void oops_do(OopClosure* f);
 
   // debugging
+  static void sanity_checks(const bool verbose,
+                            const unsigned int cache_line_size,
+                            int *error_cnt_ptr, int *warning_cnt_ptr);
   static void verify() PRODUCT_RETURN;
   static int  verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
 
diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp
index a1779a85fe2773ec46188ec2dfabf53b94ba38c6..bbebb4157be615f86bd80ca7d9d98a52b2fb048f 100644
--- a/hotspot/src/share/vm/runtime/vm_version.cpp
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp
@@ -50,6 +50,7 @@ bool Abstract_VM_Version::_supports_atomic_getset8 = false;
 bool Abstract_VM_Version::_supports_atomic_getadd4 = false;
 bool Abstract_VM_Version::_supports_atomic_getadd8 = false;
 unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;
+unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
 int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
 
 #ifndef HOTSPOT_RELEASE_VERSION
diff --git a/hotspot/src/share/vm/runtime/vm_version.hpp b/hotspot/src/share/vm/runtime/vm_version.hpp
index 27a5717d383e1a45ed4ab76085912e4ce7056459..fcd7b229348aa6590a8e943821247824345c6f63 100644
--- a/hotspot/src/share/vm/runtime/vm_version.hpp
+++ b/hotspot/src/share/vm/runtime/vm_version.hpp
@@ -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
@@ -42,6 +42,7 @@ class Abstract_VM_Version: AllStatic {
   static bool         _supports_atomic_getadd4;
   static bool         _supports_atomic_getadd8;
   static unsigned int _logical_processors_per_package;
+  static unsigned int _L1_data_cache_line_size;
   static int          _vm_major_version;
   static int          _vm_minor_version;
   static int          _vm_micro_version;
@@ -98,6 +99,10 @@ class Abstract_VM_Version: AllStatic {
     return _logical_processors_per_package;
   }
 
+  static unsigned int L1_data_cache_line_size() {
+    return _L1_data_cache_line_size;
+  }
+
   // Need a space at the end of TLAB for prefetch instructions
   // which may fault when accessing memory outside of heap.
   static int reserve_for_allocation_prefetch() {
diff --git a/hotspot/test/Makefile b/hotspot/test/Makefile
index f81cc8d64df6b5fde19866af38b13ffeeb0e20b8..929de70cdf0e9bbb4b8432164e39d012e0dfe173 100644
--- a/hotspot/test/Makefile
+++ b/hotspot/test/Makefile
@@ -23,14 +23,36 @@
 #
 
 #
-# Makefile to run various jdk tests
+# Makefile to run various hotspot tests
 #
 
 GETMIXEDPATH=echo
 
-# Get OS/ARCH specifics
-OSNAME = $(shell uname -s)
-ifeq ($(OSNAME), SunOS)
+# Utilities used
+AWK       = awk
+CAT       = cat
+CD        = cd
+CHMOD     = chmod
+CP        = cp
+CUT       = cut
+DIRNAME   = dirname
+ECHO      = echo
+EGREP     = egrep
+EXPAND    = expand
+FIND      = find
+MKDIR     = mkdir
+PWD       = pwd
+SED       = sed
+SORT      = sort
+TEE       = tee
+UNAME     = uname
+UNIQ      = uniq
+WC        = wc
+ZIP       = zip
+
+# Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
+UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
+ifeq ($(UNAME_S), SunOS)
   PLATFORM = solaris
   SLASH_JAVA = /java
   ARCH = $(shell uname -p)
@@ -38,7 +60,7 @@ ifeq ($(OSNAME), SunOS)
     ARCH=i586
   endif
 endif
-ifeq ($(OSNAME), Linux)
+ifeq ($(UNAME_S), Linux)
   PLATFORM = linux
   SLASH_JAVA = /java
   ARCH = $(shell uname -m)
@@ -46,7 +68,7 @@ ifeq ($(OSNAME), Linux)
     ARCH = i586
   endif
 endif
-ifeq ($(OSNAME), Darwin)
+ifeq ($(UNAME_S), Darwin)
   PLATFORM = bsd
   SLASH_JAVA = /java
   ARCH = $(shell uname -m)
@@ -54,7 +76,7 @@ ifeq ($(OSNAME), Darwin)
     ARCH = i586
   endif
 endif
-ifeq ($(findstring BSD,$(OSNAME)), BSD)
+ifeq ($(findstring BSD,$(UNAME_S)), BSD)
   PLATFORM = bsd
   SLASH_JAVA = /java
   ARCH = $(shell uname -m)
@@ -63,12 +85,12 @@ ifeq ($(findstring BSD,$(OSNAME)), BSD)
   endif
 endif
 ifeq ($(PLATFORM),)
-  # detect wether we're running in MKS or cygwin
-  ifeq ($(OSNAME), Windows_NT) # MKS
+  # detect whether we're running in MKS or cygwin
+  ifeq ($(UNAME_S), Windows_NT) # MKS
     GETMIXEDPATH=dosname -s
   endif
-  ifeq ($(findstring CYGWIN,$(OSNAME)), CYGWIN)
-    GETMIXEDPATH=cygpath -m -s
+  ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN)
+    GETMIXEDPATH=cygpath -m
   endif
   PLATFORM = windows
   SLASH_JAVA = J:
@@ -92,13 +114,6 @@ ifdef ALT_SLASH_JAVA
   SLASH_JAVA = $(ALT_SLASH_JAVA)
 endif
 
-# Utilities used
-CD    = cd
-CP    = cp
-ECHO  = echo
-MKDIR = mkdir
-ZIP   = zip
-
 # Root of this test area (important to use full paths in some places)
 TEST_ROOT := $(shell pwd)
 
@@ -136,21 +151,82 @@ ifdef JPRT_ARCHIVE_BUNDLE
 endif
 
 # How to create the test bundle (pass or fail, we want to create this)
-BUNDLE_UP = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)`     \
-	      && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
-	      && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
-BUNDLE_UP_FAILED = ( exitCode=$$? && $(BUNDLE_UP) && exit $${exitCode} )
+#   Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
+ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
+	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
+	           && $(CHMOD) -R a+r . \
+	           && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
+
+# important results files
+SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
+STATS_TXT_NAME = Stats.txt
+STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)")
+RUNLIST   = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt")
+PASSLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt")
+FAILLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt")
+EXITCODE  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt")
+
+TESTEXIT = \
+  if [ ! -s $(EXITCODE) ] ; then \
+    $(ECHO) "ERROR: EXITCODE file not filled in."; \
+    $(ECHO) "1" > $(EXITCODE); \
+  fi ; \
+  testExitCode=`$(CAT) $(EXITCODE)`; \
+  $(ECHO) "EXIT CODE: $${testExitCode}"; \
+  exit $${testExitCode}
+
+BUNDLE_UP_AND_EXIT = \
+( \
+  jtregExitCode=$$? && \
+  _summary="$(SUMMARY_TXT)"; \
+  $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \
+  $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \
+  if [ -r "$${_summary}" ] ; then \
+    $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \
+    $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \
+    $(EGREP) ' Passed\.' $(RUNLIST) \
+      | $(EGREP) -v ' Error\.' \
+      | $(EGREP) -v ' Failed\.' > $(PASSLIST); \
+    ( $(EGREP) ' Failed\.' $(RUNLIST); \
+      $(EGREP) ' Error\.' $(RUNLIST); \
+      $(EGREP) -v ' Passed\.' $(RUNLIST) ) \
+      | $(SORT) | $(UNIQ) > $(FAILLIST); \
+    if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \
+      $(EXPAND) $(FAILLIST) \
+        | $(CUT) -d' ' -f1 \
+        | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \
+      if [ $${jtregExitCode} = 0 ] ; then \
+        jtregExitCode=1; \
+      fi; \
+    fi; \
+    runc="`$(CAT) $(RUNLIST)      | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    passc="`$(CAT) $(PASSLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    failc="`$(CAT) $(FAILLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    exclc="FIXME CODETOOLS-7900176"; \
+    $(ECHO) "TEST STATS: name=$(UNIQUE_DIR)  run=$${runc}  pass=$${passc}  fail=$${failc}" \
+      >> $(STATS_TXT); \
+  else \
+    $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
+  fi; \
+  if [ -f $(STATS_TXT) ] ; then \
+    $(CAT) $(STATS_TXT); \
+  fi; \
+  $(ZIP_UP_RESULTS) ; \
+  $(TESTEXIT) \
+)
 
 ################################################################
 
 # Default make rule (runs jtreg_tests)
-all: jtreg_tests
+all: hotspot_all
 	@$(ECHO) "Testing completed successfully"
 
-# Support "hotspot_" prefixed test make targets too
-# The hotspot_% targets are for example invoked by the top level Makefile
+# Support "hotspot_" prefixed test make targets (too)
+# The hotspot_% targets are used by the top level Makefile
+# Unless explicitly defined below, hotspot_<x> is interpreted as a jtreg test group name
 hotspot_%:
-	$(MAKE) $*
+	$(ECHO) "Running tests: $@"
+	$(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests;
 
 # Prep for output
 prep: clean
@@ -168,41 +244,64 @@ clean:
 
 # Expect JT_HOME to be set for jtreg tests. (home for jtreg)
 ifndef JT_HOME
-  JT_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg
-endif
-ifdef JPRT_JTREG_HOME
-  JT_HOME = $(JPRT_JTREG_HOME)
+  JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg
+  ifdef JPRT_JTREG_HOME
+    JT_HOME = $(JPRT_JTREG_HOME)
+  endif
 endif
 
-# Expect JPRT to set TESTDIRS to the jtreg test dirs
-JTREG_TESTDIRS = demo/jvmti/gctest demo/jvmti/hprof
+# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run
 ifdef TESTDIRS
-  JTREG_TESTDIRS = $(TESTDIRS)
+  TEST_SELECTION = $(TESTDIRS)
+endif
+
+ifdef CONCURRENCY
+  EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
 endif
 
 # Default JTREG to run (win32 script works for everybody)
 JTREG = $(JT_HOME)/win32/bin/jtreg
 
+# Only run automatic tests
+JTREG_BASIC_OPTIONS += -a
+# Report details on all failed or error tests, times too
+JTREG_BASIC_OPTIONS += -v:fail,error,time
+# Retain all files for failing tests
+JTREG_BASIC_OPTIONS += -retain:fail,error
+# Ignore tests are not run and completely silent about it
+JTREG_IGNORE_OPTION = -ignore:quiet
+JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION)
+# Add any extra options
+JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
+# Set other vm and test options
+JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%)
+
 # Option to tell jtreg to not run tests marked with "ignore"
 ifeq ($(PLATFORM), windows)
   JTREG_KEY_OPTION = -k:!ignore
 else
   JTREG_KEY_OPTION = -k:\!ignore
 endif
-
-#EXTRA_JTREG_OPTIONS =
-
-jtreg_tests: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG)
-	$(JTREG) -a -v:fail,error               \
-          $(JTREG_KEY_OPTION)                   \
-          $(EXTRA_JTREG_OPTIONS)                \
-          -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport    \
-          -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork      \
-          -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                  \
-          $(JAVA_OPTIONS:%=-vmoption:%)         \
-          $(JTREG_TESTDIRS)                     \
-	  || $(BUNDLE_UP_FAILED)
-	$(BUNDLE_UP)
+JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION)
+
+# Make sure jtreg exists
+$(JTREG): $(JT_HOME)
+
+jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
+	(                                                                    \
+	  ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                   \
+            export JT_HOME;                                                  \
+            $(shell $(GETMIXEDPATH) "$(JTREG)")                              \
+              $(JTREG_BASIC_OPTIONS)                                         \
+              -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport")  \
+              -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork")    \
+              -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \
+              $(JTREG_EXCLUSIONS)                                            \
+              $(JTREG_TEST_OPTIONS)                                          \
+              $(TEST_SELECTION)                                              \
+	  ) ;                                                                \
+	  $(BUNDLE_UP_AND_EXIT)                                              \
+	) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
 
 PHONY_LIST += jtreg_tests
 
@@ -210,7 +309,7 @@ PHONY_LIST += jtreg_tests
 
 # clienttest (make sure various basic java client options work)
 
-clienttest: prep $(PRODUCT_HOME)
+hotspot_clienttest clienttest: prep $(PRODUCT_HOME)
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X
@@ -218,73 +317,27 @@ clienttest: prep $(PRODUCT_HOME)
 	$(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump
 
-PHONY_LIST += clienttest
+PHONY_LIST += hotspot_clienttest clienttest
 
 ################################################################
 
 # servertest (make sure various basic java server options work)
 
-servertest: prep $(PRODUCT_HOME)
+hotspot_servertest servertest: prep $(PRODUCT_HOME)
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X
 
-PHONY_LIST += servertest
+PHONY_LIST += hotspot_servertest servertest
 
 ################################################################
 
 # internalvmtests (run internal unit tests inside the VM)
 
-internalvmtests: prep $(PRODUCT_HOME)
+hotspot_internalvmtests internalvmtests: prep $(PRODUCT_HOME)
 	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -XX:+ExecuteInternalVMTests -version
 
-PHONY_LIST += internalvmtests
-
-################################################################
-
-# wbapitest (make sure the whitebox testing api classes work
-
-wbapitest: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG)
-	$(JTREG) -a -v:fail,error               \
-          $(JTREG_KEY_OPTION)                   \
-          $(EXTRA_JTREG_OPTIONS)                \
-          -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport    \
-          -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork      \
-          -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                  \
-          $(JAVA_OPTIONS:%=-vmoption:%)         \
-          $(shell $(GETMIXEDPATH) "$(TEST_ROOT)")/sanity                   \
-	  || $(BUNDLE_UP_FAILED)
-	$(BUNDLE_UP)
-
-PHONY_LIST += wbapitest
-
-################################################################
-
-# packtest
-
-# Expect JPRT to set JPRT_PACKTEST_HOME.
-PACKTEST_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/packtest
-ifdef JPRT_PACKTEST_HOME
-  PACKTEST_HOME = $(JPRT_PACKTEST_HOME)
-endif
-
-#EXTRA_PACKTEST_OPTIONS =
-
-packtest: prep $(PACKTEST_HOME)/ptest $(PRODUCT_HOME)
-	( $(CD) $(PACKTEST_HOME) &&            \
-	    $(PACKTEST_HOME)/ptest             \
-		 -t "$(PRODUCT_HOME)"          \
-	         $(PACKTEST_STRESS_OPTION)     \
-		 $(EXTRA_PACKTEST_OPTIONS)     \
-		 -W $(ABS_TEST_OUTPUT_DIR)     \
-                 $(JAVA_OPTIONS:%=-J %)        \
-	 ) || $(BUNDLE_UP_FAILED)
-	$(BUNDLE_UP)
-
-packtest_stress: PACKTEST_STRESS_OPTION=-s
-packtest_stress: packtest
-
-PHONY_LIST += packtest packtest_stress
+PHONY_LIST += hotspot_internalvmtests internalvmtests
 
 ################################################################
 
@@ -292,4 +345,3 @@ PHONY_LIST += packtest packtest_stress
 .PHONY: all clean prep $(PHONY_LIST)
 
 ################################################################
-
diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups
index 22ff9c82228ff68bf8ed2372ab68504bc41c60bf..6a89ec446d387f572945244e928e400431e21c3a 100644
--- a/hotspot/test/TEST.groups
+++ b/hotspot/test/TEST.groups
@@ -271,6 +271,7 @@ needs_cmsgc = \
   gc/arguments/TestCMSHeapSizeFlags.java \
   gc/arguments/TestMaxNewSize.java \
   gc/arguments/TestUseCompressedOopsErgo.java \
+  gc/class_unloading/TestCMSClassUnloadingDisabledHWM.java \
   gc/concurrentMarkSweep/ \
   gc/startup_warnings/TestCMS.java \
   gc/startup_warnings/TestCMSIncrementalMode.java \
@@ -325,3 +326,24 @@ applicable_cmsgc = \
  -:needs_parallelgc
 
 
+# When called from top level the test suites use the hotspot_ prefix
+hotspot_wbapitest = \
+  sanity/
+
+hotspot_compiler = \
+  sanity/ExecuteInternalVMTests.java
+
+hotspot_gc = \
+  sanity/ExecuteInternalVMTests.java
+
+hotspot_runtime = \
+  sanity/ExecuteInternalVMTests.java
+
+hotspot_serviceability = \
+  sanity/ExecuteInternalVMTests.java
+
+hotspot_all = \
+  :hotspot_compiler \
+  :hotspot_gc \
+  :hotspot_runtime \
+  :hotspot_serviceability
diff --git a/hotspot/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java b/hotspot/test/compiler/profiling/TestSpecTrapClassUnloading.java
similarity index 100%
rename from hotspot/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java
rename to hotspot/test/compiler/profiling/TestSpecTrapClassUnloading.java
diff --git a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/A.java b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/A.java
new file mode 100644
index 0000000000000000000000000000000000000000..cae091e8531046bb86a8861a8d3afe68da71fe70
--- /dev/null
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/A.java
@@ -0,0 +1,4 @@
+public class A {
+    void m() {
+    }
+}
diff --git a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Agent.java b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Agent.java
new file mode 100644
index 0000000000000000000000000000000000000000..d03f7de7378f4fce9471d379353fe0f3d1e0cef9
--- /dev/null
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Agent.java
@@ -0,0 +1,115 @@
+/*
+ * 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.security.*;
+import java.lang.instrument.*;
+import java.lang.reflect.*;
+import java.lang.management.ManagementFactory;
+import com.sun.tools.attach.VirtualMachine;
+import java.lang.reflect.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Paths;
+
+public class Agent implements ClassFileTransformer {
+    public static ClassLoader newClassLoader() {
+        try {
+            return new URLClassLoader(new URL[] {
+                    Paths.get(System.getProperty("test.classes",".")).toUri().toURL(),
+            }, null);
+        } catch (MalformedURLException e){
+            throw new RuntimeException("Unexpected URL conversion failure", e);
+        }
+    }
+
+    static public Class Test_class;
+
+    static public void main(String[] args) throws Exception {
+
+        // loader2 must be first on the list so loader 1 must be used first
+        ClassLoader loader1 = newClassLoader();
+        Class dummy = loader1.loadClass("Test");
+
+        ClassLoader loader2 = newClassLoader();
+
+        Test_class = loader2.loadClass("Test");
+        Method m3 = Test_class.getMethod("m3", ClassLoader.class);
+        // Add speculative trap in m2() (loaded by loader1) that
+        // references m4() (loaded by loader2).
+        m3.invoke(Test_class.newInstance(), loader1);
+
+        String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName();
+        int p = nameOfRunningVM.indexOf('@');
+        String pid = nameOfRunningVM.substring(0, p);
+
+        // Make the nmethod go away
+        for (int i = 0; i < 10; i++) {
+            System.gc();
+        }
+
+        // Redefine class Test loaded by loader2
+        for (int i = 0; i < 2; i++) {
+            try {
+                VirtualMachine vm = VirtualMachine.attach(pid);
+                vm.loadAgent(System.getProperty("test.classes",".") + "/agent.jar", "");
+                vm.detach();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+        // Will process loader2 first, find m4() is redefined and
+        // needs to be freed then process loader1, check the
+        // speculative trap in m2() and try to access m4() which was
+        // freed already.
+        for (int i = 0; i < 10; i++) {
+            System.gc();
+        }
+    }
+
+    public synchronized byte[] transform(final ClassLoader classLoader,
+                                         final String className,
+                                         Class<?> classBeingRedefined,
+                                         ProtectionDomain protectionDomain,
+                                         byte[] classfileBuffer) {
+        System.out.println("Transforming class " + className + " "+ classLoader);
+        return classfileBuffer;
+    }
+
+    public static void redefine(String agentArgs, Instrumentation instrumentation, Class to_redefine) {
+
+        try {
+            instrumentation.retransformClasses(to_redefine);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public static void agentmain(String agentArgs, Instrumentation instrumentation) throws Exception {
+        Agent transformer = new Agent();
+        instrumentation.addTransformer(transformer, true);
+
+        redefine(agentArgs, instrumentation, Test_class);
+    }
+}
diff --git a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/B.java b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/B.java
new file mode 100644
index 0000000000000000000000000000000000000000..1b71f43d973e712dee33b5e26e429502be4b8aca
--- /dev/null
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/B.java
@@ -0,0 +1,5 @@
+public class B extends A {
+    void m() {
+    }
+}
+
diff --git a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java
new file mode 100644
index 0000000000000000000000000000000000000000..3c49cd58ea7e4bd8f2b83a49ed7d070e5b6acc1e
--- /dev/null
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java
@@ -0,0 +1,47 @@
+/*
+ * 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.PrintWriter;
+import com.oracle.java.testlibrary.*;
+
+/*
+ * @test
+ * @bug 8040237
+ * @library /testlibrary
+ * @build Agent Test A B
+ * @run main ClassFileInstaller Agent
+ * @run main Launcher
+ * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -XX:ReservedCodeCacheSize=3M Agent
+ */
+public class Launcher {
+    public static void main(String[] args) throws Exception  {
+
+      PrintWriter pw = new PrintWriter("MANIFEST.MF");
+      pw.println("Agent-Class: Agent");
+      pw.println("Can-Retransform-Classes: true");
+      pw.close();
+
+      ProcessBuilder pb = new ProcessBuilder();
+      pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", System.getProperty("test.classes",".") + "/agent.jar", "Agent.class"});
+      pb.start().waitFor();
+    }
+}
diff --git a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Test.java b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Test.java
new file mode 100644
index 0000000000000000000000000000000000000000..189d39abb129a5e64ca24d1a95c65051dc93c654
--- /dev/null
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Test.java
@@ -0,0 +1,50 @@
+import java.lang.reflect.*;
+
+public class Test {
+
+    public boolean m1(A a, Boolean early_return) {
+        if (early_return.booleanValue()) return true;
+        boolean res =  m2(a);
+        return res;
+    }
+
+    public boolean m2(A a) {
+        boolean res = false;
+        if (a.getClass() == B.class) {
+            a.m();
+        } else {
+            res = true;
+        }
+        return res;
+    }
+
+    public void m3(ClassLoader loader) throws Exception {
+        Class Test_class = loader.loadClass("Test");
+        Object test = Test_class.newInstance();
+        Class A_class = loader.loadClass("A");
+        Object a = A_class.newInstance();
+        Class B_class = loader.loadClass("B");
+        Object b = B_class.newInstance();
+        Method m1 = Test_class.getMethod("m1", A_class, Boolean.class);
+
+        // So we don't hit uncommon trap in the next loop
+        for (int i = 0; i < 4000; i++) {
+            m4(m1, test, a, Boolean.TRUE);
+            m4(m1, test, b, Boolean.TRUE);
+        }
+        for (int i = 0; i < 20000; i++) {
+            m4(m1, test, a, Boolean.FALSE);
+        }
+        for (int i = 0; i < 4; i++) {
+            m4(m1, test, b, Boolean.FALSE);
+        }
+    }
+
+    public Object m4(Method m, Object test, Object a, Object early_return) throws Exception {
+        return m.invoke(test, a, early_return);
+    }
+
+    static public A a = new A();
+    static public B b = new B();
+}
+
diff --git a/hotspot/test/compiler/stable/StableConfiguration.java b/hotspot/test/compiler/stable/StableConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..09e395707e7dc6f5bc0963ab7c88447227890a49
--- /dev/null
+++ b/hotspot/test/compiler/stable/StableConfiguration.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package java.lang.invoke;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+import sun.hotspot.WhiteBox;
+
+public class StableConfiguration {
+    static final WhiteBox WB = WhiteBox.getWhiteBox();
+    static final boolean isStableEnabled;
+    static final boolean isServerWithStable;
+
+    static {
+        Boolean value = WB.getBooleanVMFlag("FoldStableValues");
+        isStableEnabled = (value == null ? false : value);
+        isServerWithStable = isStableEnabled && get();
+        System.out.println("@Stable:         " + (isStableEnabled ? "enabled" : "disabled"));
+        System.out.println("Server Compiler: " + get());
+    }
+
+    // ::get() is among immediately compiled methods.
+    static boolean get() {
+        try {
+            Method m = StableConfiguration.class.getDeclaredMethod("get");
+            int level = WB.getMethodCompilationLevel(m);
+            if (level > 0) {
+              return (level == 4);
+            } else {
+              String javaVM = System.getProperty("java.vm.name", "");
+              if (javaVM.contains("Server")) return true;
+              if (javaVM.contains("Client")) return false;
+              throw new Error("Unknown VM type: "+javaVM);
+            }
+        } catch (NoSuchMethodException e) {
+            throw new Error(e);
+        }
+    }
+
+}
diff --git a/hotspot/test/compiler/stable/TestStableBoolean.java b/hotspot/test/compiler/stable/TestStableBoolean.java
index 37f42875022571964f0d4c85d81f9a4cfd79d5f3..37641d1b101d77a8d9ab270bf831334317cacf35 100644
--- a/hotspot/test/compiler/stable/TestStableBoolean.java
+++ b/hotspot/test/compiler/stable/TestStableBoolean.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableBoolean
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableBoolean.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableBoolean StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableBoolean
  *           java/lang/invoke/TestStableBoolean$BooleanStable
  *           java/lang/invoke/TestStableBoolean$StaticBooleanStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableBoolean$NestedStableField3
  *           java/lang/invoke/TestStableBoolean$NestedStableField3$A
  *           java/lang/invoke/TestStableBoolean$DefaultValue
+ *           java/lang/invoke/TestStableBoolean$DefaultStaticValue
  *           java/lang/invoke/TestStableBoolean$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableBoolean
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableBoolean
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableBoolean
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableBoolean
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableBoolean
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableBoolean
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableBoolean {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(BooleanStable.class);
+        run(DefaultStaticValue.class);
         run(StaticBooleanStable.class);
         run(VolatileBooleanStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableBoolean {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable boolean v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static boolean get() { return c.v; }
+        public static void test() throws Exception {
+                        boolean val1 = get();
+            c.v = true; boolean val2 = get();
+            assertEquals(val1, false);
+            assertEquals(val2, true);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticBooleanStable {
         public static @Stable boolean v;
 
@@ -188,14 +219,14 @@ public class TestStableBoolean {
                 c.v = new boolean[1]; c.v[0] = true;  boolean val1 = get();
                                       c.v[0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isStableEnabled ? true : false));
+                assertEquals(val2, (isServerWithStable ? true : false));
             }
 
             {
                 c.v = new boolean[20]; c.v[10] = true;  boolean val1 = get1();
                                        c.v[10] = false; boolean val2 = get1();
                 assertEquals(val1, true);
-                assertEquals(val2, (isStableEnabled ? true : false));
+                assertEquals(val2, (isServerWithStable ? true : false));
             }
 
             {
@@ -220,19 +251,19 @@ public class TestStableBoolean {
                 c.v = new boolean[1][1]; c.v[0][0] = true;  boolean val1 = get();
                                          c.v[0][0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isStableEnabled ? true : false));
+                assertEquals(val2, (isServerWithStable ? true : false));
 
                 c.v = new boolean[1][1]; c.v[0][0] = false; boolean val3 = get();
-                assertEquals(val3, (isStableEnabled ? true : false));
+                assertEquals(val3, (isServerWithStable ? true : false));
 
                 c.v[0] = new boolean[1]; c.v[0][0] = false; boolean val4 = get();
-                assertEquals(val4, (isStableEnabled ? true : false));
+                assertEquals(val4, (isServerWithStable ? true : false));
             }
 
             {
                 c.v = new boolean[1][1]; boolean[] val1 = get1();
                 c.v[0] = new boolean[1]; boolean[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -258,28 +289,28 @@ public class TestStableBoolean {
                 c.v = new boolean[1][1][1]; c.v[0][0][0] = true;  boolean val1 = get();
                                             c.v[0][0][0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isStableEnabled ? true : false));
+                assertEquals(val2, (isServerWithStable ? true : false));
 
                 c.v = new boolean[1][1][1]; c.v[0][0][0] = false; boolean val3 = get();
-                assertEquals(val3, (isStableEnabled ? true : false));
+                assertEquals(val3, (isServerWithStable ? true : false));
 
                 c.v[0] = new boolean[1][1]; c.v[0][0][0] = false; boolean val4 = get();
-                assertEquals(val4, (isStableEnabled ? true : false));
+                assertEquals(val4, (isServerWithStable ? true : false));
 
                 c.v[0][0] = new boolean[1]; c.v[0][0][0] = false; boolean val5 = get();
-                assertEquals(val5, (isStableEnabled ? true : false));
+                assertEquals(val5, (isServerWithStable ? true : false));
             }
 
             {
                 c.v = new boolean[1][1][1]; boolean[] val1 = get1();
                 c.v[0][0] = new boolean[1]; boolean[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1]; boolean[][] val1 = get2();
                 c.v[0] = new boolean[1][1]; boolean[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -306,37 +337,37 @@ public class TestStableBoolean {
                 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = true;  boolean val1 = get();
                                                c.v[0][0][0][0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isStableEnabled ? true : false));
+                assertEquals(val2, (isServerWithStable ? true : false));
 
                 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = false; boolean val3 = get();
-                assertEquals(val3, (isStableEnabled ? true : false));
+                assertEquals(val3, (isServerWithStable ? true : false));
 
                 c.v[0] = new boolean[1][1][1]; c.v[0][0][0][0] = false; boolean val4 = get();
-                assertEquals(val4, (isStableEnabled ? true : false));
+                assertEquals(val4, (isServerWithStable ? true : false));
 
                 c.v[0][0] = new boolean[1][1]; c.v[0][0][0][0] = false; boolean val5 = get();
-                assertEquals(val5, (isStableEnabled ? true : false));
+                assertEquals(val5, (isServerWithStable ? true : false));
 
                 c.v[0][0][0] = new boolean[1]; c.v[0][0][0][0] = false; boolean val6 = get();
-                assertEquals(val6, (isStableEnabled ? true : false));
+                assertEquals(val6, (isServerWithStable ? true : false));
             }
 
             {
                 c.v = new boolean[1][1][1][1]; boolean[] val1 = get1();
                 c.v[0][0][0] = new boolean[1]; boolean[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1][1]; boolean[][] val1 = get2();
                 c.v[0][0] = new boolean[1][1]; boolean[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1][1]; boolean[][][] val1 = get3();
                 c.v[0] = new boolean[1][1][1]; boolean[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -399,7 +430,7 @@ public class TestStableBoolean {
                 c.v = new boolean[1][1]; c.v[0] = new boolean[0]; boolean[] val1 = get1();
                                          c.v[0] = new boolean[0]; boolean[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -435,14 +466,14 @@ public class TestStableBoolean {
                 c.v = new boolean[1][1][1]; c.v[0][0] = new boolean[0]; boolean[] val1 = get1();
                                             c.v[0][0] = new boolean[0]; boolean[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1]; c.v[0] = new boolean[0][0]; boolean[][] val1 = get2();
                                             c.v[0] = new boolean[0][0]; boolean[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -577,7 +608,7 @@ public class TestStableBoolean {
                                elem.a = false; boolean val3 = get(); boolean val4 = get1();
 
                 assertEquals(val1, true);
-                assertEquals(val3, (isStableEnabled ? true : false));
+                assertEquals(val3, (isServerWithStable ? true : false));
 
                 assertEquals(val2, true);
                 assertEquals(val4, false);
@@ -611,17 +642,4 @@ public class TestStableBoolean {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableByte.java b/hotspot/test/compiler/stable/TestStableByte.java
index 4a14fcc3b2fadf355a4376cf96cf665354d99e9b..c62bc35081fe7e30ff34017e215084dc652ffb73 100644
--- a/hotspot/test/compiler/stable/TestStableByte.java
+++ b/hotspot/test/compiler/stable/TestStableByte.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableByte
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableByte.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableByte StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableByte
  *           java/lang/invoke/TestStableByte$ByteStable
  *           java/lang/invoke/TestStableByte$StaticByteStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableByte$NestedStableField3
  *           java/lang/invoke/TestStableByte$NestedStableField3$A
  *           java/lang/invoke/TestStableByte$DefaultValue
+ *           java/lang/invoke/TestStableByte$DefaultStaticValue
  *           java/lang/invoke/TestStableByte$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableByte
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableByte
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableByte
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableByte
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableByte
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableByte
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableByte {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(ByteStable.class);
+        run(DefaultStaticValue.class);
         run(StaticByteStable.class);
         run(VolatileByteStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableByte {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable byte v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static byte get() { return c.v; }
+        public static void test() throws Exception {
+                     byte val1 = get();
+            c.v = 1; byte val2 = get();
+            assertEquals(val1, 0);
+            assertEquals(val2, 1);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticByteStable {
         public static @Stable byte v;
 
@@ -188,20 +219,22 @@ public class TestStableByte {
                 c.v = new byte[1]; c.v[0] = 1; byte val1 = get();
                                    c.v[0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new byte[1]; c.v[0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
                 c.v = new byte[20]; c.v[10] = 1; byte val1 = get1();
                                     c.v[10] = 2; byte val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new byte[20]; c.v[10] = 3; byte val3 = get1();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
@@ -226,19 +259,21 @@ public class TestStableByte {
                 c.v = new byte[1][1]; c.v[0][0] = 1; byte val1 = get();
                                       c.v[0][0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new byte[1][1]; c.v[0][0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new byte[1]; c.v[0][0] = 4; byte val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
             }
 
             {
                 c.v = new byte[1][1]; byte[] val1 = get1();
                 c.v[0] = new byte[1]; byte[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,28 +299,31 @@ public class TestStableByte {
                 c.v = new byte[1][1][1]; c.v[0][0][0] = 1; byte val1 = get();
                                          c.v[0][0][0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new byte[1][1][1]; c.v[0][0][0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new byte[1][1]; c.v[0][0][0] = 4; byte val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new byte[1]; c.v[0][0][0] = 5; byte val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
             }
 
             {
                 c.v = new byte[1][1][1]; byte[] val1 = get1();
                 c.v[0][0] = new byte[1]; byte[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1]; byte[][] val1 = get2();
                 c.v[0] = new byte[1][1]; byte[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -312,37 +350,41 @@ public class TestStableByte {
                 c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 1; byte val1 = get();
                                             c.v[0][0][0][0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new byte[1][1][1]; c.v[0][0][0][0] = 4; byte val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new byte[1][1]; c.v[0][0][0][0] = 5; byte val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
 
                 c.v[0][0][0] = new byte[1]; c.v[0][0][0][0] = 6; byte val6 = get();
-                assertEquals(val6, (isStableEnabled ? 1 : 6));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 6));
             }
 
             {
                 c.v = new byte[1][1][1][1]; byte[] val1 = get1();
                 c.v[0][0][0] = new byte[1]; byte[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1][1]; byte[][] val1 = get2();
                 c.v[0][0] = new byte[1][1]; byte[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1][1]; byte[][][] val1 = get3();
                 c.v[0] = new byte[1][1][1]; byte[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -404,7 +446,7 @@ public class TestStableByte {
                 c.v = new byte[1][1]; c.v[0] = new byte[0]; byte[] val1 = get1();
                                      c.v[0] = new byte[0]; byte[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -440,14 +482,14 @@ public class TestStableByte {
                 c.v = new byte[1][1][1]; c.v[0][0] = new byte[0]; byte[] val1 = get1();
                                          c.v[0][0] = new byte[0]; byte[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1]; c.v[0] = new byte[0][0]; byte[][] val1 = get2();
                                          c.v[0] = new byte[0][0]; byte[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -582,7 +624,7 @@ public class TestStableByte {
                                elem.a = 2; byte val3 = get(); byte val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isStableEnabled ? 1 : 2));
+                assertEquals(val3, (isServerWithStable ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
@@ -616,17 +658,4 @@ public class TestStableByte {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableChar.java b/hotspot/test/compiler/stable/TestStableChar.java
index ede8e9a4df7318aecc7e8805b13eff42c6d3e5c7..55bf749bf02f32011a23c31d81066a6efee95922 100644
--- a/hotspot/test/compiler/stable/TestStableChar.java
+++ b/hotspot/test/compiler/stable/TestStableChar.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableChar
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableChar.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableChar StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableChar
  *           java/lang/invoke/TestStableChar$CharStable
  *           java/lang/invoke/TestStableChar$StaticCharStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableChar$NestedStableField3
  *           java/lang/invoke/TestStableChar$NestedStableField3$A
  *           java/lang/invoke/TestStableChar$DefaultValue
+ *           java/lang/invoke/TestStableChar$DefaultStaticValue
  *           java/lang/invoke/TestStableChar$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableChar
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableChar
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableChar
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableChar
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableChar
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableChar
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableChar {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(CharStable.class);
+        run(DefaultStaticValue.class);
         run(StaticCharStable.class);
         run(VolatileCharStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableChar {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable char v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static char get() { return c.v; }
+        public static void test() throws Exception {
+                       char val1 = get();
+            c.v = 'a'; char val2 = get();
+            assertEquals(val1, 0);
+            assertEquals(val2, 'a');
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticCharStable {
         public @Stable char v;
 
@@ -188,20 +219,22 @@ public class TestStableChar {
                 c.v = new char[1]; c.v[0] = 'a'; char val1 = get();
                                    c.v[0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
 
                 c.v = new char[1]; c.v[0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'c'));
             }
 
             {
                 c.v = new char[20]; c.v[10] = 'a'; char val1 = get1();
                                     c.v[10] = 'b'; char val2 = get1();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
 
                 c.v = new char[20]; c.v[10] = 'c'; char val3 = get1();
-                assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'c'));
             }
 
             {
@@ -226,19 +259,21 @@ public class TestStableChar {
                 c.v = new char[1][1]; c.v[0][0] = 'a'; char val1 = get();
                                       c.v[0][0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
 
                 c.v = new char[1][1]; c.v[0][0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'c'));
 
                 c.v[0] = new char[1]; c.v[0][0] = 'd'; char val4 = get();
-                assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'd'));
             }
 
             {
                 c.v = new char[1][1]; char[] val1 = get1();
                 c.v[0] = new char[1]; char[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,28 +299,31 @@ public class TestStableChar {
                 c.v = new char[1][1][1]; c.v[0][0][0] = 'a'; char val1 = get();
                                          c.v[0][0][0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
 
                 c.v = new char[1][1][1]; c.v[0][0][0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'c'));
 
                 c.v[0] = new char[1][1]; c.v[0][0][0] = 'd'; char val4 = get();
-                assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'd'));
 
                 c.v[0][0] = new char[1]; c.v[0][0][0] = 'e'; char val5 = get();
-                assertEquals(val5, (isStableEnabled ? 'a' : 'e'));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'e'));
             }
 
             {
                 c.v = new char[1][1][1]; char[] val1 = get1();
                 c.v[0][0] = new char[1]; char[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1]; char[][] val1 = get2();
                 c.v[0] = new char[1][1]; char[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -312,37 +350,41 @@ public class TestStableChar {
                 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'a'; char val1 = get();
                                             c.v[0][0][0][0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
+                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
 
                 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? 'a' : 'c'));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'c'));
 
                 c.v[0] = new char[1][1][1]; c.v[0][0][0][0] = 'd'; char val4 = get();
-                assertEquals(val4, (isStableEnabled ? 'a' : 'd'));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'd'));
 
                 c.v[0][0] = new char[1][1]; c.v[0][0][0][0] = 'e'; char val5 = get();
-                assertEquals(val5, (isStableEnabled ? 'a' : 'e'));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'e'));
 
                 c.v[0][0][0] = new char[1]; c.v[0][0][0][0] = 'f'; char val6 = get();
-                assertEquals(val6, (isStableEnabled ? 'a' : 'f'));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                                                    : 'f'));
             }
 
             {
                 c.v = new char[1][1][1][1]; char[] val1 = get1();
                 c.v[0][0][0] = new char[1]; char[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1][1]; char[][] val1 = get2();
                 c.v[0][0] = new char[1][1]; char[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1][1]; char[][][] val1 = get3();
                 c.v[0] = new char[1][1][1]; char[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -350,7 +392,6 @@ public class TestStableChar {
                 c.v = new char[1][1][1][1]; char[][][][] val2 = get4();
                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
-
         }
     }
 
@@ -403,7 +444,7 @@ public class TestStableChar {
                 c.v = new char[1][1]; c.v[0] = new char[0]; char[] val1 = get1();
                                       c.v[0] = new char[0]; char[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -439,14 +480,14 @@ public class TestStableChar {
                 c.v = new char[1][1][1]; c.v[0][0] = new char[0]; char[] val1 = get1();
                                          c.v[0][0] = new char[0]; char[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1]; c.v[0] = new char[0][0]; char[][] val1 = get2();
                                          c.v[0] = new char[0][0]; char[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -581,7 +622,7 @@ public class TestStableChar {
                                elem.a = 'b'; char val3 = get(); char val4 = get1();
 
                 assertEquals(val1, 'a');
-                assertEquals(val3, (isStableEnabled ? 'a' : 'b'));
+                assertEquals(val3, (isServerWithStable ? 'a' : 'b'));
 
                 assertEquals(val2, 'a');
                 assertEquals(val4, 'b');
@@ -615,17 +656,4 @@ public class TestStableChar {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableDouble.java b/hotspot/test/compiler/stable/TestStableDouble.java
index b656acbd1aec3f211ae643b34e6c6ae8f0db20db..112d83633b69565dcdd2e8511a41c5719c816cee 100644
--- a/hotspot/test/compiler/stable/TestStableDouble.java
+++ b/hotspot/test/compiler/stable/TestStableDouble.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableDouble
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableDouble.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableDouble StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableDouble
  *           java/lang/invoke/TestStableDouble$DoubleStable
  *           java/lang/invoke/TestStableDouble$StaticDoubleStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableDouble$NestedStableField3
  *           java/lang/invoke/TestStableDouble$NestedStableField3$A
  *           java/lang/invoke/TestStableDouble$DefaultValue
+ *           java/lang/invoke/TestStableDouble$DefaultStaticValue
  *           java/lang/invoke/TestStableDouble$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableDouble
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableDouble
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableDouble
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableDouble
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableDouble
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableDouble
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableDouble {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(DoubleStable.class);
+        run(DefaultStaticValue.class);
         run(StaticDoubleStable.class);
         run(VolatileDoubleStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableDouble {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable double v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static double get() { return c.v; }
+        public static void test() throws Exception {
+                       double val1 = get();
+            c.v = 1.0; double val2 = get();
+            assertEquals(val1, 0);
+            assertEquals(val2, 1.0);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticDoubleStable {
         public static @Stable double v;
 
@@ -188,20 +219,22 @@ public class TestStableDouble {
                 c.v = new double[1]; c.v[0] = 1.0; double val1 = get();
                                      c.v[0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
 
                 c.v = new double[1]; c.v[0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 3.0));
             }
 
             {
                 c.v = new double[20]; c.v[10] = 1.0; double val1 = get1();
                                       c.v[10] = 2.0; double val2 = get1();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
 
                 c.v = new double[20]; c.v[10] = 3.0; double val3 = get1();
-                assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 3.0));
             }
 
             {
@@ -226,19 +259,21 @@ public class TestStableDouble {
                 c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get();
                                         c.v[0][0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
 
                 c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 3.0));
 
                 c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1.0 : 4.0));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 4.0));
             }
 
             {
                 c.v = new double[1][1]; double[] val1 = get1();
                 c.v[0] = new double[1]; double[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,28 +299,31 @@ public class TestStableDouble {
                 c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get();
                                            c.v[0][0][0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
 
                 c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 3.0));
 
                 c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1.0 : 4.0));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 4.0));
 
                 c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1.0 : 5.0));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 5.0));
             }
 
             {
                 c.v = new double[1][1][1]; double[] val1 = get1();
                 c.v[0][0] = new double[1]; double[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1]; double[][] val1 = get2();
                 c.v[0] = new double[1][1]; double[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -312,37 +350,41 @@ public class TestStableDouble {
                 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get();
                                               c.v[0][0][0][0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
+                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
 
                 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 3.0));
 
                 c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1.0 : 4.0));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 4.0));
 
                 c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1.0 : 5.0));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 5.0));
 
                 c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get();
-                assertEquals(val6, (isStableEnabled ? 1.0 : 6.0));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                                                    : 6.0));
             }
 
             {
                 c.v = new double[1][1][1][1]; double[] val1 = get1();
                 c.v[0][0][0] = new double[1]; double[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1][1]; double[][] val1 = get2();
                 c.v[0][0] = new double[1][1]; double[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1][1]; double[][][] val1 = get3();
                 c.v[0] = new double[1][1][1]; double[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -350,13 +392,11 @@ public class TestStableDouble {
                 c.v = new double[1][1][1][1]; double[][][][] val2 = get4();
                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
-
         }
     }
 
     /* ==================================================== */
     // Dynamic Dim is higher than static
-
     static class ObjectArrayLowerDim0 {
         public @Stable Object v;
 
@@ -404,7 +444,7 @@ public class TestStableDouble {
                 c.v = new double[1][1]; c.v[0] = new double[0]; double[] val1 = get1();
                                         c.v[0] = new double[0]; double[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -440,14 +480,14 @@ public class TestStableDouble {
                 c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1();
                                            c.v[0][0] = new double[0]; double[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2();
                                            c.v[0] = new double[0][0]; double[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -582,7 +622,7 @@ public class TestStableDouble {
                                elem.a = 2.0; double val3 = get(); double val4 = get1();
 
                 assertEquals(val1, 1.0);
-                assertEquals(val3, (isStableEnabled ? 1.0 : 2.0));
+                assertEquals(val3, (isServerWithStable ? 1.0 : 2.0));
 
                 assertEquals(val2, 1.0);
                 assertEquals(val4, 2.0);
@@ -616,17 +656,4 @@ public class TestStableDouble {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableFloat.java b/hotspot/test/compiler/stable/TestStableFloat.java
index ab1c3f0be1f8efed17ea24f635c15cc736cf359c..973a6016575c77ab76aff2918d6fa7f7911a831e 100644
--- a/hotspot/test/compiler/stable/TestStableFloat.java
+++ b/hotspot/test/compiler/stable/TestStableFloat.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableFloat
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableFloat.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableFloat StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableFloat
  *           java/lang/invoke/TestStableFloat$FloatStable
  *           java/lang/invoke/TestStableFloat$StaticFloatStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableFloat$NestedStableField3
  *           java/lang/invoke/TestStableFloat$NestedStableField3$A
  *           java/lang/invoke/TestStableFloat$DefaultValue
+ *           java/lang/invoke/TestStableFloat$DefaultStaticValue
  *           java/lang/invoke/TestStableFloat$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableFloat
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableFloat
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableFloat
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableFloat
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableFloat
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableFloat
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableFloat {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(FloatStable.class);
+        run(DefaultStaticValue.class);
         run(StaticFloatStable.class);
         run(VolatileFloatStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableFloat {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable float v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static float get() { return c.v; }
+        public static void test() throws Exception {
+                        float val1 = get();
+            c.v = 1.0F; float val2 = get();
+            assertEquals(val1, 0F);
+            assertEquals(val2, 1.0F);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticFloatStable {
         public static @Stable float v;
 
@@ -188,20 +219,22 @@ public class TestStableFloat {
                 c.v = new float[1]; c.v[0] = 1.0F; float val1 = get();
                                     c.v[0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
 
                 c.v = new float[1]; c.v[0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 3.0F));
             }
 
             {
                 c.v = new float[20]; c.v[10] = 1.0F; float val1 = get1();
                                      c.v[10] = 2.0F; float val2 = get1();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
 
                 c.v = new float[20]; c.v[10] = 3.0F; float val3 = get1();
-                assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 3.0F));
             }
 
             {
@@ -226,19 +259,21 @@ public class TestStableFloat {
                 c.v = new float[1][1]; c.v[0][0] = 1.0F; float val1 = get();
                                        c.v[0][0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
 
                 c.v = new float[1][1]; c.v[0][0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 3.0F));
 
                 c.v[0] = new float[1]; c.v[0][0] = 4.0F; float val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 4.0F));
             }
 
             {
                 c.v = new float[1][1]; float[] val1 = get1();
                 c.v[0] = new float[1]; float[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,28 +299,31 @@ public class TestStableFloat {
                 c.v = new float[1][1][1]; c.v[0][0][0] = 1.0F; float val1 = get();
                                           c.v[0][0][0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
 
                 c.v = new float[1][1][1]; c.v[0][0][0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 3.0F));
 
                 c.v[0] = new float[1][1]; c.v[0][0][0] = 4.0F; float val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 4.0F));
 
                 c.v[0][0] = new float[1]; c.v[0][0][0] = 5.0F; float val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 5.0F));
             }
 
             {
                 c.v = new float[1][1][1]; float[] val1 = get1();
                 c.v[0][0] = new float[1]; float[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1]; float[][] val1 = get2();
                 c.v[0] = new float[1][1]; float[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -312,37 +350,41 @@ public class TestStableFloat {
                 c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 1.0F; float val1 = get();
                                              c.v[0][0][0][0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
+                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
 
                 c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1.0F : 3.0F));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 3.0F));
 
                 c.v[0] = new float[1][1][1]; c.v[0][0][0][0] = 4.0F; float val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1.0F : 4.0F));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 4.0F));
 
                 c.v[0][0] = new float[1][1]; c.v[0][0][0][0] = 5.0F; float val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1.0F : 5.0F));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 5.0F));
 
                 c.v[0][0][0] = new float[1]; c.v[0][0][0][0] = 6.0F; float val6 = get();
-                assertEquals(val6, (isStableEnabled ? 1.0F : 6.0F));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                                                    : 6.0F));
             }
 
             {
                 c.v = new float[1][1][1][1]; float[] val1 = get1();
                 c.v[0][0][0] = new float[1]; float[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1][1]; float[][] val1 = get2();
                 c.v[0][0] = new float[1][1]; float[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1][1]; float[][][] val1 = get3();
                 c.v[0] = new float[1][1][1]; float[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -350,13 +392,11 @@ public class TestStableFloat {
                 c.v = new float[1][1][1][1]; float[][][][] val2 = get4();
                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
-
         }
     }
 
     /* ==================================================== */
     // Dynamic Dim is higher than static
-
     static class ObjectArrayLowerDim0 {
         public @Stable Object v;
 
@@ -404,7 +444,7 @@ public class TestStableFloat {
                 c.v = new float[1][1]; c.v[0] = new float[0]; float[] val1 = get1();
                                        c.v[0] = new float[0]; float[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -440,14 +480,14 @@ public class TestStableFloat {
                 c.v = new float[1][1][1]; c.v[0][0] = new float[0]; float[] val1 = get1();
                                           c.v[0][0] = new float[0]; float[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1]; c.v[0] = new float[0][0]; float[][] val1 = get2();
                                           c.v[0] = new float[0][0]; float[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -582,7 +622,7 @@ public class TestStableFloat {
                                elem.a = 2.0F; float val3 = get(); float val4 = get1();
 
                 assertEquals(val1, 1.0F);
-                assertEquals(val3, (isStableEnabled ? 1.0F : 2.0F));
+                assertEquals(val3, (isServerWithStable ? 1.0F : 2.0F));
 
                 assertEquals(val2, 1.0F);
                 assertEquals(val4, 2.0F);
@@ -616,17 +656,4 @@ public class TestStableFloat {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableInt.java b/hotspot/test/compiler/stable/TestStableInt.java
index 9632a8dc39d4cb16e87ccd78d4707ea9d2daf418..bf7fe337baa8302865ebb94722edc242293fce4a 100644
--- a/hotspot/test/compiler/stable/TestStableInt.java
+++ b/hotspot/test/compiler/stable/TestStableInt.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableInt
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableInt.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableInt StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableInt
  *           java/lang/invoke/TestStableInt$IntStable
  *           java/lang/invoke/TestStableInt$StaticIntStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableInt$NestedStableField3
  *           java/lang/invoke/TestStableInt$NestedStableField3$A
  *           java/lang/invoke/TestStableInt$DefaultValue
+ *           java/lang/invoke/TestStableInt$DefaultStaticValue
  *           java/lang/invoke/TestStableInt$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableInt
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableInt
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableInt
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableInt
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableInt
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableInt
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableInt {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(IntStable.class);
+        run(DefaultStaticValue.class);
         run(StaticIntStable.class);
         run(VolatileIntStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableInt {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable int v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static int get() { return c.v; }
+        public static void test() throws Exception {
+                        int val1 = get();
+            c.v = 1; int val2 = get();
+            assertEquals(val1, 0);
+            assertEquals(val2, 1);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticIntStable {
         public static @Stable int v;
 
@@ -188,20 +219,22 @@ public class TestStableInt {
                 c.v = new int[1]; c.v[0] = 1; int val1 = get();
                                   c.v[0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new int[1]; c.v[0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
                 c.v = new int[20]; c.v[10] = 1; int val1 = get1();
                                    c.v[10] = 2; int val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new int[20]; c.v[10] = 3; int val3 = get1();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
@@ -226,19 +259,21 @@ public class TestStableInt {
                 c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get();
                                      c.v[0][0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
             }
 
             {
                 c.v = new int[1][1]; int[] val1 = get1();
                 c.v[0] = new int[1]; int[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,28 +299,31 @@ public class TestStableInt {
                 c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get();
                                         c.v[0][0][0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
             }
 
             {
                 c.v = new int[1][1][1]; int[] val1 = get1();
                 c.v[0][0] = new int[1]; int[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1]; int[][] val1 = get2();
                 c.v[0] = new int[1][1]; int[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -312,37 +350,41 @@ public class TestStableInt {
                 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get();
                                            c.v[0][0][0][0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
 
                 c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get();
-                assertEquals(val6, (isStableEnabled ? 1 : 6));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 6));
             }
 
             {
                 c.v = new int[1][1][1][1]; int[] val1 = get1();
                 c.v[0][0][0] = new int[1]; int[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1][1]; int[][] val1 = get2();
                 c.v[0][0] = new int[1][1]; int[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1][1]; int[][][] val1 = get3();
                 c.v[0] = new int[1][1][1]; int[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -350,13 +392,11 @@ public class TestStableInt {
                 c.v = new int[1][1][1][1]; int[][][][] val2 = get4();
                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
-
         }
     }
 
     /* ==================================================== */
     // Dynamic Dim is higher than static
-
     static class ObjectArrayLowerDim0 {
         public @Stable Object v;
 
@@ -404,7 +444,7 @@ public class TestStableInt {
                 c.v = new int[1][1]; c.v[0] = new int[0]; int[] val1 = get1();
                                      c.v[0] = new int[0]; int[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -440,14 +480,14 @@ public class TestStableInt {
                 c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1();
                                         c.v[0][0] = new int[0]; int[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2();
                                         c.v[0] = new int[0][0]; int[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -582,7 +622,7 @@ public class TestStableInt {
                                elem.a = 2; int val3 = get(); int val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isStableEnabled ? 1 : 2));
+                assertEquals(val3, (isServerWithStable ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
@@ -616,17 +656,4 @@ public class TestStableInt {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableLong.java b/hotspot/test/compiler/stable/TestStableLong.java
index d1c72f5609c7f7c02c41fd9aecdfa8d25594f1de..f97e7e143d00b0cf60e55a501ee2538425aa0550 100644
--- a/hotspot/test/compiler/stable/TestStableLong.java
+++ b/hotspot/test/compiler/stable/TestStableLong.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableLong
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableLong.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableLong StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableLong
  *           java/lang/invoke/TestStableLong$LongStable
  *           java/lang/invoke/TestStableLong$StaticLongStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableLong$NestedStableField3
  *           java/lang/invoke/TestStableLong$NestedStableField3$A
  *           java/lang/invoke/TestStableLong$DefaultValue
+ *           java/lang/invoke/TestStableLong$DefaultStaticValue
  *           java/lang/invoke/TestStableLong$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableLong
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableLong
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableLong
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableLong
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableLong
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableLong
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableLong {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(LongStable.class);
+        run(DefaultStaticValue.class);
         run(StaticLongStable.class);
         run(VolatileLongStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableLong {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable long v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static long get() { return c.v; }
+        public static void test() throws Exception {
+                      long val1 = get();
+            c.v = 1L; long val2 = get();
+            assertEquals(val1, 0);
+            assertEquals(val2, 1L);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticLongStable {
         public static @Stable long v;
 
@@ -188,20 +219,22 @@ public class TestStableLong {
                 c.v = new long[1]; c.v[0] = 1; long val1 = get();
                                    c.v[0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new long[1]; c.v[0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
                 c.v = new long[20]; c.v[10] = 1; long val1 = get1();
                                     c.v[10] = 2; long val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new long[20]; c.v[10] = 3; long val3 = get1();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
@@ -226,19 +259,21 @@ public class TestStableLong {
                 c.v = new long[1][1]; c.v[0][0] = 1; long val1 = get();
                                       c.v[0][0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new long[1][1]; c.v[0][0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new long[1]; c.v[0][0] = 4; long val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
             }
 
             {
                 c.v = new long[1][1]; long[] val1 = get1();
                 c.v[0] = new long[1]; long[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,28 +299,31 @@ public class TestStableLong {
                 c.v = new long[1][1][1]; c.v[0][0][0] = 1; long val1 = get();
                                          c.v[0][0][0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new long[1][1][1]; c.v[0][0][0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new long[1][1]; c.v[0][0][0] = 4; long val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new long[1]; c.v[0][0][0] = 5; long val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
             }
 
             {
                 c.v = new long[1][1][1]; long[] val1 = get1();
                 c.v[0][0] = new long[1]; long[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1]; long[][] val1 = get2();
                 c.v[0] = new long[1][1]; long[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -312,37 +350,41 @@ public class TestStableLong {
                 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 1; long val1 = get();
                                             c.v[0][0][0][0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new long[1][1][1]; c.v[0][0][0][0] = 4; long val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new long[1][1]; c.v[0][0][0][0] = 5; long val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
 
                 c.v[0][0][0] = new long[1]; c.v[0][0][0][0] = 6; long val6 = get();
-                assertEquals(val6, (isStableEnabled ? 1 : 6));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 6));
             }
 
             {
                 c.v = new long[1][1][1][1]; long[] val1 = get1();
                 c.v[0][0][0] = new long[1]; long[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1][1]; long[][] val1 = get2();
                 c.v[0][0] = new long[1][1]; long[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1][1]; long[][][] val1 = get3();
                 c.v[0] = new long[1][1][1]; long[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -350,13 +392,11 @@ public class TestStableLong {
                 c.v = new long[1][1][1][1]; long[][][][] val2 = get4();
                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
-
         }
     }
 
     /* ==================================================== */
     // Dynamic Dim is higher than static
-
     static class ObjectArrayLowerDim0 {
         public @Stable Object v;
 
@@ -404,7 +444,7 @@ public class TestStableLong {
                 c.v = new long[1][1]; c.v[0] = new long[0]; long[] val1 = get1();
                                      c.v[0] = new long[0]; long[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -440,14 +480,14 @@ public class TestStableLong {
                 c.v = new long[1][1][1]; c.v[0][0] = new long[0]; long[] val1 = get1();
                                          c.v[0][0] = new long[0]; long[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1]; c.v[0] = new long[0][0]; long[][] val1 = get2();
                                          c.v[0] = new long[0][0]; long[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -582,7 +622,7 @@ public class TestStableLong {
                                elem.a = 2; long val3 = get(); long val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isStableEnabled ? 1 : 2));
+                assertEquals(val3, (isServerWithStable ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
@@ -616,17 +656,4 @@ public class TestStableLong {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableObject.java b/hotspot/test/compiler/stable/TestStableObject.java
index 7958c6500c44f240c6dcfa72995ac2fe10b1f0ac..dec466adc03262f87753c1161f5a900d77e482f3 100644
--- a/hotspot/test/compiler/stable/TestStableObject.java
+++ b/hotspot/test/compiler/stable/TestStableObject.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableObject
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableObject.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableObject StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableObject
  *           java/lang/invoke/TestStableObject$ObjectStable
  *           java/lang/invoke/TestStableObject$StaticObjectStable
@@ -49,46 +51,60 @@
  *           java/lang/invoke/TestStableObject$NestedStableField3$A
  *           java/lang/invoke/TestStableObject$Values
  *           java/lang/invoke/TestStableObject$DefaultValue
+ *           java/lang/invoke/TestStableObject$DefaultStaticValue
  *           java/lang/invoke/TestStableObject$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableObject
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableObject
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableObject
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableObject
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableObject
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableObject
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableObject {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(ObjectStable.class);
+        run(DefaultStaticValue.class);
         run(StaticObjectStable.class);
         run(VolatileObjectStable.class);
 
@@ -148,6 +164,21 @@ public class TestStableObject {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable Object v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static Object get() { return c.v; }
+        public static void test() throws Exception {
+                            Object val1 = get();
+            c.v = Values.A; Object val2 = get();
+            assertEquals(val1, null);
+            assertEquals(val2, Values.A);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticObjectStable {
         public static @Stable Values v;
 
@@ -191,20 +222,22 @@ public class TestStableObject {
                 c.v = new Object[1]; c.v[0] = Values.A; Object val1 = get();
                                      c.v[0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
 
                 c.v = new Object[1]; c.v[0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.C));
             }
 
             {
                 c.v = new Object[20]; c.v[10] = Values.A; Object val1 = get1();
                                       c.v[10] = Values.B; Object val2 = get1();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
 
                 c.v = new Object[20]; c.v[10] = Values.C; Object val3 = get1();
-                assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.C));
             }
 
             {
@@ -229,19 +262,21 @@ public class TestStableObject {
                 c.v = new Object[1][1]; c.v[0][0] = Values.A; Object val1 = get();
                                         c.v[0][0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
 
                 c.v = new Object[1][1]; c.v[0][0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.C));
 
                 c.v[0] = new Object[1]; c.v[0][0] = Values.D; Object val4 = get();
-                assertEquals(val4, (isStableEnabled ? Values.A : Values.D));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.D));
             }
 
             {
                 c.v = new Object[1][1]; Object[] val1 = get1();
                 c.v[0] = new Object[1]; Object[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -267,28 +302,31 @@ public class TestStableObject {
                 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.A; Object val1 = get();
                                            c.v[0][0][0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
 
                 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.C));
 
                 c.v[0] = new Object[1][1]; c.v[0][0][0] = Values.D; Object val4 = get();
-                assertEquals(val4, (isStableEnabled ? Values.A : Values.D));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.D));
 
                 c.v[0][0] = new Object[1]; c.v[0][0][0] = Values.E; Object val5 = get();
-                assertEquals(val5, (isStableEnabled ? Values.A : Values.E));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.E));
             }
 
             {
                 c.v = new Object[1][1][1]; Object[] val1 = get1();
                 c.v[0][0] = new Object[1]; Object[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1]; Object[][] val1 = get2();
                 c.v[0] = new Object[1][1]; Object[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -315,37 +353,41 @@ public class TestStableObject {
                 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.A; Object val1 = get();
                                               c.v[0][0][0][0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
+                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
 
                 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? Values.A : Values.C));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.C));
 
                 c.v[0] = new Object[1][1][1]; c.v[0][0][0][0] = Values.D; Object val4 = get();
-                assertEquals(val4, (isStableEnabled ? Values.A : Values.D));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.D));
 
                 c.v[0][0] = new Object[1][1]; c.v[0][0][0][0] = Values.E; Object val5 = get();
-                assertEquals(val5, (isStableEnabled ? Values.A : Values.E));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.E));
 
                 c.v[0][0][0] = new Object[1]; c.v[0][0][0][0] = Values.F; Object val6 = get();
-                assertEquals(val6, (isStableEnabled ? Values.A : Values.F));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                                                    : Values.F));
             }
 
             {
                 c.v = new Object[1][1][1][1]; Object[] val1 = get1();
                 c.v[0][0][0] = new Object[1]; Object[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1][1]; Object[][] val1 = get2();
                 c.v[0][0] = new Object[1][1]; Object[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1][1]; Object[][][] val1 = get3();
                 c.v[0] = new Object[1][1][1]; Object[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -353,13 +395,11 @@ public class TestStableObject {
                 c.v = new Object[1][1][1][1]; Object[][][][] val2 = get4();
                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
-
         }
     }
 
     /* ==================================================== */
     // Dynamic Dim is higher than static
-
     static class ObjectArrayLowerDim0 {
         public @Stable Object v;
 
@@ -407,7 +447,7 @@ public class TestStableObject {
                 c.v = new Object[1][1]; c.v[0] = new Object[0]; Object[] val1 = get1();
                                      c.v[0] = new Object[0]; Object[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -443,14 +483,14 @@ public class TestStableObject {
                 c.v = new Object[1][1][1]; c.v[0][0] = new Object[0]; Object[] val1 = get1();
                                            c.v[0][0] = new Object[0]; Object[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1]; c.v[0] = new Object[0][0]; Object[][] val1 = get2();
                                            c.v[0] = new Object[0][0]; Object[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -585,7 +625,7 @@ public class TestStableObject {
                                elem.a = Values.B; Object val3 = get(); Object val4 = get1();
 
                 assertEquals(val1, Values.A);
-                assertEquals(val3, (isStableEnabled ? Values.A : Values.B));
+                assertEquals(val3, (isServerWithStable ? Values.A : Values.B));
 
                 assertEquals(val2, Values.A);
                 assertEquals(val4, Values.B);
@@ -619,17 +659,4 @@ public class TestStableObject {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/compiler/stable/TestStableShort.java b/hotspot/test/compiler/stable/TestStableShort.java
index a80d0726db6cfc9f5ce86a3a3dbf35b2e5c82c23..67a7f0453fb26fcbaccbf5ad6d0e517a1c337a59 100644
--- a/hotspot/test/compiler/stable/TestStableShort.java
+++ b/hotspot/test/compiler/stable/TestStableShort.java
@@ -26,9 +26,11 @@
 /*
  * @test TestStableShort
  * @summary tests on stable fields and arrays
- * @library /testlibrary
- * @compile -XDignore.symbol.file TestStableShort.java
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestStableShort StableConfiguration sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run main ClassFileInstaller
+ *           java/lang/invoke/StableConfiguration
  *           java/lang/invoke/TestStableShort
  *           java/lang/invoke/TestStableShort$ShortStable
  *           java/lang/invoke/TestStableShort$StaticShortStable
@@ -48,46 +50,60 @@
  *           java/lang/invoke/TestStableShort$NestedStableField3
  *           java/lang/invoke/TestStableShort$NestedStableField3$A
  *           java/lang/invoke/TestStableShort$DefaultValue
+ *           java/lang/invoke/TestStableShort$DefaultStaticValue
  *           java/lang/invoke/TestStableShort$ObjectArrayLowerDim2
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableShort
- *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableShort
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableShort
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableShort
  *
  * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
- *                   -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop
- *                   -server -XX:-TieredCompilation -Xcomp
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:+FoldStableValues
+ *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
+ *                   java.lang.invoke.TestStableShort
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
+ *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
+ *                   -client -XX:-TieredCompilation
+ *                   -XX:-FoldStableValues
  *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
  *                   java.lang.invoke.TestStableShort
  */
 package java.lang.invoke;
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import sun.management.ManagementFactoryHelper;
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableShort {
-    public static void main(String[] args) throws Exception {
-        System.out.println("@Stable enabled: "+isStableEnabled);
-        System.out.println();
+    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
+    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
+    public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
         run(ShortStable.class);
+        run(DefaultStaticValue.class);
         run(StaticShortStable.class);
         run(VolatileShortStable.class);
 
@@ -145,6 +161,21 @@ public class TestStableShort {
 
     /* ==================================================== */
 
+    static class DefaultStaticValue {
+        public static @Stable short v;
+
+        public static final DefaultStaticValue c = new DefaultStaticValue();
+        public static short get() { return c.v; }
+        public static void test() throws Exception {
+                     short val1 = get();
+            c.v = 1; short val2 = get();
+            assertEquals(val1, 0);
+            assertEquals(val2, 1);
+        }
+    }
+
+    /* ==================================================== */
+
     static class StaticShortStable {
         public static @Stable short v;
 
@@ -188,20 +219,22 @@ public class TestStableShort {
                 c.v = new short[1]; c.v[0] = 1; short val1 = get();
                                     c.v[0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new short[1]; c.v[0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
                 c.v = new short[20]; c.v[10] = 1; short val1 = get1();
                                      c.v[10] = 2; short val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new short[20]; c.v[10] = 3; short val3 = get1();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
             }
 
             {
@@ -226,19 +259,21 @@ public class TestStableShort {
                 c.v = new short[1][1]; c.v[0][0] = 1; short val1 = get();
                                        c.v[0][0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new short[1][1]; c.v[0][0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new short[1]; c.v[0][0] = 4; short val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
             }
 
             {
                 c.v = new short[1][1]; short[] val1 = get1();
                 c.v[0] = new short[1]; short[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,28 +299,31 @@ public class TestStableShort {
                 c.v = new short[1][1][1]; c.v[0][0][0] = 1; short val1 = get();
                                           c.v[0][0][0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new short[1][1][1]; c.v[0][0][0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new short[1][1]; c.v[0][0][0] = 4; short val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new short[1]; c.v[0][0][0] = 5; short val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
             }
 
             {
                 c.v = new short[1][1][1]; short[] val1 = get1();
                 c.v[0][0] = new short[1]; short[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1]; short[][] val1 = get2();
                 c.v[0] = new short[1][1]; short[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -312,37 +350,41 @@ public class TestStableShort {
                 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 1; short val1 = get();
                                              c.v[0][0][0][0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isStableEnabled ? 1 : 2));
+                assertEquals(val2, (isServerWithStable ? 1 : 2));
 
                 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? 1 : 3));
+                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 3));
 
                 c.v[0] = new short[1][1][1]; c.v[0][0][0][0] = 4; short val4 = get();
-                assertEquals(val4, (isStableEnabled ? 1 : 4));
+                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 4));
 
                 c.v[0][0] = new short[1][1]; c.v[0][0][0][0] = 5; short val5 = get();
-                assertEquals(val5, (isStableEnabled ? 1 : 5));
+                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 5));
 
                 c.v[0][0][0] = new short[1]; c.v[0][0][0][0] = 6; short val6 = get();
-                assertEquals(val6, (isStableEnabled ? 1 : 6));
+                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                                                    : 6));
             }
 
             {
                 c.v = new short[1][1][1][1]; short[] val1 = get1();
                 c.v[0][0][0] = new short[1]; short[] val2 = get1();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1][1]; short[][] val1 = get2();
                 c.v[0][0] = new short[1][1]; short[][] val2 = get2();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1][1]; short[][][] val1 = get3();
                 c.v[0] = new short[1][1][1]; short[][][] val2 = get3();
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -350,13 +392,11 @@ public class TestStableShort {
                 c.v = new short[1][1][1][1]; short[][][][] val2 = get4();
                 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
-
         }
     }
 
     /* ==================================================== */
     // Dynamic Dim is higher than static
-
     static class ObjectArrayLowerDim0 {
         public @Stable Object v;
 
@@ -404,7 +444,7 @@ public class TestStableShort {
                 c.v = new short[1][1]; c.v[0] = new short[0]; short[] val1 = get1();
                                        c.v[0] = new short[0]; short[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -440,14 +480,14 @@ public class TestStableShort {
                 c.v = new short[1][1][1]; c.v[0][0] = new short[0]; short[] val1 = get1();
                                           c.v[0][0] = new short[0]; short[] val2 = get1();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1]; c.v[0] = new short[0][0]; short[][] val1 = get2();
                                           c.v[0] = new short[0][0]; short[][] val2 = get2();
 
-                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -582,7 +622,7 @@ public class TestStableShort {
                                elem.a = 2; short val3 = get(); short val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isStableEnabled ? 1 : 2));
+                assertEquals(val3, (isServerWithStable ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
@@ -616,17 +656,4 @@ public class TestStableShort {
             }
         }
     }
-
-    static final boolean isStableEnabled;
-    static {
-        HotSpotDiagnosticMXBean diagnostic
-                = ManagementFactoryHelper.getDiagnosticMXBean();
-        VMOption tmp;
-        try {
-            tmp = diagnostic.getVMOption("FoldStableValues");
-        } catch (IllegalArgumentException e) {
-            tmp = null;
-        }
-        isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue()));
-    }
 }
diff --git a/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8cba4a5bf728cb84486f561b2a1a81267d49621e
--- /dev/null
+++ b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * @bug 8048933
+ * @summary TraceExceptions output should have the exception message - useful for ClassNotFoundExceptions especially
+ * @library /testlibrary
+ */
+
+import com.oracle.java.testlibrary.*;
+
+public class TraceExceptionsTest {
+    public static void main(String[] args) throws Exception {
+
+        if (!Platform.isDebugBuild()) {
+          System.out.println("Skip the test on product builds since XX:+TraceExceptions is not available on product builds");
+          return;
+        }
+
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+TraceExceptions", "NoClassFound");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("<a 'java/lang/ClassNotFoundException': NoClassFound>");
+        output.shouldNotContain("<a 'java/lang/ClassNotFoundException'>");
+        output.shouldHaveExitValue(1);
+    }
+}
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index 964da1c7094ad5105407319fb63ff998ed39f401..70e4a78662fb938d6bd8c25e6e5edecdb2a32613 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -266,3 +266,4 @@ f9c82769a6bc2b219a8f01c24afe5c91039267d7 jdk9-b19
 7eb0ab676ea75cb1dd31c613e77008a7d8cb0af7 jdk9-b21
 82b94ff002c6e007a03bf0f364ca94b381e09135 jdk9-b22
 2e5b63006187bfc64d8eace374dbc2806267a160 jdk9-b23
+345af113f57206711f75089c3ebf84a36a789122 jdk9-b24
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java
index 63123391ca38a5d6c24f56cc882b84012e110874..23289a7b55f544eaf18d527869f44acc73703b54 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java
@@ -54,6 +54,7 @@ import com.sun.org.apache.xerces.internal.util.Status;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
 import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
@@ -982,6 +983,18 @@ XSLoader, DOMConfiguration {
      */
     public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
 
+        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
+        if (spm == null) {
+            spm = new XMLSecurityPropertyManager();
+            setProperty(XML_SECURITY_PROPERTY_MANAGER, spm);
+        }
+
+        XMLSecurityManager sm = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
+        if (sm == null)
+            setProperty(SECURITY_MANAGER,new XMLSecurityManager(true));
+
+        faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
+
         fGrammarBucket.reset();
 
         fSubGroupHandler.reset();
@@ -1065,9 +1078,6 @@ XSLoader, DOMConfiguration {
         // get generate-synthetic-annotations feature
         fSchemaHandler.setGenerateSyntheticAnnotations(componentManager.getFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false));
         fSchemaHandler.reset(componentManager);
-
-        XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager)componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
-        faccessExternalSchema = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
     }
 
     private void initGrammarBucket(){
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index fdc0137241f486b5242e8198d36f63ebd129cbbc..fce4d5f73079ed6145a3e284ded01cfe236a493b 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -269,3 +269,4 @@ e9780330017a6b464a385356d77e5136f9de8d09 jdk9-b15
 4a099451fd7e17b6cc4772fe9547907576a45b6f jdk9-b21
 7f5e5902cde75fd9335c52f469491f061fe0239e jdk9-b22
 ce19e0403ec8a80223cc47320c905b2a4d45881d jdk9-b23
+0b35542d6bf32af23a9fc59a37c52aa091fee388 jdk9-b24
diff --git a/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java b/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java
index 93393377a0607b6c38fa1bc7133ffe5a30a06c89..d07ae3ec38bbfb61a7a620108723fa3060d25cfd 100644
--- a/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java
+++ b/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, 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
@@ -93,10 +93,11 @@ public abstract class CommandMap {
                 // otherwise, we also allow it if this code and the
                 // factory come from the same (non-system) class loader (e.g.,
                 // the JAF classes were loaded with the applet classes).
-                if (CommandMap.class.getClassLoader() == null ||
-                    CommandMap.class.getClassLoader() !=
-                            commandMap.getClass().getClassLoader())
+                ClassLoader cl = CommandMap.class.getClassLoader();
+                if (cl == null || cl.getParent() == null ||
+                    cl != commandMap.getClass().getClassLoader()) {
                     throw ex;
+                }
             }
         }
         // remove any per-thread-context-class-loader CommandMap
diff --git a/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java b/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java
index a7c4118527350c36e24339a521a4c831aa71a791..313998a6aec62272049c49d818fd8ae910ad6c0c 100644
--- a/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java
+++ b/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, 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
@@ -96,9 +96,9 @@ public abstract class FileTypeMap {
                 // otherwise, we also allow it if this code and the
                 // factory come from the same (non-system) class loader (e.g.,
                 // the JAF classes were loaded with the applet classes).
-                if (FileTypeMap.class.getClassLoader() == null ||
-                    FileTypeMap.class.getClassLoader() !=
-                        fileTypeMap.getClass().getClassLoader())
+                ClassLoader cl = FileTypeMap.class.getClassLoader();
+                if (cl == null || cl.getParent() == null ||
+                    cl != fileTypeMap.getClass().getClassLoader())
                     throw ex;
             }
         }
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java
index 7f25c89d688ab0adc711fac44dc4b24884fcd507..7d86d087ffc6194307983338f704376880d01462 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java
@@ -35,6 +35,8 @@ import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.lang.reflect.WildcardType;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Arrays;
 import java.util.Collection;
 
@@ -264,20 +266,38 @@ import com.sun.xml.internal.bind.v2.runtime.Location;
         return clazz.getSimpleName();
     }
 
-    public Collection<? extends Field> getDeclaredFields(Class clazz) {
-        return Arrays.asList(clazz.getDeclaredFields());
+    public Collection<? extends Field> getDeclaredFields(final Class clazz) {
+        Field[] fields = AccessController.doPrivileged(new PrivilegedAction<Field[]>() {
+            @Override
+            public Field[] run() {
+                return clazz.getDeclaredFields();
+            }
+        });
+        return Arrays.asList(fields);
     }
 
-    public Field getDeclaredField(Class clazz, String fieldName) {
-        try {
-            return clazz.getDeclaredField(fieldName);
-        } catch (NoSuchFieldException e) {
-            return null;
-        }
+    public Field getDeclaredField(final Class clazz, final String fieldName) {
+        return AccessController.doPrivileged(new PrivilegedAction<Field>() {
+            @Override
+            public Field run() {
+                try {
+                    return clazz.getDeclaredField(fieldName);
+                } catch (NoSuchFieldException e) {
+                    return null;
+                }
+            }
+        });
     }
 
-    public Collection<? extends Method> getDeclaredMethods(Class clazz) {
-        return Arrays.asList(clazz.getDeclaredMethods());
+    public Collection<? extends Method> getDeclaredMethods(final Class clazz) {
+        Method[] methods =
+            AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+                @Override
+                public Method[] run() {
+                    return clazz.getDeclaredMethods();
+                }
+            });
+        return Arrays.asList(methods);
     }
 
     public Class getDeclaringClassForField(Field field) {
@@ -565,7 +585,7 @@ import com.sun.xml.internal.bind.v2.runtime.Location;
         return method.isBridge();
     }
 
-    public boolean isOverriding(Method method, Class base) {
+    public boolean isOverriding(Method method, final Class base) {
         // this isn't actually correct,
         // as the JLS considers
         // class Derived extends Base<Integer> {
@@ -576,22 +596,30 @@ import com.sun.xml.internal.bind.v2.runtime.Location;
         // }
         // to be overrided. Handling this correctly needs a careful implementation
 
-        String name = method.getName();
-        Class[] params = method.getParameterTypes();
-
-        while (base != null) {
-            try {
-                if (base.getDeclaredMethod(name, params) != null) {
-                    return true;
+        final String name = method.getName();
+        final Class[] params = method.getParameterTypes();
+
+        return AccessController.doPrivileged(
+                new PrivilegedAction<Boolean>() {
+
+                    @Override
+                    public Boolean run() {
+                        Class clazz = base;
+                        while (clazz != null) {
+                            try {
+                                Method m = clazz.getDeclaredMethod(name, params);
+                                if (m != null) {
+                                    return Boolean.TRUE;
+                                }
+                            } catch (NoSuchMethodException ignored) {
+                                // recursively go into the base class
+                            }
+                            clazz = clazz.getSuperclass();
+                        }
+                        return Boolean.FALSE;
+                    }
                 }
-            } catch (NoSuchMethodException e) {
-                // recursively go into the base class
-            }
-
-            base = base.getSuperclass();
-        }
-
-        return false;
+        );
     }
 
     public boolean isInterface(Class clazz) {
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java
index 059d9e32018de97ca77610752ab7943a53476cbb..eaf696c4f2937af84cea4862cad4f44e04067c70 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, 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
@@ -28,6 +28,8 @@ package com.sun.xml.internal.bind.v2.runtime;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -415,6 +417,15 @@ public abstract class JaxBeanInfo<BeanT> {
     private static final Class[] unmarshalEventParams = { Unmarshaller.class, Object.class };
     private static Class[] marshalEventParams = { Marshaller.class };
 
+    private Method[] getDeclaredMethods(final Class<BeanT> c) {
+        return AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+            @Override
+            public Method[] run() {
+                return c.getDeclaredMethods();
+            }
+        });
+    }
+
     /**
      * use reflection to determine which of the 4 object lifecycle methods exist on
      * the JAXB bound type.
@@ -428,7 +439,7 @@ public abstract class JaxBeanInfo<BeanT> {
             }
 
             while (jt != null) {
-                for (Method m : jt.getDeclaredMethods()) {
+                for (Method m : getDeclaredMethods(jt)) {
                     String name = m.getName();
 
                     if (lcm.beforeUnmarshal == null) {
@@ -468,7 +479,7 @@ public abstract class JaxBeanInfo<BeanT> {
         } catch (SecurityException e) {
             // this happens when we don't have enough permission.
             logger.log(Level.WARNING, Messages.UNABLE_TO_DISCOVER_EVENTHANDLER.format(
-                    jaxbType.getName(), e));
+                    jaxbType.getName(), e), e);
         }
     }
 
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java
index 7923cab28d740b3f84f262078cf212593fbd7d59..e005de2e538a59f3bd346dad695cf60f3130c4ed 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java
@@ -229,8 +229,7 @@ public abstract class Accessor<BeanT, ValueT> implements Receiver {
             if (!Modifier.isPublic(mod) || Modifier.isFinal(mod) || !Modifier.isPublic(f.getDeclaringClass().getModifiers())) {
                 try {
                     // attempt to make it accessible, but do so in the security context of the calling application.
-                    // don't do this in the doPrivilege block, as that would create a security hole for anyone
-                    // to make any field accessible.
+                    // don't do this in the doPrivilege block
                     f.setAccessible(true);
                 } catch (SecurityException e) {
                     if ((!accessWarned) && (!supressAccessorWarnings)) {
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java
index 78f4746abea9dc3c7a5d34969ba7de09a548bc8b..17c99557d9fb8a39996c59c4b9d504ba3b3d80ba 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/opt/Injector.java
@@ -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
@@ -146,26 +146,31 @@ final class Injector {
     private static final Method findLoadedClass;
 
     static {
+        Method[] m = AccessController.doPrivileged(
+                new PrivilegedAction<Method[]>() {
+                    @Override
+                    public Method[] run() {
+                        return new Method[]{
+                                getMethod(ClassLoader.class, "defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE),
+                                getMethod(ClassLoader.class, "resolveClass", Class.class),
+                                getMethod(ClassLoader.class, "findLoadedClass", String.class)
+                        };
+                    }
+                }
+        );
+        defineClass = m[0];
+        resolveClass = m[1];
+        findLoadedClass = m[2];
+    }
+
+    private static Method getMethod(final Class<?> c, final String methodname, final Class<?>... params) {
         try {
-            defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE);
-            resolveClass = ClassLoader.class.getDeclaredMethod("resolveClass", Class.class);
-            findLoadedClass = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
+            Method m = c.getDeclaredMethod(methodname, params);
+            m.setAccessible(true);
+            return m;
         } catch (NoSuchMethodException e) {
-            // impossible
             throw new NoSuchMethodError(e.getMessage());
         }
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-
-            @Override
-            public Void run() {
-                // TODO: check security implication
-                // do these setAccessible allow anyone to call these methods freely?s
-                defineClass.setAccessible(true);
-                resolveClass.setAccessible(true);
-                findLoadedClass.setAccessible(true);
-                return null;
-            }
-        });
     }
 
     private Injector(ClassLoader parent) {
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java
index 6cff489ba7bb4b6963bc23917b981889cd02a68a..fa52778a9f1add918343d30f22d87a6a48ac729b 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java
@@ -42,6 +42,8 @@ import java.io.OutputStream;
 import java.io.StringWriter;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -91,8 +93,6 @@ public abstract class XMLStreamWriterFactory {
                     }
                 } catch (XMLStreamException ex) {
                     Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
-                } catch (NoSuchMethodException ex) {
-                    Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
                 }
             }
 
@@ -282,17 +282,31 @@ public abstract class XMLStreamWriterFactory {
                 return new Zephyr(xof,clazz);
             } catch (XMLStreamException e) {
                 return null;    // impossible
-            } catch (NoSuchMethodException e) {
-                return null;    // this xof wasn't Zephyr
             }
         }
 
-        private Zephyr(XMLOutputFactory xof, Class clazz) throws NoSuchMethodException {
+        private Zephyr(XMLOutputFactory xof, Class clazz) {
             this.xof = xof;
 
             zephyrClass = clazz;
-            setOutputMethod = clazz.getMethod("setOutput", StreamResult.class, String.class);
-            resetMethod = clazz.getMethod("reset");
+            setOutputMethod = getMethod(clazz, "setOutput", StreamResult.class, String.class);
+            resetMethod = getMethod(clazz, "reset");
+        }
+
+        private static Method getMethod(final Class<?> c, final String methodname, final Class<?>... params) {
+            return AccessController.doPrivileged(
+                    new PrivilegedAction<Method>() {
+                        @Override
+                        public Method run() {
+                            try {
+                                return c.getMethod(methodname, params);
+                            } catch (NoSuchMethodException e) {
+                                // impossible
+                                throw new NoSuchMethodError(e.getMessage());
+                            }
+                        }
+                    }
+            );
         }
 
         /**
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java
index 1e33628b0c1dbeb279c3b3f781f22f84130906a8..966e1736aacadc7508c8ec339b080c03c6c54c6c 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java
@@ -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
@@ -42,13 +42,12 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.ws.WebServiceException;
 import java.lang.reflect.Method;
-import java.lang.reflect.ReflectPermission;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.security.*;
-import java.util.PropertyPermission;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
 import java.util.logging.Level;
 
 /**
@@ -258,24 +257,13 @@ class MetroConfigLoader {
                         public JAXBContext run() throws Exception {
                             return JAXBContext.newInstance(MetroConfig.class.getPackage().getName());
                         }
-                    }, createSecurityContext()
-            );
+                    });
         } else {
             // usage from JAX-WS/Metro/Glassfish
             return JAXBContext.newInstance(MetroConfig.class.getPackage().getName());
         }
     }
 
-    private static AccessControlContext createSecurityContext() {
-        PermissionCollection perms = new Permissions();
-        perms.add(new RuntimePermission("accessClassInPackage.com" + ".sun.xml.internal.ws.runtime.config")); // avoid repackaging
-        perms.add(new ReflectPermission("suppressAccessChecks"));
-        return new AccessControlContext(
-                new ProtectionDomain[]{
-                        new ProtectionDomain(null, perms),
-                });
-    }
-
     private static boolean isJDKInternal() {
         // avoid "string repackaging"
         return MetroConfigLoader.class.getName().startsWith("com." + "sun.xml.internal.ws");
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java
index d0e980ce93704ffa22d9c70b7fca9f586f74a4ba..d68f854c38f6af8327b5544dad310c7fef1c7f43 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubeCreator.java
@@ -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
@@ -49,7 +49,7 @@ final class TubeCreator {
         try {
             Class<?> factoryClass;
             if (isJDKInternal(className)) {
-                factoryClass = Class.forName(className, true, null);
+                factoryClass = Class.forName(className, true, TubeCreator.class.getClassLoader());
             } else {
                 factoryClass = Class.forName(className, true, tubeFactoryClassLoader);
             }
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java
index 3f925581a85fc30ea6cabfcc3103feb739ec8921..a82c491e7fc4c8faa3b8bd898b9236c2d6a3e6a4 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/TubelineAssemblyController.java
@@ -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
@@ -109,11 +109,12 @@ final class TubelineAssemblyController {
     }
 
     private Collection<TubeCreator> initializeTubeCreators(TubeFactoryList tfl) {
-        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        ClassLoader classLoader = tccl != null ? tccl : TubelineAssemblyController.class.getClassLoader();
 
         LinkedList<TubeCreator> tubeCreators = new LinkedList<TubeCreator>();
         for (TubeFactoryConfig tubeFactoryConfig : tfl.getTubeFactoryConfigs()) {
-            tubeCreators.addFirst(new TubeCreator(tubeFactoryConfig, contextClassLoader));
+            tubeCreators.addFirst(new TubeCreator(tubeFactoryConfig, classLoader));
         }
         return tubeCreators;
     }
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java
index 7805320d90a9a4cee1c20fb9da6ddc8f1f796935..1c054547a4e7008d71131d3d4f1bdb08137e3675 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/client/WSServiceDelegate.java
@@ -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
@@ -91,7 +91,8 @@ import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -715,11 +716,6 @@ public class WSServiceDelegate extends WSService {
         final ClassLoader loader = getDelegatingLoader(portInterface.getClassLoader(),
                 WSServiceDelegate.class.getClassLoader());
 
-        // accessClassInPackage privilege needs to be granted ...
-        RuntimePermission perm = new RuntimePermission("accessClassInPackage.com.sun." + "xml.internal.*");
-        PermissionCollection perms = perm.newPermissionCollection();
-        perms.add(perm);
-
         return AccessController.doPrivileged(
                 new PrivilegedAction<T>() {
                     @Override
@@ -728,12 +724,8 @@ public class WSServiceDelegate extends WSService {
                                 new Class[]{portInterface, WSBindingProvider.class, Closeable.class}, pis);
                         return portInterface.cast(proxy);
                     }
-                },
-                new AccessControlContext(
-                        new ProtectionDomain[]{
-                                new ProtectionDomain(null, perms)
-                        })
-        );
+                });
+
     }
 
     private WSDLService getWSDLModelfromSEI(final Class sei) {
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java
index 92bd3b261677ae1cd03f9244be7dd05fc044cad3..bf258021c3361b6dd5f616e0378d92c025b00d18 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java
@@ -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
@@ -58,12 +58,8 @@ import javax.xml.ws.soap.SOAPFaultException;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.lang.reflect.ReflectPermission;
-import java.security.AccessControlContext;
 import java.security.AccessController;
-import java.security.Permissions;
 import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.logging.Level;
@@ -569,9 +565,6 @@ public abstract class SOAPFaultBuilder {
 
         // in jdk runtime doPrivileged is necessary since JAX-WS internal classes are in restricted packages
         if (isJDKRuntime()) {
-            Permissions permissions = new Permissions();
-            permissions.add(new RuntimePermission("accessClassInPackage.com.sun." + "xml.internal.ws.fault"));
-            permissions.add(new ReflectPermission("suppressAccessChecks"));
             return AccessController.doPrivileged(
                     new PrivilegedAction<JAXBContext>() {
                         @Override
@@ -582,9 +575,7 @@ public abstract class SOAPFaultBuilder {
                                 throw new Error(e);
                             }
                         }
-                    },
-                    new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain(null, permissions)})
-            );
+                    });
 
         } else {
             try {
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java
index 9d07e99b7c7b8357c2ee76e81f648449c8b7e3a7..158e0a9f8efc98a2c252a0911bb11c4f24d3abad 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Injector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -50,28 +50,36 @@ final class Injector {
     private static final Method definePackage;
 
     static {
+        Method[] m = AccessController.doPrivileged(
+                new PrivilegedAction<Method[]>() {
+                    @Override
+                    public Method[] run() {
+                        return new Method[]{
+                                getMethod(ClassLoader.class, "defineClass", String.class, byte[].class, Integer.TYPE, Integer.TYPE),
+                                getMethod(ClassLoader.class, "resolveClass", Class.class),
+                                getMethod(ClassLoader.class, "getPackage", String.class),
+                                getMethod(ClassLoader.class, "definePackage",
+                                        String.class, String.class, String.class, String.class,
+                                        String.class, String.class, String.class, URL.class)
+                        };
+                    }
+                }
+        );
+        defineClass = m[0];
+        resolveClass = m[1];
+        getPackage = m[2];
+        definePackage = m[3];
+    }
+
+    private static Method getMethod(final Class<?> c, final String methodname, final Class<?>... params) {
         try {
-            defineClass = ClassLoader.class.getDeclaredMethod("defineClass",String.class,byte[].class,Integer.TYPE,Integer.TYPE);
-            resolveClass = ClassLoader.class.getDeclaredMethod("resolveClass",Class.class);
-            getPackage = ClassLoader.class.getDeclaredMethod("getPackage", String.class);
-            definePackage = ClassLoader.class.getDeclaredMethod("definePackage",
-                    String.class, String.class, String.class, String.class,
-                    String.class, String.class, String.class, URL.class);
+            Method m = c.getDeclaredMethod(methodname, params);
+            m.setAccessible(true);
+            return m;
         } catch (NoSuchMethodException e) {
             // impossible
             throw new NoSuchMethodError(e.getMessage());
         }
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                // TODO: check security implication
-                // do these setAccessible allow anyone to call these methods freely?s
-                defineClass.setAccessible(true);
-                resolveClass.setAccessible(true);
-                getPackage.setAccessible(true);
-                definePackage.setAccessible(true);
-                return null;
-            }
-        });
     }
 
     static synchronized Class inject(ClassLoader cl, String className, byte[] image) {
diff --git a/jdk/.hgtags b/jdk/.hgtags
index d8119ddf45f35695aa550caa8d49a4f90b7cdd06..0718a4f34ab6c9e46b3b2e28c2499e90776e3b4f 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -266,3 +266,4 @@ f87c5be90e01a7ffb47947108eb3e0b0b1920880 jdk9-b20
 2df45ac1bf491278f38c12e0dfbeebadb6c54c8c jdk9-b21
 85bcf0f99edc08873614afbe5a5563e13ce13c83 jdk9-b22
 9febf9dbc0a4b15323f2dbd29931cfbf086332b4 jdk9-b23
+875450e7ef8dde8f59db662ec1351ea30b8cb35d jdk9-b24
diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java b/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java
index d1ea853a9b4474661fa00a8a31be08ae9ab2e30a..8009b67aa2c977a002c190cfb02b9e6be3b302a9 100644
--- a/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java
+++ b/jdk/src/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java
@@ -55,7 +55,6 @@ public class CorbaUtils {
       * Returns the CORBA object reference associated with a Remote
       * object by using the javax.rmi.CORBA package.
       *<p>
-      * Use reflection to avoid hard dependencies on javax.rmi.CORBA package.
       * This method effective does the following:
       *<blockquote><pre>
       * java.lang.Object stub;
diff --git a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
index 8539a266ee583eac5c5af5c6f99a82567cff113f..12ee20b126ba8310588e4d929f73efb5221dac09 100644
--- a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
+++ b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java
@@ -33,7 +33,10 @@ import java.text.MessageFormat;
 import java.util.*;
 
 import javax.security.auth.*;
-import javax.security.auth.kerberos.*;
+import javax.security.auth.kerberos.KerberosTicket;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.kerberos.KerberosKey;
+import javax.security.auth.kerberos.KeyTab;
 import javax.security.auth.callback.*;
 import javax.security.auth.login.*;
 import javax.security.auth.spi.*;
diff --git a/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java b/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java
index 2733c7b08f838469ea60ae94a032aa93545078de..0f3a27dfac92b48d0ecb7f9b8200eeed591bba9f 100644
--- a/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java
+++ b/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java
@@ -36,33 +36,7 @@ import org.ietf.jgss.*;
 public interface ExtendedGSSContext extends GSSContext {
     /**
      * Return the mechanism-specific attribute associated with {@code type}.
-     * <br><br>
-     * For each supported attribute type, the type for the output are
-     * defined below.
-     * <ol>
-     * <li>{@code KRB5_GET_TKT_FLAGS}:
-     * the returned object is a boolean array for the service ticket flags,
-     * which is long enough to contain all true bits. This means if
-     * the user wants to get the <em>n</em>'th bit but the length of the
-     * returned array is less than <em>n</em>, it is regarded as false.
-     * <li>{@code KRB5_GET_SESSION_KEY}:
-     * the returned object is an instance of {@link java.security.Key},
-     * which has the following properties:
-     *    <ul>
-     *    <li>Algorithm: enctype as a string, where
-     *        enctype is defined in RFC 3961, section 8.
-     *    <li>Format: "RAW"
-     *    <li>Encoded form: the raw key bytes, not in any ASN.1 encoding
-     *    </ul>
-     * <li>{@code KRB5_GET_AUTHZ_DATA}:
-     * the returned object is an array of
-     * {@link com.sun.security.jgss.AuthorizationDataEntry}, or null if the
-     * optional field is missing in the service ticket.
-     * <li>{@code KRB5_GET_AUTHTIME}:
-     * the returned object is a String object in the standard KerberosTime
-     * format defined in RFC 4120 5.2.3
-     * </ol>
-     *
+     * <p>
      * If there is a security manager, an {@link InquireSecContextPermission}
      * with the name {@code type.mech} must be granted. Otherwise, this could
      * result in a {@link SecurityException}.<p>
@@ -97,6 +71,7 @@ public interface ExtendedGSSContext extends GSSContext {
      * @throws SecurityException if a security manager exists and a proper
      *   {@link InquireSecContextPermission} is not granted.
      * @see InquireSecContextPermission
+     * @see InquireType
      */
     public Object inquireSecContext(InquireType type)
             throws GSSException;
diff --git a/jdk/src/share/classes/com/sun/security/jgss/InquireType.java b/jdk/src/share/classes/com/sun/security/jgss/InquireType.java
index 9dfc83abf7c9f6d447758dfc67cf46cb48880455..440a85c178fedb759496d9fb6c360fe913c5fbb1 100644
--- a/jdk/src/share/classes/com/sun/security/jgss/InquireType.java
+++ b/jdk/src/share/classes/com/sun/security/jgss/InquireType.java
@@ -32,13 +32,38 @@ package com.sun.security.jgss;
 @jdk.Exported
 public enum InquireType {
     /**
-     * Attribute type for retrieving the session key of an
-     * established Kerberos 5 security context.
+     * Attribute type for retrieving the session key of an established
+     * Kerberos 5 security context. The returned object is an instance of
+     * {@link java.security.Key}, which has the following properties:
+     *    <ul>
+     *    <li>Algorithm: enctype as a string, where
+     *        enctype is defined in RFC 3961, section 8.
+     *    <li>Format: "RAW"
+     *    <li>Encoded form: the raw key bytes, not in any ASN.1 encoding
+     *    </ul>
+     * @deprecated as of 1.9, replaced by {@link #KRB5_GET_SESSION_KEY_EX}
+     * which returns an instance of
+     * {@link sun.security.jgss.krb5.Krb5Context.EncryptionKey}
+     * that implements the {@link javax.crypto.SecretKey} interface and
+     * has similar methods with {@link javax.security.auth.kerberos.KerberosKey}.
      */
+    @Deprecated
     KRB5_GET_SESSION_KEY,
+    /**
+     * Attribute type for retrieving the session key of an
+     * established Kerberos 5 security context. The return value is an
+     * instance of {@link javax.security.auth.kerberos.EncryptionKey}.
+     *
+     * @since 1.9
+     */
+    KRB5_GET_SESSION_KEY_EX,
     /**
      * Attribute type for retrieving the service ticket flags of an
-     * established Kerberos 5 security context.
+     * established Kerberos 5 security context. The returned object is
+     * a boolean array for the service ticket flags, which is long enough
+     * to contain all true bits. This means if the user wants to get the
+     * <em>n</em>'th bit but the length of the returned array is less than
+     * <em>n</em>, it is regarded as false.
      */
     KRB5_GET_TKT_FLAGS,
     /**
@@ -49,7 +74,17 @@ public enum InquireType {
     KRB5_GET_AUTHZ_DATA,
     /**
      * Attribute type for retrieving the authtime in the service ticket
-     * of an established Kerberos 5 security context.
+     * of an established Kerberos 5 security context. The returned object
+     * is a String object in the standard KerberosTime format defined in
+     * RFC 4120 Section 5.2.3.
+     */
+    KRB5_GET_AUTHTIME,
+    /**
+     * Attribute type for retrieving the KRB_CRED message that an initiator
+     * is about to send to an acceptor. The return type is an instance of
+     * {@link javax.security.auth.kerberos.KerberosCredMessage}.
+     *
+     * @since 1.9
      */
-    KRB5_GET_AUTHTIME
+    KRB5_GET_KRB_CRED,
 }
diff --git a/jdk/src/share/classes/java/lang/Integer.java b/jdk/src/share/classes/java/lang/Integer.java
index a6a06bc35106ca6e22e418c1354f09a30e189b7a..94b0aff79706053c68b0ecc1c7be35d9de7f22b6 100644
--- a/jdk/src/share/classes/java/lang/Integer.java
+++ b/jdk/src/share/classes/java/lang/Integer.java
@@ -26,6 +26,7 @@
 package java.lang;
 
 import java.lang.annotation.Native;
+import java.util.Objects;
 
 /**
  * The {@code Integer} class wraps a value of the primitive type
@@ -319,24 +320,27 @@ public final class Integer extends Number implements Comparable<Integer> {
     }
 
     /**
-     * Format a long (treated as unsigned) into a character buffer.
+     * Format an {@code int} (treated as unsigned) into a character buffer. If
+     * {@code len} exceeds the formatted ASCII representation of {@code val},
+     * {@code buf} will be padded with leading zeroes.
+     *
      * @param val the unsigned int to format
      * @param shift the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary)
      * @param buf the character buffer to write to
      * @param offset the offset in the destination buffer to start at
      * @param len the number of characters to write
-     * @return the lowest character  location used
      */
-     static int formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) {
-        int charPos = len;
+     static void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) {
+        // assert shift > 0 && shift <=5 : "Illegal shift value";
+        // assert offset >= 0 && offset < buf.length : "illegal offset";
+        // assert len > 0 && (offset + len) <= buf.length : "illegal length";
+        int charPos = offset + len;
         int radix = 1 << shift;
         int mask = radix - 1;
         do {
-            buf[offset + --charPos] = Integer.digits[val & mask];
+            buf[--charPos] = Integer.digits[val & mask];
             val >>>= shift;
-        } while (val != 0 && charPos > 0);
-
-        return charPos;
+        } while (charPos > offset);
     }
 
     final static char [] DigitTens = {
@@ -549,12 +553,9 @@ public final class Integer extends Number implements Comparable<Integer> {
                                             " greater than Character.MAX_RADIX");
         }
 
-        int result = 0;
         boolean negative = false;
         int i = 0, len = s.length();
         int limit = -Integer.MAX_VALUE;
-        int multmin;
-        int digit;
 
         if (len > 0) {
             char firstChar = s.charAt(0);
@@ -562,21 +563,21 @@ public final class Integer extends Number implements Comparable<Integer> {
                 if (firstChar == '-') {
                     negative = true;
                     limit = Integer.MIN_VALUE;
-                } else if (firstChar != '+')
+                } else if (firstChar != '+') {
                     throw NumberFormatException.forInputString(s);
+                }
 
-                if (len == 1) // Cannot have lone "+" or "-"
+                if (len == 1) { // Cannot have lone "+" or "-"
                     throw NumberFormatException.forInputString(s);
+                }
                 i++;
             }
-            multmin = limit / radix;
+            int multmin = limit / radix;
+            int result = 0;
             while (i < len) {
                 // Accumulating negatively avoids surprises near MAX_VALUE
-                digit = Character.digit(s.charAt(i++),radix);
-                if (digit < 0) {
-                    throw NumberFormatException.forInputString(s);
-                }
-                if (result < multmin) {
+                int digit = Character.digit(s.charAt(i++), radix);
+                if (digit < 0 || result < multmin) {
                     throw NumberFormatException.forInputString(s);
                 }
                 result *= radix;
@@ -585,10 +586,126 @@ public final class Integer extends Number implements Comparable<Integer> {
                 }
                 result -= digit;
             }
+            return negative ? result : -result;
         } else {
             throw NumberFormatException.forInputString(s);
         }
-        return negative ? result : -result;
+    }
+
+    /**
+     * Parses the {@link CharSequence} argument as a signed {@code int} in the
+     * specified {@code radix}, beginning at the specified {@code beginIndex}
+     * and extending to the end of the sequence.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the {@code int}
+     *                  representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @return     the signed {@code int} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable {@code int} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static int parseInt(CharSequence s, int radix, int beginIndex)
+                throws NumberFormatException {
+        // forces an implicit null check of s
+        return parseInt(s, radix, beginIndex, s.length());
+    }
+
+    /**
+     * Parses the {@link CharSequence} argument as a signed {@code int} in the
+     * specified {@code radix}, beginning at the specified {@code beginIndex}
+     * and extending to {@code endIndex - 1}.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the {@code int}
+     *                  representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @param      endIndex     the ending index, exclusive.
+     * @return     the signed {@code int} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code endIndex} or if {@code endIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable {@code int} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static int parseInt(CharSequence s, int radix, int beginIndex, int endIndex)
+                throws NumberFormatException {
+        s = Objects.requireNonNull(s);
+
+        if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
+            throw new IndexOutOfBoundsException();
+        }
+        if (radix < Character.MIN_RADIX) {
+            throw new NumberFormatException("radix " + radix +
+                                            " less than Character.MIN_RADIX");
+        }
+        if (radix > Character.MAX_RADIX) {
+            throw new NumberFormatException("radix " + radix +
+                                            " greater than Character.MAX_RADIX");
+        }
+
+        boolean negative = false;
+        int i = beginIndex;
+        int limit = -Integer.MAX_VALUE;
+
+        if (i < endIndex) {
+            char firstChar = s.charAt(i);
+            if (firstChar < '0') { // Possible leading "+" or "-"
+                if (firstChar == '-') {
+                    negative = true;
+                    limit = Integer.MIN_VALUE;
+                } else if (firstChar != '+') {
+                    throw NumberFormatException.forCharSequence(s, beginIndex,
+                            endIndex, i);
+                }
+                i++;
+                if (i == endIndex) { // Cannot have lone "+" or "-"
+                    throw NumberFormatException.forCharSequence(s, beginIndex,
+                            endIndex, i);
+                }
+            }
+            int multmin = limit / radix;
+            int result = 0;
+            while (i < endIndex) {
+                // Accumulating negatively avoids surprises near MAX_VALUE
+                int digit = Character.digit(s.charAt(i++), radix);
+                if (digit < 0 || result < multmin) {
+                    throw NumberFormatException.forCharSequence(s, beginIndex,
+                            endIndex, i);
+                }
+                result *= radix;
+                if (result < limit + digit) {
+                    throw NumberFormatException.forCharSequence(s, beginIndex,
+                            endIndex, i);
+                }
+                result -= digit;
+            }
+            return negative ? result : -result;
+        } else {
+            throw NumberFormatException.forInputString("");
+        }
     }
 
     /**
@@ -688,6 +805,99 @@ public final class Integer extends Number implements Comparable<Integer> {
         }
     }
 
+    /**
+     * Parses the {@link CharSequence} argument as an unsigned {@code int} in
+     * the specified {@code radix}, beginning at the specified
+     * {@code beginIndex} and extending to the end of the sequence.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the unsigned
+     *                 {@code int} representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @return     the unsigned {@code int} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable unsigned {@code int} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static int parseUnsignedInt(CharSequence s, int radix, int beginIndex)
+                throws NumberFormatException {
+        // forces an implicit null check of s
+        return parseUnsignedInt(s, radix, beginIndex, s.length());
+    }
+
+    /**
+     * Parses the {@link CharSequence} argument as an unsigned {@code int} in
+     * the specified {@code radix}, beginning at the specified
+     * {@code beginIndex} and extending to {@code endIndex - 1}.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the unsigned
+     *                 {@code int} representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @param      endIndex     the ending index, exclusive.
+     * @return     the unsigned {@code int} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code endIndex} or if {@code endIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable unsigned {@code int} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static int parseUnsignedInt(CharSequence s, int radix, int beginIndex, int endIndex)
+                throws NumberFormatException {
+        s = Objects.requireNonNull(s);
+
+        if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
+            throw new IndexOutOfBoundsException();
+        }
+        int start = beginIndex, len = endIndex - beginIndex;
+
+        if (len > 0) {
+            char firstChar = s.charAt(start);
+            if (firstChar == '-') {
+                throw new
+                    NumberFormatException(String.format("Illegal leading minus sign " +
+                                                       "on unsigned string %s.", s));
+            } else {
+                if (len <= 5 || // Integer.MAX_VALUE in Character.MAX_RADIX is 6 digits
+                        (radix == 10 && len <= 9)) { // Integer.MAX_VALUE in base 10 is 10 digits
+                    return parseInt(s, radix, start, start + len);
+                } else {
+                    long ell = Long.parseLong(s, radix, start, start + len);
+                    if ((ell & 0xffff_ffff_0000_0000L) == 0) {
+                        return (int) ell;
+                    } else {
+                        throw new
+                            NumberFormatException(String.format("String value %s exceeds " +
+                                                                "range of unsigned int.", s));
+                    }
+                }
+            }
+        } else {
+            throw new NumberFormatException("");
+        }
+    }
+
     /**
      * Parses the string argument as an unsigned decimal integer. The
      * characters in the string must all be decimal digits, except
diff --git a/jdk/src/share/classes/java/lang/Long.java b/jdk/src/share/classes/java/lang/Long.java
index 63a7cb3654a7be32f9b1e3f8d9f4cffe16d16ec2..76caa77fac7882cc789a74090b72e914c4e587e2 100644
--- a/jdk/src/share/classes/java/lang/Long.java
+++ b/jdk/src/share/classes/java/lang/Long.java
@@ -27,6 +27,7 @@ package java.lang;
 
 import java.lang.annotation.Native;
 import java.math.*;
+import java.util.Objects;
 
 
 /**
@@ -360,24 +361,27 @@ public final class Long extends Number implements Comparable<Long> {
     }
 
     /**
-     * Format a long (treated as unsigned) into a character buffer.
+     * Format a long (treated as unsigned) into a character buffer. If
+     * {@code len} exceeds the formatted ASCII representation of {@code val},
+     * {@code buf} will be padded with leading zeroes.
+     *
      * @param val the unsigned long to format
      * @param shift the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary)
      * @param buf the character buffer to write to
      * @param offset the offset in the destination buffer to start at
      * @param len the number of characters to write
-     * @return the lowest character location used
      */
-     static int formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) {
-        int charPos = len;
+     static void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) {
+        // assert shift > 0 && shift <=5 : "Illegal shift value";
+        // assert offset >= 0 && offset < buf.length : "illegal offset";
+        // assert len > 0 && (offset + len) <= buf.length : "illegal length";
+        int charPos = offset + len;
         int radix = 1 << shift;
         int mask = radix - 1;
         do {
-            buf[offset + --charPos] = Integer.digits[((int) val) & mask];
+            buf[--charPos] = Integer.digits[((int) val) & mask];
             val >>>= shift;
-        } while (val != 0 && charPos > 0);
-
-        return charPos;
+        } while (charPos > offset);
     }
 
     /**
@@ -561,12 +565,9 @@ public final class Long extends Number implements Comparable<Long> {
                                             " greater than Character.MAX_RADIX");
         }
 
-        long result = 0;
         boolean negative = false;
         int i = 0, len = s.length();
         long limit = -Long.MAX_VALUE;
-        long multmin;
-        int digit;
 
         if (len > 0) {
             char firstChar = s.charAt(0);
@@ -574,21 +575,21 @@ public final class Long extends Number implements Comparable<Long> {
                 if (firstChar == '-') {
                     negative = true;
                     limit = Long.MIN_VALUE;
-                } else if (firstChar != '+')
+                } else if (firstChar != '+') {
                     throw NumberFormatException.forInputString(s);
+                }
 
-                if (len == 1) // Cannot have lone "+" or "-"
+                if (len == 1) { // Cannot have lone "+" or "-"
                     throw NumberFormatException.forInputString(s);
+                }
                 i++;
             }
-            multmin = limit / radix;
+            long multmin = limit / radix;
+            long result = 0;
             while (i < len) {
                 // Accumulating negatively avoids surprises near MAX_VALUE
-                digit = Character.digit(s.charAt(i++),radix);
-                if (digit < 0) {
-                    throw NumberFormatException.forInputString(s);
-                }
-                if (result < multmin) {
+                int digit = Character.digit(s.charAt(i++),radix);
+                if (digit < 0 || result < multmin) {
                     throw NumberFormatException.forInputString(s);
                 }
                 result *= radix;
@@ -597,10 +598,126 @@ public final class Long extends Number implements Comparable<Long> {
                 }
                 result -= digit;
             }
+            return negative ? result : -result;
         } else {
             throw NumberFormatException.forInputString(s);
         }
-        return negative ? result : -result;
+    }
+
+    /**
+     * Parses the {@link CharSequence} argument as a signed {@code long} in
+     * the specified {@code radix}, beginning at the specified {@code beginIndex}
+     * and extending to the end of the sequence.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the {@code long}
+     *                  representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @return     the signed {@code long} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable {@code long} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static long parseLong(CharSequence s, int radix, int beginIndex)
+            throws NumberFormatException {
+        // forces a null check of s
+        return parseLong(s, radix, beginIndex, s.length());
+    }
+
+    /**
+     * Parses the {@link CharSequence} argument as a signed {@code long} in
+     * the specified {@code radix}, beginning at the specified
+     * {@code beginIndex} and extending to {@code endIndex - 1}.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the {@code long}
+     *                  representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @param      endIndex     the ending index, exclusive.
+     * @return     the signed {@code long} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code endIndex} or if {@code endIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable {@code int} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static long parseLong(CharSequence s, int radix, int beginIndex, int endIndex)
+                throws NumberFormatException {
+        s = Objects.requireNonNull(s);
+
+        if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
+            throw new IndexOutOfBoundsException();
+        }
+        if (radix < Character.MIN_RADIX) {
+            throw new NumberFormatException("radix " + radix +
+                    " less than Character.MIN_RADIX");
+        }
+        if (radix > Character.MAX_RADIX) {
+            throw new NumberFormatException("radix " + radix +
+                    " greater than Character.MAX_RADIX");
+        }
+
+        boolean negative = false;
+        int i = beginIndex;
+        long limit = -Long.MAX_VALUE;
+
+        if (i < endIndex) {
+            char firstChar = s.charAt(i);
+            if (firstChar < '0') { // Possible leading "+" or "-"
+                if (firstChar == '-') {
+                    negative = true;
+                    limit = Long.MIN_VALUE;
+                } else if (firstChar != '+') {
+                    throw NumberFormatException.forCharSequence(s, beginIndex,
+                            endIndex, i);
+                }
+                i++;
+            }
+            if (i >= endIndex) { // Cannot have lone "+", "-" or ""
+                throw NumberFormatException.forCharSequence(s, beginIndex,
+                        endIndex, i);
+            }
+            long multmin = limit / radix;
+            long result = 0;
+            while (i < endIndex) {
+                // Accumulating negatively avoids surprises near MAX_VALUE
+                int digit = Character.digit(s.charAt(i++), radix);
+                if (digit < 0 || result < multmin) {
+                    throw NumberFormatException.forCharSequence(s, beginIndex,
+                            endIndex, i);
+                }
+                result *= radix;
+                if (result < limit + digit) {
+                    throw NumberFormatException.forCharSequence(s, beginIndex,
+                            endIndex, i);
+                }
+                result -= digit;
+            }
+            return negative ? result : -result;
+        } else {
+            throw new NumberFormatException("");
+        }
     }
 
     /**
@@ -694,7 +811,7 @@ public final class Long extends Number implements Comparable<Long> {
                 }
 
                 // No need for range checks on len due to testing above.
-                long first = parseLong(s.substring(0, len - 1), radix);
+                long first = parseLong(s, radix, 0, len - 1);
                 int second = Character.digit(s.charAt(len - 1), radix);
                 if (second < 0) {
                     throw new NumberFormatException("Bad digit at end of " + s);
@@ -763,6 +880,155 @@ public final class Long extends Number implements Comparable<Long> {
         }
     }
 
+    /**
+     * Parses the {@link CharSequence} argument as an unsigned {@code long} in
+     * the specified {@code radix}, beginning at the specified
+     * {@code beginIndex} and extending to the end of the sequence.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the unsigned
+     *                 {@code long} representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @return     the unsigned {@code long} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable unsigned {@code long} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static long parseUnsignedLong(CharSequence s, int radix, int beginIndex)
+                throws NumberFormatException {
+        // forces a null check of s
+        return parseUnsignedLong(s, radix, beginIndex, s.length());
+    }
+
+    /**
+     * Parses the {@link CharSequence} argument as an unsigned {@code long} in
+     * the specified {@code radix}, beginning at the specified
+     * {@code beginIndex} and extending to {@code endIndex - 1}.
+     *
+     * <p>The method does not take steps to guard against the
+     * {@code CharSequence} being mutated while parsing.
+     *
+     * @param      s   the {@code CharSequence} containing the unsigned
+     *                 {@code long} representation to be parsed
+     * @param      radix   the radix to be used while parsing {@code s}.
+     * @param      beginIndex   the beginning index, inclusive.
+     * @param      endIndex     the ending index, exclusive.
+     * @return     the unsigned {@code long} represented by the subsequence in
+     *             the specified radix.
+     * @throws     NullPointerException  if {@code s} is null.
+     * @throws     IndexOutOfBoundsException  if {@code beginIndex} is
+     *             negative, or if {@code beginIndex} is greater than
+     *             {@code endIndex} or if {@code endIndex} is greater than
+     *             {@code s.length()}.
+     * @throws     NumberFormatException  if the {@code CharSequence} does not
+     *             contain a parsable unsigned {@code long} in the specified
+     *             {@code radix}, or if {@code radix} is either smaller than
+     *             {@link java.lang.Character#MIN_RADIX} or larger than
+     *             {@link java.lang.Character#MAX_RADIX}.
+     * @since  1.9
+     */
+    public static long parseUnsignedLong(CharSequence s, int radix, int beginIndex, int endIndex)
+                throws NumberFormatException {
+        s = Objects.requireNonNull(s);
+
+        if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
+            throw new IndexOutOfBoundsException();
+        }
+        int start = beginIndex, len = endIndex - beginIndex;
+
+        if (len > 0) {
+            char firstChar = s.charAt(start);
+            if (firstChar == '-') {
+                throw new NumberFormatException(String.format("Illegal leading minus sign " +
+                        "on unsigned string %s.", s.subSequence(start, start + len)));
+            } else {
+                if (len <= 12 || // Long.MAX_VALUE in Character.MAX_RADIX is 13 digits
+                    (radix == 10 && len <= 18) ) { // Long.MAX_VALUE in base 10 is 19 digits
+                    return parseLong(s, radix, start, start + len);
+                }
+
+                // No need for range checks on end due to testing above.
+                long first = parseLong(s, radix, start, start + len - 1);
+                int second = Character.digit(s.charAt(start + len - 1), radix);
+                if (second < 0) {
+                    throw new NumberFormatException("Bad digit at end of " +
+                            s.subSequence(start, start + len));
+                }
+                long result = first * radix + second;
+
+                /*
+                 * Test leftmost bits of multiprecision extension of first*radix
+                 * for overflow. The number of bits needed is defined by
+                 * GUARD_BIT = ceil(log2(Character.MAX_RADIX)) + 1 = 7. Then
+                 * int guard = radix*(int)(first >>> (64 - GUARD_BIT)) and
+                 * overflow is tested by splitting guard in the ranges
+                 * guard < 92, 92 <= guard < 128, and 128 <= guard, where
+                 * 92 = 128 - Character.MAX_RADIX. Note that guard cannot take
+                 * on a value which does not include a prime factor in the legal
+                 * radix range.
+                 */
+                int guard = radix * (int) (first >>> 57);
+                if (guard >= 128 ||
+                        (result >= 0 && guard >= 128 - Character.MAX_RADIX)) {
+                    /*
+                     * For purposes of exposition, the programmatic statements
+                     * below should be taken to be multi-precision, i.e., not
+                     * subject to overflow.
+                     *
+                     * A) Condition guard >= 128:
+                     * If guard >= 128 then first*radix >= 2^7 * 2^57 = 2^64
+                     * hence always overflow.
+                     *
+                     * B) Condition guard < 92:
+                     * Define left7 = first >>> 57.
+                     * Given first = (left7 * 2^57) + (first & (2^57 - 1)) then
+                     * result <= (radix*left7)*2^57 + radix*(2^57 - 1) + second.
+                     * Thus if radix*left7 < 92, radix <= 36, and second < 36,
+                     * then result < 92*2^57 + 36*(2^57 - 1) + 36 = 2^64 hence
+                     * never overflow.
+                     *
+                     * C) Condition 92 <= guard < 128:
+                     * first*radix + second >= radix*left7*2^57 + second
+                     * so that first*radix + second >= 92*2^57 + 0 > 2^63
+                     *
+                     * D) Condition guard < 128:
+                     * radix*first <= (radix*left7) * 2^57 + radix*(2^57 - 1)
+                     * so
+                     * radix*first + second <= (radix*left7) * 2^57 + radix*(2^57 - 1) + 36
+                     * thus
+                     * radix*first + second < 128 * 2^57 + 36*2^57 - radix + 36
+                     * whence
+                     * radix*first + second < 2^64 + 2^6*2^57 = 2^64 + 2^63
+                     *
+                     * E) Conditions C, D, and result >= 0:
+                     * C and D combined imply the mathematical result
+                     * 2^63 < first*radix + second < 2^64 + 2^63. The lower
+                     * bound is therefore negative as a signed long, but the
+                     * upper bound is too small to overflow again after the
+                     * signed long overflows to positive above 2^64 - 1. Hence
+                     * result >= 0 implies overflow given C and D.
+                     */
+                    throw new NumberFormatException(String.format("String value %s exceeds " +
+                            "range of unsigned long.", s.subSequence(start, start + len)));
+                }
+                return result;
+            }
+        } else {
+            throw NumberFormatException.forInputString("");
+        }
+    }
+
     /**
      * Parses the string argument as an unsigned decimal {@code long}. The
      * characters in the string must all be decimal digits, except
diff --git a/jdk/src/share/classes/java/lang/NumberFormatException.java b/jdk/src/share/classes/java/lang/NumberFormatException.java
index 1774ce52e5c1a09ea757cb089f2ac0529e675285..7c6345dcd074993f858d17b1ec5588118aaf1228 100644
--- a/jdk/src/share/classes/java/lang/NumberFormatException.java
+++ b/jdk/src/share/classes/java/lang/NumberFormatException.java
@@ -56,7 +56,7 @@ class NumberFormatException extends IllegalArgumentException {
     }
 
     /**
-     * Factory method for making a <code>NumberFormatException</code>
+     * Factory method for making a {@code NumberFormatException}
      * given the specified input which caused the error.
      *
      * @param   s   the input causing the error
@@ -64,4 +64,20 @@ class NumberFormatException extends IllegalArgumentException {
     static NumberFormatException forInputString(String s) {
         return new NumberFormatException("For input string: \"" + s + "\"");
     }
+
+    /**
+     * Factory method for making a {@code NumberFormatException}
+     * given the specified input which caused the error.
+     *
+     * @param   s   the input causing the error
+     * @param   beginIndex   the beginning index, inclusive.
+     * @param   endIndex     the ending index, exclusive.
+     * @param   errorIndex   the index of the first error in s
+     */
+    static NumberFormatException forCharSequence(CharSequence s,
+            int beginIndex, int endIndex, int errorIndex) {
+        return new NumberFormatException("Error at index "
+                + (errorIndex - beginIndex) + " in: \""
+                + s.subSequence(beginIndex, endIndex) + "\"");
+    }
 }
diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java
index c4f67778d4270bbf20fca2f9330684be8e566d40..ce673fba2d47a699292eacaf28fcb88e1847a733 100644
--- a/jdk/src/share/classes/java/lang/String.java
+++ b/jdk/src/share/classes/java/lang/String.java
@@ -2580,7 +2580,8 @@ public final class String
         }
         for (int i = first; i < len; i++) {
             int cp = (int)value[i];
-            if (cp == '\u03A3') {                       // GREEK CAPITAL LETTER SIGMA
+            if (cp == '\u03A3' ||                       // GREEK CAPITAL LETTER SIGMA
+                Character.isSurrogate((char)cp)) {
                 return toLowerCaseEx(result, i, locale, false);
             }
             if (cp == '\u0130') {                       // LATIN CAPITAL LETTER I WITH DOT ABOVE
@@ -2742,7 +2743,11 @@ public final class String
             return toUpperCaseEx(result, first, locale, false);
         }
         for (int i = first; i < len; i++) {
-            int cp = Character.toUpperCaseEx((int)value[i]);
+            int cp = (int)value[i];
+            if (Character.isSurrogate((char)cp)) {
+                return toUpperCaseEx(result, i, locale, false);
+            }
+            cp = Character.toUpperCaseEx(cp);
             if (!Character.isBmpCodePoint(cp)) {    // Character.ERROR is not bmp
                 return toUpperCaseEx(result, i, locale, false);
             }
diff --git a/jdk/src/share/classes/java/lang/System.java b/jdk/src/share/classes/java/lang/System.java
index e96bd3b6f143d2c1d0fa5dcba6f20b1c0dcf8199..fbac697c245655a0e8cd193543aa6c2a2c5f5a33 100644
--- a/jdk/src/share/classes/java/lang/System.java
+++ b/jdk/src/share/classes/java/lang/System.java
@@ -1263,6 +1263,12 @@ public final class System {
             public void invokeFinalize(Object o) throws Throwable {
                 o.finalize();
             }
+            public void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) {
+                Long.formatUnsignedLong(val, shift, buf, offset, len);
+            }
+            public void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) {
+                Integer.formatUnsignedInt(val, shift, buf, offset, len);
+            }
         });
     }
 }
diff --git a/jdk/src/share/classes/java/nio/StringCharBuffer.java b/jdk/src/share/classes/java/nio/StringCharBuffer.java
index 0c20fa669c501eac36572b54a32201bd813ca834..4a5f05176911b19346667bd1b4f30a8e2ca58b53 100644
--- a/jdk/src/share/classes/java/nio/StringCharBuffer.java
+++ b/jdk/src/share/classes/java/nio/StringCharBuffer.java
@@ -100,7 +100,7 @@ class StringCharBuffer                                  // package-private
     }
 
     final String toString(int start, int end) {
-        return str.toString().substring(start + offset, end + offset);
+        return str.subSequence(start + offset, end + offset).toString();
     }
 
     public final CharBuffer subSequence(int start, int end) {
diff --git a/jdk/src/share/classes/java/util/UUID.java b/jdk/src/share/classes/java/util/UUID.java
index b4ea41ff06156ba238fa3c943a47a7e3f7e48006..11e024678e0277f8ab07cd2edaa0a5f1877a8495 100644
--- a/jdk/src/share/classes/java/util/UUID.java
+++ b/jdk/src/share/classes/java/util/UUID.java
@@ -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
@@ -27,6 +27,9 @@ package java.util;
 
 import java.security.*;
 
+import sun.misc.JavaLangAccess;
+import sun.misc.SharedSecrets;
+
 /**
  * A class that represents an immutable universally unique identifier (UUID).
  * A UUID represents a 128-bit value.
@@ -88,6 +91,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
      */
     private final long leastSigBits;
 
+    private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
+
     /*
      * The random number generator used by this class to create random
      * based UUIDs. In a holder class to defer initialization until needed.
@@ -189,21 +194,35 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
      *
      */
     public static UUID fromString(String name) {
-        String[] components = name.split("-");
-        if (components.length != 5)
-            throw new IllegalArgumentException("Invalid UUID string: "+name);
-        for (int i=0; i<5; i++)
-            components[i] = "0x"+components[i];
+        if (name.length() > 36) {
+            throw new IllegalArgumentException("UUID string too large");
+        }
 
-        long mostSigBits = Long.decode(components[0]).longValue();
+        int dash1 = name.indexOf('-', 0);
+        int dash2 = name.indexOf('-', dash1 + 1);
+        int dash3 = name.indexOf('-', dash2 + 1);
+        int dash4 = name.indexOf('-', dash3 + 1);
+        int dash5 = name.indexOf('-', dash4 + 1);
+
+        // For any valid input, dash1 through dash4 will be positive and dash5
+        // negative, but it's enough to check dash4 and dash5:
+        // - if dash1 is -1, dash4 will be -1
+        // - if dash1 is positive but dash2 is -1, dash4 will be -1
+        // - if dash1 and dash2 is positive, dash3 will be -1, dash4 will be
+        //   positive, but so will dash5
+        if (dash4 < 0 || dash5 >= 0) {
+            throw new IllegalArgumentException("Invalid UUID string: " + name);
+        }
+
+        long mostSigBits = Long.parseLong(name, 16, 0, dash1) & 0xffffffffL;
         mostSigBits <<= 16;
-        mostSigBits |= Long.decode(components[1]).longValue();
+        mostSigBits |= Long.parseLong(name, 16, dash1 + 1, dash2) & 0xffffL;
         mostSigBits <<= 16;
-        mostSigBits |= Long.decode(components[2]).longValue();
+        mostSigBits |= Long.parseLong(name, 16, dash2 + 1, dash3) & 0xffffL;
 
-        long leastSigBits = Long.decode(components[3]).longValue();
+        long leastSigBits = Long.parseLong(name, 16, dash3 + 1, dash4) & 0xffffL;
         leastSigBits <<= 48;
-        leastSigBits |= Long.decode(components[4]).longValue();
+        leastSigBits |= Long.parseLong(name, 16, dash4 + 1) & 0xffffffffffffL;
 
         return new UUID(mostSigBits, leastSigBits);
     }
@@ -373,17 +392,17 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
      * @return  A string representation of this {@code UUID}
      */
     public String toString() {
-        return (digits(mostSigBits >> 32, 8) + "-" +
-                digits(mostSigBits >> 16, 4) + "-" +
-                digits(mostSigBits, 4) + "-" +
-                digits(leastSigBits >> 48, 4) + "-" +
-                digits(leastSigBits, 12));
-    }
-
-    /** Returns val represented by the specified number of hex digits. */
-    private static String digits(long val, int digits) {
-        long hi = 1L << (digits * 4);
-        return Long.toHexString(hi | (val & (hi - 1))).substring(1);
+        char[] chars = new char[36];
+        jla.formatUnsignedLong(mostSigBits >> 32, 4, chars, 0, 8);
+        chars[8] = '-';
+        jla.formatUnsignedLong(mostSigBits >> 16, 4, chars, 9, 4);
+        chars[13] = '-';
+        jla.formatUnsignedLong(mostSigBits, 4, chars, 14, 4);
+        chars[18] = '-';
+        jla.formatUnsignedLong(leastSigBits >> 48, 4, chars, 19, 4);
+        chars[23] = '-';
+        jla.formatUnsignedLong(leastSigBits, 4, chars, 24, 12);
+        return jla.newStringUnsafe(chars);
     }
 
     /**
diff --git a/jdk/src/share/classes/java/util/package.html b/jdk/src/share/classes/java/util/package.html
index abcf84bef43689e8c4ee875cfd58e7490fd664f5..eb77a146b0f0c68199b5992b61c6c54f044b126c 100644
--- a/jdk/src/share/classes/java/util/package.html
+++ b/jdk/src/share/classes/java/util/package.html
@@ -43,7 +43,7 @@ classes (a string tokenizer, a random-number generator, and a bit array).
 <h2>Related Documentation</h2>
 For overviews, tutorials, examples, guides, and tool documentation, please see:
 <ul>
-    <li><a href="http://www.java.sun.com/docs/books/tutorial/collections/">
+    <li><a href="http://docs.oracle.com/javase/tutorial/collections/index.html">
        <b>Collections Framework Tutorial</b></a>
     <li><a
     href="../../../technotes/guides/collections/designfaq.html"><b>Collections
diff --git a/jdk/src/share/classes/javax/security/auth/kerberos/EncryptionKey.java b/jdk/src/share/classes/javax/security/auth/kerberos/EncryptionKey.java
new file mode 100644
index 0000000000000000000000000000000000000000..22730b608440c6b04c475a3d62adb2edb74b1368
--- /dev/null
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/EncryptionKey.java
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+package javax.security.auth.kerberos;
+
+import java.util.Arrays;
+import java.util.Objects;
+import javax.crypto.SecretKey;
+import javax.security.auth.DestroyFailedException;
+
+/**
+ * This class encapsulates an EncryptionKey used in Kerberos.<p>
+ *
+ * An EncryptionKey is defined in Section 4.2.9 of the Kerberos Protocol
+ * Specification (<a href=http://www.ietf.org/rfc/rfc4120.txt>RFC 4120</a>) as:
+ * <pre>
+ *     EncryptionKey   ::= SEQUENCE {
+ *             keytype         [0] Int32 -- actually encryption type --,
+ *             keyvalue        [1] OCTET STRING
+ *     }
+ * </pre>
+ * The key material of an {@code EncryptionKey} is defined as the value
+ * of the {@code keyValue} above.<p>
+ *
+ * @since 1.9
+ */
+public final class EncryptionKey implements SecretKey {
+
+    private static final long serialVersionUID = 9L;
+
+   /**
+    * {@code KeyImpl} is serialized by writing out the ASN.1 encoded bytes
+    * of the encryption key.
+    *
+    * @serial
+    */
+    final private KeyImpl key;
+
+    private transient boolean destroyed = false;
+
+    /**
+     * Constructs a {@code EncryptionKey} from the given bytes and
+     * the key type.
+     * <p>
+     * The contents of the byte array are copied; subsequent modification of
+     * the byte array does not affect the newly created key.
+     *
+     * @param keyBytes the key material for the key
+     * @param keyType the key type for the key as defined by the
+     *                Kerberos protocol specification.
+     * @throws NullPointerException if keyBytes is null
+     */
+    public EncryptionKey(byte[] keyBytes, int keyType) {
+        key = new KeyImpl(Objects.requireNonNull(keyBytes), keyType);
+    }
+
+    /**
+     * Returns the key type for this key.
+     *
+     * @return the key type.
+     * @throws IllegalStateException if the key is destroyed
+     */
+    public int getKeyType() {
+        // KeyImpl already checked if destroyed
+        return key.getKeyType();
+    }
+
+    /*
+     * Methods from java.security.Key
+     */
+
+    /**
+     * Returns the standard algorithm name for this key. The algorithm names
+     * are the encryption type string defined on the IANA
+     * <a href="https://www.iana.org/assignments/kerberos-parameters/kerberos-parameters.xhtml#kerberos-parameters-1">Kerberos Encryption Type Numbers</a>
+     * page.
+     * <p>
+     * This method can return the following value not defined on the IANA page:
+     * <ol>
+     *     <li>none: for etype equal to 0</li>
+     *     <li>unknown: for etype greater than 0 but unsupported by
+     *         the implementation</li>
+     *     <li>private: for etype smaller than 0</li>
+     * </ol>
+     *
+     * @return the name of the algorithm associated with this key.
+     * @throws IllegalStateException if the key is destroyed
+     */
+    @Override
+    public String getAlgorithm() {
+        // KeyImpl already checked if destroyed
+        return key.getAlgorithm();
+    }
+
+    /**
+     * Returns the name of the encoding format for this key.
+     *
+     * @return the String "RAW"
+     * @throws IllegalStateException if the key is destroyed
+     */
+    @Override
+    public String getFormat() {
+        // KeyImpl already checked if destroyed
+        return key.getFormat();
+    }
+
+    /**
+     * Returns the key material of this key.
+     *
+     * @return a newly allocated byte array that contains the key material
+     * @throws IllegalStateException if the key is destroyed
+     */
+    @Override
+    public byte[] getEncoded() {
+        // KeyImpl already checked if destroyed
+        return key.getEncoded();
+    }
+
+    /**
+     * Destroys this key by clearing out the key material of this key.
+     *
+     * @throws DestroyFailedException if some error occurs while destorying
+     * this key.
+     */
+    @Override
+    public void destroy() throws DestroyFailedException {
+        if (!destroyed) {
+            key.destroy();
+            destroyed = true;
+        }
+    }
+
+
+    @Override
+    public boolean isDestroyed() {
+        return destroyed;
+    }
+
+    @Override
+    public String toString() {
+        if (destroyed) {
+            return "Destroyed EncryptionKey";
+        }
+        return "key "  + key.toString();
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 17;
+        if (isDestroyed()) {
+            return result;
+        }
+        result = 37 * result + Arrays.hashCode(getEncoded());
+        return 37 * result + getKeyType();
+    }
+
+    /**
+     * Compares the specified Object with this key for equality.
+     * Returns true if the given object is also a
+     * {@code EncryptionKey} and the two
+     * {@code EncryptionKey} instances are equivalent.
+     *
+     * @param other the Object to compare to
+     * @return true if the specified object is equal to this EncryptionKey,
+     * false otherwise. NOTE: Returns false if either of the EncryptionKey
+     * objects has been destroyed.
+     */
+    @Override
+    public boolean equals(Object other) {
+
+        if (other == this)
+            return true;
+
+        if (! (other instanceof EncryptionKey)) {
+            return false;
+        }
+
+        EncryptionKey otherKey = ((EncryptionKey) other);
+        if (isDestroyed() || otherKey.isDestroyed()) {
+            return false;
+        }
+
+        return getKeyType() == otherKey.getKeyType()
+                && Arrays.equals(getEncoded(), otherKey.getEncoded());
+    }
+}
diff --git a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee2010b1531ba6bf0c0d461e96bfdb6e68d8d2b3
--- /dev/null
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+package javax.security.auth.kerberos;
+
+import javax.security.auth.Destroyable;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+/**
+ * This class encapsulates a Kerberos 5 KRB_CRED message which can be used to
+ * send Kerberos credentials from one principal to another.<p>
+ *
+ * A KRB_CRED message is defined in Section 5.8.1 of the Kerberos Protocol
+ * Specification (<a href=http://www.ietf.org/rfc/rfc4120.txt>RFC 4120</a>) as:
+ * <pre>
+ *    KRB-CRED        ::= [APPLICATION 22] SEQUENCE {
+ *            pvno            [0] INTEGER (5),
+ *            msg-type        [1] INTEGER (22),
+ *            tickets         [2] SEQUENCE OF Ticket,
+ *            enc-part        [3] EncryptedData -- EncKrbCredPart
+ *    }
+ * </pre><p>
+ *
+ * @since 1.9
+ */
+public final class KerberosCredMessage implements Destroyable {
+
+    final private KerberosPrincipal sender;
+    final private KerberosPrincipal recipient;
+    final private byte[] message;
+
+    private boolean destroyed = false;
+
+    /**
+     * Constructs a {@code KerberosCredMessage} object.
+     * <p>
+     * The contents of the {@code message} argument are copied; subsequent
+     * modification of the byte array does not affect the newly created object.
+     *
+     * @param sender the sender of the message
+     * @param recipient the recipient of the message
+     * @param message the DER encoded KRB_CRED message
+     * @throws NullPointerException if any of sender, recipient
+     *                              or message is null
+     */
+    public KerberosCredMessage(KerberosPrincipal sender,
+                               KerberosPrincipal recipient,
+                               byte[] message) {
+        this.sender = Objects.requireNonNull(sender);
+        this.recipient = Objects.requireNonNull(recipient);
+        this.message = Objects.requireNonNull(message).clone();
+    }
+
+    /**
+     * Returns the DER encoded form of the KRB_CRED message.
+     *
+     * @return a newly allocated byte array that contains the encoded form
+     * @throws IllegalStateException if the object is destroyed
+     */
+    public byte[] getEncoded() {
+        if (destroyed) {
+            throw new IllegalStateException("This object is no longer valid");
+        }
+        return message.clone();
+    }
+
+    /**
+     * Returns the sender of this message.
+     *
+     * @return the sender
+     * @throws IllegalStateException if the object is destroyed
+     */
+    public KerberosPrincipal getSender() {
+        if (destroyed) {
+            throw new IllegalStateException("This object is no longer valid");
+        }
+        return sender;
+    }
+
+    /**
+     * Returns the recipient of this message.
+     *
+     * @return the recipient
+     * @throws IllegalStateException if the object is destroyed
+     */
+    public KerberosPrincipal getRecipient() {
+        if (destroyed) {
+            throw new IllegalStateException("This object is no longer valid");
+        }
+        return recipient;
+    }
+
+    /**
+     * Destroys this object by clearing out the message.
+     */
+    @Override
+    public void destroy() {
+        if (!destroyed) {
+            Arrays.fill(message, (byte)0);
+            destroyed = true;
+        }
+    }
+
+    @Override
+    public boolean isDestroyed() {
+        return destroyed;
+    }
+
+    @Override
+    public String toString() {
+        if (destroyed) {
+            return "Destroyed KerberosCredMessage";
+        } else {
+            return "KRB_CRED from " + sender + " to " + recipient + ":\n"
+                    + Base64.getUrlEncoder().encodeToString(message);
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        if (isDestroyed()) {
+            return -1;
+        } else {
+            return Objects.hash(sender, recipient, Arrays.hashCode(message));
+        }
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+
+        if (! (other instanceof KerberosCredMessage)) {
+            return false;
+        }
+
+        KerberosCredMessage otherMessage = ((KerberosCredMessage) other);
+        if (isDestroyed() || otherMessage.isDestroyed()) {
+            return false;
+        }
+
+        return Objects.equals(sender, otherMessage.sender)
+                && Objects.equals(recipient, otherMessage.recipient)
+                && Arrays.equals(message, otherMessage.message);
+    }
+}
diff --git a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosKey.java b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosKey.java
index a8d12131aafc606a831c8e016a8093f4cf0a5d92..b233052f44f5721e8dad6cf93ba458fb3fd13f11 100644
--- a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosKey.java
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosKey.java
@@ -27,13 +27,27 @@ package javax.security.auth.kerberos;
 
 import java.util.Arrays;
 import javax.crypto.SecretKey;
-import javax.security.auth.Destroyable;
 import javax.security.auth.DestroyFailedException;
 
 /**
  * This class encapsulates a long term secret key for a Kerberos
  * principal.<p>
  *
+ * A {@code KerberosKey} object includes an EncryptionKey, a
+ * {@link KerberosPrincipal} as its owner, and the version number
+ * of the key.<p>
+ *
+ * An EncryptionKey is defined in Section 4.2.9 of the Kerberos Protocol
+ * Specification (<a href=http://www.ietf.org/rfc/rfc4120.txt>RFC 4120</a>) as:
+ * <pre>
+ *     EncryptionKey   ::= SEQUENCE {
+ *             keytype         [0] Int32 -- actually encryption type --,
+ *             keyvalue        [1] OCTET STRING
+ *     }
+ * </pre>
+ * The key material of a {@code KerberosKey} is defined as the value
+ * of the {@code keyValue} above.<p>
+ *
  * All Kerberos JAAS login modules that obtain a principal's password and
  * generate the secret key from it should use this class.
  * Sometimes, such as when authenticating a server in
@@ -70,7 +84,7 @@ import javax.security.auth.DestroyFailedException;
  * @author Mayank Upadhyay
  * @since 1.4
  */
-public class KerberosKey implements SecretKey, Destroyable {
+public class KerberosKey implements SecretKey {
 
     private static final long serialVersionUID = -4625402278148246993L;
 
@@ -89,15 +103,8 @@ public class KerberosKey implements SecretKey, Destroyable {
     private final int versionNum;
 
    /**
-    * {@code KeyImpl} is serialized by writing out the ASN1 Encoded bytes
+    * {@code KeyImpl} is serialized by writing out the ASN.1 encoded bytes
     * of the encryption key.
-    * The ASN1 encoding is defined in RFC4120 and as  follows:
-    * <pre>
-    * EncryptionKey   ::= SEQUENCE {
-    *           keytype   [0] Int32 -- actually encryption type --,
-    *           keyvalue  [1] OCTET STRING
-    * }
-    * </pre>
     *
     * @serial
     */
@@ -111,7 +118,7 @@ public class KerberosKey implements SecretKey, Destroyable {
      * key information from a Kerberos "keytab".
      *
      * @param principal the principal that this secret key belongs to
-     * @param keyBytes the raw bytes for the secret key
+     * @param keyBytes the key material for the secret key
      * @param keyType the key type for the secret key as defined by the
      * Kerberos protocol specification.
      * @param versionNum the version number of this secret key
@@ -153,10 +160,12 @@ public class KerberosKey implements SecretKey, Destroyable {
      * Returns the principal that this key belongs to.
      *
      * @return the principal this key belongs to.
+     * @throws IllegalStateException if the key is destroyed
      */
     public final KerberosPrincipal getPrincipal() {
-        if (destroyed)
+        if (destroyed) {
             throw new IllegalStateException("This key is no longer valid");
+        }
         return principal;
     }
 
@@ -164,10 +173,12 @@ public class KerberosKey implements SecretKey, Destroyable {
      * Returns the key version number.
      *
      * @return the key version number.
+     * @throws IllegalStateException if the key is destroyed
      */
     public final int getVersionNumber() {
-        if (destroyed)
+        if (destroyed) {
             throw new IllegalStateException("This key is no longer valid");
+        }
         return versionNum;
     }
 
@@ -175,10 +186,10 @@ public class KerberosKey implements SecretKey, Destroyable {
      * Returns the key type for this long-term key.
      *
      * @return the key type.
+     * @throws IllegalStateException if the key is destroyed
      */
     public final int getKeyType() {
-        if (destroyed)
-            throw new IllegalStateException("This key is no longer valid");
+        // KeyImpl already checked if destroyed
         return key.getKeyType();
     }
 
@@ -201,10 +212,10 @@ public class KerberosKey implements SecretKey, Destroyable {
      * </ol>
      *
      * @return the name of the algorithm associated with this key.
+     * @throws IllegalStateException if the key is destroyed
      */
     public final String getAlgorithm() {
-        if (destroyed)
-            throw new IllegalStateException("This key is no longer valid");
+        // KeyImpl already checked if destroyed
         return key.getAlgorithm();
     }
 
@@ -212,10 +223,10 @@ public class KerberosKey implements SecretKey, Destroyable {
      * Returns the name of the encoding format for this secret key.
      *
      * @return the String "RAW"
+     * @throws IllegalStateException if the key is destroyed
      */
     public final String getFormat() {
-        if (destroyed)
-            throw new IllegalStateException("This key is no longer valid");
+        // KeyImpl already checked if destroyed
         return key.getFormat();
     }
 
@@ -223,16 +234,15 @@ public class KerberosKey implements SecretKey, Destroyable {
      * Returns the key material of this secret key.
      *
      * @return the key material
+     * @throws IllegalStateException if the key is destroyed
      */
     public final byte[] getEncoded() {
-        if (destroyed)
-            throw new IllegalStateException("This key is no longer valid");
+        // KeyImpl already checked if destroyed
         return key.getEncoded();
     }
 
     /**
-     * Destroys this key. A call to any of its other methods after this
-     * will cause an  IllegalStateException to be thrown.
+     * Destroys this key by clearing out the key material of this secret key.
      *
      * @throws DestroyFailedException if some error occurs while destorying
      * this key.
@@ -253,9 +263,9 @@ public class KerberosKey implements SecretKey, Destroyable {
 
     public String toString() {
         if (destroyed) {
-            return "Destroyed Principal";
+            return "Destroyed KerberosKey";
         }
-        return "Kerberos Principal " + principal.toString() +
+        return "Kerberos Principal " + principal +
                 "Key Version " + versionNum +
                 "key "  + key.toString();
     }
@@ -293,8 +303,9 @@ public class KerberosKey implements SecretKey, Destroyable {
      */
     public boolean equals(Object other) {
 
-        if (other == this)
+        if (other == this) {
             return true;
+        }
 
         if (! (other instanceof KerberosKey)) {
             return false;
diff --git a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java
index da38df976e7bbdb0eb91bb0d35c6ae4e44d4218c..513b49c1fc0de9b2942d3ab8382223dbfebb4eed 100644
--- a/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/KerberosTicket.java
@@ -35,9 +35,6 @@ import javax.security.auth.Destroyable;
 import javax.security.auth.RefreshFailedException;
 import javax.security.auth.DestroyFailedException;
 import sun.misc.HexDumpEncoder;
-import sun.security.krb5.EncryptionKey;
-import sun.security.krb5.Asn1Exception;
-import sun.security.util.*;
 
 /**
  * This class encapsulates a Kerberos ticket and associated
@@ -253,9 +250,10 @@ public class KerberosTicket implements Destroyable, Refreshable,
                          Date endTime,
                          Date renewTill,
                          InetAddress[] clientAddresses) {
-        if (sessionKey == null)
-           throw new IllegalArgumentException("Session key for ticket"
-                                              + " cannot be null");
+        if (sessionKey == null) {
+            throw new IllegalArgumentException("Session key for ticket"
+                    + " cannot be null");
+        }
         init(asn1Encoding, client, server,
              new KeyImpl(sessionKey, keyType), flags, authTime,
              startTime, endTime, renewTill, clientAddresses);
@@ -271,41 +269,46 @@ public class KerberosTicket implements Destroyable, Refreshable,
                          Date endTime,
                          Date renewTill,
                          InetAddress[] clientAddresses) {
-        if (asn1Encoding == null)
-           throw new IllegalArgumentException("ASN.1 encoding of ticket"
-                                              + " cannot be null");
+        if (asn1Encoding == null) {
+            throw new IllegalArgumentException("ASN.1 encoding of ticket"
+                    + " cannot be null");
+        }
         this.asn1Encoding = asn1Encoding.clone();
 
-        if (client == null)
-           throw new IllegalArgumentException("Client name in ticket"
-                                              + " cannot be null");
+        if (client == null) {
+            throw new IllegalArgumentException("Client name in ticket"
+                    + " cannot be null");
+        }
         this.client = client;
 
-        if (server == null)
-           throw new IllegalArgumentException("Server name in ticket"
-                                              + " cannot be null");
+        if (server == null) {
+            throw new IllegalArgumentException("Server name in ticket"
+                    + " cannot be null");
+        }
         this.server = server;
 
         // Caller needs to make sure `sessionKey` will not be null
         this.sessionKey = sessionKey;
 
         if (flags != null) {
-           if (flags.length >= NUM_FLAGS)
-                this.flags = flags.clone();
-           else {
+           if (flags.length >= NUM_FLAGS) {
+               this.flags = flags.clone();
+           } else {
                 this.flags = new boolean[NUM_FLAGS];
                 // Fill in whatever we have
-                for (int i = 0; i < flags.length; i++)
+                for (int i = 0; i < flags.length; i++) {
                     this.flags[i] = flags[i];
+                }
            }
-        } else
-           this.flags = new boolean[NUM_FLAGS];
+        } else {
+            this.flags = new boolean[NUM_FLAGS];
+        }
 
         if (this.flags[RENEWABLE_TICKET_FLAG]) {
-           if (renewTill == null)
-                throw new IllegalArgumentException("The renewable period "
+           if (renewTill == null) {
+               throw new IllegalArgumentException("The renewable period "
                        + "end time cannot be null for renewable tickets.");
-
+           }
            this.renewTill = new Date(renewTill.getTime());
         }
 
@@ -318,13 +321,15 @@ public class KerberosTicket implements Destroyable, Refreshable,
             this.startTime = this.authTime;
         }
 
-        if (endTime == null)
-           throw new IllegalArgumentException("End time for ticket validity"
-                                              + " cannot be null");
+        if (endTime == null) {
+            throw new IllegalArgumentException("End time for ticket validity"
+                    + " cannot be null");
+        }
         this.endTime = new Date(endTime.getTime());
 
-        if (clientAddresses != null)
-           this.clientAddresses = clientAddresses.clone();
+        if (clientAddresses != null) {
+            this.clientAddresses = clientAddresses.clone();
+        }
     }
 
     /**
@@ -346,14 +351,17 @@ public class KerberosTicket implements Destroyable, Refreshable,
     }
 
     /**
-     * Returns the session key associated with this ticket.
+     * Returns the session key associated with this ticket. The return value
+     * is always a {@link EncryptionKey} object.
      *
      * @return the session key.
      */
     public final SecretKey getSessionKey() {
-        if (destroyed)
+        if (destroyed) {
             throw new IllegalStateException("This ticket is no longer valid");
-        return sessionKey;
+        }
+        return new EncryptionKey(
+                sessionKey.getEncoded(), sessionKey.getKeyType());
     }
 
     /**
@@ -366,8 +374,9 @@ public class KerberosTicket implements Destroyable, Refreshable,
      * @see #getSessionKey()
      */
     public final int getSessionKeyType() {
-        if (destroyed)
+        if (destroyed) {
             throw new IllegalStateException("This ticket is no longer valid");
+        }
         return sessionKey.getKeyType();
     }
 
@@ -508,8 +517,9 @@ public class KerberosTicket implements Destroyable, Refreshable,
      * @return an ASN.1 encoding of the entire ticket.
      */
     public final byte[] getEncoded() {
-        if (destroyed)
+        if (destroyed) {
             throw new IllegalStateException("This ticket is no longer valid");
+        }
         return asn1Encoding.clone();
     }
 
@@ -539,16 +549,17 @@ public class KerberosTicket implements Destroyable, Refreshable,
      */
     public void refresh() throws RefreshFailedException {
 
-        if (destroyed)
+        if (destroyed) {
             throw new RefreshFailedException("A destroyed ticket "
-                                             + "cannot be renewd.");
-
-        if (!isRenewable())
+                    + "cannot be renewd.");
+        }
+        if (!isRenewable()) {
             throw new RefreshFailedException("This ticket is not renewable");
-
-        if (System.currentTimeMillis() > getRenewTill().getTime())
+        }
+        if (System.currentTimeMillis() > getRenewTill().getTime()) {
             throw new RefreshFailedException("This ticket is past "
-                                             + "its last renewal time.");
+                                           + "its last renewal time.");
+        }
         Throwable e = null;
         sun.security.krb5.Credentials krb5Creds = null;
 
@@ -634,8 +645,9 @@ public class KerberosTicket implements Destroyable, Refreshable,
     }
 
     public String toString() {
-        if (destroyed)
-            throw new IllegalStateException("This ticket is no longer valid");
+        if (destroyed) {
+            return "Destroyed KerberosTicket";
+        }
         StringBuilder caddrString = new StringBuilder();
         if (clientAddresses != null) {
             for (int i = 0; i < clientAddresses.length; i++) {
@@ -715,8 +727,9 @@ public class KerberosTicket implements Destroyable, Refreshable,
      */
     public boolean equals(Object other) {
 
-        if (other == this)
+        if (other == this) {
             return true;
+        }
 
         if (! (other instanceof KerberosTicket)) {
             return false;
@@ -731,7 +744,7 @@ public class KerberosTicket implements Destroyable, Refreshable,
                 !endTime.equals(otherTicket.getEndTime()) ||
                 !server.equals(otherTicket.getServer()) ||
                 !client.equals(otherTicket.getClient()) ||
-                !sessionKey.equals(otherTicket.getSessionKey()) ||
+                !sessionKey.equals(otherTicket.sessionKey) ||
                 !Arrays.equals(clientAddresses, otherTicket.getClientAddresses()) ||
                 !Arrays.equals(flags, otherTicket.getFlags())) {
             return false;
@@ -739,35 +752,41 @@ public class KerberosTicket implements Destroyable, Refreshable,
 
         // authTime may be null
         if (authTime == null) {
-            if (otherTicket.getAuthTime() != null)
+            if (otherTicket.getAuthTime() != null) {
                 return false;
+            }
         } else {
-            if (!authTime.equals(otherTicket.getAuthTime()))
+            if (!authTime.equals(otherTicket.getAuthTime())) {
                 return false;
+            }
         }
 
         // startTime may be null
         if (startTime == null) {
-            if (otherTicket.getStartTime() != null)
+            if (otherTicket.getStartTime() != null) {
                 return false;
+            }
         } else {
-            if (!startTime.equals(otherTicket.getStartTime()))
+            if (!startTime.equals(otherTicket.getStartTime())) {
                 return false;
+            }
         }
 
         if (renewTill == null) {
-            if (otherTicket.getRenewTill() != null)
+            if (otherTicket.getRenewTill() != null) {
                 return false;
+            }
         } else {
-            if (!renewTill.equals(otherTicket.getRenewTill()))
+            if (!renewTill.equals(otherTicket.getRenewTill())) {
                 return false;
+            }
         }
 
         return true;
     }
 
     private void readObject(ObjectInputStream s)
-        throws IOException, ClassNotFoundException {
+            throws IOException, ClassNotFoundException {
         s.defaultReadObject();
         if (sessionKey == null) {
            throw new InvalidObjectException("Session key cannot be null");
diff --git a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
index 61aa8a6b2463e496cb48d783baa6e5e27443e941..12939570d2b3a95cd5c377cc0961a7d1aa558f22 100644
--- a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
+++ b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
@@ -364,7 +364,7 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
         }
 
         void getMethods() throws ClassNotFoundException, NoSuchMethodException {
-            Class<?> c  = Class.forName("sun.security.ec.ECParameters");
+            Class<?> c  = Class.forName("sun.security.util.ECParameters");
             Class<?>[] params = new Class<?>[] { ECPoint.class,
                                                  EllipticCurve.class };
             encodePoint = c.getMethod("encodePoint", params);
@@ -372,7 +372,7 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
             getCurveName = c.getMethod("getCurveName", params);
             params = new Class<?>[] { byte[].class, EllipticCurve.class };
             decodePoint = c.getMethod("decodePoint", params);
-            c  = Class.forName("sun.security.ec.NamedCurve");
+            c  = Class.forName("sun.security.util.NamedCurve");
             params = new Class<?>[] { String.class };
             getECParameterSpec = c.getMethod("getECParameterSpec", params);
         }
@@ -477,7 +477,7 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue {
                 throw new MarshalException(ite);
             }
 /*
-                ecPoint = sun.security.ec.ECParameters.decodePoint(
+                ecPoint = sun.security.util.ECParameters.decodePoint(
                     Base64.decode(curElem), ecParams.getCurve());
 */
             ECPublicKeySpec spec = new ECPublicKeySpec(ecPoint, ecParams);
diff --git a/jdk/src/share/classes/sun/misc/JavaLangAccess.java b/jdk/src/share/classes/sun/misc/JavaLangAccess.java
index 812f88e20988d7011b6c85eb21c2aab0aadf7d39..a86453df43073f83b8d7f592e1e10a7a4b4a5541 100644
--- a/jdk/src/share/classes/sun/misc/JavaLangAccess.java
+++ b/jdk/src/share/classes/sun/misc/JavaLangAccess.java
@@ -132,4 +132,14 @@ public interface JavaLangAccess {
      * Invokes the finalize method of the given object.
      */
     void invokeFinalize(Object o) throws Throwable;
+
+    /**
+     * Invokes Long.formatUnsignedLong(long val, int shift, char[] buf, int offset, int len)
+     */
+    void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len);
+
+    /**
+     * Invokes Integer.formatUnsignedInt(long val, int shift, char[] buf, int offset, int len)
+     */
+    void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len);
 }
diff --git a/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java
index 91b676c2c0c9e30362b1ed4fa7800aeebf254696..7b1db203305ec670562ae026adbd362de777ebd3 100644
--- a/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java
+++ b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java
@@ -1173,8 +1173,7 @@ public class ExtendedCharsets
         if (!sun.misc.VM.isBooted())
             return;
 
-        String map = AccessController.doPrivileged(
-            (PrivilegedAction<String>) () -> System.getProperty("sun.nio.cs.map"));
+        String map = getProperty("sun.nio.cs.map");
         boolean sjisIsMS932 = false;
         boolean iso2022jpIsMS50221 = false;
         boolean iso2022jpIsMS50220 = false;
@@ -1294,8 +1293,7 @@ public class ExtendedCharsets
 
             }
         }
-        String osName = AccessController.doPrivileged(
-            (PrivilegedAction<String>) () -> System.getProperty("os.name"));
+        String osName = getProperty("os.name");
         if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName)
                || osName.contains("OS X")) {
             charset("x-COMPOUND_TEXT", "COMPOUND_TEXT",
@@ -1308,6 +1306,18 @@ public class ExtendedCharsets
         initialized = true;
     }
 
+    private static String getProperty(String key) {
+        // this method may be called during initialization of
+        // system class loader and thus not using lambda
+        return AccessController.doPrivileged(
+            new PrivilegedAction<String>() {
+                @Override
+                public String run() {
+                    return System.getProperty(key);
+                }
+            });
+    }
+
     public static String[] aliasesFor(String charsetName) {
         if (instance == null)
             return null;
diff --git a/jdk/src/share/classes/sun/security/ec/ECKeyPairGenerator.java b/jdk/src/share/classes/sun/security/ec/ECKeyPairGenerator.java
index b70d7f4ca648f913e693a177092a4190c9df80c8..2df53fb60ed553ebfaeacb87ad52835d70527b6a 100644
--- a/jdk/src/share/classes/sun/security/ec/ECKeyPairGenerator.java
+++ b/jdk/src/share/classes/sun/security/ec/ECKeyPairGenerator.java
@@ -32,11 +32,10 @@ import java.security.spec.ECGenParameterSpec;
 import java.security.spec.ECParameterSpec;
 import java.security.spec.ECPoint;
 
-import sun.security.ec.NamedCurve;
-import sun.security.ec.ECParameters;
 import sun.security.ec.ECPrivateKeyImpl;
 import sun.security.ec.ECPublicKeyImpl;
 import sun.security.jca.JCAUtil;
+import sun.security.util.ECParameters;
 import sun.security.util.ECUtil;
 
 /**
diff --git a/jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java b/jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java
index b974c3ca86cc4b505e04efd6c2ebd98436c9a00f..ef3b87639f2222b9f7dbbe1504082349f5ccf759 100644
--- a/jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java
+++ b/jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java
@@ -32,7 +32,11 @@ import java.security.*;
 import java.security.interfaces.*;
 import java.security.spec.*;
 
-import sun.security.util.*;
+import sun.security.util.DerInputStream;
+import sun.security.util.DerOutputStream;
+import sun.security.util.DerValue;
+import sun.security.util.ECParameters;
+import sun.security.util.ECUtil;
 import sun.security.x509.AlgorithmId;
 import sun.security.pkcs.PKCS8Key;
 
diff --git a/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java b/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java
index 0e82e734e4aed479d8f6a8f692f85c177749b06e..bc403026c4d2b2e75449654e01bd4b490ac2ec69 100644
--- a/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java
+++ b/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java
@@ -31,7 +31,9 @@ import java.security.*;
 import java.security.interfaces.*;
 import java.security.spec.*;
 
-import sun.security.util.*;
+import sun.security.util.ECParameters;
+import sun.security.util.ECUtil;
+
 import sun.security.x509.*;
 
 /**
diff --git a/jdk/src/share/classes/sun/security/ec/SunECEntries.java b/jdk/src/share/classes/sun/security/ec/SunECEntries.java
index 4e297183453b3c59e3e26d8fab77d40ebc0a7009..aa6ad6e7cc37d55da600ecd131ec2c3a08376feb 100644
--- a/jdk/src/share/classes/sun/security/ec/SunECEntries.java
+++ b/jdk/src/share/classes/sun/security/ec/SunECEntries.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -29,6 +29,8 @@ import java.util.Collection;
 import java.util.Map;
 
 import java.util.regex.Pattern;
+import sun.security.util.CurveDB;
+import sun.security.util.NamedCurve;
 
 /**
  * Defines the entries of the SunEC provider.
@@ -55,7 +57,7 @@ final class SunECEntries {
         /*
          * Algorithm Parameter engine
          */
-        map.put("AlgorithmParameters.EC", "sun.security.ec.ECParameters");
+        map.put("AlgorithmParameters.EC", "sun.security.util.ECParameters");
         map.put("Alg.Alias.AlgorithmParameters.EllipticCurve", "EC");
         map.put("Alg.Alias.AlgorithmParameters.1.2.840.10045.2.1", "EC");
 
diff --git a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Context.java b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Context.java
index 53c13f0894f2ae8a7e540191075a2ebf2a8f5c3b..abce4c05987be9e2801f1bf9b5a7b933ab563ff2 100644
--- a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Context.java
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Context.java
@@ -40,11 +40,13 @@ import java.security.Provider;
 import java.security.AccessController;
 import java.security.AccessControlContext;
 import java.security.Key;
-import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedActionException;
-import javax.crypto.Cipher;
+import java.security.PrivilegedExceptionAction;
 import javax.security.auth.Subject;
-import javax.security.auth.kerberos.*;
+import javax.security.auth.kerberos.ServicePermission;
+import javax.security.auth.kerberos.KerberosCredMessage;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.kerberos.KerberosTicket;
 import sun.security.krb5.internal.Ticket;
 
 /**
@@ -118,6 +120,7 @@ class Krb5Context implements GSSContextSpi {
 
     // XXX See if the required info from these can be extracted and
     // stored elsewhere
+    private Credentials tgt;
     private Credentials serviceCreds;
     private KrbApReq apReq;
     Ticket serviceTicket;
@@ -616,7 +619,6 @@ class Krb5Context implements GSSContextSpi {
                                            "No TGT available");
                     }
                     myName = (Krb5NameElement) myCred.getName();
-                    Credentials tgt;
                     final Krb5ProxyCredential second;
                     if (myCred instanceof Krb5InitCredential) {
                         second = null;
@@ -750,7 +752,6 @@ class Krb5Context implements GSSContextSpi {
                     // No need to write anything;
                     // just validate the incoming token
                     new AcceptSecContextToken(this, serviceCreds, apReq, is);
-                    serviceCreds = null;
                     apReq = null;
                     state = STATE_DONE;
                 } else {
@@ -1304,6 +1305,9 @@ class Krb5Context implements GSSContextSpi {
     public final void dispose() throws GSSException {
         state = STATE_DELETED;
         delegatedCred = null;
+        tgt = null;
+        serviceCreds = null;
+        key = null;
     }
 
     public final Provider getProvider() {
@@ -1424,6 +1428,9 @@ class Krb5Context implements GSSContextSpi {
         switch (type) {
             case KRB5_GET_SESSION_KEY:
                 return new KerberosSessionKey(key);
+            case KRB5_GET_SESSION_KEY_EX:
+                return new javax.security.auth.kerberos.EncryptionKey(
+                        key.getBytes(), key.getEType());
             case KRB5_GET_TKT_FLAGS:
                 return tktFlags.clone();
             case KRB5_GET_AUTHZ_DATA:
@@ -1435,6 +1442,26 @@ class Krb5Context implements GSSContextSpi {
                 }
             case KRB5_GET_AUTHTIME:
                 return authTime;
+            case KRB5_GET_KRB_CRED:
+                if (!isInitiator()) {
+                    throw new GSSException(GSSException.UNAVAILABLE, -1,
+                            "KRB_CRED not available on acceptor side.");
+                }
+                KerberosPrincipal sender = new KerberosPrincipal(
+                        myName.getKrb5PrincipalName().getName());
+                KerberosPrincipal recipient = new KerberosPrincipal(
+                        peerName.getKrb5PrincipalName().getName());
+                try {
+                    byte[] krbCred = new KrbCred(tgt, serviceCreds, key)
+                            .getMessage();
+                    return new KerberosCredMessage(
+                            sender, recipient, krbCred);
+                } catch (KrbException | IOException e) {
+                    GSSException gsse = new GSSException(GSSException.UNAVAILABLE, -1,
+                            "KRB_CRED not generated correctly.");
+                    gsse.initCause(e);
+                    throw gsse;
+                }
         }
         throw new GSSException(GSSException.UNAVAILABLE, -1,
                 "Inquire type not supported.");
@@ -1456,4 +1483,5 @@ class Krb5Context implements GSSContextSpi {
     public void setAuthzData(com.sun.security.jgss.AuthorizationDataEntry[] authzData) {
         this.authzData = authzData;
     }
+
 }
diff --git a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java
index 536f927aa30429200d9fa078311a111f7bc00513..aabe0a103de7cc7dafd0674ddaed675f3a6c5c6c 100644
--- a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5InitCredential.java
@@ -29,8 +29,8 @@ import org.ietf.jgss.*;
 import sun.security.jgss.GSSCaller;
 import sun.security.jgss.spi.*;
 import sun.security.krb5.*;
-import sun.security.krb5.Config;
-import javax.security.auth.kerberos.*;
+import javax.security.auth.kerberos.KerberosTicket;
+import javax.security.auth.kerberos.KerberosPrincipal;
 import java.net.InetAddress;
 import java.io.IOException;
 import java.util.Date;
diff --git a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
index 1c66bf53897f4279b1eaa090e4681ebf91275fe7..2390639537bddb80e583d8188f23f71c2ea72a7a 100644
--- a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
+++ b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
@@ -523,13 +523,6 @@ public class SpNegoContext implements GSSContextSpi {
                     valid = false;
                 }
 
-                // get the mechanism token
-                byte[] mechToken = initToken.getMechToken();
-                if (mechToken == null) {
-                    throw new GSSException(GSSException.FAILURE, -1,
-                            "mechToken is missing");
-                }
-
                 /*
                  * Select the best match between the list of mechs
                  * that the initiator requested and the list that
@@ -545,7 +538,19 @@ public class SpNegoContext implements GSSContextSpi {
                 internal_mech = mech_wanted;
 
                 // get the token for mechanism
-                byte[] accept_token = GSS_acceptSecContext(mechToken);
+                byte[] accept_token;
+
+                if (mechList[0].equals(mech_wanted)) {
+                    // get the mechanism token
+                    byte[] mechToken = initToken.getMechToken();
+                    if (mechToken == null) {
+                        throw new GSSException(GSSException.FAILURE, -1,
+                                "mechToken is missing");
+                    }
+                    accept_token = GSS_acceptSecContext(mechToken);
+                } else {
+                    accept_token = null;
+                }
 
                 // verify MIC
                 if (!GSSUtil.useMSInterop() && valid) {
@@ -594,9 +599,27 @@ public class SpNegoContext implements GSSContextSpi {
                 retVal = targToken.getEncoded();
 
             } else if (state == STATE_IN_PROCESS) {
+                // read data
+                byte[] token = new byte[is.available()];
+                SpNegoToken.readFully(is, token);
+                if (DEBUG) {
+                    System.out.println("SpNegoContext.acceptSecContext: " +
+                            "receiving token = " +
+                            SpNegoToken.getHexBytes(token));
+                }
+
+                // read the SPNEGO token
+                // token will be validated when parsing
+                NegTokenTarg inputToken = new NegTokenTarg(token);
+
+                if (DEBUG) {
+                    System.out.println("SpNegoContext.acceptSecContext: " +
+                            "received token of type = " +
+                            SpNegoToken.getTokenName(inputToken.getType()));
+                }
+
                 // read the token
-                byte[] client_token = new byte[is.available()];
-                SpNegoToken.readFully(is, client_token);
+                byte[] client_token = inputToken.getResponseToken();
                 byte[] accept_token = GSS_acceptSecContext(client_token);
                 if (accept_token == null) {
                     valid = false;
@@ -1055,7 +1078,7 @@ public class SpNegoContext implements GSSContextSpi {
      * This is only valid on the acceptor side of the context.
      * @return GSSCredentialSpi object for the delegated credential
      * @exception GSSException
-     * @see GSSContext#getDelegCredState
+     * @see GSSContext#getCredDelegState
      */
     public final GSSCredentialSpi getDelegCred() throws GSSException {
         if (state != STATE_IN_PROCESS && state != STATE_DONE)
diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java b/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java
index 32002c2885a664f616ab327793889f3f5cdb101a..436613c160245e3d6b4c53f8b36c79045002c8c7 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java
@@ -67,8 +67,6 @@ import sun.security.util.Debug;
 import sun.security.util.DerValue;
 import sun.security.util.ECUtil;
 
-import sun.security.ec.ECParameters;
-
 import sun.security.pkcs11.Secmod.*;
 import static sun.security.pkcs11.P11Util.*;
 
diff --git a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java
index 630cff1e41ee661f56c4e0f6bbd20c01eb766133..74e5d1e56af593f83a41a3cd1584937cebc51866 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java
@@ -593,7 +593,7 @@ public final class SunPKCS11 extends AuthProvider {
 
         // AlgorithmParameters for EC.
         // Only needed until we have an EC implementation in the SUN provider.
-        d(AGP, "EC",            "sun.security.ec.ECParameters",
+        d(AGP, "EC",            "sun.security.util.ECParameters",
                                                 s("1.2.840.10045.2.1"),
                 m(CKM_EC_KEY_PAIR_GEN, CKM_ECDH1_DERIVE,
                     CKM_ECDSA, CKM_ECDSA_SHA1));
@@ -1032,7 +1032,7 @@ public final class SunPKCS11 extends AuthProvider {
             } else if (type == KS) {
                 return token.getKeyStore();
             } else if (type == AGP) {
-                return new sun.security.ec.ECParameters();
+                return new sun.security.util.ECParameters();
             } else {
                 throw new NoSuchAlgorithmException("Unknown type: " + type);
             }
diff --git a/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java b/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java
index 8933fab1fbc90e8d05ef6146461c5fd33ea24f00..6278769586d0e80521d3012a3b133d6e42c781f0 100644
--- a/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java
+++ b/jdk/src/share/classes/sun/security/ssl/SupportedEllipticCurvesExtension.java
@@ -176,7 +176,7 @@ final class SupportedEllipticCurvesExtension extends HelloExtension {
     private final static int ARBITRARY_PRIME = 0xff01;
     private final static int ARBITRARY_CHAR2 = 0xff02;
 
-    // See sun.security.ec.NamedCurve for the OIDs
+    // See sun.security.util.NamedCurve for the OIDs
     private final static String[] NAMED_CURVE_OID_TABLE = new String[] {
         null,                   //  (0) unused
         "1.3.132.0.1",          //  (1) sect163k1, NIST K-163
diff --git a/jdk/src/share/classes/sun/security/ec/CurveDB.java b/jdk/src/share/classes/sun/security/util/CurveDB.java
similarity index 99%
rename from jdk/src/share/classes/sun/security/ec/CurveDB.java
rename to jdk/src/share/classes/sun/security/util/CurveDB.java
index 0e2db6809f3a248092510ecd01539e67bb9f9ccc..d10d644283787b0b2b1bd80df160edfea6cb8011 100644
--- a/jdk/src/share/classes/sun/security/ec/CurveDB.java
+++ b/jdk/src/share/classes/sun/security/util/CurveDB.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.security.ec;
+package sun.security.util;
 
 import java.math.BigInteger;
 
@@ -54,10 +54,10 @@ public class CurveDB {
 
     private static Collection<? extends NamedCurve> specCollection;
 
-    static final String SPLIT_PATTERN = ",|\\[|\\]";
+    public static final String SPLIT_PATTERN = ",|\\[|\\]";
 
     // Used by SunECEntries
-    static Collection<? extends NamedCurve>getSupportedCurves() {
+    public static Collection<? extends NamedCurve>getSupportedCurves() {
         return specCollection;
     }
 
diff --git a/jdk/src/share/classes/sun/security/ec/ECParameters.java b/jdk/src/share/classes/sun/security/util/ECParameters.java
similarity index 97%
rename from jdk/src/share/classes/sun/security/ec/ECParameters.java
rename to jdk/src/share/classes/sun/security/util/ECParameters.java
index 8292c95d2644a9aa462054daa04b92a748e4e224..317fad31ce4e92f74602ea5565e7da644f057758 100644
--- a/jdk/src/share/classes/sun/security/ec/ECParameters.java
+++ b/jdk/src/share/classes/sun/security/util/ECParameters.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -23,15 +23,13 @@
  * questions.
  */
 
-package sun.security.ec;
+package sun.security.util;
 
 import java.io.IOException;
 
 import java.security.*;
 import java.security.spec.*;
 
-import sun.security.util.*;
-
 /**
  * This class implements encoding and decoding of Elliptic Curve parameters
  * as specified in RFC 3279.
@@ -77,7 +75,7 @@ import sun.security.util.*;
 public final class ECParameters extends AlgorithmParametersSpi {
 
     // used by ECPublicKeyImpl and ECPrivateKeyImpl
-    static AlgorithmParameters getAlgorithmParameters(ECParameterSpec spec)
+    public static AlgorithmParameters getAlgorithmParameters(ECParameterSpec spec)
             throws InvalidKeyException {
         try {
             AlgorithmParameters params =
diff --git a/jdk/src/share/classes/sun/security/ec/NamedCurve.java b/jdk/src/share/classes/sun/security/util/NamedCurve.java
similarity index 88%
rename from jdk/src/share/classes/sun/security/ec/NamedCurve.java
rename to jdk/src/share/classes/sun/security/util/NamedCurve.java
index 97597c86e92246fcd50ede54cf5cf4a7ded9435d..0a677aad414d592040e96f46b2ddd9407dc100b9 100644
--- a/jdk/src/share/classes/sun/security/ec/NamedCurve.java
+++ b/jdk/src/share/classes/sun/security/util/NamedCurve.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -23,16 +23,13 @@
  * questions.
  */
 
-package sun.security.ec;
+package sun.security.util;
 
 import java.io.IOException;
 import java.math.BigInteger;
 
 import java.security.spec.*;
 
-import sun.security.util.DerOutputStream;
-import sun.security.util.ObjectIdentifier;
-
 
 /**
  * Contains Elliptic Curve parameters.
@@ -40,7 +37,7 @@ import sun.security.util.ObjectIdentifier;
  * @since   1.6
  * @author  Andreas Sterbenz
  */
-class NamedCurve extends ECParameterSpec {
+public final class NamedCurve extends ECParameterSpec {
 
     // friendly name for toString() output
     private final String name;
@@ -68,15 +65,15 @@ class NamedCurve extends ECParameterSpec {
         encoded = out.toByteArray();
     }
 
-    String getName() {
+    public String getName() {
         return name;
     }
 
-    byte[] getEncoded() {
+    public byte[] getEncoded() {
         return encoded.clone();
     }
 
-    String getObjectId() {
+    public String getObjectId() {
         return oid;
     }
 
diff --git a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
index 94fb2f72cebc7260365ca1a63bf203b01faa8120..411d1777a54d69907e2a37eeb5eb2b363face704 100644
--- a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
+++ b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c
@@ -388,6 +388,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue
     if (argsLen > 0) {
         if (argsLen > MAX_ARGS) {
             JNU_ThrowInternalError(env, "Too many arguments");
+            return;
         }
         for (i=0; i<argsLen; i++) {
             jobject obj = (*env)->GetObjectArrayElement(env, args, i);
@@ -423,6 +424,8 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue
     stubLen = (DWORD)(*env)->GetArrayLength(env, stub);
     stubCode = (*env)->GetByteArrayElements(env, stub, &isCopy);
 
+    if ((*env)->ExceptionOccurred(env)) return;
+
     pCode = (PDWORD) VirtualAllocEx( hProcess, 0, stubLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
     if (pCode == NULL) {
         JNU_ThrowIOExceptionWithLastError(env, "VirtualAllocEx failed");
@@ -592,6 +595,8 @@ static void jstring_to_cstring(JNIEnv* env, jstring jstr, char* cstr, int len) {
         cstr[0] = '\0';
     } else {
         str = JNU_GetStringPlatformChars(env, jstr, &isCopy);
+        if ((*env)->ExceptionOccurred(env)) return;
+
         strncpy(cstr, str, len);
         cstr[len-1] = '\0';
         if (isCopy) {
diff --git a/jdk/test/java/lang/Integer/ParsingTest.java b/jdk/test/java/lang/Integer/ParsingTest.java
index 699ae05d4bad3f3210cc4c1db32da3b4543b676f..920e81232a227de2c02437a58123cc0c9b98b64b 100644
--- a/jdk/test/java/lang/Integer/ParsingTest.java
+++ b/jdk/test/java/lang/Integer/ParsingTest.java
@@ -23,29 +23,37 @@
 
 /*
  * @test
- * @bug 5017980 6576055
+ * @bug 5017980 6576055 8041972
  * @summary Test parsing methods
  * @author Joseph D. Darcy
  */
 
+import java.lang.IllegalArgumentException;
+import java.lang.IndexOutOfBoundsException;
+import java.lang.NullPointerException;
+import java.lang.RuntimeException;
 
 /**
- * There are six methods in java.lang.Integer which transform strings
+ * There are eight methods in java.lang.Integer which transform strings
  * into an int or Integer value:
  *
  * public Integer(String s)
  * public static Integer decode(String nm)
+ * public static int parseInt(CharSequence s, int radix, int beginIndex, int endIndex)
+ * public static int parseInt(CharSequence s, int radix, int beginIndex)
  * public static int parseInt(String s, int radix)
  * public static int parseInt(String s)
  * public static Integer valueOf(String s, int radix)
  * public static Integer valueOf(String s)
  *
  * Besides decode, all the methods and constructor call down into
- * parseInt(String, int) to do the actual work.  Therefore, the
- * behavior of parseInt(String, int) will be tested here.
+ * parseInt(CharSequence, int, int, int) to do the actual work.  Therefore, the
+ * behavior of parseInt(CharSequence, int, int, int) will be tested here.
+ *
  */
 
 public class ParsingTest {
+
     public static void main(String... argv) {
         check("+100", +100);
         check("-100", -100);
@@ -55,10 +63,14 @@ public class ParsingTest {
         check("+00000", 0);
         check("-00000", 0);
 
+        check("+00000", 0, 0, 6);
+        check("-00000", 0, 0, 6);
+
         check("0", 0);
         check("1", 1);
         check("9", 9);
 
+        checkFailure("");
         checkFailure("\u0000");
         checkFailure("\u002f");
         checkFailure("+");
@@ -72,12 +84,45 @@ public class ParsingTest {
         checkFailure("+-6");
         checkFailure("-+6");
         checkFailure("*100");
+
+        check("test-00000", 0, 4, 10);
+        check("test-12345", -12345, 4, 10);
+        check("xx12345yy", 12345, 2, 7);
+
+        checkNumberFormatException("", 10, 0);
+        checkNumberFormatException("100", 10, 3);
+        checkNumberFormatException("+1000000", 10, 8);
+        checkNumberFormatException("-1000000", 10, 8);
+
+        checkNumberFormatException("", 10, 0, 0);
+        checkNumberFormatException("+-6", 10, 0, 3);
+        checkNumberFormatException("1000000", 10, 7);
+        checkNumberFormatException("1000000", 10, 7, 7);
+        checkNumberFormatException("1000000", Character.MAX_RADIX + 1, 0, 2);
+        checkNumberFormatException("1000000", Character.MIN_RADIX - 1, 0, 2);
+
+        checkIndexOutOfBoundsException("1000000", 10, 8);
+        checkIndexOutOfBoundsException("1000000", 10, -1);
+        checkIndexOutOfBoundsException("1000000", 10, 10, 4);
+        checkIndexOutOfBoundsException("1000000", Character.MAX_RADIX + 1, -1, 2);
+        checkIndexOutOfBoundsException("1000000", Character.MIN_RADIX - 1, -1, 2);
+        checkIndexOutOfBoundsException("1000000", Character.MAX_RADIX + 1, 10, 2);
+        checkIndexOutOfBoundsException("1000000", Character.MIN_RADIX - 1, 10, 2);
+        checkIndexOutOfBoundsException("-1", 10, 0, 3);
+        checkIndexOutOfBoundsException("-1", 10, 2, 3);
+        checkIndexOutOfBoundsException("-1", 10, -1, 2);
+
+        checkNull(10, 0, 1);
+        checkNull(10, -1, 0);
+        checkNull(10, 0, 0);
+        checkNull(10, 0, -1);
+        checkNull(-1, -1, -1);
     }
 
     private static void check(String val, int expected) {
         int n = Integer.parseInt(val);
         if (n != expected)
-            throw new RuntimeException("Integer.parsedInt failed. String:" +
+            throw new RuntimeException("Integer.parseInt failed. String:" +
                                                 val + " Result:" + n);
     }
 
@@ -91,4 +136,71 @@ public class ParsingTest {
             ; // Expected
         }
     }
+
+    private static void checkNumberFormatException(String val, int radix, int start) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(val, radix, start);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NumberFormatException nfe) {
+            ; // Expected
+        }
+    }
+
+    private static void checkNumberFormatException(String val, int radix, int start, int end) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(val, radix, start, end);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start + ", " + end +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NumberFormatException nfe) {
+            ; // Expected
+        }
+    }
+
+    private static void checkIndexOutOfBoundsException(String val, int radix, int start) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(val, radix, start);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (IndexOutOfBoundsException ioob) {
+            ; // Expected
+        }
+    }
+
+    private static void checkIndexOutOfBoundsException(String val, int radix, int start, int end) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(val, radix, start, end);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start + ", " + end +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (IndexOutOfBoundsException ioob) {
+            ; // Expected
+        }
+    }
+
+    private static void checkNull(int radix, int start, int end) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(null, 10, start, end);
+            System.err.println("parseInt(null, " + radix + ", " + start + ", " + end +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NullPointerException npe) {
+            ; // Expected
+        }
+    }
+
+    private static void check(String val, int expected, int start, int end) {
+        int n = Integer.parseInt(val, 10, start, end);
+        if (n != expected)
+            throw new RuntimeException("Integer.parsedInt failed. String:" +
+                    val + ", start: " + start + ", end: " + end + " Result:" + n);
+    }
 }
diff --git a/jdk/test/java/lang/Long/ParsingTest.java b/jdk/test/java/lang/Long/ParsingTest.java
index 79dfdf463bb4ea39b26f5ce96e6b471b84d9e33c..388c889ee6c710101847644c4132474c1ed9bb38 100644
--- a/jdk/test/java/lang/Long/ParsingTest.java
+++ b/jdk/test/java/lang/Long/ParsingTest.java
@@ -23,29 +23,31 @@
 
 /*
  * @test
- * @bug 5017980 6576055
+ * @bug 5017980 6576055 8041972
  * @summary Test parsing methods
  * @author Joseph D. Darcy
  */
 
-
 /**
- * There are six methods in java.lang.Long which transform strings
+ * There are eight methods in java.lang.Long which transform strings
  * into a long or Long value:
  *
  * public Long(String s)
  * public static Long decode(String nm)
+ * public static long parseLong(CharSequence s, int radix, int beginIndex, int endIndex)
+ * public static long parseLong(CharSequence s, int radix, int beginIndex)
  * public static long parseLong(String s, int radix)
  * public static long parseLong(String s)
  * public static Long valueOf(String s, int radix)
  * public static Long valueOf(String s)
  *
  * Besides decode, all the methods and constructor call down into
- * parseLong(String, int) to do the actual work.  Therefore, the
- * behavior of parseLong(String, int) will be tested here.
+ * parseLong(CharSequence, int, int, int) to do the actual work.  Therefore, the
+ * behavior of parseLong(CharSequence, int, int, int) will be tested here.
  */
 
 public class ParsingTest {
+
     public static void main(String... argv) {
         check("+100", +100L);
         check("-100", -100L);
@@ -59,6 +61,7 @@ public class ParsingTest {
         check("1", 1L);
         check("9", 9L);
 
+        checkFailure("");
         checkFailure("\u0000");
         checkFailure("\u002f");
         checkFailure("+");
@@ -72,12 +75,44 @@ public class ParsingTest {
         checkFailure("+-6");
         checkFailure("-+6");
         checkFailure("*100");
+
+        check("test-00000", 0L, 4, 10);
+        check("test-12345", -12345L, 4, 10);
+        check("xx12345yy", 12345L, 2, 7);
+        check("xx123456789012345yy", 123456789012345L, 2, 17);
+
+        checkNumberFormatException("100", 10, 3);
+        checkNumberFormatException("", 10, 0);
+        checkNumberFormatException("+1000000", 10, 8);
+        checkNumberFormatException("-1000000", 10, 8);
+
+        checkNumberFormatException("", 10, 0, 0);
+        checkNumberFormatException("+-6", 10, 0, 3);
+        checkNumberFormatException("1000000", 10, 7, 7);
+        checkNumberFormatException("1000000", Character.MAX_RADIX + 1, 0, 2);
+        checkNumberFormatException("1000000", Character.MIN_RADIX - 1, 0, 2);
+
+        checkIndexOutOfBoundsException("", 10, 1, 1);
+        checkIndexOutOfBoundsException("1000000", 10, 10, 4);
+        checkIndexOutOfBoundsException("1000000", Character.MAX_RADIX + 1, 10, 2);
+        checkIndexOutOfBoundsException("1000000", Character.MIN_RADIX - 1, 10, 2);
+        checkIndexOutOfBoundsException("1000000", Character.MAX_RADIX + 1, -1, 2);
+        checkIndexOutOfBoundsException("1000000", Character.MIN_RADIX - 1, -1, 2);
+        checkIndexOutOfBoundsException("-1", 10, 0, 3);
+        checkIndexOutOfBoundsException("-1", 10, 2, 3);
+        checkIndexOutOfBoundsException("-1", 10, -1, 2);
+
+        checkNull(10, 0, 1);
+        checkNull(10, -1, 0);
+        checkNull(10, 0, 0);
+        checkNull(10, 0, -1);
+        checkNull(-1, -1, -1);
     }
 
     private static void check(String val, long expected) {
         long n = Long.parseLong(val);
         if (n != expected)
-            throw new RuntimeException("Long.parsedLong failed. String:" +
+            throw new RuntimeException("Long.parseLong failed. String:" +
                                        val + " Result:" + n);
     }
 
@@ -91,4 +126,71 @@ public class ParsingTest {
             ; // Expected
         }
     }
+
+    private static void checkNumberFormatException(String val, int radix, int start) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(val, radix, start);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NumberFormatException nfe) {
+            ; // Expected
+        }
+    }
+
+    private static void checkNumberFormatException(String val, int radix, int start, int end) {
+        long n = 0;
+        try {
+            n = Long.parseLong(val, radix, start, end);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start + ", " + end +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NumberFormatException nfe) {
+            ; // Expected
+        }
+    }
+
+    private static void checkIndexOutOfBoundsException(String val, int radix, int start) {
+        int n = 0;
+        try {
+            n = Integer.parseInt(val, radix, start);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (IndexOutOfBoundsException ioob) {
+            ; // Expected
+        }
+    }
+
+    private static void checkIndexOutOfBoundsException(String val, int radix, int start, int end) {
+        long n = 0;
+        try {
+            n = Long.parseLong(val, radix, start, end);
+            System.err.println("parseInt(" + val + ", " + radix + ", " + start + ", " + end +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (IndexOutOfBoundsException ioob) {
+            ; // Expected
+        }
+    }
+
+    private static void checkNull(int radix, int start, int end) {
+        long n = 0;
+        try {
+            n = Long.parseLong(null, 10, start, end);
+            System.err.println("parseInt(null, " + radix + ", " + start + ", " + end +
+                    ") incorrectly returned " + n);
+            throw new RuntimeException();
+        } catch (NullPointerException npe) {
+            ; // Expected
+        }
+    }
+
+    private static void check(String val, long expected, int start, int end) {
+        long n = Long.parseLong(val, 10, start, end);
+        if (n != expected)
+            throw new RuntimeException("Long.parseLong failed. String:" +
+                    val + ", start: " + start + ", end: " + end + " Result:" + n);
+    }
 }
diff --git a/jdk/test/java/lang/String/ToLowerCase.java b/jdk/test/java/lang/String/ToLowerCase.java
index 5aebf7275e0992f7e9b5bf19e87ecc1c5731297c..784f810e052acd081355d066dfee076a208d4181 100644
--- a/jdk/test/java/lang/String/ToLowerCase.java
+++ b/jdk/test/java/lang/String/ToLowerCase.java
@@ -23,7 +23,7 @@
 
 /*
     @test
-    @bug 4217441 4533872 4900935 8020037 8032012 8041791
+    @bug 4217441 4533872 4900935 8020037 8032012 8041791 8042589
     @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
@@ -106,6 +106,12 @@ public class ToLowerCase {
         // invalid code point tests:
         test("\uD800\uD800\uD801A\uDC00\uDC00\uDC00B", Locale.US, "\uD800\uD800\uD801a\uDC00\uDC00\uDC00b");
 
+        // lower/uppercase + surrogates
+        test("a\uD801\uDC1c", Locale.ROOT, "a\uD801\uDC44");
+        test("A\uD801\uDC1c", Locale.ROOT, "a\uD801\uDC44");
+        test("a\uD801\uDC00\uD801\uDC01\uD801\uDC02", Locale.US, "a\uD801\uDC28\uD801\uDC29\uD801\uDC2A");
+        test("A\uD801\uDC00\uD801\uDC01\uD801\uDC02", Locale.US, "a\uD801\uDC28\uD801\uDC29\uD801\uDC2A");
+
         // test bmp + supp1
         StringBuilder src = new StringBuilder(0x20000);
         StringBuilder exp = new StringBuilder(0x20000);
diff --git a/jdk/test/java/lang/String/ToUpperCase.java b/jdk/test/java/lang/String/ToUpperCase.java
index 9b3af882cef7eed80ddda6d6975ed971c20335f4..020c2ae02da5a5ab6038457e8e7a75ab9052a366 100644
--- a/jdk/test/java/lang/String/ToUpperCase.java
+++ b/jdk/test/java/lang/String/ToUpperCase.java
@@ -23,7 +23,7 @@
 
 /*
     @test
-    @bug 4219630 4304573 4533872 4900935
+    @bug 4219630 4304573 4533872 4900935 8042589
     @summary toUpperCase should upper-case German sharp s correctly even if
              it's the only character in the string. should also uppercase
              all of the 1:M char mappings correctly.  Also it should handle
@@ -91,6 +91,12 @@ public class ToUpperCase {
         test("\uD801\uDC28a\uD801\uDC29b\uD801\uDC2Ac", Locale.US, "\uD801\uDC00A\uD801\uDC01B\uD801\uDC02C");
         // invalid code point tests:
         test("\uD800\uD800\uD801a\uDC00\uDC00\uDC00b", Locale.US, "\uD800\uD800\uD801A\uDC00\uDC00\uDC00B");
+
+        // lower/uppercase + surrogates
+        test("a\uD801\uDC44", Locale.ROOT, "A\uD801\uDC1c");
+        test("A\uD801\uDC44", Locale.ROOT, "A\uD801\uDC1c");
+        test("a\uD801\uDC28\uD801\uDC29\uD801\uDC2A", Locale.US, "A\uD801\uDC00\uD801\uDC01\uD801\uDC02");
+        test("A\uD801\uDC28a\uD801\uDC29b\uD801\uDC2Ac", Locale.US, "A\uD801\uDC00A\uD801\uDC01B\uD801\uDC02C");
     }
 
     static void test(String in, Locale locale, String expected) {
diff --git a/jdk/test/java/net/MulticastSocket/TestInterfaces.java b/jdk/test/java/net/MulticastSocket/TestInterfaces.java
index 1d87d8d062f67bd9a2dd8b190136f55e1af1e107..958e77eb0b4ddaba59bdf110a95b76531bc9f61d 100644
--- a/jdk/test/java/net/MulticastSocket/TestInterfaces.java
+++ b/jdk/test/java/net/MulticastSocket/TestInterfaces.java
@@ -28,6 +28,8 @@
  *          same InetAddress set by MulticastSocket.setInterface
  */
 import java.net.*;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.io.IOException;
 
@@ -47,6 +49,7 @@ public class TestInterfaces {
             /*
              * Test MulticastSocket.getInterface
              */
+            System.out.println("Testing network interface " + ni);
             Enumeration addrs = ni.getInetAddresses();
             while (addrs.hasMoreElements()) {
                 InetAddress ia = (InetAddress)addrs.nextElement();
@@ -64,6 +67,8 @@ public class TestInterfaces {
 
                 InetAddress curr = soc.getInterface();
                 if (!curr.equals(ia)) {
+                    System.err.println("NetworkInterface under test " + ni);
+                    displayInterfaceInformation(ni);
                     System.err.println("MulticastSocket.getInterface returned: " + curr);
                     System.err.println("Failed! Expected: " + ia);
                     failures++;
@@ -96,6 +101,10 @@ public class TestInterfaces {
             if (!curr.equals(ni)) {
                 System.err.println("MulticastSocket.getNetworkInterface returned: " + curr);
                 System.err.println("Failed! Expected: " + ni);
+                System.err.println("NetworkInterface details for curr variable ");
+                displayInterfaceInformation(curr);
+                System.err.println("NetworkInterface details for ni variable ");
+                displayInterfaceInformation(ni) ;
                 failures++;
             } else {
                 System.out.println("Passed.");
@@ -110,4 +119,23 @@ public class TestInterfaces {
 
     }
 
+    static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
+        System.err.println("Display name: " + netint.getDisplayName());
+        System.err.println("Name: " + netint.getName());
+        Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
+
+        for (InetAddress inetAddress : Collections.list(inetAddresses))
+            System.err.println("InetAddress: " + inetAddress);
+
+        System.err.println("Up? " + netint.isUp());
+        System.err.println("Loopback? " + netint.isLoopback());
+        System.err.println("PointToPoint? " + netint.isPointToPoint());
+        System.err.println("Supports multicast? " + netint.supportsMulticast());
+        System.err.println("Virtual? " + netint.isVirtual());
+        System.err.println("Hardware address: " +
+                Arrays.toString(netint.getHardwareAddress()));
+        System.err.println("MTU: " + netint.getMTU());
+        System.err.println("Index: " + netint.getIndex());
+        System.err.println();
+    }
 }
diff --git a/jdk/test/java/util/UUID/UUIDTest.java b/jdk/test/java/util/UUID/UUIDTest.java
index de73a66a183ea1f0ca51561056411f2bcbce7e08..93ad7ad349020e71943d8ee4923590caa94c6441 100644
--- a/jdk/test/java/util/UUID/UUIDTest.java
+++ b/jdk/test/java/util/UUID/UUIDTest.java
@@ -96,6 +96,23 @@ public class UUIDTest {
             if (!u1.equals(u2))
                 throw new Exception("UUID -> string -> UUID failed");
         }
+
+        testFromStringError("-0");
+        testFromStringError("x");
+        testFromStringError("----");
+        testFromStringError("-0-0-0-0");
+        testFromStringError("0-0-0-0-");
+        testFromStringError("0-0-0-0-0-");
+        testFromStringError("0-0-0-0-x");
+    }
+
+    private static void testFromStringError(String str) {
+        try {
+            UUID test = UUID.fromString(str);
+            throw new RuntimeException("Should have thrown IAE");
+        } catch (IllegalArgumentException iae) {
+            // pass
+        }
     }
 
     private static void versionTest() throws Exception {
diff --git a/jdk/test/javax/security/auth/kerberos/KerberosHashEqualsTest.java b/jdk/test/javax/security/auth/kerberos/KerberosHashEqualsTest.java
index 9578a59547a7ac4fb17a699b5477eef165892ffa..7eed2ccf4255b5488970f5b7d611b0dbb5b81d67 100644
--- a/jdk/test/javax/security/auth/kerberos/KerberosHashEqualsTest.java
+++ b/jdk/test/javax/security/auth/kerberos/KerberosHashEqualsTest.java
@@ -33,9 +33,7 @@
 
 import java.net.InetAddress;
 import java.util.Date;
-import javax.security.auth.kerberos.KerberosKey;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import javax.security.auth.kerberos.KerberosTicket;
+import javax.security.auth.kerberos.*;
 
 public class KerberosHashEqualsTest {
     public static void main(String[] args) throws Exception {
@@ -66,28 +64,67 @@ public class KerberosHashEqualsTest {
 
         k2.destroy();
         checkNotSame(k1, k2);
-
-        // destroyed keys doesn't equal to each other
         checkNotSame(k2, k1);
         checkSame(k2, k2);
 
+        k1.destroy();
+        checkNotSame(k1, k2);
+
+        // Destroyed key has string and hashCode
+        k1.toString(); k1.hashCode();
+
         // a little different
+        k1 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 1);
         k2 = new KerberosKey(newKP("B"), "pass".getBytes(), 1, 1);
         checkNotSame(k1, k2);
+
         k2 = new KerberosKey(newKP("A"), "ssap".getBytes(), 1, 1);
         checkNotSame(k1, k2);
+
         k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 2, 1);
         checkNotSame(k1, k2);
+
         k2 = new KerberosKey(newKP("A"), "pass".getBytes(), 1, 2);
         checkNotSame(k1, k2);
 
+        // Null
         k1 = new KerberosKey(null, "pass".getBytes(), 1, 2);
         checkNotSame(k1, k2); // null to non-null
         k2 = new KerberosKey(null, "pass".getBytes(), 1, 2);
         checkSame(k1, k2);    // null to null
 
+        // Even key with null principal has a string and hashCode
+        k1.toString(); k1.hashCode();
+
         checkNotSame(k1, "Another Object");
 
+        EncryptionKey e1, e2;
+        e1 = new EncryptionKey("pass".getBytes(), 1);
+        e2 = new EncryptionKey("pass".getBytes(), 1);
+        checkSame(e1, e1);  // me to me
+        checkSame(e1, e2);  // same
+
+        e2.destroy();
+        checkNotSame(e1, e2);
+        checkNotSame(e2, e1);
+        checkSame(e2, e2);
+
+        e1.destroy();
+        checkNotSame(e1, e2);
+
+        // Destroyed key has string and hashCode
+        e1.toString(); e1.hashCode();
+
+        // a little different
+        e1 = new EncryptionKey("pass".getBytes(), 1);
+        e2 = new EncryptionKey("ssap".getBytes(), 1);
+        checkNotSame(e1, e2);
+
+        e2 = new EncryptionKey("pass".getBytes(), 2);
+        checkNotSame(e1, e2);
+
+        checkNotSame(e1, "Another Object");
+
         KerberosTicket t1, t2;
         t1 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
         t2 = new KerberosTicket("asn1".getBytes(), newKP("client"), newKP("server"), "pass".getBytes(), 1, new boolean[] {true, true}, new Date(0), new Date(0), new Date(0), new Date(0), null);
@@ -120,6 +157,7 @@ public class KerberosHashEqualsTest {
 
         t2.destroy();
         checkNotSame(t1, t2);
+        t2.hashCode(); t2.toString();
 
         // destroyed tickets doesn't equal to each other
         checkNotSame(t2, t1);
@@ -130,6 +168,37 @@ public class KerberosHashEqualsTest {
         checkNotSame(t1, t2);  // renewtill is useful
 
         checkNotSame(t1, "Another Object");
+
+        KerberosCredMessage m1, m2;
+        m1 = new KerberosCredMessage(newKP("C"), newKP("S"), "message".getBytes());
+        m2 = new KerberosCredMessage(newKP("C"), newKP("S"), "message".getBytes());
+        checkSame(m1, m1);  // me to me
+        checkSame(m1, m2);  // same
+
+        m2.destroy();
+        checkNotSame(m1, m2);
+        checkNotSame(m2, m1);
+        checkSame(m2, m2);
+
+        m1.destroy();
+        checkNotSame(m1, m2);
+
+        // Destroyed message has string and hashCode
+        m1.toString(); m1.hashCode();
+
+        // a little different
+        m1 = new KerberosCredMessage(newKP("C"), newKP("S"), "message".getBytes());
+        m2 = new KerberosCredMessage(newKP("A"), newKP("S"), "message".getBytes());
+        checkNotSame(m1, m2);
+
+        m2 = new KerberosCredMessage(newKP("C"), newKP("B"), "message".getBytes());
+        checkNotSame(m1, m2);
+
+        m1 = new KerberosCredMessage(newKP("C"), newKP("S"), "hello".getBytes());
+        checkNotSame(m1, m2);
+
+        checkNotSame(m1, "Another Object");
+
         System.out.println("Good!");
     }
 
diff --git a/jdk/test/javax/security/auth/kerberos/KerberosNullsAndDestroyTest.java b/jdk/test/javax/security/auth/kerberos/KerberosNullsAndDestroyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..06bb71cd90bf00135e232b583fcf237a252ede2b
--- /dev/null
+++ b/jdk/test/javax/security/auth/kerberos/KerberosNullsAndDestroyTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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
+ * @bug 8043071
+ * @summary Expose session key and KRB_CRED through extended GSS-API
+ */
+
+import javax.security.auth.kerberos.*;
+import java.util.function.Supplier;
+
+public class KerberosNullsAndDestroyTest {
+
+    public static void main(String[] args) throws Exception {
+
+        KerberosPrincipal c = new KerberosPrincipal("me@HERE");
+        KerberosPrincipal s = new KerberosPrincipal("you@THERE");
+
+        // These object constructions should throw NullPointerException
+        checkNPE(() -> new KerberosKey(c, null, 17, 1));
+        checkNPE(() -> new EncryptionKey(null, 17));
+        checkNPE(() -> new KerberosCredMessage(null, s, new byte[1]));
+        checkNPE(() -> new KerberosCredMessage(c, null, new byte[1]));
+        checkNPE(() -> new KerberosCredMessage(c, s, null));
+
+        KerberosKey k1 = new KerberosKey(c, new byte[16], 17, 1);
+        EncryptionKey k2 = new EncryptionKey(new byte[16], 17);
+        KerberosCredMessage m = new KerberosCredMessage(c, s, new byte[1]);
+
+        // These get calls should throw IllegalStateException
+        k1.destroy();
+        checkISE(() -> k1.getAlgorithm());
+        checkISE(() -> k1.getEncoded());
+        checkISE(() -> k1.getFormat());
+        checkISE(() -> k1.getKeyType());
+        checkISE(() -> k1.getPrincipal());
+        checkISE(() -> k1.getVersionNumber());
+
+        k2.destroy();
+        checkISE(() -> k2.getAlgorithm());
+        checkISE(() -> k2.getEncoded());
+        checkISE(() -> k2.getFormat());
+        checkISE(() -> k2.getKeyType());
+
+        m.destroy();
+        checkISE(() -> m.getSender());
+        checkISE(() -> m.getRecipient());
+        checkISE(() -> m.getEncoded());
+    }
+
+    static void checkNPE(Supplier<?> f) throws Exception {
+        check(f, NullPointerException.class);
+    }
+
+    static void checkISE(Supplier<?> f) throws Exception {
+        check(f, IllegalStateException.class);
+    }
+
+    static void check(Supplier<?> f, Class<? extends Exception> type) throws Exception {
+        try {
+            f.get();
+        } catch (Exception e) {
+            if (e.getClass() != type) {
+                throw e;
+            } else {
+                return;
+            }
+        }
+        throw new Exception("Should fail");
+    }
+}
diff --git a/jdk/test/javax/xml/bind/xjc/8029837/PreParseGrammarTest.java b/jdk/test/javax/xml/bind/xjc/8029837/PreParseGrammarTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ae62650465145e96643dd1fe4f148eacb2bee07b
--- /dev/null
+++ b/jdk/test/javax/xml/bind/xjc/8029837/PreParseGrammarTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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
+ * @bug 8029837
+ * @summary Test simulates the partial call to xjc ant task that fails with
+ *          NullPointer exception
+ * @run main/othervm PreParseGrammarTest
+ */
+
+import com.sun.org.apache.xerces.internal.parsers.XMLGrammarPreparser;
+import com.sun.org.apache.xerces.internal.xni.XNIException;
+import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
+import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
+import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class PreParseGrammarTest {
+
+    public static void main(String[] args) throws FileNotFoundException, XNIException, IOException {
+        File xsdf = new File(System.getProperty("test.src", ".") + "/test.xsd");
+        InputStream is = new BufferedInputStream(new FileInputStream(xsdf));
+        XMLInputSource xis = new XMLInputSource(null, null, null, is, null);
+        XMLGrammarPreparser gp = new XMLGrammarPreparser();
+        gp.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+        //The NullPointerException is observed on next call during ant task
+        // execution
+        Grammar res = gp.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, xis);
+        System.out.println("Grammar preparsed successfully:" + res);
+        return;
+    }
+}
diff --git a/jdk/test/javax/xml/bind/xjc/8029837/test.xsd b/jdk/test/javax/xml/bind/xjc/8029837/test.xsd
new file mode 100644
index 0000000000000000000000000000000000000000..f7ee730e98a5b4a80a1df270cab8fbb5b1fcfe30
--- /dev/null
+++ b/jdk/test/javax/xml/bind/xjc/8029837/test.xsd
@@ -0,0 +1,4 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+	<xsd:element name="root">
+	</xsd:element>
+</xsd:schema>
diff --git a/jdk/test/sun/misc/JavaLangAccess/FormatUnsigned.java b/jdk/test/sun/misc/JavaLangAccess/FormatUnsigned.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff3411af2446bc8abcf81620127e028c82667981
--- /dev/null
+++ b/jdk/test/sun/misc/JavaLangAccess/FormatUnsigned.java
@@ -0,0 +1,78 @@
+/*
+ * 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
+ * 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 sun.misc.JavaLangAccess;
+import sun.misc.SharedSecrets;
+
+/*
+ * @test
+ * @summary Test JavaLangAccess.formatUnsignedInt/-Long
+ * @bug 8050114
+ */
+public class FormatUnsigned {
+
+    static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
+
+    public static void testFormatUnsignedInt() {
+        testFormatUnsignedInt("7fffffff", Integer.MAX_VALUE, 8, 4, 0, 8);
+        testFormatUnsignedInt("80000000", Integer.MIN_VALUE, 8, 4, 0, 8);
+        testFormatUnsignedInt("4711", 04711, 4, 3, 0, 4);
+        testFormatUnsignedInt("4711", 0x4711, 4, 4, 0, 4);
+        testFormatUnsignedInt("1010", 0b1010, 4, 1, 0, 4);
+        testFormatUnsignedInt("00001010", 0b1010, 8, 1, 0, 8);
+        testFormatUnsignedInt("\u0000\u000000001010", 0b1010, 10, 1, 2, 8);
+    }
+
+    public static void testFormatUnsignedLong() {
+        testFormatUnsignedLong("7fffffffffffffff", Long.MAX_VALUE, 16, 4, 0, 16);
+        testFormatUnsignedLong("8000000000000000", Long.MIN_VALUE, 16, 4, 0, 16);
+        testFormatUnsignedLong("4711", 04711L, 4, 3, 0, 4);
+        testFormatUnsignedLong("4711", 0x4711L, 4, 4, 0, 4);
+        testFormatUnsignedLong("1010", 0b1010L, 4, 1, 0, 4);
+        testFormatUnsignedLong("00001010", 0b1010L, 8, 1, 0, 8);
+        testFormatUnsignedLong("\u0000\u000000001010", 0b1010L, 10, 1, 2, 8);
+    }
+
+    public static void testFormatUnsignedInt(String expected, int value, int arraySize, int shift, int offset, int length) {
+        char[] chars = new char[arraySize];
+        jla.formatUnsignedInt(value, shift, chars, offset, length);
+        String s = new String(chars);
+        if (!expected.equals(s)) {
+            throw new Error(s + " should be equal to expected " + expected);
+        }
+    }
+
+    public static void testFormatUnsignedLong(String expected, long value, int arraySize, int shift, int offset, int length) {
+        char[] chars = new char[arraySize];
+        jla.formatUnsignedLong(value, shift, chars, offset, length);
+        String s = new String(chars);
+        if (!expected.equals(s)) {
+            throw new Error(s + " should be equal to expected " + expected);
+        }
+    }
+
+    public static void main(String[] args) {
+        testFormatUnsignedInt();
+        testFormatUnsignedLong();
+    }
+}
diff --git a/jdk/test/sun/security/jgss/spnego/NotPreferredMech.java b/jdk/test/sun/security/jgss/spnego/NotPreferredMech.java
new file mode 100644
index 0000000000000000000000000000000000000000..5eb8150d265ea50b341d77fd693935c835bcb481
--- /dev/null
+++ b/jdk/test/sun/security/jgss/spnego/NotPreferredMech.java
@@ -0,0 +1,100 @@
+/*
+ * 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
+ * @bug 8048194
+ * @run main/othervm NotPreferredMech
+ * @summary GSSContext.acceptSecContext fails when a supported mech is not initiator preferred
+ */
+
+import org.ietf.jgss.*;
+import sun.security.jgss.*;
+import sun.security.jgss.spnego.NegTokenInit;
+import sun.security.jgss.spnego.NegTokenTarg;
+import sun.security.util.BitArray;
+import sun.security.util.DerOutputStream;
+import sun.security.util.DerValue;
+import sun.security.util.ObjectIdentifier;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+public class NotPreferredMech {
+
+    public static void main(String[] argv) throws Exception {
+
+        // Generates a NegTokenInit mechTypes field, with an
+        // unsupported mech as the preferred.
+        DerOutputStream mech = new DerOutputStream();
+        mech.write(new Oid("1.2.3.4").getDER());
+        mech.write(GSSUtil.GSS_KRB5_MECH_OID.getDER());
+        DerOutputStream mechTypeList = new DerOutputStream();
+        mechTypeList.write(DerValue.tag_Sequence, mech);
+
+        // Generates a NegTokenInit mechToken field for 1.2.3.4 mech
+        GSSHeader h1 = new GSSHeader(new ObjectIdentifier("1.2.3.4"), 1);
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        h1.encode(bout);
+        bout.write(new byte[1]);
+
+        // Generates the NegTokenInit token
+        Constructor<NegTokenInit> ctor = NegTokenInit.class.getDeclaredConstructor(
+                byte[].class, BitArray.class, byte[].class, byte[].class);
+        ctor.setAccessible(true);
+        NegTokenInit initToken = ctor.newInstance(
+                mechTypeList.toByteArray(),
+                new BitArray(0),
+                bout.toByteArray(),
+                null);
+        Method m = Class.forName("sun.security.jgss.spnego.SpNegoToken")
+                .getDeclaredMethod("getEncoded");
+        m.setAccessible(true);
+        byte[] spnegoToken = (byte[])m.invoke(initToken);
+
+        // and wraps it into a GSSToken
+        GSSHeader h = new GSSHeader(
+                new ObjectIdentifier(GSSUtil.GSS_SPNEGO_MECH_OID.toString()),
+                spnegoToken.length);
+        bout = new ByteArrayOutputStream();
+        h.encode(bout);
+        bout.write(spnegoToken);
+        byte[] token = bout.toByteArray();
+
+        // and feeds it to a GSS acceptor
+        GSSManager man = GSSManager.getInstance();
+        GSSContext ctxt = man.createContext((GSSCredential) null);
+        token = ctxt.acceptSecContext(token, 0, token.length);
+        NegTokenTarg targ = new NegTokenTarg(token);
+
+        // Make sure it's a GO-ON message
+        Method m2 = NegTokenTarg.class.getDeclaredMethod("getNegotiatedResult");
+        m2.setAccessible(true);
+        int negResult = (int)m2.invoke(targ);
+
+        if (negResult != 1 /* ACCEPT_INCOMPLETE */) {
+            throw new Exception("Not a continue");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/krb5/auto/Context.java b/jdk/test/sun/security/krb5/auto/Context.java
index 715a1ad59788fea9c818fde03cc51f4522c2644e..28395d612956ab9451f5ab7b3017b93599470fff 100644
--- a/jdk/test/sun/security/krb5/auto/Context.java
+++ b/jdk/test/sun/security/krb5/auto/Context.java
@@ -26,9 +26,11 @@ import java.security.Key;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.Arrays;
+import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
 import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosCredMessage;
 import javax.security.auth.kerberos.KerberosKey;
 import javax.security.auth.kerberos.KerberosTicket;
 import javax.security.auth.login.LoginContext;
@@ -86,7 +88,6 @@ public class Context {
 
     /**
      * Using the delegated credentials from a previous acceptor
-     * @param c
      */
     public Context delegated() throws Exception {
         Context out = new Context();
@@ -177,7 +178,6 @@ public class Context {
     /**
      * Logins with username/keytab as an existing Subject. The
      * same subject can be used multiple times to simulate multiple logins.
-     * @param s existing subject
      */
     public static Context fromUserKtab(
             String user, String ktab, boolean storeKey) throws Exception {
@@ -411,6 +411,12 @@ public class Context {
                 Key k = (Key)ex.inquireSecContext(
                         InquireType.KRB5_GET_SESSION_KEY);
                 if (k == null) {
+                    throw new Exception("(Old) Session key cannot be null");
+                }
+                System.out.println("(Old) Session key is: " + k);
+                Key k2 = (Key)ex.inquireSecContext(
+                        InquireType.KRB5_GET_SESSION_KEY_EX);
+                if (k2 == null) {
                     throw new Exception("Session key cannot be null");
                 }
                 System.out.println("Session key is: " + k);
@@ -431,6 +437,19 @@ public class Context {
                             InquireType.KRB5_GET_AUTHZ_DATA);
                     System.out.println("AuthzData is: " + Arrays.toString(ad));
                 }
+                try {
+                    KerberosCredMessage tok = (KerberosCredMessage)ex.inquireSecContext(
+                            InquireType.KRB5_GET_KRB_CRED);
+                    System.out.println("KRB_CRED is " +
+                            (tok == null?"not ":"") + "available");
+                    if (tok != null) {
+                        System.out.println("From " + tok.getSender() + " to "
+                                + tok.getRecipient());
+                        System.out.println(Base64.getEncoder().encodeToString(tok.getEncoded()));
+                    }
+                } catch (Exception e) {
+                    System.out.println("KRB_CRED is not available: " + e);
+                }
             }
         }
     }
diff --git a/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java b/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java
deleted file mode 100644
index e7c026dab03a4686577a18a490556a12b46c143a..0000000000000000000000000000000000000000
--- a/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2005, 2011, 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 4641821
- * @run main/othervm KerberosHashEqualsTest
- * @summary hashCode() and equals() for KerberosKey and KerberosTicket
- */
-
-import java.net.InetAddress;
-import java.util.Date;
-import javax.security.auth.kerberos.KerberosKey;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import javax.security.auth.kerberos.KerberosTicket;
-
-public class KerberosHashEqualsTest {
-    public static void main(String[] args) throws Exception {
-        new OneKDC(null);
-        new KerberosHashEqualsTest().check();
-    }
-
-    void checkSame(Object o1, Object o2) {
-        if(!o1.equals(o2)) {
-            throw new RuntimeException("equals() fails");
-        }
-        if(o1.hashCode() != o2.hashCode()) {
-            throw new RuntimeException("hashCode() not same");
-        }
-    }
-
-    void checkNotSame(Object o1, Object o2) {
-        if(o1.equals(o2)) {
-            throw new RuntimeException("equals() succeeds");
-        }
-    }
-
-    void check() throws Exception {
-
-        // The key part:
-        // new KerberosKey(principal, bytes, keyType, version)
-
-        KerberosKey k1, k2;
-        KerberosPrincipal CLIENT = new KerberosPrincipal("client");
-        KerberosPrincipal SERVER = new KerberosPrincipal("server");
-        byte[] PASS = "pass".getBytes();
-
-        k1 = new KerberosKey(CLIENT, PASS, 1, 1);
-        k2 = new KerberosKey(CLIENT, PASS, 1, 1);
-        checkSame(k1, k1);  // me is me
-        checkSame(k1, k2);  // same
-
-        // A destroyed key doesn't equal to any key
-        k2.destroy();
-        checkNotSame(k1, k2);
-        checkNotSame(k2, k1);
-        k1.destroy();
-        checkNotSame(k1, k2);   // even if they are both destroyed
-        checkNotSame(k2, k1);
-        checkSame(k2, k2);
-
-        // a little difference means not equal
-        k1 = new KerberosKey(CLIENT, PASS, 1, 1);
-        k2 = new KerberosKey(SERVER, PASS, 1, 1);
-        checkNotSame(k1, k2);   // Different principal name
-
-        k2 = new KerberosKey(CLIENT, "ssap".getBytes(), 1, 1);
-        checkNotSame(k1, k2);   // Different password
-
-        k2 = new KerberosKey(CLIENT, PASS, 2, 1);
-        checkNotSame(k1, k2);   // Different keytype
-
-        k2 = new KerberosKey(CLIENT, PASS, 1, 2);
-        checkNotSame(k1, k2);   // Different version
-
-        k2 = new KerberosKey(null, PASS, 1, 2);
-        checkNotSame(k1, k2);   // null is not non-null
-
-        k1 = new KerberosKey(null, PASS, 1, 2);
-        checkSame(k1, k2);      // null is null
-
-        checkNotSame(k1, "Another Object");
-
-        // The ticket part:
-        // new KerberosTicket(asn1 bytes, client, server, session key, type, flags,
-        //      auth, start, end, renewUntil times, address)
-
-        KerberosTicket t1, t2;
-
-        byte[] ASN1 = "asn1".getBytes();
-        boolean[] FORWARDABLE = new boolean[] {true, true};
-        boolean[] ALLTRUE = new boolean[] {true, true, true, true, true, true, true, true, true, true};
-        Date D0 = new Date(0);
-
-        t1 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, D0, null);
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, D0, null);
-        checkSame(t1, t1);
-        checkSame(t1, t2);
-
-        // destroyed tickets doesn't equal to each other
-        t1.destroy();
-        checkNotSame(t1, t2);
-        checkNotSame(t2, t1);
-
-        t2.destroy();
-        checkNotSame(t1, t2);   // even if they are both destroyed
-        checkNotSame(t2, t1);
-
-        checkSame(t2, t2);  // unless they are the same object
-
-        // a little difference means not equal
-        t1 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, D0, null);
-        t2 = new KerberosTicket("asn11".getBytes(), CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, D0, null);
-        checkNotSame(t1, t2);   // Different ASN1 encoding
-
-        t2 = new KerberosTicket(ASN1, new KerberosPrincipal("client1"), SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, D0, null);
-        checkNotSame(t1, t2);   // Different client
-
-        t2 = new KerberosTicket(ASN1, CLIENT, new KerberosPrincipal("server1"), PASS, 1, FORWARDABLE, D0, D0, D0, D0, null);
-        checkNotSame(t1, t2);   // Different server
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, "pass1".getBytes(), 1, FORWARDABLE, D0, D0, D0, D0, null);
-        checkNotSame(t1, t2);   // Different session key
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 2, FORWARDABLE, D0, D0, D0, D0, null);
-        checkNotSame(t1, t2);   // Different key type
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, new boolean[] {true, false}, D0, D0, D0, D0, null);
-        checkNotSame(t1, t2);   // Different flags, not FORWARDABLE
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, new Date(1), D0, D0, D0, null);
-        checkNotSame(t1, t2);   // Different authtime
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, new Date(1), D0, D0, null);
-        checkNotSame(t1, t2);   // Different starttime
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, new Date(1), D0, null);
-        checkNotSame(t1, t2);   // Different endtime
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, D0, new InetAddress[2]);
-        checkNotSame(t1, t2);   // Different client addresses
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, new Date(1), null);
-        t1 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, FORWARDABLE, D0, D0, D0, new Date(2), null);
-        checkSame(t1, t2);      // renewtill is ignored when RENEWABLE ticket flag is not set.
-
-        t2 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, ALLTRUE, D0, D0, D0, new Date(1), null);
-        t1 = new KerberosTicket(ASN1, CLIENT, SERVER, PASS, 1, ALLTRUE, D0, D0, D0, new Date(2), null);
-        checkNotSame(t1, t2);   // renewtill is used when RENEWABLE is set.
-
-        checkNotSame(t1, "Another Object");
-        System.out.println("Good!");
-    }
-}
diff --git a/jdk/test/sun/security/krb5/auto/NewInquireTypes.java b/jdk/test/sun/security/krb5/auto/NewInquireTypes.java
new file mode 100644
index 0000000000000000000000000000000000000000..0a922468b622ffe00f6dcbabffd9a726748a7152
--- /dev/null
+++ b/jdk/test/sun/security/krb5/auto/NewInquireTypes.java
@@ -0,0 +1,65 @@
+/*
+ * 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
+ * @bug 8043071
+ * @summary Expose session key and KRB_CRED through extended GSS-API
+ * @compile -XDignore.symbol.file NewInquireTypes.java
+ * @run main/othervm NewInquireTypes
+ */
+
+import com.sun.security.jgss.InquireType;
+import sun.security.jgss.GSSUtil;
+import sun.security.krb5.internal.KRBCred;
+import sun.security.krb5.internal.crypto.KeyUsage;
+
+import javax.security.auth.kerberos.KerberosCredMessage;
+import javax.security.auth.kerberos.EncryptionKey;
+
+public class NewInquireTypes {
+
+    public static void main(String[] args) throws Exception {
+
+        new OneKDC(null).writeJAASConf();
+
+        Context c, s;
+        c = Context.fromJAAS("client");
+        s = Context.fromJAAS("server");
+
+        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
+        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
+
+        Context.handshake(c, s);
+
+        EncryptionKey key = (EncryptionKey)
+                c.x().inquireSecContext(InquireType.KRB5_GET_SESSION_KEY_EX);
+        KerberosCredMessage cred = (KerberosCredMessage)
+                c.x().inquireSecContext(InquireType.KRB5_GET_KRB_CRED);
+
+        // Confirm the KRB_CRED message is encrypted with the session key.
+        new KRBCred(cred.getEncoded()).encPart.decrypt(
+                new sun.security.krb5.EncryptionKey(key.getKeyType(), key.getEncoded()),
+                KeyUsage.KU_ENC_KRB_CRED_PART);
+    }
+}
diff --git a/jdk/test/sun/security/smartcardio/TestAll.java b/jdk/test/sun/security/smartcardio/TestAll.java
index e83706f664cc6d9f5f9853cb4e2caa9d22853298..1bd1d76ffd0d498be069ed161ac40e718a3eec63 100644
--- a/jdk/test/sun/security/smartcardio/TestAll.java
+++ b/jdk/test/sun/security/smartcardio/TestAll.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -26,7 +26,7 @@
 // Because all the tests are marked @ignore as they require special hardware,
 // we cannot use jtreg to do this.
 
-import java.lang.reflect.*;
+import java.lang.reflect.Method;
 
 public class TestAll {
 
diff --git a/jdk/test/sun/security/smartcardio/TestChannel.java b/jdk/test/sun/security/smartcardio/TestChannel.java
index 75eb211ad840da2bfa7340c81d3f9990f18fea54..e14cf833da2365b21279ce0b08c3976f45bf764e 100644
--- a/jdk/test/sun/security/smartcardio/TestChannel.java
+++ b/jdk/test/sun/security/smartcardio/TestChannel.java
@@ -31,10 +31,10 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.CommandAPDU;
 
 public class TestChannel extends Utils {
 
@@ -95,7 +95,7 @@ public class TestChannel extends Utils {
         }
 
         // disconnect
-        card.disconnect(false);
+        card.disconnect(true);
 
         System.out.println("OK.");
     }
diff --git a/jdk/test/sun/security/smartcardio/TestConnect.java b/jdk/test/sun/security/smartcardio/TestConnect.java
index b2dcc920c55e9023f67226214b7e229f47d73565..e07893437619af1a35b2ef178812881edc0dd5a5 100644
--- a/jdk/test/sun/security/smartcardio/TestConnect.java
+++ b/jdk/test/sun/security/smartcardio/TestConnect.java
@@ -31,10 +31,11 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import java.util.List;
+import javax.smartcardio.TerminalFactory;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.CardTerminal;
 
 public class TestConnect extends Utils {
 
@@ -63,7 +64,7 @@ public class TestConnect extends Utils {
             throw new Exception("Not T=0 protocol");
         }
         transmit(card);
-        card.disconnect(false);
+        card.disconnect(true);
 
         try {
             transmit(card);
@@ -96,7 +97,7 @@ public class TestConnect extends Utils {
             throw new Exception("Not T=0 protocol");
         }
         transmit(card);
-        card.disconnect(true);
+        card.disconnect(false);
 
         card = terminal.connect("*");
         System.out.println("card: " + card);
@@ -105,7 +106,6 @@ public class TestConnect extends Utils {
         }
         transmit(card);
         card.disconnect(true);
-        card.disconnect(true);
 
         System.out.println("OK.");
     }
diff --git a/jdk/test/sun/security/smartcardio/TestConnectAgain.java b/jdk/test/sun/security/smartcardio/TestConnectAgain.java
index 8f44a9783ae6fdc0258ad56295e2fff27293fdeb..e938a561dac1301d14909ae989d36fc320609d8f 100644
--- a/jdk/test/sun/security/smartcardio/TestConnectAgain.java
+++ b/jdk/test/sun/security/smartcardio/TestConnectAgain.java
@@ -31,10 +31,10 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardException;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.CardTerminal;
 
 public class TestConnectAgain extends Utils {
 
@@ -95,7 +95,7 @@ public class TestConnectAgain extends Utils {
         }
 
         // disconnect
-        card.disconnect(false);
+        card.disconnect(true);
 
         System.out.println("OK.");
     }
diff --git a/jdk/test/sun/security/smartcardio/TestControl.java b/jdk/test/sun/security/smartcardio/TestControl.java
index 05521bd617231892bc8f4552e7032ee5ba097345..5a690640311592ba12c590ff0166e8a294530d10 100644
--- a/jdk/test/sun/security/smartcardio/TestControl.java
+++ b/jdk/test/sun/security/smartcardio/TestControl.java
@@ -31,10 +31,9 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardException;
+import javax.smartcardio.CardTerminal;
 
 public class TestControl extends Utils {
 
@@ -68,7 +67,7 @@ public class TestControl extends Utils {
         }
 
         // disconnect
-        card.disconnect(false);
+        card.disconnect(true);
 
         System.out.println("OK.");
     }
diff --git a/jdk/test/sun/security/smartcardio/TestDefault.java b/jdk/test/sun/security/smartcardio/TestDefault.java
index 7499476569670dd13866a01376b3dadf810d8ef2..247537265e319cd1c9784f28634e3e50a1a8264c 100644
--- a/jdk/test/sun/security/smartcardio/TestDefault.java
+++ b/jdk/test/sun/security/smartcardio/TestDefault.java
@@ -31,10 +31,9 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import java.util.List;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.TerminalFactory;
 
 public class TestDefault {
 
diff --git a/jdk/test/sun/security/smartcardio/TestExclusive.java b/jdk/test/sun/security/smartcardio/TestExclusive.java
index a43e03ecf5b77c1f67671b6fb1c628353d883b2b..f41e2cf3e660d1d5035e32015f86a2be2f20847d 100644
--- a/jdk/test/sun/security/smartcardio/TestExclusive.java
+++ b/jdk/test/sun/security/smartcardio/TestExclusive.java
@@ -31,10 +31,11 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.CardException;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.CommandAPDU;
 
 public class TestExclusive extends Utils {
 
@@ -84,9 +85,9 @@ public class TestExclusive extends Utils {
         Thread.sleep(1000);
 
         // disconnect
-        card.disconnect(false);
+        card.disconnect(true);
 
-        if (otherOK == false) {
+        if (! otherOK) {
             throw new Exception("Secondary thread failed");
         }
 
diff --git a/jdk/test/sun/security/smartcardio/TestMultiplePresent.java b/jdk/test/sun/security/smartcardio/TestMultiplePresent.java
index fe779710762af40fa06d3899a006697cefcf84bf..6be66c926ddcf7f997e4947b3530adce8eb43590 100644
--- a/jdk/test/sun/security/smartcardio/TestMultiplePresent.java
+++ b/jdk/test/sun/security/smartcardio/TestMultiplePresent.java
@@ -31,10 +31,10 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import java.util.List;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.CardTerminals;
+import javax.smartcardio.TerminalFactory;
 import static javax.smartcardio.CardTerminals.State.*;
 
 public class TestMultiplePresent {
diff --git a/jdk/test/sun/security/smartcardio/TestPresent.java b/jdk/test/sun/security/smartcardio/TestPresent.java
index 6aa3c49ee1c5276eecd0b701b6af66b280f6c1c9..2728f903ca4e8c4159c43472172f162c0ddc100c 100644
--- a/jdk/test/sun/security/smartcardio/TestPresent.java
+++ b/jdk/test/sun/security/smartcardio/TestPresent.java
@@ -31,10 +31,9 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import java.util.List;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.TerminalFactory;
 
 public class TestPresent {
 
diff --git a/jdk/test/sun/security/smartcardio/TestTransmit.java b/jdk/test/sun/security/smartcardio/TestTransmit.java
index 5d69931095fa01637e6d42dcfe8ad4ce7ed3ccbf..2c4844173176697cd70028f3270972ced049c996 100644
--- a/jdk/test/sun/security/smartcardio/TestTransmit.java
+++ b/jdk/test/sun/security/smartcardio/TestTransmit.java
@@ -31,10 +31,16 @@
 
 // This test requires special hardware.
 
-import java.io.*;
-import java.util.*;
-
-import javax.smartcardio.*;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import javax.smartcardio.Card;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.CommandAPDU;
+import javax.smartcardio.ResponseAPDU;
 
 public class TestTransmit extends Utils {
 
@@ -79,7 +85,7 @@ public class TestTransmit extends Utils {
         }
 
         // disconnect
-        card.disconnect(false);
+        card.disconnect(true);
 
         System.out.println("OK.");
     }
diff --git a/jdk/test/sun/security/smartcardio/Utils.java b/jdk/test/sun/security/smartcardio/Utils.java
index e67bdcf06480f62656dbccd12db84fbc636b8f86..b4edbcc292be5551409878df6d51e1908c8f1f53 100644
--- a/jdk/test/sun/security/smartcardio/Utils.java
+++ b/jdk/test/sun/security/smartcardio/Utils.java
@@ -24,10 +24,16 @@
 
 // common utility functions for the PC/SC tests
 
-import javax.smartcardio.*;
-
-import java.io.*;
-import java.util.*;
+import java.io.StringReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import javax.smartcardio.CardTerminal;
+import javax.smartcardio.CardChannel;
+import javax.smartcardio.ResponseAPDU;
+import javax.smartcardio.CommandAPDU;
+import javax.smartcardio.TerminalFactory;
 
 public class Utils {
 
diff --git a/jdk/test/sun/security/tools/jarsigner/default_options.sh b/jdk/test/sun/security/tools/jarsigner/default_options.sh
new file mode 100644
index 0000000000000000000000000000000000000000..ca946bb9cb3b2f6f4ef66cf78412be87f265dbcf
--- /dev/null
+++ b/jdk/test/sun/security/tools/jarsigner/default_options.sh
@@ -0,0 +1,64 @@
+#
+# 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
+# @bug 8049834
+# @summary Two security tools tests do not run with only JRE
+#
+
+if [ "${TESTJAVA}" = "" ] ; then
+  JAVAC_CMD=`which javac`
+  TESTJAVA=`dirname $JAVAC_CMD`/..
+fi
+
+KS=ks
+KEYTOOL="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS}"
+JAR="$TESTJAVA/bin/jar ${TESTTOOLVMOPTS}"
+JARSIGNER="$TESTJAVA/bin/jarsigner ${TESTTOOLVMOPTS}"
+
+rm $KS 2> /dev/null
+
+PASS=changeit
+export PASS
+
+$KEYTOOL -genkeypair -dname CN=A -alias a \
+         -storepass:env PASS -keypass:env PASS -keystore $KS \
+         -keyalg rsa || exit 1
+
+cat <<EOF > js.conf
+jarsigner.all = -keystore \${user.dir}/$KS -storepass:env PASS -debug -strict
+jarsigner.sign = -digestalg SHA1
+jarsigner.verify = -verbose:summary
+
+EOF
+
+$JAR cvf a.jar ks js.conf
+
+$JARSIGNER -conf js.conf a.jar a || exit 21
+$JARSIGNER -conf js.conf -verify a.jar > jarsigner.out || exit 22
+grep "and 1 more" jarsigner.out || exit 23
+$JAR xvf a.jar META-INF/MANIFEST.MF
+grep "SHA1-Digest" META-INF/MANIFEST.MF || exit 24
+
+echo Done
+exit 0
diff --git a/jdk/test/sun/security/tools/keytool/weaksize.sh b/jdk/test/sun/security/tools/jarsigner/weaksize.sh
similarity index 100%
rename from jdk/test/sun/security/tools/keytool/weaksize.sh
rename to jdk/test/sun/security/tools/jarsigner/weaksize.sh
diff --git a/jdk/test/sun/security/tools/keytool/default_options.sh b/jdk/test/sun/security/tools/keytool/default_options.sh
index 5dc9894efee9c95e25785148c24fface299b13bd..182b3a202c4c625fe5d5200eb8cc0272f374ff29 100644
--- a/jdk/test/sun/security/tools/keytool/default_options.sh
+++ b/jdk/test/sun/security/tools/keytool/default_options.sh
@@ -33,16 +33,12 @@ fi
 
 KS=ks
 KEYTOOL="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS}"
-JAR="$TESTJAVA/bin/jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA/bin/jarsigner ${TESTTOOLVMOPTS}"
 
 rm $KS 2> /dev/null
 
 PASS=changeit
 export PASS
 
-# keytool
-
 cat <<EOF > kt.conf
 # A Pre-configured options file
 keytool.all = -storepass:env PASS -keypass:env PASS -keystore \${user.dir}/$KS -debug
@@ -69,23 +65,6 @@ $KEYTOOL -conf kt.conf -delete -alias a && exit 16
 # Single-valued option on command line overrides again
 $KEYTOOL -conf kt.conf -delete -alias b -keystore $KS || exit 17
 
-# jarsigner
-
-cat <<EOF > js.conf
-jarsigner.all = -keystore \${user.dir}/$KS -storepass:env PASS -debug -strict
-jarsigner.sign = -digestalg SHA1
-jarsigner.verify = -verbose:summary
-
-EOF
-
-$JAR cvf a.jar ks js.conf kt.conf
-
-$JARSIGNER -conf js.conf a.jar a || exit 21
-$JARSIGNER -conf js.conf -verify a.jar > jarsigner.out || exit 22
-grep "and 2 more" jarsigner.out || exit 23
-$JAR xvf a.jar META-INF/MANIFEST.MF
-grep "SHA1-Digest" META-INF/MANIFEST.MF || exit 24
-
 # Error cases
 
 # File does not exist
diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk
index 348ae14dbc3aad674d52ad37cf5fa892a8351f0d..8d434cfcc7ecef31b9b5d171b30f6752ff46d614 100644
--- a/make/Javadoc.gmk
+++ b/make/Javadoc.gmk
@@ -239,11 +239,15 @@ endef
 
 # Common echo of option
 define OptionOnly # opt
-	$(PRINTF) "%s\n" "$1"
+	if [ "$1" != "" ] ; then \
+		$(PRINTF) "%s\n" "$1"; \
+	fi
 endef
+
 define OptionPair # opt arg
 	$(PRINTF) "%s '%s'\n" "$1" '$2'
 endef
+
 define OptionTrip # opt arg arg
 	$(PRINTF) "%s '%s' '%s'\n" "$1" '$2' '$3'
 endef
@@ -258,14 +262,7 @@ and working code examples.<br>\
 $(call CopyrightLine,$(COPYRIGHT_URL),$(FIRST_COPYRIGHT_YEAR),)\
 </font>
 
-# Common javadoc options used by all
-COMMON_JAVADOCFLAGS = \
-    -XDignore.symbol.file=true \
-    -quiet \
-    -use \
-    -keywords \
-    -Xprofilespath $(JDK_TOPDIR)/make/profile-rtjar-includes.txt \
-    $(ADDITIONAL_JAVADOCFLAGS)
+# Common javadoc options used by all bundles
 
 ifdef OPENJDK
   ADDITIONAL_JAVADOCFLAGS = \
@@ -274,6 +271,52 @@ else
   ADDITIONAL_JAVADOCFLAGS =
 endif
 
+define COMMON_JAVADOCFLAGS
+    $(call OptionOnly,-XDignore.symbol.file=true) ; \
+    $(call OptionOnly,-quiet) ; \
+    $(call OptionOnly,-use) ; \
+    $(call OptionOnly,-keywords) ; \
+    $(call OptionPair,-Xprofilespath,$(JDK_TOPDIR)/make/profile-rtjar-includes.txt) ; \
+    $(call OptionOnly,$(ADDITIONAL_JAVADOCFLAGS))
+endef
+
+# Common javadoc tags used by all bundles
+
+# Java language specification cite
+TAG_JLS = jls:a:See <cite> \
+The Java&trade; Language Specification</cite>:
+
+# Java virtual machine specification cite
+TAG_JVMS = jvms:a:See <cite> \
+The Java&trade; Virtual Machine Specification</cite>:
+
+# In order to get a specific ordering it's necessary to specify the total
+# ordering of tags as the tags are otherwise ordered in order of definition.
+define COMMON_JAVADOCTAGS
+  $(call OptionPair,-tag,beaninfo:X) ; \
+  $(call OptionPair,-tag,revised:X) ; \
+  $(call OptionPair,-tag,since.unbundled:X) ; \
+  $(call OptionPair,-tag,spec:X) ; \
+  $(call OptionPair,-tag,specdefault:X) ; \
+  $(call OptionPair,-tag,Note:X) ; \
+  $(call OptionPair,-tag,ToDo:X) ; \
+  $(call OptionPair,-tag,apiNote:a:API Note:) ; \
+  $(call OptionPair,-tag,implSpec:a:Implementation Requirements:) ; \
+  $(call OptionPair,-tag,implNote:a:Implementation Note:) ; \
+  $(call OptionPair,-tag,param) ; \
+  $(call OptionPair,-tag,return) ; \
+  $(call OptionPair,-tag,throws) ; \
+  $(call OptionPair,-tag,since) ; \
+  $(call OptionPair,-tag,version) ; \
+  $(call OptionPair,-tag,serialData) ; \
+  $(call OptionPair,-tag,factory) ; \
+  $(call OptionPair,-tag,see) ; \
+  $(call OptionPair,-tag,$(TAG_JVMS)) ; \
+  $(call OptionPair,-tag,$(TAG_JLS))
+endef
+
+
+
 # Draft used for non-fcs documents
 DRAFT_HEADER =
 ifneq ($(MILESTONE), fcs)
@@ -338,10 +381,6 @@ COREAPI_WINDOWTITLE = Java Platform SE $(JDK_MINOR_VERSION)
 COREAPI_HEADER = \
 <strong>Java$(TRADEMARK)&nbsp;Platform<br>Standard&nbsp;Ed.&nbsp;$(JDK_MINOR_VERSION)</strong>
 
-# Java language specification cite
-TAG_JLS = jls:a:See <cite> \
-The Java&trade; Language Specification</cite>:
-
 # Overview file for core apis
 COREAPI_OVERVIEW = $(JDK_SHARE_CLASSES)/overview-core.html
 
@@ -365,29 +404,11 @@ $(COREAPI_INDEX_FILE): $(COREAPI_OPTIONS_FILE) $(COREAPI_PACKAGES_FILE)
 # Create file with javadoc options in it
 $(COREAPI_OPTIONS_FILE): $(COREAPI_OVERVIEW)
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
-	  $(call OptionOnly,-Xdoclint:none) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
+          $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ISO-8859-1) ; \
-	  $(call OptionPair,-tag,beaninfo:X) ; \
-	  $(call OptionPair,-tag,revised:X) ; \
-	  $(call OptionPair,-tag,since.unbundled:X) ; \
-	  $(call OptionPair,-tag,spec:X) ; \
-	  $(call OptionPair,-tag,specdefault:X) ; \
-	  $(call OptionPair,-tag,Note:X) ; \
-	  $(call OptionPair,-tag,ToDo:X) ; \
-	  $(call OptionPair,-tag,apiNote:a:API Note:) ; \
-	  $(call OptionPair,-tag,implSpec:a:Implementation Requirements:) ; \
-	  $(call OptionPair,-tag,implNote:a:Implementation Note:) ; \
-	  $(call OptionPair,-tag,param) ; \
-	  $(call OptionPair,-tag,return) ; \
-	  $(call OptionPair,-tag,throws) ; \
-	  $(call OptionPair,-tag,since) ; \
-	  $(call OptionPair,-tag,version) ; \
-	  $(call OptionPair,-tag,serialData) ; \
-	  $(call OptionPair,-tag,factory) ; \
-	  $(call OptionPair,-tag,see) ; \
-	  $(call OptionPair,-tag,$(TAG_JLS)) ; \
 	  $(call OptionOnly,-splitIndex) ; \
 	  $(call OptionPair,-overview,$(COREAPI_OVERVIEW)) ; \
 	  $(call OptionPair,-doctitle,$(COREAPI_DOCTITLE)) ; \
@@ -441,7 +462,8 @@ $(DOCLETAPI_INDEX_FILE): $(DOCLETAPI_OPTIONS_FILE) $(DOCLETAPI_PACKAGES_FILE) $(
 # Create file with javadoc options in it
 $(DOCLETAPI_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -498,7 +520,8 @@ $(TAGLETAPI_INDEX_FILE): $(TAGLETAPI_OPTIONS_FILE) $(TAGLETAPI_PACKAGES_FILE) $(
 # Create file with javadoc options in it
 $(TAGLETAPI_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -550,7 +573,8 @@ $(DOMAPI_INDEX_FILE): $(DOMAPI_OPTIONS_FILE) $(DOMAPI_PACKAGES_FILE) $(COREAPI_I
 # Create file with javadoc options in it
 $(DOMAPI_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -613,7 +637,8 @@ $(JDI_INDEX_FILE): $(JDI_OPTIONS_FILE) $(JDI_PACKAGES_FILE) $(COREAPI_INDEX_FILE
 # Create file with javadoc options in it
 $(JDI_OPTIONS_FILE): $(JDI_OVERVIEW)
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -700,7 +725,8 @@ $(JAAS_INDEX_FILE): $(JAAS_OPTIONS_FILE) $(JAAS_PACKAGES_FILE) $(COREAPI_INDEX_F
 # Create file with javadoc options in it
 $(JAAS_OPTIONS_FILE): $(JAAS_OVERVIEW)
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -753,7 +779,8 @@ $(JGSS_INDEX_FILE): $(JGSS_OPTIONS_FILE) $(JGSS_PACKAGES_FILE) $(COREAPI_INDEX_F
 # Create file with javadoc options in it
 $(JGSS_OPTIONS_FILE): $(JGSS_OVERVIEW)
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -806,7 +833,8 @@ $(SMARTCARDIO_INDEX_FILE): $(SMARTCARDIO_OPTIONS_FILE) $(SMARTCARDIO_PACKAGES_FI
 # Create file with javadoc options in it
 $(SMARTCARDIO_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -857,7 +885,8 @@ $(HTTPSERVER_INDEX_HTML): $(HTTPSERVER_OPTIONS_FILE) $(HTTPSERVER_PACKAGES_FILE)
 # Create file with javadoc options in it
 $(HTTPSERVER_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -917,7 +946,8 @@ $(MGMT_INDEX_FILE): $(MGMT_OPTIONS_FILE) $(MGMT_PACKAGES_FILE) $(COREAPI_INDEX_F
 # Create file with javadoc options in it
 $(MGMT_OPTIONS_FILE): $(MGMT_OVERVIEW)
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -969,7 +999,8 @@ $(ATTACH_INDEX_HTML): $(ATTACH_OPTIONS_FILE) $(ATTACH_PACKAGES_FILE) $(COREAPI_I
 # Create file with javadoc options in it
 $(ATTACH_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -1020,7 +1051,8 @@ $(JCONSOLE_INDEX_HTML): $(JCONSOLE_OPTIONS_FILE) $(JCONSOLE_PACKAGES_FILE) $(COR
 # Create file with javadoc options in it
 $(JCONSOLE_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -1073,14 +1105,14 @@ $(TREEAPI_INDEX_HTML): $(TREEAPI_OPTIONS_FILE) $(TREEAPI_PACKAGES_FILE) $(COREAP
 # Create file with javadoc options in it
 $(TREEAPI_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionPair,-doctitle,$(TREEAPI_DOCTITLE)) ; \
 	  $(call OptionPair,-windowtitle,$(TREEAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
 	  $(call OptionPair,-header,$(TREEAPI_HEADER)$(DRAFT_HEADER)) ; \
-	  $(call OptionPair,-tag,$(TAG_JLS)) ; \
 	  $(call OptionPair,-bottom,$(TREEAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \
 	  $(call OptionTrip,-group,$(TREEAPI_GROUPNAME),$(TREEAPI_REGEXP)); \
 	  $(call OptionTrip,-linkoffline,$(TREEAPI2COREAPI),$(COREAPI_DOCSDIR)/); \
@@ -1125,7 +1157,8 @@ $(SCTPAPI_INDEX_HTML): $(SCTPAPI_OPTIONS_FILE) $(SCTPAPI_PACKAGES_FILE) $(COREAP
 # Create file with javadoc options in it
 $(SCTPAPI_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
@@ -1176,7 +1209,8 @@ $(JDKNET_INDEX_HTML): $(JDKNET_OPTIONS_FILE) $(JDKNET_PACKAGES_FILE) $(COREAPI_I
 # Create file with javadoc options in it
 $(JDKNET_OPTIONS_FILE):
 	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \
+	@($(call COMMON_JAVADOCFLAGS) ; \
+          $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
 	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
diff --git a/make/jprt.properties b/make/jprt.properties
index a5ca05cb8c9a0e6de5d9afb8667a7254d9b58652..d3d9c9e9e6c91bee9d0c2b377012680f41825633 100644
--- a/make/jprt.properties
+++ b/make/jprt.properties
@@ -460,19 +460,23 @@ my.make.rule.test.targets.hotspot.internalvmtests=			\
   windows_i586_6.1-fastdebug-c2-hotspot_internalvmtests,		\
   windows_x64_6.1-fastdebug-c2-hotspot_internalvmtests
 
-my.make.rule.test.targets.hotspot.wbapitests=				\
-  solaris_sparcv9_5.11-{product|fastdebug}-c2-hotspot_wbapitest,	\
-  solaris_x64_5.11-{product|fastdebug}-c2-hotspot_wbapitest,		\
-  linux_i586_2.6-{product|fastdebug}-c2-hotspot_wbapitest,		\
-  linux_x64_2.6-{product|fastdebug}-c2-hotspot_wbapitest,		\
-  windows_i586_6.1-{product|fastdebug}-c2-hotspot_wbapitest,		\
-  windows_x64_6.1-{product|fastdebug}-c2-hotspot_wbapitest,		\
-  linux_i586_2.6-{product|fastdebug}-c1-hotspot_wbapitest,		\
-  windows_i586_6.1-{product|fastdebug}-c1-hotspot_wbapitest
-
-my.make.rule.test.targets.hotspot=					\
-  ${my.make.rule.test.targets.hotspot.clienttests},			\
-  ${my.make.rule.test.targets.hotspot.servertests},			\
-  ${my.make.rule.test.targets.hotspot.internalvmtests},			\
-  ${my.make.rule.test.targets.hotspot.wbapitests},			\
+my.make.rule.test.targets.hotspot.reg.group=					\
+  solaris_sparcv9_5.11-{product|fastdebug}-c2-GROUP,				\
+  solaris_x64_5.11-{product|fastdebug}-c2-GROUP,				\
+  linux_i586_2.6-{product|fastdebug}-c2-GROUP,					\
+  linux_x64_2.6-{product|fastdebug}-c2-GROUP,					\
+  windows_i586_6.1-{product|fastdebug}-c2-GROUP,				\
+  windows_x64_6.1-{product|fastdebug}-c2-GROUP,					\
+  linux_i586_2.6-{product|fastdebug}-c1-GROUP,					\
+  windows_i586_6.1-{product|fastdebug}-c1-GROUP
+
+my.make.rule.test.targets.hotspot=						\
+  ${my.make.rule.test.targets.hotspot.clienttests},				\
+  ${my.make.rule.test.targets.hotspot.servertests},				\
+  ${my.make.rule.test.targets.hotspot.internalvmtests},				\
+  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_wbapitest},	\
+  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_compiler},	\
+  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_gc},		\
+  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_runtime},	\
+  ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_serviceability},	\
   ${my.additional.make.rule.test.targets.hotspot}
diff --git a/nashorn/.hgtags b/nashorn/.hgtags
index 8a3b96daa6c7eed6e078d7efa1e782f7b65239b4..b59b5a487f0f61b3ab010a550bf62b9bddee88c7 100644
--- a/nashorn/.hgtags
+++ b/nashorn/.hgtags
@@ -257,3 +257,4 @@ d703c59c556f9fcd9604272806ef7acf55c92363 jdk9-b20
 174cf53bce4e93a3d5d880ed7915ce8d0f08bc5e jdk9-b21
 a9d39bcfeb1bb3f7de929c56a2ecbea10a554ca1 jdk9-b22
 aa3fda2d2967847dbd264aa962d624c07fc6c29f jdk9-b23
+49d7a2a66ae6b70fee367e2ceb29d0c20f8be01b jdk9-b24
diff --git a/nashorn/make/build-nasgen.xml b/nashorn/make/build-nasgen.xml
index 9dca55053169337bd386bea36348e525bfda2651..16094cc964bc5155a57a50f9cd02143d4b9acb09 100644
--- a/nashorn/make/build-nasgen.xml
+++ b/nashorn/make/build-nasgen.xml
@@ -36,11 +36,13 @@
                 <pathelement location="${basedir}/jcov2/lib/jcov_j2se_rt.jar"/>
                 <pathelement location="${basedir}/buildtools/nasgen/dist/nasgen.jar"/>
                 <pathelement path="${basedir}/build/classes"/>
+                <pathelement location="${dist.dir}/nasgen.jar"/>
+                <pathelement path="${build.dir}/classes"/>
             </classpath>
             <jvmarg value="-Djava.ext.dirs="/>
-            <arg value="${basedir}/build/classes"/>
+            <arg value="${build.dir}/classes"/>
             <arg value="jdk.nashorn.internal.objects"/>
-            <arg value="${basedir}/build/classes"/>
+            <arg value="${build.dir}/classes"/>
         </java>
     </target>
 
diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml
index 78cc8f9ea2650a16b470ce08cfd513b227d78b1e..35edc417edbbefcfd3a0605eb4f5f40f4f50aa3c 100644
--- a/nashorn/make/build.xml
+++ b/nashorn/make/build.xml
@@ -304,6 +304,14 @@ grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" {
 grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {
     permission java.security.AllPermission;
 };
+//// in case of absolute path:
+grant codeBase "file:/${nashorn.internal.tests.jar}" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:/${file.reference.testng.jar}" {
+    permission java.security.AllPermission;
+};
 
 grant codeBase "file:/${basedir}/test/script/trusted/*" {
     permission java.security.AllPermission;
@@ -391,7 +399,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" {
     <testng outputdir="${build.nosecurity.test.results.dir}" classfilesetref="test.nosecurity.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
       <sysproperty key="nashorn.jar" value="${dist.dir}/nashorn.jar"/>
       <propertyset>
         <propertyref prefix="nashorn."/>
@@ -413,7 +421,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" {
     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
       <jvmarg line="${debug.test.jvmargs}"/>
       <propertyset>
         <propertyref prefix="nashorn."/>
@@ -451,7 +459,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" {
     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
       <propertyset>
         <propertyref prefix="testjfx-test-sys-prop."/>
         <mapper from="testjfx-test-sys-prop.*" to="*" type="glob"/>
@@ -471,7 +479,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" {
     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
       <propertyset>
         <propertyref prefix="testmarkdown-test-sys-prop."/>
         <mapper from="testmarkdown-test-sys-prop.*" to="*" type="glob"/>
@@ -490,7 +498,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" {
     <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
        verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
       <propertyset>
         <propertyref prefix="nashorn."/>
       </propertyset>
@@ -510,7 +518,7 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" {
     <!-- use just build.test.classes.dir to avoid referring to TestNG -->
     <java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
       <jvmarg line="${ext.class.path}"/>
-      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
+      <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
       <classpath>
           <pathelement path="${run.test.classpath}"/>
       </classpath>
diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties
index 77f8ed73bf72e9669be961770fa528cfde5aa826..642793a8e66ae4aae94f1baf8167465ea1509984 100644
--- a/nashorn/make/project.properties
+++ b/nashorn/make/project.properties
@@ -309,7 +309,7 @@ run.test.jvmargs.main=${run.test.jvmargs.common} -ea
 run.test.jvmargs.octane.main=${run.test.jvmargs.common} -XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode -XX:TypeProfileLevel=222
 
 # Security manager args - make sure that we run with the nashorn.policy that the build creates
-run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
+run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${build.dir}/nashorn.policy
 
 # VM options for script tests with @fork option
 test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -cp ${run.test.classpath}
diff --git a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java
index b48ed8b5c1953388dbda44f3b45b3dee63b3b029..bb16cf48caa16c9234b47606d0f36b264ac3cb91 100644
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestHelper.java
@@ -39,7 +39,8 @@ import java.io.Reader;
 public abstract class TestHelper {
 
     public static final String TEST_ROOT   = "test";
-    public static final String BUILD_ROOT  = "build/test";
+    public static final String BUILD_ROOT =
+        System.getProperty("build.dir", "build") + File.separator + "test";
     public static final String TEST_PREFIX = TEST_ROOT + File.separator;
 
     private TestHelper() {