changeset 13214:1bc968d8314a

Merge
author lana
date Wed, 02 Dec 2015 09:34:55 -0800
parents 8581faf0d474 54b3b3dd0eb9
children 600834e2e9c1 dcfdd2a451d5
files make/gensrc/GensrcMisc.gmk make/launcher/Launcher-jdk.jvmstat.gmk make/launcher/LauncherCommon.gmk make/mapfiles/libjava/mapfile-vers src/java.base/share/classes/sun/misc/Contended.java src/java.base/share/native/include/jvm.h src/java.base/unix/classes/sun/nio/ch/DefaultSelectorProvider.java src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/remote/RemoteHost.java src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/remote/RemoteVm.java src/jdk.jvmstat/share/classes/sun/jvmstat/monitor/remote/package.html src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostProvider.java src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostRmiService.java src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/PerfDataBuffer.java src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/RemoteMonitoredVm.java src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/RemoteVmManager.java src/jdk.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/package.html src/jdk.jvmstat/share/classes/sun/tools/jstatd/Jstatd.java src/jdk.jvmstat/share/classes/sun/tools/jstatd/RemoteHostImpl.java src/jdk.jvmstat/share/classes/sun/tools/jstatd/RemoteVmImpl.java test/lib/testlibrary/jdk/testlibrary/InputArguments.java test/sun/security/tools/jarsigner/warning.sh
diffstat 311 files changed, 14330 insertions(+), 4710 deletions(-) [+]
line wrap: on
line diff
--- a/make/Import.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/Import.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -34,11 +34,9 @@
 ifneq ($(OPENJDK_TARGET_OS), windows)
   HOTSPOT_LIB_DIR := $(HOTSPOT_DIST)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
   BASE_INSTALL_LIBRARIES_HERE := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base$(OPENJDK_TARGET_CPU_LIBDIR)
-  SA_INSTALL_LIBRARIES_HERE := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent$(OPENJDK_TARGET_CPU_LIBDIR)
 else
   HOTSPOT_LIB_DIR := $(HOTSPOT_DIST)/bin
   BASE_INSTALL_LIBRARIES_HERE := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base
-  SA_INSTALL_LIBRARIES_HERE := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent
 endif
 
 ################################################################################
@@ -58,10 +56,6 @@
     Xusage.txt \
     #
 
-HOTSPOT_SA_IMPORT_FILES := \
-    $(addprefix $(LIBRARY_PREFIX), saproc.* sawindbg.*) \
-    #
-
 $(eval $(call SetupCopyFiles,COPY_HOTSPOT_BASE, \
     SRC := $(HOTSPOT_LIB_DIR), \
     DEST := $(BASE_INSTALL_LIBRARIES_HERE), \
@@ -77,14 +71,6 @@
 
 BASE_TARGETS := $(COPY_HOTSPOT_BASE) $(COPY_HOTSPOT_BASE_JVMLIB)
 
-$(eval $(call SetupCopyFiles,COPY_HOTSPOT_SA, \
-    SRC := $(HOTSPOT_LIB_DIR), \
-    DEST := $(SA_INSTALL_LIBRARIES_HERE), \
-    FILES := $(shell $(FIND) $(HOTSPOT_LIB_DIR) -type f  \
-        -a \( -name DUMMY $(addprefix -o$(SPACE)-name$(SPACE), $(HOTSPOT_SA_IMPORT_FILES)) \) )))
-
-SA_TARGETS := $(COPY_HOTSPOT_SA)
-
 ################################################################################
 
 ifneq ($(STATIC_BUILD), true)
@@ -213,34 +199,6 @@
 
 ################################################################################
 
-$(JDK_OUTPUTDIR)/modules/jdk.hotspot.agent/_the.sa.jar.unpacked: $(HOTSPOT_DIST)/lib/sa-jdi.jar \
-    $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/_the.sa.services
-	$(ECHO) $(LOG_INFO) Unzipping $(<F)
-	$(RM) -r $(@D)
-	$(MKDIR) -p $(@D)
-	$(CD) $(@D) && $(UNZIP) $< -x META-INF/MANIFEST.MF $(LOG_DEBUG)
-        # We must move the service provider file out of the way so that
-        # Gensrc-jdk.jdi.gmk can combine them.
-	$(MKDIR) -p $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent
-	$(MV) $(JDK_OUTPUTDIR)/modules/jdk.hotspot.agent/META-INF/services/com.sun.jdi.connect.Connector \
-	    $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/_the.sa.services
-	$(TOUCH) $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/_the.sa.services
-	$(TOUCH) $@
-
-# Declaring this dependency guarantees that _the.sa.services will be rebuilt
-# even if zip is already unpacked.
-$(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/_the.sa.services: $(HOTSPOT_DIST)/lib/sa-jdi.jar
-
-# Some platforms don't have the serviceability agent
-ifeq (, $(filter $(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), aix-ppc64))
-  ifneq ($(JVM_VARIANT_ZERO), true)
-    SA_TARGETS += $(JDK_OUTPUTDIR)/modules/jdk.hotspot.agent/_the.sa.jar.unpacked \
-        $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/_the.sa.services
-  endif
-endif
-
-################################################################################
-
 ifeq ($(OPENJDK_TARGET_OS), windows)
   $(eval $(call SetupCopyFiles,BASE_COPY_LIBS_BIN, \
       SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
@@ -252,33 +210,16 @@
       DEST := $(JDK_OUTPUTDIR)/lib, \
       FILES := $(filter %.lib, $(BASE_TARGETS))))
 
-  $(eval $(call SetupCopyFiles,SA_COPY_LIBS, \
-      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent, \
-      DEST := $(JDK_OUTPUTDIR)/lib, \
-      FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent/%, \
-          $(SA_TARGETS))))
-
-  $(eval $(call SetupCopyFiles,SA_COPY_LIBS, \
-      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent, \
-      DEST := $(JDK_OUTPUTDIR)/bin, \
-      FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent/%, \
-          $(SA_TARGETS))))
 else
   $(eval $(call SetupCopyFiles,BASE_COPY_LIBS, \
       SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
       DEST := $(JDK_OUTPUTDIR)/lib, \
       FILES := $(BASE_TARGETS)))
-
-  $(eval $(call SetupCopyFiles,SA_COPY_LIBS, \
-      SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent, \
-      DEST := $(JDK_OUTPUTDIR)/lib, \
-      FILES := $(filter $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.hotspot.agent/%, $(SA_TARGETS))))
 endif
 
 ################################################################################
 
-all: $(BASE_TARGETS) $(SA_TARGETS) \
-    $(BASE_COPY_LIBS_BIN) $(BASE_COPY_LIBS_LIB) \
-    $(BASE_COPY_LIBS) $(SA_COPY_LIBS)
+all: $(BASE_TARGETS) $(BASE_COPY_LIBS_BIN) $(BASE_COPY_LIBS_LIB) \
+    $(BASE_COPY_LIBS)
 
 .PHONY: default all
--- a/make/gendata/GendataBreakIterator.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/gendata/GendataBreakIterator.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -58,13 +58,13 @@
 
 # output
 BASE_DATA_PKG_DIR := $(JDK_OUTPUTDIR)/modules/java.base/sun/text/resources
-SL_DATA_PKG_DIR := $(JDK_OUTPUTDIR)/modules/jdk.localedata/sun/text/resources
+LD_DATA_PKG_DIR := $(JDK_OUTPUTDIR)/modules/jdk.localedata/sun/text/resources
 BIFILES := $(BASE_DATA_PKG_DIR)/CharacterBreakIteratorData \
     $(BASE_DATA_PKG_DIR)/WordBreakIteratorData \
     $(BASE_DATA_PKG_DIR)/LineBreakIteratorData \
     $(BASE_DATA_PKG_DIR)/SentenceBreakIteratorData
-BIFILES_TH := $(SA_DATA_PKG_DIR)/th/WordBreakIteratorData_th \
-    $(SA_DATA_PKG_DIR)/th/LineBreakIteratorData_th
+BIFILES_TH := $(LD_DATA_PKG_DIR)/th/WordBreakIteratorData_th \
+    $(LD_DATA_PKG_DIR)/th/LineBreakIteratorData_th
 
 $(BIFILES): $(BASE_DATA_PKG_DIR)/_the.bifiles
 $(BASE_DATA_PKG_DIR)/_the.bifiles: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
@@ -77,9 +77,9 @@
 	    -spec $(UNICODEDATA)
 	$(TOUCH) $@
 
-$(BIFILES_TH): $(SL_DATA_PKG_DIR)/_the.bifiles_th
-$(SL_DATA_PKG_DIR)/_the.bifiles_th: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
-$(SL_DATA_PKG_DIR)/_the.bifiles_th: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
+$(BIFILES_TH): $(LD_DATA_PKG_DIR)/_the.bifiles_th
+$(LD_DATA_PKG_DIR)/_the.bifiles_th: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
+$(LD_DATA_PKG_DIR)/_the.bifiles_th: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
 	$(ECHO) $(LOG_INFO) "Generating BreakIteratorData_th"
 	$(MKDIR) -p $(@D)/th
 	$(RM) $(BIFILES_TH)
--- a/make/gensrc/Gensrc-jdk.jdi.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/gensrc/Gensrc-jdk.jdi.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -70,11 +70,11 @@
 # Filter com.sun.jdi.connect.Connector
 $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector: \
     $(JDK_TOPDIR)/src/jdk.jdi/share/classes/META-INF/services/com.sun.jdi.connect.Connector \
-    $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/_the.sa.services
+    $(HOTSPOT_TOPDIR)/agent/src/share/classes/META-INF/services/com.sun.jdi.connect.Connector
 	$(process-provider)
 
 # Copy the same service file into jdk.hotspot.agent so that they are kept the same.
-$(JDK_OUTPUTDIR)/modules/jdk.hotspot.agent/META-INF/services/com.sun.jdi.connect.Connector: \
+$(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/META-INF/services/com.sun.jdi.connect.Connector: \
     $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector
 	$(install-file)
 
@@ -82,7 +82,7 @@
 ifeq (, $(filter $(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), aix-ppc64))
   ifneq ($(JVM_VARIANT_ZERO), true)
     GENSRC_JDK_JDI += $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector \
-        $(JDK_OUTPUTDIR)/modules/jdk.hotspot.agent/META-INF/services/com.sun.jdi.connect.Connector
+        $(SUPPORT_OUTPUTDIR)/gensrc/jdk.hotspot.agent/META-INF/services/com.sun.jdi.connect.Connector
   endif
 endif
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/gensrc/Gensrc-jdk.jvmstat.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+include GensrcCommon.gmk
+
+################################################################################
+
+define merge-providers
+	$(MKDIR) -p $(@D)
+	$(CAT) $^ > $@
+endef
+
+PROVIDER_FILE := META-INF/services/sun.jvmstat.monitor.MonitoredHostService
+
+# Merge the local and remote sevice providers into jdk.jvmstat/META-INF/services
+$(SUPPORT_OUTPUTDIR)/gensrc/jdk.jvmstat/$(PROVIDER_FILE): \
+    $(JDK_TOPDIR)/src/jdk.jvmstat/share/classes/$(PROVIDER_FILE) \
+    $(JDK_TOPDIR)/src/jdk.jvmstat.rmi/share/classes/$(PROVIDER_FILE)
+	$(merge-providers)
+
+# Copy the same service file into jdk.jvmstat.rmi so that they are kept the same.
+$(SUPPORT_OUTPUTDIR)/gensrc/jdk.jvmstat.rmi/$(PROVIDER_FILE): \
+    $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jvmstat/$(PROVIDER_FILE)
+	$(install-file)
+
+################################################################################
+
+jdk.jvmstat: $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jvmstat/$(PROVIDER_FILE) \
+    $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jvmstat.rmi/$(PROVIDER_FILE)
+
+all: jdk.jvmstat
+
+.PHONY: all
\ No newline at end of file
--- a/make/gensrc/GensrcCommon.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/gensrc/GensrcCommon.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -33,4 +33,3 @@
 include SetupJavaCompilers.gmk
 # We need the tools.
 include Tools.gmk
-
--- a/make/gensrc/GensrcMisc.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/gensrc/GensrcMisc.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -90,7 +90,6 @@
       SRC := $(GENSRC_UC_SRC), \
       INCLUDE_FILES := $(GENSRC_UC_SRC_FILE), \
       TOOLCHAIN := TOOLCHAIN_BUILD, \
-      CFLAGS := $(filter -D%, $(CFLAGS_JDKEXE)), \
       OBJECT_DIR := $(GENSRC_UC_BIN), \
       OUTPUT_DIR := $(GENSRC_UC_BIN), \
       PROGRAM := genUnixConstants))
--- a/make/gensrc/GensrcProperties.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/gensrc/GensrcProperties.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -75,7 +75,7 @@
 
   # Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
   # to .../support/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
-  # Strip away prefix and suffix, leaving for example only:
+  # Strip away prefix and suffix, leaving for example only: 
   # "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
   $1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \
       $(SUPPORT_OUTPUTDIR)/gensrc/%, \
--- a/make/launcher/Launcher-jdk.jcmd.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/launcher/Launcher-jdk.jcmd.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -30,7 +30,6 @@
     JAVA_ARGS := \
         -Dsun.jvm.hotspot.debugger.useProcDebugger \
         -Dsun.jvm.hotspot.debugger.useWindbgDebugger, \
-    APP_CLASSPATH := /lib/tools.jar /lib/sa-jdi.jar /classes, \
     MACOSX_SIGNED := true, \
 ))
 
@@ -39,7 +38,6 @@
     JAVA_ARGS := \
         -Dsun.jvm.hotspot.debugger.useProcDebugger \
         -Dsun.jvm.hotspot.debugger.useWindbgDebugger, \
-    APP_CLASSPATH := /lib/tools.jar /lib/sa-jdi.jar /classes, \
     MACOSX_SIGNED := true, \
 ))
 
@@ -52,7 +50,6 @@
     JAVA_ARGS := \
         -Dsun.jvm.hotspot.debugger.useProcDebugger \
         -Dsun.jvm.hotspot.debugger.useWindbgDebugger, \
-    APP_CLASSPATH := /lib/tools.jar /lib/sa-jdi.jar /classes, \
     MACOSX_SIGNED := true, \
 ))
 
--- a/make/launcher/Launcher-jdk.jconsole.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/launcher/Launcher-jdk.jconsole.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -28,7 +28,6 @@
 $(eval $(call SetupBuildLauncher, jconsole, \
     MAIN_CLASS := sun.tools.jconsole.JConsole, \
     JAVA_ARGS := -Djconsole.showOutputViewer, \
-    APP_CLASSPATH := /lib/jconsole.jar /lib/tools.jar /classes, \
     CFLAGS_windows := -DJAVAW, \
     LIBS_windows := user32.lib, \
 ))
--- a/make/launcher/Launcher-jdk.jdi.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/launcher/Launcher-jdk.jdi.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -27,5 +27,4 @@
 
 $(eval $(call SetupBuildLauncher, jdb, \
     MAIN_CLASS := com.sun.tools.example.debug.tty.TTY, \
-    APP_CLASSPATH := /lib/tools.jar /lib/sa-jdi.jar /classes, \
 ))
--- a/make/launcher/Launcher-jdk.jvmstat.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-include LauncherCommon.gmk
-
-$(eval $(call SetupBuildLauncher, jstatd, \
-    MAIN_CLASS := sun.tools.jstatd.Jstatd, \
-))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/launcher/Launcher-jdk.jvmstat.rmi.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+include LauncherCommon.gmk
+
+$(eval $(call SetupBuildLauncher, jstatd, \
+    MAIN_CLASS := sun.tools.jstatd.Jstatd, \
+))
--- a/make/launcher/LauncherCommon.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/launcher/LauncherCommon.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -64,7 +64,6 @@
 # Remaining parameters are named arguments. These include:
 # MAIN_CLASS   The Java main class to launch
 # JAVA_ARGS   Processed into a -DJAVA_ARGS C flag
-# APP_CLASSPATH   Processed into a -DAPP_CLASSPATH C flag
 # CFLAGS   Additional CFLAGS
 # CFLAGS_windows   Additional CFLAGS_windows
 # LIBS_unix   Additional LIBS_unix
@@ -103,15 +102,6 @@
     $1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR)
   endif
 
-  ifneq ($$($1_APP_CLASSPATH), )
-    $1_APP_CLASSPATH_STR := '{ $$(strip $$(foreach a, \
-        $$($1_APP_CLASSPATH), "$$a"$(COMMA) )) }'
-    # Remove the trailing comma
-    $1_APP_CLASSPATH_STR := $$(strip $$(subst $$(COMMA) }', }', \
-        $$($1_APP_CLASSPATH_STR)))
-    $1_CFLAGS += -DAPP_CLASSPATH=$$($1_APP_CLASSPATH_STR)
-  endif
-
   $1_LIBS :=
   ifeq ($(OPENJDK_TARGET_OS), macosx)
     ifeq ($$($1_MACOSX_SIGNED), true)
--- a/make/lib/Lib-jdk.crypto.ucrypto.gmk	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/lib/Lib-jdk.crypto.ucrypto.gmk	Wed Dec 02 09:34:55 2015 -0800
@@ -43,7 +43,7 @@
       LDFLAGS := $(LDFLAGS_JDKLIB), \
       LIBS := $(LIBDL), \
       LIBS_solaris := -lc, \
-      OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libj2ucrypto, \
+      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2ucrypto, \
       DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
 
   $(BUILD_LIBJ2UCRYPTO): $(BUILD_LIBJAVA)
--- a/make/mapfiles/libjava/mapfile-vers	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/mapfiles/libjava/mapfile-vers	Wed Dec 02 09:34:55 2015 -0800
@@ -138,9 +138,14 @@
 		Java_java_lang_Double_longBitsToDouble;
 		Java_java_lang_Double_doubleToRawLongBits;
 		Java_java_lang_reflect_Proxy_defineClass0;
-		Java_java_lang_Shutdown_runAllFinalizers;
 		Java_java_lang_Float_intBitsToFloat;
 		Java_java_lang_Float_floatToRawIntBits;
+                Java_java_lang_StackFrameInfo_fillInStackFrames;
+                Java_java_lang_StackFrameInfo_setMethodInfo;
+                Java_java_lang_StackStreamFactory_checkStackWalkModes;
+                Java_java_lang_StackStreamFactory_00024AbstractStackWalker_callStackWalk;
+                Java_java_lang_StackStreamFactory_00024AbstractStackWalker_fetchStackFrames;
+		Java_java_lang_Shutdown_runAllFinalizers;
 		Java_java_lang_StrictMath_IEEEremainder;
 		Java_java_lang_StrictMath_acos;
 		Java_java_lang_StrictMath_asin;
--- a/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java	Wed Dec 02 09:34:55 2015 -0800
@@ -89,7 +89,7 @@
         }
 
         // Filter out platform-unrelated ones. We only support
-        // #ifdef, #ifndef, and #endif.
+        // #ifdef, #ifndef, #else, and #endif. Nesting not supported (yet).
         int mode = 0;   // 0: out of block, 1: in match, 2: in non-match
         Iterator<String> iter = lines.iterator();
         while (iter.hasNext()) {
@@ -105,7 +105,17 @@
                 }
                 iter.remove();
             } else if (line.startsWith("#ifndef ")) {
-                mode = line.endsWith(args[2])?2:1;
+                if (line.indexOf('-') > 0) {
+                    mode = line.endsWith(args[2]+"-"+args[3]) ? 2 : 1;
+                } else {
+                    mode = line.endsWith(args[2]) ? 2 : 1;
+                }
+                iter.remove();
+            } else if (line.startsWith("#else")) {
+                if (mode == 0) {
+                    throw new IllegalStateException("#else not in #if block");
+                }
+                mode = 3 - mode;
                 iter.remove();
             } else {
                 if (mode == 2) iter.remove();
@@ -150,7 +160,7 @@
                                     List<String> args) throws IOException {
         // parse property until EOL, not including line breaks
         boolean first = true;
-        while (!line.isEmpty()) {
+        while (line != null && !line.isEmpty()) {
             if (!line.startsWith("#")) {
                 if (!line.endsWith(",\\") ||
                         (!first && line.contains("="))) {
@@ -169,6 +179,8 @@
                 lines.add(String.format("%"+numSpaces+"s", "") + arg + ",\\");
             }
         }
-        lines.add(line);
+        if (line != null) {
+            lines.add(line);
+        }
     }
 }
--- a/make/src/classes/build/tools/module/boot.modules	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/src/classes/build/tools/module/boot.modules	Wed Dec 02 09:34:55 2015 -0800
@@ -19,6 +19,7 @@
 jdk.charsets
 jdk.deploy
 jdk.deploy.osx
+jdk.vm.cds
 jdk.httpserver
 jdk.jfr
 jdk.management
--- a/make/src/classes/build/tools/module/ext.modules	Sun Nov 29 20:29:45 2015 -0800
+++ b/make/src/classes/build/tools/module/ext.modules	Wed Dec 02 09:34:55 2015 -0800
@@ -9,6 +9,7 @@
 jdk.crypto.mscapi
 jdk.crypto.pkcs11
 jdk.crypto.ucrypto
+jdk.dynalink
 jdk.localedata
 jdk.naming.dns
 jdk.scripting.nashorn
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.nio.ch;
+
+import java.nio.channels.spi.SelectorProvider;
+
+/**
+ * Creates this platform's default SelectorProvider
+ */
+
+public class DefaultSelectorProvider {
+
+    /**
+     * Prevent instantiation.
+     */
+    private DefaultSelectorProvider() { }
+
+    /**
+     * Returns the default SelectorProvider.
+     */
+    public static SelectorProvider create() {
+        return new sun.nio.ch.PollSelectorProvider();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.nio.ch;
+
+import java.nio.channels.spi.SelectorProvider;
+
+/**
+ * Creates this platform's default SelectorProvider
+ */
+
+public class DefaultSelectorProvider {
+
+    /**
+     * Prevent instantiation.
+     */
+    private DefaultSelectorProvider() { }
+
+    /**
+     * Returns the default SelectorProvider.
+     */
+    public static SelectorProvider create() {
+        return new sun.nio.ch.EPollSelectorProvider();
+    }
+
+}
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/PackerImpl.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/PackerImpl.java	Wed Dec 02 09:34:55 2015 -0800
@@ -272,22 +272,6 @@
 
         // (Done collecting options from props.)
 
-        boolean isClassFile(String name) {
-            if (!name.endsWith(".class"))  return false;
-            for (String prefix = name; ; ) {
-                if (passFiles.contains(prefix))  return false;
-                int chop = prefix.lastIndexOf('/');
-                if (chop < 0)  break;
-                prefix = prefix.substring(0, chop);
-            }
-            return true;
-        }
-
-        boolean isMetaInfFile(String name) {
-            return name.startsWith("/" + Utils.METAINF) ||
-                        name.startsWith(Utils.METAINF);
-        }
-
         // Get a new package, based on the old one.
         private void makeNextPackage() {
             pkg.reset();
@@ -332,6 +316,29 @@
             InFile(JarEntry je) {
                 this(null, je);
             }
+            boolean isClassFile() {
+                if (!name.endsWith(".class")) {
+                    return false;
+                }
+                for (String prefix = name;;) {
+                    if (passFiles.contains(prefix)) {
+                        return false;
+                    }
+                    int chop = prefix.lastIndexOf('/');
+                    if (chop < 0) {
+                        break;
+                    }
+                    prefix = prefix.substring(0, chop);
+                }
+                return true;
+            }
+            boolean isMetaInfFile() {
+                return name.startsWith("/" + Utils.METAINF)
+                        || name.startsWith(Utils.METAINF);
+            }
+            boolean mustProcess() {
+                return !isMetaInfFile() && isClassFile();
+            }
             long getInputLength() {
                 long len = (je != null)? je.getSize(): f.length();
                 assert(len >= 0) : this+".len="+len;
@@ -391,7 +398,7 @@
                 Package.File file = null;
                 // (5078608) : discount the resource files in META-INF
                 // from segment computation.
-                long inflen = (isMetaInfFile(name))
+                long inflen = (inFile.isMetaInfFile())
                               ? 0L
                               : inFile.getInputLength();
 
@@ -406,7 +413,7 @@
 
                 assert(je.isDirectory() == name.endsWith("/"));
 
-                if (isClassFile(name)) {
+                if (inFile.mustProcess()) {
                     file = readClass(name, bits.getInputStream());
                 }
                 if (file == null) {
@@ -429,7 +436,7 @@
             for (InFile inFile : inFiles) {
                 String name      = inFile.name;
                 // (5078608) : discount the resource files completely from segmenting
-                long inflen = (isMetaInfFile(name))
+                long inflen = (inFile.isMetaInfFile())
                                ? 0L
                                : inFile.getInputLength() ;
                 if ((segmentSize += inflen) > segmentLimit) {
@@ -447,7 +454,7 @@
                 if (verbose > 1)
                     Utils.log.fine("Reading " + name);
                 Package.File file = null;
-                if (isClassFile(name)) {
+                if (inFile.mustProcess()) {
                     file = readClass(name, strm);
                     if (file == null) {
                         strm.close();
--- a/src/java.base/share/classes/java/io/ObjectStreamClass.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/io/ObjectStreamClass.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,6 +54,8 @@
 import sun.reflect.ReflectionFactory;
 import sun.reflect.misc.ReflectUtil;
 
+import static java.io.ObjectStreamField.*;
+
 /**
  * Serialization's descriptor for classes.  It contains the name and
  * serialVersionUID of the class.  The ObjectStreamClass for a specific class
@@ -1519,62 +1521,15 @@
      * if class names equal, false otherwise.
      */
     private static boolean classNamesEqual(String name1, String name2) {
-        name1 = name1.substring(name1.lastIndexOf('.') + 1);
-        name2 = name2.substring(name2.lastIndexOf('.') + 1);
-        return name1.equals(name2);
+        int idx1 = name1.lastIndexOf('.') + 1;
+        int idx2 = name2.lastIndexOf('.') + 1;
+        int len1 = name1.length() - idx1;
+        int len2 = name2.length() - idx2;
+        return len1 == len2 &&
+                name1.regionMatches(idx1, name2, idx2, len1);
     }
 
     /**
-     * Returns JVM type signature for given primitive.
-     */
-    private static String getPrimitiveSignature(Class<?> cl) {
-        if (cl == Integer.TYPE)
-            return "I";
-        else if (cl == Byte.TYPE)
-            return "B";
-        else if (cl == Long.TYPE)
-            return "J";
-        else if (cl == Float.TYPE)
-            return "F";
-        else if (cl == Double.TYPE)
-            return "D";
-        else if (cl == Short.TYPE)
-            return "S";
-        else if (cl == Character.TYPE)
-            return "C";
-        else if (cl == Boolean.TYPE)
-            return "Z";
-        else if (cl == Void.TYPE)
-            return "V";
-        else
-            throw new InternalError();
-    }
-
-    /**
-     * Returns JVM type signature for given class.
-     */
-    static String getClassSignature(Class<?> cl) {
-        if (cl.isPrimitive())
-            return getPrimitiveSignature(cl);
-        else
-            return appendClassSignature(new StringBuilder(), cl).toString();
-    }
-
-    private static StringBuilder appendClassSignature(StringBuilder sbuf, Class<?> cl) {
-       while (cl.isArray()) {
-           sbuf.append('[');
-           cl = cl.getComponentType();
-       }
-
-       if (cl.isPrimitive())
-           sbuf.append(getPrimitiveSignature(cl));
-       else
-           sbuf.append('L').append(cl.getName().replace('.', '/')).append(';');
-
-       return sbuf;
-   }
-
-    /**
      * Returns JVM type signature for given list of parameters and return type.
      */
     private static String getMethodSignature(Class<?>[] paramTypes,
--- a/src/java.base/share/classes/java/io/ObjectStreamField.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/io/ObjectStreamField.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,7 +91,7 @@
         this.name = name;
         this.type = type;
         this.unshared = unshared;
-        signature = ObjectStreamClass.getClassSignature(type).intern();
+        signature = getClassSignature(type).intern();
         field = null;
     }
 
@@ -124,6 +124,58 @@
     }
 
     /**
+     * Returns JVM type signature for given primitive.
+     */
+    private static String getPrimitiveSignature(Class<?> cl) {
+        if (cl == Integer.TYPE)
+            return "I";
+        else if (cl == Byte.TYPE)
+            return "B";
+        else if (cl == Long.TYPE)
+            return "J";
+        else if (cl == Float.TYPE)
+            return "F";
+        else if (cl == Double.TYPE)
+            return "D";
+        else if (cl == Short.TYPE)
+            return "S";
+        else if (cl == Character.TYPE)
+            return "C";
+        else if (cl == Boolean.TYPE)
+            return "Z";
+        else if (cl == Void.TYPE)
+            return "V";
+        else
+            throw new InternalError();
+    }
+
+    /**
+     * Returns JVM type signature for given class.
+     */
+    static String getClassSignature(Class<?> cl) {
+        if (cl.isPrimitive()) {
+            return getPrimitiveSignature(cl);
+        } else {
+            return appendClassSignature(new StringBuilder(), cl).toString();
+        }
+    }
+
+    static StringBuilder appendClassSignature(StringBuilder sbuf, Class<?> cl) {
+        while (cl.isArray()) {
+            sbuf.append('[');
+            cl = cl.getComponentType();
+        }
+
+        if (cl.isPrimitive()) {
+            sbuf.append(getPrimitiveSignature(cl));
+        } else {
+            sbuf.append('L').append(cl.getName().replace('.', '/')).append(';');
+        }
+
+        return sbuf;
+    }
+
+    /**
      * Creates an ObjectStreamField representing the given field with the
      * specified unshared setting.  For compatibility with the behavior of
      * earlier serialization implementations, a "showType" parameter is
@@ -137,7 +189,7 @@
         name = field.getName();
         Class<?> ftype = field.getType();
         type = (showType || ftype.isPrimitive()) ? ftype : Object.class;
-        signature = ObjectStreamClass.getClassSignature(ftype).intern();
+        signature = getClassSignature(ftype).intern();
     }
 
     /**
--- a/src/java.base/share/classes/java/lang/AbstractStringBuilder.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/AbstractStringBuilder.java	Wed Dec 02 09:34:55 2015 -0800
@@ -732,13 +732,7 @@
      * @return  a reference to this object.
      */
     public AbstractStringBuilder append(int i) {
-        if (i == Integer.MIN_VALUE) {
-            append("-2147483648");
-            return this;
-        }
-        int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1
-                                     : Integer.stringSize(i);
-        int spaceNeeded = count + appendedLength;
+        int spaceNeeded = count + Integer.stringSize(i);
         ensureCapacityInternal(spaceNeeded);
         if (isLatin1()) {
             Integer.getChars(i, spaceNeeded, value);
@@ -764,13 +758,7 @@
      * @return  a reference to this object.
      */
     public AbstractStringBuilder append(long l) {
-        if (l == Long.MIN_VALUE) {
-            append("-9223372036854775808");
-            return this;
-        }
-        int appendedLength = (l < 0) ? Long.stringSize(-l) + 1
-                                     : Long.stringSize(l);
-        int spaceNeeded = count + appendedLength;
+        int spaceNeeded = count + Long.stringSize(l);
         ensureCapacityInternal(spaceNeeded);
         if (isLatin1()) {
             Long.getChars(l, spaceNeeded, value);
--- a/src/java.base/share/classes/java/lang/Integer.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/Integer.java	Wed Dec 02 09:34:55 2015 -0800
@@ -396,7 +396,7 @@
         } while (charPos > offset);
     }
 
-    static final char [] DigitTens = {
+    static final byte[] DigitTens = {
         '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
         '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
         '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
@@ -409,7 +409,7 @@
         '9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
         } ;
 
-    static final char [] DigitOnes = {
+    static final byte[] DigitOnes = {
         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
@@ -422,21 +422,6 @@
         '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
         } ;
 
-        // I use the "invariant division by multiplication" trick to
-        // accelerate Integer.toString.  In particular we want to
-        // avoid division by 10.
-        //
-        // The "trick" has roughly the same performance characteristics
-        // as the "classic" Integer.toString code on a non-JIT VM.
-        // The trick avoids .rem and .div calls but has a longer code
-        // path and is thus dominated by dispatch overhead.  In the
-        // JIT case the dispatch overhead doesn't exist and the
-        // "trick" is considerably faster than the classic code.
-        //
-        // RE:  Division by Invariant Integers using Multiplication
-        //      T Gralund, P Montgomery
-        //      ACM PLDI 1994
-        //
 
     /**
      * Returns a {@code String} object representing the
@@ -450,9 +435,7 @@
      */
     @HotSpotIntrinsicCandidate
     public static String toString(int i) {
-        if (i == Integer.MIN_VALUE)
-            return "-2147483648";
-        int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
+        int size = stringSize(i);
         if (COMPACT_STRINGS) {
             byte[] buf = new byte[size];
             getChars(i, size, buf);
@@ -489,84 +472,105 @@
      * digit at the specified index (exclusive), and working
      * backwards from there.
      *
-     * Will fail if i == Integer.MIN_VALUE
+     * @implNote This method converts positive inputs into negative
+     * values, to cover the Integer.MIN_VALUE case. Converting otherwise
+     * (negative to positive) will expose -Integer.MIN_VALUE that overflows
+     * integer.
      */
     static void getChars(int i, int index, byte[] buf) {
         int q, r;
         int charPos = index;
-        char sign = 0;
 
-        if (i < 0) {
-            sign = '-';
+        boolean negative = i < 0;
+        if (!negative) {
             i = -i;
         }
 
         // Generate two digits per iteration
-        while (i >= 65536) {
+        while (i <= -100) {
             q = i / 100;
-        // really: r = i - (q * 100);
-            r = i - ((q << 6) + (q << 5) + (q << 2));
+            r = (q * 100) - i;
             i = q;
-            buf [--charPos] = (byte)DigitOnes[r];
-            buf [--charPos] = (byte)DigitTens[r];
+            buf[--charPos] = DigitOnes[r];
+            buf[--charPos] = DigitTens[r];
         }
 
-        // Fall thru to fast mode for smaller numbers
-        // assert(i <= 65536, i);
-        for (;;) {
-            q = (i * 52429) >>> (16+3);
-            r = i - ((q << 3) + (q << 1));  // r = i-(q*10) ...
-            buf [--charPos] = (byte)digits [r];
-            i = q;
-            if (i == 0) break;
+        // We know there are at most two digits left at this point.
+        q = i / 10;
+        r = (q * 10) - i;
+        buf[--charPos] = (byte)('0' + r);
+
+        // Whatever left is the remaining digit.
+        if (q < 0) {
+            buf[--charPos] = (byte)('0' - q);
         }
-        if (sign != 0) {
-            buf [--charPos] = (byte)sign;
+
+        if (negative) {
+            buf[--charPos] = (byte)'-';
         }
     }
 
     static void getCharsUTF16(int i, int index, byte[] buf) {
         int q, r;
         int charPos = index;
-        char sign = 0;
 
-        if (i < 0) {
-            sign = '-';
+        boolean negative = (i < 0);
+        if (!negative) {
             i = -i;
         }
 
-        // Generate two digits per iteration
-        while (i >= 65536) {
+        // Get 2 digits/iteration using ints
+        while (i <= -100) {
             q = i / 100;
-        // really: r = i - (q * 100);
-            r = i - ((q << 6) + (q << 5) + (q << 2));
+            r = (q * 100) - i;
             i = q;
             StringUTF16.putChar(buf, --charPos, DigitOnes[r]);
             StringUTF16.putChar(buf, --charPos, DigitTens[r]);
         }
 
-        // Fall thru to fast mode for smaller numbers
-        // assert(i <= 65536, i);
-        for (;;) {
-            q = (i * 52429) >>> (16+3);
-            r = i - ((q << 3) + (q << 1));  // r = i-(q*10) ...
-            StringUTF16.putChar(buf, --charPos, Integer.digits[r]);
-            i = q;
-            if (i == 0) break;
+        // We know there are at most two digits left at this point.
+        q = i / 10;
+        r = (q * 10) - i;
+        StringUTF16.putChar(buf, --charPos, '0' + r);
+
+        // Whatever left is the remaining digit.
+        if (q < 0) {
+            StringUTF16.putChar(buf, --charPos, '0' - q);
         }
-        if (sign != 0) {
-            StringUTF16.putChar(buf, --charPos, sign);
+
+        if (negative) {
+            StringUTF16.putChar(buf, --charPos, '-');
         }
     }
 
+    // Left here for compatibility reasons, see JDK-8143900.
     static final int [] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999,
                                       99999999, 999999999, Integer.MAX_VALUE };
 
-    // Requires positive x
+    /**
+     * Returns the string representation size for a given int value.
+     *
+     * @param x int value
+     * @return string size
+     *
+     * @implNote There are other ways to compute this: e.g. binary search,
+     * but values are biased heavily towards zero, and therefore linear search
+     * wins. The iteration results are also routinely inlined in the generated
+     * code after loop unrolling.
+     */
     static int stringSize(int x) {
-        for (int i=0; ; i++)
-            if (x <= sizeTable[i])
-                return i+1;
+        int d = 1;
+        if (x >= 0) {
+            d = 0;
+            x = -x;
+        }
+        int p = -10;
+        for (int i = 1; i < 10; i++) {
+            if (x > p)
+                return i + d;
+            p = 10 * p;
+        }
+        return 10 + d;
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/lang/LiveStackFrame.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang;
+
+import java.lang.StackWalker.StackFrame;
+import java.util.EnumSet;
+import java.util.Set;
+
+import static java.lang.StackWalker.ExtendedOption.LOCALS_AND_OPERANDS;
+
+/**
+ * <em>UNSUPPORTED</em> This interface is intended to be package-private
+ * or move to an internal package.<p>
+ *
+ * {@code LiveStackFrame} represents a frame storing data and partial results.
+ * Each frame has its own array of local variables (JVMS section 2.6.1),
+ * its own operand stack (JVMS section 2.6.2) for a method invocation.
+ *
+ * @jvms 2.6 Frames
+ */
+/* package-private */
+interface LiveStackFrame extends StackFrame {
+    /**
+     * Return the monitors held by this stack frame. This method returns
+     * an empty array if no monitor is held by this stack frame.
+     *
+     * @return the monitors held by this stack frames
+     */
+    public Object[] getMonitors();
+
+    /**
+     * Gets the local variable array of this stack frame.
+     *
+     * <p>A single local variable can hold a value of type boolean, byte, char,
+     * short, int, float, reference or returnAddress.  A pair of local variables
+     * can hold a value of type long or double.  In other words,
+     * a value of type long or type double occupies two consecutive local
+     * variables.  For a value of primitive type, the element in the
+     * local variable array is an {@link PrimitiveValue} object;
+     * otherwise, the element is an {@code Object}.
+     *
+     * @return  the local variable array of this stack frame.
+     */
+    public Object[] getLocals();
+
+    /**
+     * Gets the operand stack of this stack frame.
+     *
+     * <p>
+     * The 0-th element of the returned array represents the top of the operand stack.
+     * This method returns an empty array if the operand stack is empty.
+     *
+     * <p>Each entry on the operand stack can hold a value of any Java Virtual
+     * Machine Type.
+     * For a value of primitive type, the element in the returned array is
+     * an {@link PrimitiveValue} object; otherwise, the element is the {@code Object}
+     * on the operand stack.
+     *
+     * @return the operand stack of this stack frame.
+     */
+    public Object[] getStack();
+
+    /**
+     * <em>UNSUPPORTED</em> This interface is intended to be package-private
+     * or move to an internal package.<p>
+     *
+     * Represents a local variable or an entry on the operand whose value is
+     * of primitive type.
+     */
+    public abstract class PrimitiveValue {
+        /**
+         * Returns the base type of this primitive value, one of
+         * {@code B, D, C, F, I, J, S, Z}.
+         *
+         * @return Name of a base type
+         * @jvms table 4.3-A
+         */
+        abstract char type();
+
+        /**
+         * Returns the boolean value if this primitive value is of type boolean.
+         * @return the boolean value if this primitive value is of type boolean.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type boolean.
+         */
+        public boolean booleanValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+
+        /**
+         * Returns the int value if this primitive value is of type int.
+         * @return the int value if this primitive value is of type int.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type int.
+         */
+        public int intValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+
+        /**
+         * Returns the long value if this primitive value is of type long.
+         * @return the long value if this primitive value is of type long.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type long.
+         */
+        public long longValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+
+        /**
+         * Returns the char value if this primitive value is of type char.
+         * @return the char value if this primitive value is of type char.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type char.
+         */
+        public char charValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+
+        /**
+         * Returns the byte value if this primitive value is of type byte.
+         * @return the byte value if this primitive value is of type byte.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type byte.
+         */
+        public byte byteValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+
+        /**
+         * Returns the short value if this primitive value is of type short.
+         * @return the short value if this primitive value is of type short.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type short.
+         */
+        public short shortValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+
+        /**
+         * Returns the float value if this primitive value is of type float.
+         * @return the float value if this primitive value is of type float.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type float.
+         */
+        public float floatValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+
+        /**
+         * Returns the double value if this primitive value is of type double.
+         * @return the double value if this primitive value is of type double.
+         *
+         * @throws UnsupportedOperationException if this primitive value is not
+         * of type double.
+         */
+        public double doubleValue() {
+            throw new UnsupportedOperationException("this primitive of type " + type());
+        }
+    }
+
+
+    /**
+     * Gets {@code StackWalker} that can get locals and operands.
+     *
+     * @throws SecurityException if the security manager is present and
+     * denies access to {@code RuntimePermission("liveStackFrames")}
+     */
+    public static StackWalker getStackWalker() {
+        return getStackWalker(EnumSet.noneOf(StackWalker.Option.class));
+    }
+
+    /**
+     * Gets a {@code StackWalker} instance with the given options specifying
+     * the stack frame information it can access, and which will traverse at most
+     * the given {@code maxDepth} number of stack frames.  If no option is
+     * specified, this {@code StackWalker} obtains the method name and
+     * the class name with all
+     * {@linkplain StackWalker.Option#SHOW_HIDDEN_FRAMES hidden frames} skipped.
+     * The returned {@code StackWalker} can get locals and operands.
+     *
+     * @param options stack walk {@link StackWalker.Option options}
+     *
+     * @throws SecurityException if the security manager is present and
+     * it denies access to {@code RuntimePermission("liveStackFrames")}; or
+     * or if the given {@code options} contains
+     * {@link StackWalker.Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE}
+     * and it denies access to {@code StackFramePermission("retainClassReference")}.
+     */
+    public static StackWalker getStackWalker(Set<StackWalker.Option> options) {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new RuntimePermission("liveStackFrames"));
+        }
+        return StackWalker.newInstance(options, LOCALS_AND_OPERANDS);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/lang/LiveStackFrameInfo.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang;
+
+import java.lang.StackWalker.Option;
+import java.util.EnumSet;
+import java.util.Set;
+
+import static java.lang.StackWalker.ExtendedOption.*;
+
+final class LiveStackFrameInfo extends StackFrameInfo implements LiveStackFrame {
+    private static Object[] EMPTY_ARRAY = new Object[0];
+
+    LiveStackFrameInfo(StackWalker walker) {
+        super(walker);
+    }
+
+    // These fields are initialized by the VM if ExtendedOption.LOCALS_AND_OPERANDS is set
+    private Object[] monitors = EMPTY_ARRAY;
+    private Object[] locals = EMPTY_ARRAY;
+    private Object[] operands = EMPTY_ARRAY;
+
+    @Override
+    public Object[] getMonitors() {
+        return monitors;
+    }
+
+    @Override
+    public Object[] getLocals() {
+        return locals;
+    }
+
+    @Override
+    public Object[] getStack() {
+        return operands;
+    }
+
+    /*
+     * Convert primitive value to {@code Primitive} object to represent
+     * a local variable or an element on the operand stack of primitive type.
+     */
+    static PrimitiveValue asPrimitive(boolean value) {
+        return new BooleanPrimitive(value);
+    }
+
+    static PrimitiveValue asPrimitive(int value) {
+        return new IntPrimitive(value);
+    }
+
+    static PrimitiveValue asPrimitive(short value) {
+        return new ShortPrimitive(value);
+    }
+
+    static PrimitiveValue asPrimitive(char value) {
+        return new CharPrimitive(value);
+    }
+
+    static PrimitiveValue asPrimitive(byte value) {
+        return new BytePrimitive(value);
+    }
+
+    static PrimitiveValue asPrimitive(long value) {
+        return new LongPrimitive(value);
+    }
+
+    static PrimitiveValue asPrimitive(float value) {
+        return new FloatPrimitive(value);
+    }
+
+    static PrimitiveValue asPrimitive(double value) {
+        return new DoublePrimitive(value);
+    }
+
+    private static class IntPrimitive extends PrimitiveValue {
+        final int value;
+        IntPrimitive(int value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'I';
+        }
+
+        @Override
+        public int intValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+
+    private static class ShortPrimitive extends PrimitiveValue {
+        final short value;
+        ShortPrimitive(short value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'S';
+        }
+
+        @Override
+        public short shortValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+
+    private static class BooleanPrimitive extends PrimitiveValue {
+        final boolean value;
+        BooleanPrimitive(boolean value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'Z';
+        }
+
+        @Override
+        public boolean booleanValue()  {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+
+    private static class CharPrimitive extends PrimitiveValue {
+        final char value;
+        CharPrimitive(char value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'C';
+        }
+
+        @Override
+        public char charValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+
+    private static class BytePrimitive extends PrimitiveValue {
+        final byte value;
+        BytePrimitive(byte value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'B';
+        }
+
+        @Override
+        public byte byteValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+
+    private static class LongPrimitive extends PrimitiveValue {
+        final long value;
+        LongPrimitive(long value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'J';
+        }
+
+        @Override
+        public long longValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+
+    private static class FloatPrimitive extends PrimitiveValue {
+        final float value;
+        FloatPrimitive(float value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'F';
+        }
+
+        @Override
+        public float floatValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+
+    private static class DoublePrimitive extends PrimitiveValue {
+        final double value;
+        DoublePrimitive(double value) {
+            this.value = value;
+        }
+
+        @Override
+        public char type() {
+            return 'D';
+        }
+
+        @Override
+        public double doubleValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(value);
+        }
+    }
+}
--- a/src/java.base/share/classes/java/lang/Long.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/Long.java	Wed Dec 02 09:34:55 2015 -0800
@@ -448,9 +448,7 @@
      * @return  a string representation of the argument in base&nbsp;10.
      */
     public static String toString(long i) {
-        if (i == Long.MIN_VALUE)
-            return "-9223372036854775808";
-        int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
+        int size = stringSize(i);
         if (COMPACT_STRINGS) {
             byte[] buf = new byte[size];
             getChars(i, size, buf);
@@ -481,58 +479,59 @@
     }
 
     /**
-     * Places characters representing the integer i into the
+     * Places characters representing the long i into the
      * character array buf. The characters are placed into
      * the buffer backwards starting with the least significant
      * digit at the specified index (exclusive), and working
      * backwards from there.
      *
-     * Will fail if i == Long.MIN_VALUE
+     * @implNote This method converts positive inputs into negative
+     * values, to cover the Long.MIN_VALUE case. Converting otherwise
+     * (negative to positive) will expose -Long.MIN_VALUE that overflows
+     * long.
      */
     static void getChars(long i, int index, byte[] buf) {
         long q;
         int r;
         int charPos = index;
-        char sign = 0;
 
-        if (i < 0) {
-            sign = '-';
+        boolean negative = (i < 0);
+        if (!negative) {
             i = -i;
         }
 
         // Get 2 digits/iteration using longs until quotient fits into an int
-        while (i > Integer.MAX_VALUE) {
+        while (i <= Integer.MIN_VALUE) {
             q = i / 100;
-            // really: r = i - (q * 100);
-            r = (int)(i - ((q << 6) + (q << 5) + (q << 2)));
+            r = (int)((q * 100) - i);
             i = q;
-            buf[--charPos] = (byte)Integer.DigitOnes[r];
-            buf[--charPos] = (byte)Integer.DigitTens[r];
+            buf[--charPos] = Integer.DigitOnes[r];
+            buf[--charPos] = Integer.DigitTens[r];
         }
 
         // Get 2 digits/iteration using ints
         int q2;
         int i2 = (int)i;
-        while (i2 >= 65536) {
+        while (i2 <= -100) {
             q2 = i2 / 100;
-            // really: r = i2 - (q * 100);
-            r = i2 - ((q2 << 6) + (q2 << 5) + (q2 << 2));
+            r  = (q2 * 100) - i2;
             i2 = q2;
-            buf[--charPos] = (byte)Integer.DigitOnes[r];
-            buf[--charPos] = (byte)Integer.DigitTens[r];
+            buf[--charPos] = Integer.DigitOnes[r];
+            buf[--charPos] = Integer.DigitTens[r];
         }
 
-        // Fall thru to fast mode for smaller numbers
-        // assert(i2 <= 65536, i2);
-        for (;;) {
-            q2 = (i2 * 52429) >>> (16+3);
-            r = i2 - ((q2 << 3) + (q2 << 1));  // r = i2-(q2*10) ...
-            buf[--charPos] = (byte)Integer.digits[r];
-            i2 = q2;
-            if (i2 == 0) break;
+        // We know there are at most two digits left at this point.
+        q2 = i2 / 10;
+        r  = (q2 * 10) - i2;
+        buf[--charPos] = (byte)('0' + r);
+
+        // Whatever left is the remaining digit.
+        if (q2 < 0) {
+            buf[--charPos] = (byte)('0' - q2);
         }
-        if (sign != 0) {
-            buf[--charPos] = (byte)sign;
+
+        if (negative) {
+            buf[--charPos] = (byte)'-';
         }
     }
 
@@ -540,18 +539,16 @@
         long q;
         int r;
         int charPos = index;
-        char sign = 0;
 
-        if (i < 0) {
-            sign = '-';
+        boolean negative = (i < 0);
+        if (!negative) {
             i = -i;
         }
 
         // Get 2 digits/iteration using longs until quotient fits into an int
-        while (i > Integer.MAX_VALUE) {
+        while (i <= Integer.MIN_VALUE) {
             q = i / 100;
-            // really: r = i - (q * 100);
-            r = (int)(i - ((q << 6) + (q << 5) + (q << 2)));
+            r = (int)((q * 100) - i);
             i = q;
             StringUTF16.putChar(buf, --charPos, Integer.DigitOnes[r]);
             StringUTF16.putChar(buf, --charPos, Integer.DigitTens[r]);
@@ -560,38 +557,53 @@
         // Get 2 digits/iteration using ints
         int q2;
         int i2 = (int)i;
-        while (i2 >= 65536) {
+        while (i2 <= -100) {
             q2 = i2 / 100;
-            // really: r = i2 - (q * 100);
-            r = i2 - ((q2 << 6) + (q2 << 5) + (q2 << 2));
+            r  = (q2 * 100) - i2;
             i2 = q2;
             StringUTF16.putChar(buf, --charPos, Integer.DigitOnes[r]);
             StringUTF16.putChar(buf, --charPos, Integer.DigitTens[r]);
         }
 
-        // Fall thru to fast mode for smaller numbers
-        // assert(i2 <= 65536, i2);
-        for (;;) {
-            q2 = (i2 * 52429) >>> (16+3);
-            r = i2 - ((q2 << 3) + (q2 << 1));  // r = i2-(q2*10) ...
-            StringUTF16.putChar(buf, --charPos, Integer.digits[r]);
-            i2 = q2;
-            if (i2 == 0) break;
+        // We know there are at most two digits left at this point.
+        q2 = i2 / 10;
+        r  = (q2 * 10) - i2;
+        StringUTF16.putChar(buf, --charPos, '0' + r);
+
+        // Whatever left is the remaining digit.
+        if (q2 < 0) {
+            StringUTF16.putChar(buf, --charPos, '0' - q2);
         }
-        if (sign != 0) {
-            StringUTF16.putChar(buf, --charPos, sign);
+
+        if (negative) {
+            StringUTF16.putChar(buf, --charPos, '-');
         }
     }
 
-    // Requires positive x
+    /**
+     * Returns the string representation size for a given long value.
+     *
+     * @param x long value
+     * @return string size
+     *
+     * @implNote There are other ways to compute this: e.g. binary search,
+     * but values are biased heavily towards zero, and therefore linear search
+     * wins. The iteration results are also routinely inlined in the generated
+     * code after loop unrolling.
+     */
     static int stringSize(long x) {
-        long p = 10;
-        for (int i=1; i<19; i++) {
-            if (x < p)
-                return i;
-            p = 10*p;
+        int d = 1;
+        if (x >= 0) {
+            d = 0;
+            x = -x;
         }
-        return 19;
+        long p = -10;
+        for (int i = 1; i < 19; i++) {
+            if (x > p)
+                return i + d;
+            p = 10 * p;
+        }
+        return 19 + d;
     }
 
     /**
--- a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java	Wed Dec 02 09:34:55 2015 -0800
@@ -359,7 +359,14 @@
 
     @Override
     public Stream<ProcessHandle> children() {
-        return children(pid);
+        // The native OS code selects based on matching the requested parent pid.
+        // If the original parent exits, the pid may have been re-used for
+        // this newer process.
+        // Processes started by the original parent (now dead) will all have
+        // start times less than the start of this newer parent.
+        // Processes started by this newer parent will have start times equal
+        // or after this parent.
+        return children(pid).filter(ph -> startTime <= ((ProcessHandleImpl)ph).startTime);
     }
 
     /**
@@ -408,11 +415,21 @@
         int next = 0;       // index of next process to check
         int count = -1;     // count of subprocesses scanned
         long ppid = pid;    // start looking for this parent
+        long ppStart = 0;
+        // Find the start time of the parent
+        for (int i = 0; i < size; i++) {
+            if (pids[i] == ppid) {
+                ppStart = starttimes[i];
+                break;
+            }
+        }
         do {
-            // Scan from next to size looking for ppid
-            // if found, exchange it to index next
+            // Scan from next to size looking for ppid with child start time
+            // the same or later than the parent.
+            // If found, exchange it with index next
             for (int i = next; i < size; i++) {
-                if (ppids[i] == ppid) {
+                if (ppids[i] == ppid &&
+                        ppStart <= starttimes[i]) {
                     swap(pids, i, next);
                     swap(ppids, i, next);
                     swap(starttimes, i, next);
@@ -420,6 +437,7 @@
                 }
             }
             ppid = pids[++count];   // pick up the next pid to scan for
+            ppStart = starttimes[count];    // and its start time
         } while (count < next);
 
         final long[] cpids = pids;
--- a/src/java.base/share/classes/java/lang/Runtime.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/Runtime.java	Wed Dec 02 09:34:55 2015 -0800
@@ -44,7 +44,7 @@
  */
 
 public class Runtime {
-    private static Runtime currentRuntime = new Runtime();
+    private static final Runtime currentRuntime = new Runtime();
 
     /**
      * Returns the runtime object associated with the current Java application.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/lang/StackFrameInfo.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang;
+
+import jdk.internal.misc.JavaLangInvokeAccess;
+import jdk.internal.misc.SharedSecrets;
+
+import static java.lang.StackWalker.Option.*;
+import java.lang.StackWalker.StackFrame;
+import java.util.Optional;
+import java.util.OptionalInt;
+
+class StackFrameInfo implements StackFrame {
+    private final static JavaLangInvokeAccess jlInvokeAccess =
+        SharedSecrets.getJavaLangInvokeAccess();
+
+    // -XX:+MemberNameInStackFrame will initialize MemberName and all other fields;
+    // otherwise, VM will set the hidden fields (injected by the VM).
+    // -XX:+MemberNameInStackFrame is temporary to enable performance measurement
+    //
+    // Footprint improvement: MemberName::clazz and MemberName::name
+    // can replace StackFrameInfo::declaringClass and StackFrameInfo::methodName
+    // Currently VM sets StackFrameInfo::methodName instead of expanding MemberName::name
+
+    final StackWalker walker;
+    final Class<?> declaringClass;
+    final Object memberName;
+    final int bci;
+
+    // methodName, fileName, and lineNumber will be lazily set by the VM
+    // when first requested.
+    private String methodName;
+    private String fileName = null;     // default for unavailable filename
+    private int    lineNumber = -1;     // default for unavailable lineNumber
+
+    /*
+     * Create StackFrameInfo for StackFrameTraverser and LiveStackFrameTraverser
+     * to use
+     */
+    StackFrameInfo(StackWalker walker) {
+        this.walker = walker;
+        this.declaringClass = null;
+        this.bci = -1;
+        this.memberName = jlInvokeAccess.newMemberName();
+    }
+
+    @Override
+    public String getClassName() {
+        return declaringClass.getName();
+    }
+
+    @Override
+    public Class<?> getDeclaringClass() {
+        walker.ensureAccessEnabled(RETAIN_CLASS_REFERENCE);
+        return declaringClass;
+    }
+
+    // Call the VM to set methodName, lineNumber, and fileName
+    private synchronized void ensureMethodInfoInitialized() {
+        if (methodName == null) {
+            setMethodInfo();
+        }
+    }
+
+    @Override
+    public String getMethodName() {
+        ensureMethodInfoInitialized();
+        return methodName;
+    }
+
+    @Override
+    public Optional<String> getFileName() {
+        ensureMethodInfoInitialized();
+        return fileName != null ? Optional.of(fileName) : Optional.empty();
+    }
+
+    @Override
+    public OptionalInt getLineNumber() {
+        ensureMethodInfoInitialized();
+        return lineNumber > 0 ? OptionalInt.of(lineNumber) : OptionalInt.empty();
+    }
+
+    @Override
+    public boolean isNativeMethod() {
+        ensureMethodInfoInitialized();
+        return lineNumber == -2;
+    }
+
+    @Override
+    public String toString() {
+        ensureMethodInfoInitialized();
+        // similar format as StackTraceElement::toString
+        if (isNativeMethod()) {
+            return getClassName() + "." + getMethodName() + "(Native Method)";
+        } else {
+            // avoid allocating Optional objects
+            return getClassName() + "." + getMethodName() +
+                "(" + (fileName != null ? fileName : "Unknown Source") +
+                      (lineNumber > 0 ? ":" + lineNumber : " bci:" + bci) + ")";
+        }
+    }
+
+    /**
+     * Lazily initialize method name, file name, line number
+     */
+    private native void setMethodInfo();
+
+    /**
+     * Fill in source file name and line number of the given StackFrame array.
+     */
+    static native void fillInStackFrames(int startIndex,
+                                         Object[] stackframes,
+                                         int fromIndex, int toIndex);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/lang/StackFramePermission.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang;
+
+/**
+ * Permission to access {@link StackWalker.StackFrame}.
+ *
+ * @see java.lang.StackWalker.Option#RETAIN_CLASS_REFERENCE
+ * @see StackWalker.StackFrame#getDeclaringClass()
+ */
+public class StackFramePermission extends java.security.BasicPermission {
+    private static final long serialVersionUID = 2841894854386706014L;
+
+    /**
+     * Creates a new {@code StackFramePermission} object.
+     *
+     * @param name Permission name.  Must be "retainClassReference".
+     *
+     * @throws IllegalArgumentException if {@code name} is invalid.
+     * @throws NullPointerException if {@code name} is {@code null}.
+     */
+    public StackFramePermission(String name) {
+        super(name);
+        if (!name.equals("retainClassReference")) {
+            throw new IllegalArgumentException("name: " + name);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/lang/StackStreamFactory.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,1106 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang;
+
+import sun.misc.VM;
+
+import java.io.PrintStream;
+import java.lang.StackWalker.Option;
+import java.lang.StackWalker.StackFrame;
+
+import java.lang.annotation.Native;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+import static java.lang.StackStreamFactory.WalkerState.*;
+
+/**
+ * StackStreamFactory class provides static factory methods
+ * to get different kinds of stack walker/traverser.
+ *
+ * AbstractStackWalker provides the basic stack walking support
+ * fetching stack frames from VM in batches.
+ *
+ * AbstractStackWalker subclass is specialized for a specific kind of stack traversal
+ * to avoid overhead of Stream/Lambda
+ * 1. Support traversing Stream<StackFrame>
+ * 2. StackWalker::getCallerClass
+ * 3. Throwable::init and Throwable::getStackTrace
+ * 4. AccessControlContext getting ProtectionDomain
+ */
+final class StackStreamFactory {
+    private StackStreamFactory() {}
+
+    // Stack walk implementation classes to be excluded during stack walking
+    // lazily add subclasses when they are loaded.
+    private final static Set<Class<?>> stackWalkImplClasses = init();
+
+    private static final int SMALL_BATCH       = 8;
+    private static final int BATCH_SIZE        = 32;
+    private static final int LARGE_BATCH_SIZE  = 256;
+    private static final int MIN_BATCH_SIZE    = SMALL_BATCH;
+
+    // These flags must match the values maintained in the VM
+    @Native private static final int DEFAULT_MODE              = 0x0;
+    @Native private static final int FILL_CLASS_REFS_ONLY      = 0x2;
+    @Native private static final int FILTER_FILL_IN_STACKTRACE = 0x10;
+    @Native private static final int SHOW_HIDDEN_FRAMES        = 0x20;  // LambdaForms are hidden by the VM
+    @Native private static final int FILL_LIVE_STACK_FRAMES    = 0x100;
+
+    /*
+     * For Throwable to use StackWalker, set useNewThrowable to true.
+     * Performance work and extensive testing is needed to replace the
+     * VM built-in backtrace filled in Throwable with the StackWalker.
+     */
+    final static boolean useNewThrowable = getProperty("stackwalk.newThrowable", false);
+    final static boolean isDebug = getProperty("stackwalk.debug", false);
+
+    static <T> StackFrameTraverser<T>
+        makeStackTraverser(StackWalker walker, Function<? super Stream<StackFrame>, ? extends T> function)
+    {
+        if (walker.hasLocalsOperandsOption())
+            return new LiveStackInfoTraverser<T>(walker, function);
+        else
+            return new StackFrameTraverser<T>(walker, function);
+    }
+
+    /**
+     * Gets a stack stream to find caller class.
+     */
+    static CallerClassFinder makeCallerFinder(StackWalker walker) {
+        return new CallerClassFinder(walker);
+    }
+
+    static boolean useStackTrace(Throwable t) {
+        if (t instanceof VirtualMachineError)
+            return false;
+
+        return VM.isBooted() && StackStreamFactory.useNewThrowable;
+    }
+
+    /*
+     * This should only be used by Throwable::<init>.
+     */
+    static StackTrace makeStackTrace(Throwable ex) {
+        return StackTrace.dump(ex);
+    }
+
+    /*
+     * This creates StackTrace for Thread::dumpThread to use.
+     */
+    static StackTrace makeStackTrace() {
+        return StackTrace.dump();
+    }
+
+    enum WalkerState {
+        NEW,     // the stream is new and stack walking has not started
+        OPEN,    // the stream is open when it is being traversed.
+        CLOSED;  // the stream is closed when the stack walking is done
+    }
+
+    static abstract class AbstractStackWalker<T> {
+        protected final StackWalker walker;
+        protected final Thread thread;
+        protected final int maxDepth;
+        protected final long mode;
+        protected int depth;                 // traversed stack depth
+        protected FrameBuffer frameBuffer;   // buffer for VM to fill in
+        protected long anchor;
+
+        // buffers to fill in stack frame information
+        protected AbstractStackWalker(StackWalker walker, int mode) {
+            this(walker, mode, Integer.MAX_VALUE);
+        }
+        protected AbstractStackWalker(StackWalker walker, int mode, int maxDepth) {
+            this.thread = Thread.currentThread();
+            this.mode = toStackWalkMode(walker, mode);
+            this.walker = walker;
+            this.maxDepth = maxDepth;
+            this.depth = 0;
+        }
+
+        private int toStackWalkMode(StackWalker walker, int mode) {
+            int newMode = mode;
+            if (walker.hasOption(Option.SHOW_HIDDEN_FRAMES) &&
+                    !fillCallerClassOnly(newMode) /* don't show hidden frames for getCallerClass */)
+                newMode |= SHOW_HIDDEN_FRAMES;
+            if (walker.hasLocalsOperandsOption())
+                newMode |= FILL_LIVE_STACK_FRAMES;
+            return newMode;
+        }
+
+        private boolean fillCallerClassOnly(int mode) {
+            return (mode|FILL_CLASS_REFS_ONLY) != FILL_CLASS_REFS_ONLY;
+        }
+        /**
+         * A callback method to consume the stack frames.  This method is invoked
+         * once stack walking begins (i.e. it is only invoked when walkFrames is called).
+         *
+         * Each specialized AbstractStackWalker subclass implements the consumeFrames method
+         * to control the following:
+         * 1. fetch the subsequent batches of stack frames
+         * 2. reuse or expand the allocated buffers
+         * 3. create specialized StackFrame objects
+         *
+         * @return the number of consumed frames
+         */
+         protected abstract T consumeFrames();
+
+        /**
+         * Initialize FrameBuffer.  Subclass should implement this method to
+         * create its custom frame buffers.
+         */
+         protected abstract void initFrameBuffer();
+
+        /**
+         * Returns the suggested next batch size.
+         *
+         * Subclass should override this method to change the batch size
+         *
+         * @param lastBatchFrameCount number of frames in the last batch; or zero
+         * @return suggested batch size
+         */
+        protected abstract int batchSize(int lastBatchFrameCount);
+
+        /*
+         * Returns the next batch size, always >= minimum batch size (32)
+         *
+         * Subclass may override this method if the minimum batch size is different.
+         */
+        protected int getNextBatchSize() {
+            int lastBatchSize = depth == 0 ? 0 : frameBuffer.curBatchFrameCount();
+            int nextBatchSize = batchSize(lastBatchSize);
+            if (isDebug) {
+                System.err.println("last batch size = " + lastBatchSize +
+                                   " next batch size = " + nextBatchSize);
+            }
+            return nextBatchSize >= MIN_BATCH_SIZE ? nextBatchSize : MIN_BATCH_SIZE;
+        }
+
+        /*
+         * Checks if this stream is in the given state. Otherwise, throws IllegalStateException.
+         *
+         * VM also validates this stream if it's anchored for stack walking
+         * when stack frames are fetched for each batch.
+         */
+        final void checkState(WalkerState state) {
+            if (thread != Thread.currentThread()) {
+                throw new IllegalStateException("Invalid thread walking this stack stream: " +
+                        Thread.currentThread().getName() + " " + thread.getName());
+            }
+            switch (state) {
+                case NEW:
+                    if (anchor != 0) {
+                        throw new IllegalStateException("This stack stream is being reused.");
+                    }
+                    break;
+                case OPEN:
+                    if (anchor == 0 || anchor == -1L) {
+                        throw new IllegalStateException("This stack stream is not valid for walking.");
+                    }
+                    break;
+                case CLOSED:
+                    if (anchor != -1L) {
+                        throw new IllegalStateException("This stack stream is not closed.");
+                    }
+            }
+        }
+
+        /*
+         * Close this stream.  This stream becomes invalid to walk.
+         */
+        private void close() {
+            this.anchor = -1L;
+        }
+
+        /*
+         * Walks stack frames until {@link #consumeFrames} is done consuming
+         * the frames it is interested in.
+         */
+        final T walk() {
+            checkState(NEW);
+            try {
+                // VM will need to stablize the stack before walking.  It will invoke
+                // the AbstractStackWalker::doStackWalk method once it fetches the first batch.
+                // the callback will be invoked within the scope of the callStackWalk frame.
+                return beginStackWalk();
+            } finally {
+                close();  // done traversal; close the stream
+            }
+        }
+
+        private boolean skipReflectionFrames() {
+            return !walker.hasOption(Option.SHOW_REFLECT_FRAMES) &&
+                       !walker.hasOption(Option.SHOW_HIDDEN_FRAMES);
+        }
+
+        /*
+         * Returns {@code Class} object at the current frame;
+         * or {@code null} if no more frame. If advanceToNextBatch is true,
+         * it will only fetch the next batch.
+         */
+        final Class<?> peekFrame() {
+            while (frameBuffer.isActive() && depth < maxDepth) {
+                if (frameBuffer.isEmpty()) {
+                    // fetch another batch of stack frames
+                    getNextBatch();
+                } else {
+                    Class<?> c = frameBuffer.get();
+                    if (skipReflectionFrames() && isReflectionFrame(c)) {
+                        if (isDebug)
+                            System.err.println("  skip: frame " + frameBuffer.getIndex() + " " + c);
+
+                        frameBuffer.next();
+                        depth++;
+                        continue;
+                    } else {
+                        return c;
+                    }
+                }
+            }
+            return null;
+        }
+
+        /*
+         * This method is only invoked by VM.
+         *
+         * It will invoke the consumeFrames method to start the stack walking
+         * with the first batch of stack frames.  Each specialized AbstractStackWalker
+         * subclass implements the consumeFrames method to control the following:
+         * 1. fetch the subsequent batches of stack frames
+         * 2. reuse or expand the allocated buffers
+         * 3. create specialized StackFrame objects
+         */
+        private Object doStackWalk(long anchor, int skipFrames, int batchSize,
+                                                int bufStartIndex, int bufEndIndex) {
+            checkState(NEW);
+
+            frameBuffer.check(skipFrames);
+
+            if (isDebug) {
+                System.err.format("doStackWalk: skip %d start %d end %d%n",
+                        skipFrames, bufStartIndex, bufEndIndex);
+            }
+
+            this.anchor = anchor;  // set anchor for this bulk stack frame traversal
+            frameBuffer.setBatch(bufStartIndex, bufEndIndex);
+
+            // traverse all frames and perform the action on the stack frames, if specified
+            return consumeFrames();
+        }
+
+        /*
+         * Get next batch of stack frames.
+         */
+        private int getNextBatch() {
+            int nextBatchSize = Math.min(maxDepth - depth, getNextBatchSize());
+            if (!frameBuffer.isActive() || nextBatchSize <= 0) {
+                if (isDebug) {
+                    System.out.format("  more stack walk done%n");
+                }
+                frameBuffer.freeze();   // stack walk done
+                return 0;
+            }
+
+            return fetchStackFrames(nextBatchSize);
+        }
+
+        /*
+         * This method traverses the next stack frame and returns the Class
+         * invoking that stack frame.
+         *
+         * This method can only be called during the walk method.  This is intended
+         * to be used to walk the stack frames in one single invocation and
+         * this stack stream will be invalidated once walk is done.
+         *
+         * @see #tryNextFrame
+         */
+        final Class<?> nextFrame() {
+            if (!hasNext()) {
+                return null;
+            }
+
+            Class<?> c = frameBuffer.next();
+            depth++;
+            return c;
+        }
+
+        /*
+         * Returns true if there is next frame to be traversed.
+         * This skips hidden frames unless this StackWalker has
+         * {@link Option#SHOW_REFLECT_FRAMES}
+         */
+        final boolean hasNext() {
+            return peekFrame() != null;
+        }
+
+        /**
+         * Begin stack walking - pass the allocated arrays to the VM to fill in
+         * stack frame information.
+         *
+         * VM first anchors the frame of the current thread.  A traversable stream
+         * on this thread's stack will be opened.  The VM will fetch the first batch
+         * of stack frames and call AbstractStackWalker::doStackWalk to invoke the
+         * stack walking function on each stack frame.
+         *
+         * If all fetched stack frames are traversed, AbstractStackWalker::fetchStackFrames will
+         * fetch the next batch of stack frames to continue.
+         */
+        private T beginStackWalk() {
+            // initialize buffers for VM to fill the stack frame info
+            initFrameBuffer();
+
+            return callStackWalk(mode, 0,
+                                 frameBuffer.curBatchFrameCount(),
+                                 frameBuffer.startIndex(),
+                                 frameBuffer.classes,
+                                 frameBuffer.stackFrames);
+        }
+
+        /*
+         * Fetches stack frames.
+         *
+         * @params batchSize number of elements of the frame  buffers for this batch
+         * @returns number of frames fetched in this batch
+         */
+        private int fetchStackFrames(int batchSize) {
+            int startIndex = frameBuffer.startIndex();
+            frameBuffer.resize(startIndex, batchSize);
+
+            int endIndex = fetchStackFrames(mode, anchor, batchSize,
+                                            startIndex,
+                                            frameBuffer.classes,
+                                            frameBuffer.stackFrames);
+            if (isDebug) {
+                System.out.format("  more stack walk requesting %d got %d to %d frames%n",
+                                  batchSize, frameBuffer.startIndex(), endIndex);
+            }
+            int numFrames = endIndex - startIndex;
+            if (numFrames == 0) {
+                frameBuffer.freeze(); // done stack walking
+            } else {
+                frameBuffer.setBatch(startIndex, endIndex);
+            }
+            return numFrames;
+        }
+
+        /**
+         * Begins stack walking.  This method anchors this frame and invokes
+         * AbstractStackWalker::doStackWalk after fetching the firt batch of stack frames.
+         *
+         * @param mode        mode of stack walking
+         * @param skipframes  number of frames to be skipped before filling the frame buffer.
+         * @param batchSize   the batch size, max. number of elements to be filled in the frame buffers.
+         * @param startIndex  start index of the frame buffers to be filled.
+         * @param classes     Classes buffer of the stack frames
+         * @param frames      StackFrame buffer, or null
+         * @return            Result of AbstractStackWalker::doStackWalk
+         */
+        private native T callStackWalk(long mode, int skipframes,
+                                       int batchSize, int startIndex,
+                                       Class<?>[] classes,
+                                       StackFrame[] frames);
+
+        /**
+         * Fetch the next batch of stack frames.
+         *
+         * @param mode        mode of stack walking
+         * @param anchor
+         * @param batchSize   the batch size, max. number of elements to be filled in the frame buffers.
+         * @param startIndex  start index of the frame buffers to be filled.
+         * @param classes     Classes buffer of the stack frames
+         * @param frames      StackFrame buffer, or null
+         *
+         * @return the end index to the frame buffers
+         */
+        private native int fetchStackFrames(long mode, long anchor,
+                                            int batchSize, int startIndex,
+                                            Class<?>[] classes,
+                                            StackFrame[] frames);
+
+
+        /*
+         * Frame buffer
+         *
+         * Each specialized AbstractStackWalker subclass may subclass the FrameBuffer.
+         */
+        class FrameBuffer {
+            static final int START_POS = 2;     // 0th and 1st elements are reserved
+
+            // buffers for VM to fill stack frame info
+            int currentBatchSize;    // current batch size
+            Class<?>[] classes;      // caller class for fast path
+
+            StackFrame[] stackFrames;
+
+            int origin;         // index to the current traversed stack frame
+            int fence;          // index to the last frame in the current batch
+
+            FrameBuffer(int initialBatchSize) {
+                if (initialBatchSize < MIN_BATCH_SIZE) {
+                    throw new IllegalArgumentException(initialBatchSize + " < minimum batch size: " + MIN_BATCH_SIZE);
+                }
+                this.origin = START_POS;
+                this.fence = 0;
+                this.currentBatchSize = initialBatchSize;
+                this.classes = new Class<?>[currentBatchSize];
+            }
+
+            int curBatchFrameCount() {
+                return currentBatchSize-START_POS;
+            }
+
+            /*
+             * Tests if this frame buffer is empty.  All frames are fetched.
+             */
+            final boolean isEmpty() {
+                return origin >= fence || (origin == START_POS && fence == 0);
+            }
+
+            /*
+             * Freezes this frame buffer.  The stack stream source is done fetching.
+             */
+            final void freeze() {
+                origin = 0;
+                fence = 0;
+            }
+
+            /*
+             * Tests if this frame buffer is active.  It is inactive when
+             * it is done for traversal.  All stack frames have been traversed.
+             */
+            final boolean isActive() {
+                return origin > 0 && (fence == 0 || origin < fence || fence == currentBatchSize);
+            }
+
+            /**
+             * Gets the class at the current frame and move to the next frame.
+             */
+            final Class<?> next() {
+                if (isEmpty()) {
+                    throw new NoSuchElementException("origin=" + origin + " fence=" + fence);
+                }
+                Class<?> c = classes[origin++];
+                if (isDebug) {
+                    int index = origin-1;
+                    System.out.format("  next frame at %d: %s (origin %d fence %d)%n", index,
+                                      Objects.toString(c), index, fence);
+                }
+                return c;
+            }
+
+            /**
+             * Gets the class at the current frame.
+             */
+            final Class<?> get() {
+                if (isEmpty()) {
+                    throw new NoSuchElementException("origin=" + origin + " fence=" + fence);
+                }
+                return classes[origin];
+            }
+
+            /*
+             * Returns the index of the current frame.
+             */
+            final int getIndex() {
+                return origin;
+            }
+
+            /*
+             * Set the start and end index of a new batch of stack frames that have
+             * been filled in this frame buffer.
+             */
+            final void setBatch(int startIndex, int endIndex) {
+                if (startIndex <= 0 || endIndex <= 0)
+                    throw new IllegalArgumentException("startIndex=" + startIndex + " endIndex=" + endIndex);
+
+                this.origin = startIndex;
+                this.fence = endIndex;
+                if (depth == 0 && fence > 0) {
+                    // filter the frames due to the stack stream implementation
+                    for (int i = START_POS; i < fence; i++) {
+                        Class<?> c = classes[i];
+                        if (isDebug) System.err.format("  frame %d: %s%n", i, c);
+                        if (filterStackWalkImpl(c)) {
+                            origin++;
+                        } else {
+                            break;
+                        }
+                    }
+                }
+            }
+
+            /*
+             * Checks if the origin is the expected start index.
+             */
+            final void check(int skipFrames) {
+                int index = skipFrames + START_POS;
+                if (origin != index) {
+                    // stack walk must continue with the previous frame depth
+                    throw new IllegalStateException("origin " + origin + " != " + index);
+                }
+            }
+
+            // ------ subclass may override the following methods -------
+            /**
+             * Resizes the buffers for VM to fill in the next batch of stack frames.
+             * The next batch will start at the given startIndex with the maximum number
+             * of elements.
+             *
+             * <p> Subclass may override this method to manage the allocated buffers.
+             *
+             * @param startIndex the start index for the first frame of the next batch to fill in.
+             * @param elements the number of elements for the next batch to fill in.
+             *
+             */
+            void resize(int startIndex, int elements) {
+                if (!isActive())
+                    throw new IllegalStateException("inactive frame buffer can't be resized");
+
+                int size = startIndex+elements;
+                if (classes.length < size) {
+                    // copy the elements in classes array to the newly allocated one.
+                    // classes[0] is a Thread object
+                    Class<?>[] prev = classes;
+                    classes = new Class<?>[size];
+                    System.arraycopy(prev, 0, classes, 0, START_POS);
+                }
+                currentBatchSize = size;
+            }
+
+            /*
+             * Returns the start index for this frame buffer is refilled.
+             *
+             * This implementation reuses the allocated buffer for the next batch
+             * of stack frames.  For subclass to retain the fetched stack frames,
+             * it should override this method to return the index at which the frame
+             * should be filled in for the next batch.
+             */
+            int startIndex() {
+                return START_POS;
+            }
+
+            /**
+             * Returns next StackFrame object in the current batch of stack frames
+             */
+            StackFrame nextStackFrame() {
+                throw new InternalError("should not reach here");
+            }
+        }
+    }
+
+    /*
+     * This StackFrameTraverser supports {@link Stream} traversal.
+     *
+     * This class implements Spliterator::forEachRemaining and Spliterator::tryAdvance.
+     */
+    static class StackFrameTraverser<T> extends AbstractStackWalker<T>
+            implements Spliterator<StackFrame>
+    {
+        static {
+            stackWalkImplClasses.add(StackFrameTraverser.class);
+        }
+        private static final int CHARACTERISTICS = Spliterator.ORDERED | Spliterator.IMMUTABLE;
+        class Buffer extends FrameBuffer {
+            Buffer(int initialBatchSize) {
+                super(initialBatchSize);
+
+                this.stackFrames = new StackFrame[initialBatchSize];
+                for (int i = START_POS; i < initialBatchSize; i++) {
+                    stackFrames[i] = new StackFrameInfo(walker);
+                }
+            }
+
+            @Override
+            void resize(int startIndex, int elements) {
+                super.resize(startIndex, elements);
+
+                int size = startIndex+elements;
+                if (stackFrames.length < size) {
+                    stackFrames = new StackFrame[size];
+                }
+                for (int i = startIndex(); i < size; i++) {
+                    stackFrames[i] = new StackFrameInfo(walker);
+                }
+            }
+
+            @Override
+            StackFrame nextStackFrame() {
+                if (isEmpty()) {
+                    throw new NoSuchElementException("origin=" + origin + " fence=" + fence);
+                }
+
+                StackFrame frame = stackFrames[origin];
+                origin++;
+                return frame;
+            }
+        }
+
+        final Function<? super Stream<StackFrame>, ? extends T> function;  // callback
+
+        StackFrameTraverser(StackWalker walker,
+                            Function<? super Stream<StackFrame>, ? extends T> function) {
+            this(walker, function, DEFAULT_MODE);
+        }
+        StackFrameTraverser(StackWalker walker,
+                            Function<? super Stream<StackFrame>, ? extends T> function,
+                            int mode) {
+            super(walker, mode);
+            this.function = function;
+        }
+
+        /**
+         * Returns next StackFrame object in the current batch of stack frames;
+         * or null if no more stack frame.
+         */
+        StackFrame nextStackFrame() {
+            if (!hasNext()) {
+                return null;
+            }
+
+            StackFrame frame = frameBuffer.nextStackFrame();
+            depth++;
+            return frame;
+        }
+
+        @Override
+        protected T consumeFrames() {
+            checkState(OPEN);
+            Stream<StackFrame> stream = StreamSupport.stream(this, false);
+            if (function != null) {
+                return function.apply(stream);
+            } else
+                throw new UnsupportedOperationException();
+        }
+
+        @Override
+        protected void initFrameBuffer() {
+            this.frameBuffer = new Buffer(getNextBatchSize());
+        }
+
+        @Override
+        protected int batchSize(int lastBatchFrameCount) {
+            if (lastBatchFrameCount == 0) {
+                // First batch, use estimateDepth if not exceed the large batch size
+                // and not too small
+                int initialBatchSize = Math.max(walker.estimateDepth(), SMALL_BATCH);
+                return Math.min(initialBatchSize, LARGE_BATCH_SIZE);
+            } else {
+                if (lastBatchFrameCount > BATCH_SIZE) {
+                    return lastBatchFrameCount;
+                } else {
+                    return Math.min(lastBatchFrameCount*2, BATCH_SIZE);
+                }
+            }
+        }
+
+        // ------- Implementation of Spliterator
+
+        @Override
+        public Spliterator<StackFrame> trySplit() {
+            return null;   // ordered stream and do not allow to split
+        }
+
+        @Override
+        public long estimateSize() {
+            return maxDepth;
+        }
+
+        @Override
+        public int characteristics() {
+            return CHARACTERISTICS;
+        }
+
+        @Override
+        public void forEachRemaining(Consumer<? super StackFrame> action) {
+            checkState(OPEN);
+            for (int n = 0; n < maxDepth; n++) {
+                StackFrame frame = nextStackFrame();
+                if (frame == null) break;
+
+                action.accept(frame);
+            }
+        }
+
+        @Override
+        public boolean tryAdvance(Consumer<? super StackFrame> action) {
+            checkState(OPEN);
+
+            int index = frameBuffer.getIndex();
+            if (hasNext()) {
+                StackFrame frame = nextStackFrame();
+                action.accept(frame);
+                if (isDebug) {
+                    System.err.println("tryAdvance: " + index + " " + frame);
+                }
+                return true;
+            }
+            if (isDebug) {
+                System.err.println("tryAdvance: " + index + " NO element");
+            }
+            return false;
+        }
+    }
+
+    /*
+     * CallerClassFinder is specialized to return Class<?> for each stack frame.
+     * StackFrame is not requested.
+     */
+    static class CallerClassFinder extends AbstractStackWalker<Integer> {
+        static {
+            stackWalkImplClasses.add(CallerClassFinder.class);
+        }
+
+        private Class<?> caller;
+
+        CallerClassFinder(StackWalker walker) {
+            super(walker, FILL_CLASS_REFS_ONLY);
+        }
+
+        Class<?> findCaller() {
+            walk();
+            return caller;
+        }
+
+        @Override
+        protected Integer consumeFrames() {
+            checkState(OPEN);
+            int n = 0;
+            Class<?>[] frames = new Class<?>[2];
+            // skip the API calling this getCallerClass method
+            // 0: StackWalker::getCallerClass
+            // 1: caller-sensitive method
+            // 2: caller class
+            while (n < 2 && (caller = nextFrame()) != null) {
+                if (isMethodHandleFrame(caller)) continue;
+                frames[n++] = caller;
+            }
+
+            if (frames[1] == null)
+                throw new IllegalStateException("no caller frame");
+            return n;
+        }
+
+        @Override
+        protected void initFrameBuffer() {
+            this.frameBuffer = new FrameBuffer(getNextBatchSize());
+        }
+
+        @Override
+        protected int batchSize(int lastBatchFrameCount) {
+            return MIN_BATCH_SIZE;
+        }
+
+        @Override
+        protected int getNextBatchSize() {
+            return MIN_BATCH_SIZE;
+        }
+    }
+
+    /*
+     * StackTrace caches all frames in the buffer.  StackTraceElements are
+     * created lazily when Throwable::getStackTrace is called.
+     */
+    static class StackTrace extends AbstractStackWalker<Integer> {
+        static {
+            stackWalkImplClasses.add(StackTrace.class);
+        }
+
+        class GrowableBuffer extends FrameBuffer {
+            GrowableBuffer(int initialBatchSize) {
+                super(initialBatchSize);
+
+                this.stackFrames = new StackFrame[initialBatchSize];
+                for (int i = START_POS; i < initialBatchSize; i++) {
+                    stackFrames[i] = new StackFrameInfo(walker);
+                }
+            }
+
+            /*
+             * Returns the next index to fill
+             */
+            @Override
+            int startIndex() {
+                return origin;
+            }
+
+            /**
+             * Initialize the buffers for VM to fill in the stack frame information.
+             * The next batch will start at the given startIndex to
+             * the length of the buffer.
+             */
+            @Override
+            void resize(int startIndex, int elements) {
+                // Expand the frame buffer.
+                // Do not call super.resize that will reuse the filled elements
+                // in this frame buffer
+                int size = startIndex+elements;
+                if (classes.length < size) {
+                    // resize the frame buffer
+                    classes = Arrays.copyOf(classes, size);
+                    stackFrames = Arrays.copyOf(stackFrames, size);
+                }
+                for (int i = startIndex; i < size; i++) {
+                    stackFrames[i] = new StackFrameInfo(walker);
+                }
+                currentBatchSize = size;
+            }
+
+            StackTraceElement get(int index) {
+                return new StackTraceElement(classes[index].getName(), "unknown", null, -1);
+            }
+
+            /**
+             * Returns an array of StackTraceElement for all stack frames cached in
+             * this StackTrace object.
+             * <p>
+             * This method is intended for Throwable::getOurStackTrace use only.
+             */
+            StackTraceElement[] toStackTraceElements() {
+                int startIndex = START_POS;
+                for (int i = startIndex; i < classes.length; i++) {
+                    if (classes[i] != null && filterStackWalkImpl(classes[i])) {
+                        startIndex++;
+                    } else {
+                        break;
+                    }
+                }
+
+                // VM fills in the method name, filename, line number info
+                StackFrameInfo.fillInStackFrames(0, stackFrames, startIndex, startIndex + depth);
+
+                StackTraceElement[] stes = new StackTraceElement[depth];
+                for (int i = startIndex, j = 0; i < classes.length && j < depth; i++, j++) {
+                    if (isDebug) {
+                        System.err.println("StackFrame: " + i + " " + stackFrames[i]);
+                    }
+                    stes[j] = stackFrames[i].toStackTraceElement();
+                }
+                return stes;
+            }
+        }
+
+        private static final int MAX_STACK_FRAMES = 1024;
+        private static final StackWalker STACKTRACE_WALKER =
+            StackWalker.newInstanceNoCheck(EnumSet.of(Option.SHOW_REFLECT_FRAMES));
+
+        private StackTraceElement[] stes;
+        static StackTrace dump() {
+            return new StackTrace();
+        }
+
+        static StackTrace dump(Throwable ex) {
+            return new StackTrace(ex);
+        }
+
+        private StackTrace() {
+            this(STACKTRACE_WALKER, DEFAULT_MODE);
+        }
+
+        /*
+         * Throwable::fillInStackTrace and <init> of Throwable and subclasses
+         * are filtered in the VM.
+         */
+        private StackTrace(Throwable ex) {
+            this(STACKTRACE_WALKER, FILTER_FILL_IN_STACKTRACE);  // skip Throwable::init frames
+            if (isDebug) {
+                System.err.println("dump stack for " + ex.getClass().getName());
+            }
+        }
+
+        StackTrace(StackWalker walker, int mode) {
+            super(walker, mode, MAX_STACK_FRAMES);
+
+            // snapshot the stack trace
+            walk();
+        }
+
+        @Override
+        protected Integer consumeFrames() {
+            // traverse all frames and perform the action on the stack frames, if specified
+            int n = 0;
+            while (n < maxDepth && nextFrame() != null) {
+                n++;
+            }
+            return n;
+        }
+
+        @Override
+        protected void initFrameBuffer() {
+            this.frameBuffer = new GrowableBuffer(getNextBatchSize());
+        }
+
+        // TODO: implement better heuristic
+        @Override
+        protected int batchSize(int lastBatchFrameCount) {
+            // chunk size of VM backtrace is 32
+            return lastBatchFrameCount == 0 ? 32 : 32;
+        }
+
+        /**
+         * Returns an array of StackTraceElement for all stack frames cached in
+         * this StackTrace object.
+         * <p>
+         * This method is intended for Throwable::getOurStackTrace use only.
+         */
+        synchronized StackTraceElement[] getStackTraceElements() {
+            if (stes == null) {
+                stes = ((GrowableBuffer) frameBuffer).toStackTraceElements();
+                // release the frameBuffer memory
+                frameBuffer = null;
+            }
+            return stes;
+        }
+
+        /*
+         * Prints stack trace to the given PrintStream.
+         *
+         * Further implementation could skip creating StackTraceElement objects
+         * print directly to the PrintStream.
+         */
+        void printStackTrace(PrintStream s) {
+            StackTraceElement[] stes = getStackTraceElements();
+            synchronized (s) {
+                s.println("Stack trace");
+                for (StackTraceElement traceElement : stes)
+                    s.println("\tat " + traceElement);
+            }
+        }
+    }
+
+    static class LiveStackInfoTraverser<T> extends StackFrameTraverser<T> {
+        static {
+            stackWalkImplClasses.add(LiveStackInfoTraverser.class);
+        }
+        // VM will fill in all method info and live stack info directly in StackFrameInfo
+        class Buffer extends FrameBuffer {
+            Buffer(int initialBatchSize) {
+                super(initialBatchSize);
+                this.stackFrames = new StackFrame[initialBatchSize];
+                for (int i = START_POS; i < initialBatchSize; i++) {
+                    stackFrames[i] = new LiveStackFrameInfo(walker);
+                }
+            }
+
+            @Override
+            void resize(int startIndex, int elements) {
+                super.resize(startIndex, elements);
+                int size = startIndex + elements;
+
+                if (stackFrames.length < size) {
+                    this.stackFrames = new StackFrame[size];
+                }
+
+                for (int i = startIndex(); i < size; i++) {
+                    stackFrames[i] = new LiveStackFrameInfo(walker);
+                }
+            }
+
+            @Override
+            StackFrame nextStackFrame() {
+                if (isEmpty()) {
+                    throw new NoSuchElementException("origin=" + origin + " fence=" + fence);
+                }
+
+                StackFrame frame = stackFrames[origin];
+                origin++;
+                return frame;
+            }
+        }
+
+        LiveStackInfoTraverser(StackWalker walker,
+                               Function<? super Stream<StackFrame>, ? extends T> function) {
+            super(walker, function, DEFAULT_MODE);
+        }
+
+        @Override
+        protected void initFrameBuffer() {
+            this.frameBuffer = new Buffer(getNextBatchSize());
+        }
+    }
+
+    private static native boolean checkStackWalkModes();
+
+    // avoid loading other subclasses as they may not be used
+    private static Set<Class<?>> init() {
+        if (!checkStackWalkModes()) {
+            throw new InternalError("StackWalker mode values do not match with JVM");
+        }
+
+        Set<Class<?>> classes = new HashSet<>();
+        classes.add(StackWalker.class);
+        classes.add(StackStreamFactory.class);
+        classes.add(AbstractStackWalker.class);
+        return classes;
+    }
+
+    private static boolean filterStackWalkImpl(Class<?> c) {
+        return stackWalkImplClasses.contains(c) ||
+                c.getName().startsWith("java.util.stream.");
+    }
+
+    // MethodHandle frames are not hidden and CallerClassFinder has
+    // to filter them out
+    private static boolean isMethodHandleFrame(Class<?> c) {
+        return c.getName().startsWith("java.lang.invoke.");
+    }
+
+    private static boolean isReflectionFrame(Class<?> c) {
+        if (c.getName().startsWith("sun.reflect") &&
+                !sun.reflect.MethodAccessor.class.isAssignableFrom(c)) {
+            throw new InternalError("Not sun.reflect.MethodAccessor: " + c.toString());
+        }
+        // ## should filter all @Hidden frames?
+        return c == Method.class ||
+                sun.reflect.MethodAccessor.class.isAssignableFrom(c) ||
+                c.getName().startsWith("java.lang.invoke.LambdaForm");
+    }
+
+    private static boolean getProperty(String key, boolean value) {
+        String s = AccessController.doPrivileged(new PrivilegedAction<>() {
+            @Override
+            public String run() {
+                return System.getProperty(key);
+            }
+        });
+        if (s != null) {
+            return Boolean.valueOf(s);
+        }
+        return value;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/lang/StackWalker.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,563 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang;
+
+import sun.reflect.CallerSensitive;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+/**
+ * A stack walker.
+ *
+ * <p> The {@link StackWalker#walk walk} method opens a sequential stream
+ * of {@link StackFrame StackFrame}s for the current thread and then applies
+ * the given function to walk the {@code StackFrame} stream.
+ * The stream reports stack frame elements in order, from the top most frame
+ * that represents the execution point at which the stack was generated to
+ * the bottom most frame.
+ * The {@code StackFrame} stream is closed when the {@code walk} method returns.
+ * If an attempt is made to reuse the closed stream,
+ * {@code IllegalStateException} will be thrown.
+ *
+ * <p> The {@linkplain Option <em>stack walking options</em>} of a
+ * {@code StackWalker} determines the information of
+ * {@link StackFrame StackFrame} objects to be returned.
+ * By default, stack frames of the reflection API and implementation
+ * classes are {@linkplain Option#SHOW_HIDDEN_FRAMES hidden}
+ * and {@code StackFrame}s have the class name and method name
+ * available but not the {@link StackFrame#getDeclaringClass() Class reference}.
+ *
+ * <p> {@code StackWalker} is thread-safe. Multiple threads can share
+ * a single {@code StackWalker} object to traverse its own stack.
+ * A permission check is performed when a {@code StackWalker} is created,
+ * according to the options it requests.
+ * No further permission check is done at stack walking time.
+ *
+ * @apiNote
+ * Examples
+ *
+ * <p>1. To find the first caller filtering a known list of implementation class:
+ * <pre>{@code
+ *     StackWalker walker = StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE);
+ *     Optional<Class<?>> callerClass = walker.walk(s ->
+ *         s.map(StackFrame::getDeclaringClass)
+ *          .filter(interestingClasses::contains)
+ *          .findFirst());
+ * }</pre>
+ *
+ * <p>2. To snapshot the top 10 stack frames of the current thread,
+ * <pre>{@code
+ *     List<StackFrame> stack = StackWalker.getInstance().walk(s ->
+ *         s.limit(10).collect(Collectors.toList()));
+ * }</pre>
+ *
+ * Unless otherwise noted, passing a {@code null} argument to a
+ * constructor or method in this {@code StackWalker} class
+ * will cause a {@link NullPointerException NullPointerException}
+ * to be thrown.
+ *
+ * @since 1.9
+ */
+public final class StackWalker {
+    /**
+     * A {@code StackFrame} object represents a method invocation returned by
+     * {@link StackWalker}.
+     *
+     * <p> The {@link #getDeclaringClass()} method may be unsupported as determined
+     * by the {@linkplain Option stack walking options} of a {@linkplain
+     * StackWalker stack walker}.
+     *
+     * @since 1.9
+     * @jvms 2.6
+     */
+    public static interface StackFrame {
+        /**
+         * Gets the <a href="ClassLoader.html#name">binary name</a>
+         * of the declaring class of the method represented by this stack frame.
+         *
+         * @return the binary name of the declaring class of the method
+         *         represented by this stack frame
+         *
+         * @jls 13.1 The Form of a Binary
+         */
+        public String getClassName();
+
+        /**
+         * Gets the name of the method represented by this stack frame.
+         * @return the name of the method represented by this stack frame
+         */
+        public String getMethodName();
+
+        /**
+         * Gets the declaring {@code Class} for the method represented by
+         * this stack frame.
+         *
+         * @return the declaring {@code Class} of the method represented by
+         * this stack frame
+         *
+         * @throws UnsupportedOperationException if this {@code StackWalker}
+         *         is not configured with {@link Option#RETAIN_CLASS_REFERENCE
+         *         Option.RETAIN_CLASS_REFERENCE}.
+         */
+        public Class<?> getDeclaringClass();
+
+        /**
+         * Returns the name of the source file containing the execution point
+         * represented by this stack frame.  Generally, this corresponds
+         * to the {@code SourceFile} attribute of the relevant {@code class}
+         * file as defined by <cite>The Java Virtual Machine Specification</cite>.
+         * In some systems, the name may refer to some source code unit
+         * other than a file, such as an entry in a source repository.
+         *
+         * @return the name of the file containing the execution point
+         *         represented by this stack frame, or empty {@code Optional}
+         *         is unavailable.
+         *
+         * @jvms 4.7.10 The {@code SourceFile} Attribute
+         */
+        public Optional<String> getFileName();
+
+        /**
+         * Returns the line number of the source line containing the execution
+         * point represented by this stack frame.  Generally, this is
+         * derived from the {@code LineNumberTable} attribute of the relevant
+         * {@code class} file as defined by <cite>The Java Virtual Machine
+         * Specification</cite>.
+         *
+         * @return the line number of the source line containing the execution
+         *         point represented by this stack frame, or empty
+         *         {@code Optional} if this information is unavailable.
+         *
+         * @jvms 4.7.12 The {@code LineNumberTable} Attribute
+         */
+        public OptionalInt getLineNumber();
+
+        /**
+         * Returns {@code true} if the method containing the execution point
+         * represented by this stack frame is a native method.
+         *
+         * @return {@code true} if the method containing the execution point
+         *         represented by this stack frame is a native method.
+         */
+        public boolean isNativeMethod();
+
+        /**
+         * Gets a {@code StackTraceElement} for this stack frame.
+         *
+         * @return {@code StackTraceElement} for this stack frame.
+         *
+         * */
+        public default StackTraceElement toStackTraceElement() {
+            int lineNumber = isNativeMethod() ? -2
+                                              : getLineNumber().orElse(-1);
+            return new StackTraceElement(getClassName(), getMethodName(),
+                                         getFileName().orElse(null),
+                                         lineNumber);
+        }
+    }
+
+    /**
+     * Stack walker option to configure the {@linkplain StackFrame stack frame}
+     * information obtained by a {@code StackWalker}.
+     *
+     * @since 1.9
+     */
+    public enum Option {
+        /**
+         * Retains {@code Class} object in {@code StackFrame}s
+         * walked by this {@code StackWalker}.
+         *
+         * <p> A {@code StackWalker} configured with this option will support
+         * {@link StackWalker#getCallerClass()} and
+         * {@link StackFrame#getDeclaringClass() StackFrame.getDeclaringClass()}.
+         */
+        RETAIN_CLASS_REFERENCE,
+        /**
+         * Shows all reflection frames.
+         *
+         * <p>By default, reflection frames are hidden.  This includes the
+         * {@link java.lang.reflect.Method#invoke} method
+         * and the reflection implementation classes. A {@code StackWalker} with
+         * this {@code SHOW_REFLECT_FRAMES} option will show all reflection frames.
+         * The {@link #SHOW_HIDDEN_FRAMES} option can also be used to show all
+         * reflection frames and it will also show other hidden frames that
+         * are implementation-specific.
+         */
+        SHOW_REFLECT_FRAMES,
+        /**
+         * Shows all hidden frames.
+         *
+         * <p>A Java Virtual Machine implementation may hide implementation
+         * specific frames in addition to {@linkplain #SHOW_REFLECT_FRAMES
+         * reflection frames}. A {@code StackWalker} with this {@code SHOW_HIDDEN_FRAMES}
+         * option will show all hidden frames (including reflection frames).
+         */
+        SHOW_HIDDEN_FRAMES;
+    }
+
+    enum ExtendedOption {
+        /**
+         * Obtain monitors, locals and operands.
+         */
+        LOCALS_AND_OPERANDS
+    };
+
+    static final EnumSet<Option> DEFAULT_EMPTY_OPTION = EnumSet.noneOf(Option.class);
+
+    private final static StackWalker DEFAULT_WALKER =
+        new StackWalker(DEFAULT_EMPTY_OPTION);
+
+    private final Set<Option> options;
+    private final ExtendedOption extendedOption;
+    private final int estimateDepth;
+
+    /**
+     * Returns a {@code StackWalker} instance.
+     *
+     * <p> This {@code StackWalker} is configured to skip all
+     * {@linkplain Option#SHOW_HIDDEN_FRAMES hidden frames} and
+     * no {@linkplain Option#RETAIN_CLASS_REFERENCE class reference} is retained.
+     *
+     * @return a {@code StackWalker} configured to skip all
+     * {@linkplain Option#SHOW_HIDDEN_FRAMES hidden frames} and
+     * no {@linkplain Option#RETAIN_CLASS_REFERENCE class reference} is retained.
+     *
+     */
+    public static StackWalker getInstance() {
+        // no permission check needed
+        return DEFAULT_WALKER;
+    }
+
+    /**
+     * Returns a {@code StackWalker} instance with the given option specifying
+     * the stack frame information it can access.
+     *
+     * <p>
+     * If a security manager is present and the given {@code option} is
+     * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
+     * it calls its {@link SecurityManager#checkPermission checkPermission}
+     * method for {@code StackFramePermission("retainClassReference")}.
+     *
+     * @param option {@link Option stack walking option}
+     *
+     * @return a {@code StackWalker} configured with the given option
+     *
+     * @throws SecurityException if a security manager exists and its
+     *         {@code checkPermission} method denies access.
+     */
+    public static StackWalker getInstance(Option option) {
+        return getInstance(EnumSet.of(Objects.requireNonNull(option)));
+    }
+
+    /**
+     * Returns a {@code StackWalker} instance with the given {@code options} specifying
+     * the stack frame information it can access.  If the given {@code options}
+     * is empty, this {@code StackWalker} is configured to skip all
+     * {@linkplain Option#SHOW_HIDDEN_FRAMES hidden frames} and no
+     * {@linkplain Option#RETAIN_CLASS_REFERENCE class reference} is retained.
+     *
+     * <p>
+     * If a security manager is present and the given {@code options} contains
+     * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
+     * it calls its {@link SecurityManager#checkPermission checkPermission}
+     * method for {@code StackFramePermission("retainClassReference")}.
+     *
+     * @param options {@link Option stack walking option}
+     *
+     * @return a {@code StackWalker} configured with the given options
+     *
+     * @throws SecurityException if a security manager exists and its
+     *         {@code checkPermission} method denies access.
+     */
+    public static StackWalker getInstance(Set<Option> options) {
+        if (options.isEmpty()) {
+            return DEFAULT_WALKER;
+        }
+
+        checkPermission(options);
+        return new StackWalker(toEnumSet(options));
+    }
+
+    /**
+     * Returns a {@code StackWalker} instance with the given {@ocde options} specifying
+     * the stack frame information it can access. If the given {@ocde options}
+     * is empty, this {@code StackWalker} is configured to skip all
+     * {@linkplain Option#SHOW_HIDDEN_FRAMES hidden frames} and no
+     * {@linkplain Option#RETAIN_CLASS_REFERENCE class reference} is retained.
+     *
+     * <p>
+     * If a security manager is present and the given {@code options} contains
+     * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
+     * it calls its {@link SecurityManager#checkPermission checkPermission}
+     * method for {@code StackFramePermission("retainClassReference")}.
+     *
+     * <p>
+     * The {@code estimateDepth} specifies the estimate number of stack frames
+     * this {@code StackWalker} will traverse that the {@code StackWalker} could
+     * use as a hint for the buffer size.
+     *
+     * @param options {@link Option stack walking options}
+     * @param estimateDepth Estimate number of stack frames to be traversed.
+     *
+     * @return a {@code StackWalker} configured with the given options
+     *
+     * @throws IllegalArgumentException if {@code estimateDepth <= 0}
+     * @throws SecurityException if a security manager exists and its
+     *         {@code checkPermission} method denies access.
+     */
+    public static StackWalker getInstance(Set<Option> options, int estimateDepth) {
+        if (estimateDepth <= 0) {
+            throw new IllegalArgumentException("estimateDepth must be > 0");
+        }
+        checkPermission(options);
+        return new StackWalker(toEnumSet(options), estimateDepth);
+    }
+
+    // ----- private constructors ------
+    private StackWalker(EnumSet<Option> options) {
+        this(options, 0, null);
+    }
+    private StackWalker(EnumSet<Option> options, int estimateDepth) {
+        this(options, estimateDepth, null);
+    }
+    private StackWalker(EnumSet<Option> options, int estimateDepth, ExtendedOption extendedOption) {
+        this.options = options;
+        this.estimateDepth = estimateDepth;
+        this.extendedOption = extendedOption;
+    }
+
+    private static void checkPermission(Set<Option> options) {
+        Objects.requireNonNull(options);
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            if (options.contains(Option.RETAIN_CLASS_REFERENCE)) {
+                sm.checkPermission(new StackFramePermission("retainClassReference"));
+            }
+        }
+    }
+
+    /*
+     * Returns a defensive copy
+     */
+    private static EnumSet<Option> toEnumSet(Set<Option> options) {
+        Objects.requireNonNull(options);
+        if (options.isEmpty()) {
+            return DEFAULT_EMPTY_OPTION;
+        } else {
+            return EnumSet.copyOf(options);
+        }
+    }
+
+    /**
+     * Applies the given function to the stream of {@code StackFrame}s
+     * for the current thread, traversing from the top frame of the stack,
+     * which is the method calling this {@code walk} method.
+     *
+     * <p>The {@code StackFrame} stream will be closed when
+     * this method returns.  When a closed {@code Stream<StackFrame>} object
+     * is reused, {@code IllegalStateException} will be thrown.
+     *
+     * @apiNote
+     * For example, to find the first 10 calling frames, first skipping those frames
+     * whose declaring class is in package {@code com.foo}:
+     * <blockquote>
+     * <pre>{@code
+     * List<StackFrame> frames = StackWalker.getInstance().walk(s ->
+     *     s.dropWhile(f -> f.getClassName().startsWith("com.foo."))
+     *      .limit(10)
+     *      .collect(Collectors.toList()));
+     * }</pre></blockquote>
+     *
+     * <p>This method takes a {@code Function} accepting a {@code Stream<StackFrame>},
+     * rather than returning a {@code Stream<StackFrame>} and allowing the
+     * caller to directly manipulate the stream. The Java virtual machine is
+     * free to reorganize a thread's control stack, for example, via
+     * deoptimization. By taking a {@code Function} parameter, this method
+     * allows access to stack frames through a stable view of a thread's control
+     * stack.
+     *
+     * <p>Parallel execution is effectively disabled and stream pipeline
+     * execution will only occur on the current thread.
+     *
+     * @implNote The implementation stabilizes the stack by anchoring a frame
+     * specific to the stack walking and ensures that the stack walking is
+     * performed above the anchored frame. When the stream object is closed or
+     * being reused, {@code IllegalStateException} will be thrown.
+     *
+     * @param function a function that takes a stream of
+     *                 {@linkplain StackFrame stack frames} and returns a result.
+     * @param <T> The type of the result of applying the function to the
+     *            stream of {@linkplain StackFrame stack frame}.
+     *
+     * @return the result of applying the function to the stream of
+     *         {@linkplain StackFrame stack frame}.
+     */
+    @CallerSensitive
+    public <T> T walk(Function<? super Stream<StackFrame>, ? extends T> function) {
+        // Returning a Stream<StackFrame> would be unsafe, as the stream could
+        // be used to access the stack frames in an uncontrolled manner.  For
+        // example, a caller might pass a Spliterator of stack frames after one
+        // or more frames had been traversed. There is no robust way to detect
+        // whether the execution point when
+        // Spliterator.tryAdvance(java.util.function.Consumer<? super T>) is
+        // invoked is the exact same execution point where the stack frame
+        // traversal is expected to resume.
+
+        Objects.requireNonNull(function);
+        return StackStreamFactory.makeStackTraverser(this, function)
+                                 .walk();
+    }
+
+    /**
+     * Performs the given action on each element of {@code StackFrame} stream
+     * of the current thread, traversing from the top frame of the stack,
+     * which is the method calling this {@code forEach} method.
+     *
+     * <p> This method is equivalent to calling
+     * <blockquote>
+     * {@code walk(s -> { s.forEach(action); return null; });}
+     * </blockquote>
+     *
+     * @param action an action to be performed on each {@code StackFrame}
+     *               of the stack of the current thread
+     */
+    @CallerSensitive
+    public void forEach(Consumer<? super StackFrame> action) {
+        Objects.requireNonNull(action);
+        StackStreamFactory.makeStackTraverser(this, s -> {
+            s.forEach(action);
+            return null;
+        }).walk();
+    }
+
+    /**
+     * Gets the {@code Class} object of the caller invoking the method
+     * that calls this {@code getCallerClass} method.
+     *
+     * <p> Reflection frames, {@link java.lang.invoke.MethodHandle} and
+     * hidden frames are filtered regardless of the
+     * {@link Option#SHOW_REFLECT_FRAMES SHOW_REFLECT_FRAMES}
+     * and {@link Option#SHOW_HIDDEN_FRAMES SHOW_HIDDEN_FRAMES} options
+     * this {@code StackWalker} has been configured.
+     *
+     * <p> This method throws {@code UnsupportedOperationException}
+     * if this {@code StackWalker} is not configured with
+     * {@link Option#RETAIN_CLASS_REFERENCE RETAIN_CLASS_REFERENCE} option,
+     * This method should be called when a caller frame is present.  If
+     * it is called from the last frame on the stack;
+     * {@code IllegalStateException} will be thrown.
+     *
+     * @apiNote
+     * For example, {@code Util::getResourceBundle} loads a resource bundle
+     * on behalf of the caller.  It calls this {@code getCallerClass} method
+     * to find the method calling {@code Util::getResourceBundle} and use the caller's
+     * class loader to load the resource bundle. The caller class in this example
+     * is the {@code MyTool} class.
+     *
+     * <pre>{@code
+     * class Util {
+     *     private final StackWalker walker = StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE);
+     *     public ResourceBundle getResourceBundle(String bundleName) {
+     *         Class<?> caller = walker.getCallerClass();
+     *         return ResourceBundle.getBundle(bundleName, Locale.getDefault(), caller.getClassLoader());
+     *     }
+     * }
+     *
+     * class MyTool {
+     *     private final Util util = new Util();
+     *     private void init() {
+     *         ResourceBundle rb = util.getResourceBundle("mybundle");
+     *     }
+     * }
+     * }</pre>
+     *
+     * An equivalent way to find the caller class using the
+     * {@link StackWalker#walk walk} method is as follows
+     * (filtering the reflection frames, {@code MethodHandle} and hidden frames
+     * not shown below):
+     * <pre>{@code
+     *     Optional<Class<?>> caller = walker.walk(s ->
+     *         s.map(StackFrame::getDeclaringClass)
+     *          .skip(2)
+     *          .findFirst());
+     * }</pre>
+     *
+     * When the {@code getCallerClass} method is called from a method that
+     * is the last frame on the stack,
+     * for example, {@code static public void main} method launched by the
+     * {@code java} launcher or a method invoked from a JNI attached thread.
+     * {@code IllegalStateException} is thrown.
+     *
+     * @return {@code Class} object of the caller's caller invoking this method.
+     *
+     * @throws UnsupportedOperationException if this {@code StackWalker}
+     *         is not configured with {@link Option#RETAIN_CLASS_REFERENCE
+     *         Option.RETAIN_CLASS_REFERENCE}.
+     * @throws IllegalStateException if there is no caller frame, i.e.
+     *         when this {@code getCallerClass} method is called from a method
+     *         which is the last frame on the stack.
+     */
+    @CallerSensitive
+    public Class<?> getCallerClass() {
+        if (!options.contains(Option.RETAIN_CLASS_REFERENCE)) {
+            throw new UnsupportedOperationException("This stack walker " +
+                    "does not have RETAIN_CLASS_REFERENCE access");
+        }
+
+        return StackStreamFactory.makeCallerFinder(this).findCaller();
+    }
+
+    // ---- package access ----
+    static StackWalker newInstanceNoCheck(EnumSet<Option> options) {
+        return new StackWalker(options, 0, null);
+    }
+
+    static StackWalker newInstance(Set<Option> options, ExtendedOption extendedOption) {
+        checkPermission(options);
+        return new StackWalker(toEnumSet(options), 0, extendedOption);
+    }
+
+    int estimateDepth() {
+        return estimateDepth;
+    }
+
+    boolean hasOption(Option option) {
+        return options.contains(option);
+    }
+
+    boolean hasLocalsOperandsOption() {
+        return extendedOption == ExtendedOption.LOCALS_AND_OPERANDS;
+    }
+
+    void ensureAccessEnabled(Option access) {
+        if (!hasOption(access)) {
+            throw new UnsupportedOperationException("No access to " + access +
+                    ": " + options.toString());
+        }
+    }
+}
--- a/src/java.base/share/classes/java/lang/StringBuffer.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/StringBuffer.java	Wed Dec 02 09:34:55 2015 -0800
@@ -730,7 +730,7 @@
         count = fields.get("count", 0);
     }
 
-    protected synchronized void getBytes(byte dst[], int dstBegin, byte coder) {
+    synchronized void getBytes(byte dst[], int dstBegin, byte coder) {
         super.getBytes(dst, dstBegin, coder);
     }
 }
--- a/src/java.base/share/classes/java/lang/System.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/System.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1896,12 +1896,6 @@
             public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
                 Shutdown.add(slot, registerShutdownInProgress, hook);
             }
-            public int getStackTraceDepth(Throwable t) {
-                return t.getStackTraceDepth();
-            }
-            public StackTraceElement getStackTraceElement(Throwable t, int i) {
-                return t.getStackTraceElement(i);
-            }
             public String newStringUnsafe(char[] chars) {
                 return new String(chars, true);
             }
--- a/src/java.base/share/classes/java/lang/Thread.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/Thread.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1329,11 +1329,9 @@
     /**
      * Prints a stack trace of the current thread to the standard error stream.
      * This method is used only for debugging.
-     *
-     * @see     Throwable#printStackTrace()
      */
     public static void dumpStack() {
-        new Exception("Stack trace").printStackTrace();
+        StackStreamFactory.makeStackTrace().printStackTrace(System.err);
     }
 
     /**
@@ -1556,7 +1554,7 @@
             return stackTrace;
         } else {
             // Don't need JVM help for current thread
-            return (new Exception()).getStackTrace();
+            return StackStreamFactory.makeStackTrace().getStackTraceElements();
         }
     }
 
@@ -2028,15 +2026,15 @@
     // Hence, the fields are isolated with @Contended.
 
     /** The current seed for a ThreadLocalRandom */
-    @sun.misc.Contended("tlr")
+    @jdk.internal.vm.annotation.Contended("tlr")
     long threadLocalRandomSeed;
 
     /** Probe hash value; nonzero if threadLocalRandomSeed initialized */
-    @sun.misc.Contended("tlr")
+    @jdk.internal.vm.annotation.Contended("tlr")
     int threadLocalRandomProbe;
 
     /** Secondary seed isolated from public ThreadLocalRandom sequence */
-    @sun.misc.Contended("tlr")
+    @jdk.internal.vm.annotation.Contended("tlr")
     int threadLocalRandomSecondarySeed;
 
     /* Some private helper methods */
--- a/src/java.base/share/classes/java/lang/Throwable.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/Throwable.java	Wed Dec 02 09:34:55 2015 -0800
@@ -24,6 +24,8 @@
  */
 
 package java.lang;
+import sun.misc.VM;
+
 import  java.io.*;
 import  java.util.*;
 
@@ -778,7 +780,11 @@
     public synchronized Throwable fillInStackTrace() {
         if (stackTrace != null ||
             backtrace != null /* Out of protocol state */ ) {
-            fillInStackTrace(0);
+            if (backtrace == null && StackStreamFactory.useStackTrace(this)) {
+                backtrace = StackStreamFactory.makeStackTrace(this);
+            } else {
+                fillInStackTrace(0);
+            }
             stackTrace = UNASSIGNED_STACK;
         }
         return this;
@@ -819,10 +825,14 @@
         // backtrace if this is the first call to this method
         if (stackTrace == UNASSIGNED_STACK ||
             (stackTrace == null && backtrace != null) /* Out of protocol state */) {
-            int depth = getStackTraceDepth();
-            stackTrace = new StackTraceElement[depth];
-            for (int i=0; i < depth; i++)
-                stackTrace[i] = getStackTraceElement(i);
+            if (backtrace instanceof StackStreamFactory.StackTrace) {
+                stackTrace = ((StackStreamFactory.StackTrace)backtrace).getStackTraceElements();
+            } else {
+                int depth = getStackTraceDepth();
+                stackTrace = new StackTraceElement[depth];
+                for (int i = 0; i < depth; i++)
+                    stackTrace[i] = getStackTraceElement(i);
+            }
         } else if (stackTrace == null) {
             return UNASSIGNED_STACK;
         }
--- a/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Wed Dec 02 09:34:55 2015 -0800
@@ -108,12 +108,6 @@
             return makeAllocator(member);
         return make(member.getDeclaringClass(), member);
     }
-    static DirectMethodHandle make(Method method) {
-        return make(method.getDeclaringClass(), new MemberName(method));
-    }
-    static DirectMethodHandle make(Field field) {
-        return make(field.getDeclaringClass(), new MemberName(field));
-    }
     private static DirectMethodHandle makeAllocator(MemberName ctor) {
         assert(ctor.isConstructor() && ctor.getName().equals("<init>"));
         Class<?> instanceClass = ctor.getDeclaringClass();
--- a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Wed Dec 02 09:34:55 2015 -0800
@@ -56,7 +56,6 @@
     private static final String OBJ     = "java/lang/Object";
     private static final String OBJARY  = "[Ljava/lang/Object;";
 
-    private static final String MH_SIG  = "L" + MH + ";";
     private static final String LF_SIG  = "L" + LF + ";";
     private static final String LFN_SIG = "L" + LFN + ";";
     private static final String LL_SIG  = "(L" + OBJ + ";)L" + OBJ + ";";
@@ -77,7 +76,6 @@
 
     /** Info about local variables in compiled lambda form */
     private final int[]       localsMap;    // index
-    private final BasicType[] localTypes;   // basic type
     private final Class<?>[]  localClasses; // type
 
     /** ASM bytecode generation. */
@@ -105,7 +103,6 @@
         this.invokerType = invokerType;
         this.localsMap = new int[localsMapSize+1];
         // last entry of localsMap is count of allocated local slots
-        this.localTypes = new BasicType[localsMapSize+1];
         this.localClasses = new Class<?>[localsMapSize+1];
     }
 
@@ -114,11 +111,8 @@
         this(null, invokerType.parameterCount(),
              className, invokerName, invokerType);
         // Create an array to map name indexes to locals indexes.
-        localTypes[localTypes.length - 1] = V_TYPE;
         for (int i = 0; i < localsMap.length; i++) {
             localsMap[i] = invokerType.parameterSlotCount() - invokerType.parameterSlotDepth(i);
-            if (i < invokerType.parameterCount())
-                localTypes[i] = basicType(invokerType.parameterType(i));
         }
     }
 
@@ -133,7 +127,6 @@
             if (i < names.length) {
                 BasicType type = names[i].type();
                 index += type.basicTypeSlots();
-                localTypes[i] = type;
             }
         }
     }
@@ -461,31 +454,6 @@
         return xas - Opcodes.AASTORE + aaop;
     }
 
-
-    private void freeFrameLocal(int oldFrameLocal) {
-        int i = indexForFrameLocal(oldFrameLocal);
-        if (i < 0)  return;
-        BasicType type = localTypes[i];
-        int newFrameLocal = makeLocalTemp(type);
-        mv.visitVarInsn(loadInsnOpcode(type), oldFrameLocal);
-        mv.visitVarInsn(storeInsnOpcode(type), newFrameLocal);
-        assert(localsMap[i] == oldFrameLocal);
-        localsMap[i] = newFrameLocal;
-        assert(indexForFrameLocal(oldFrameLocal) < 0);
-    }
-    private int indexForFrameLocal(int frameLocal) {
-        for (int i = 0; i < localsMap.length; i++) {
-            if (localsMap[i] == frameLocal && localTypes[i] != V_TYPE)
-                return i;
-        }
-        return -1;
-    }
-    private int makeLocalTemp(BasicType type) {
-        int frameLocal = localsMap[localsMap.length - 1];
-        localsMap[localsMap.length - 1] = frameLocal + type.basicTypeSlots();
-        return frameLocal;
-    }
-
     /**
      * Emit a boxing call.
      *
--- a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Wed Dec 02 09:34:55 2015 -0800
@@ -197,17 +197,6 @@
             if (!type.isPrimitive())  return L_TYPE;
             return basicType(Wrapper.forPrimitiveType(type));
         }
-
-        static char basicTypeChar(Class<?> type) {
-            return basicType(type).btChar;
-        }
-        static BasicType[] basicTypes(List<Class<?>> types) {
-            BasicType[] btypes = new BasicType[types.size()];
-            for (int i = 0; i < btypes.length; i++) {
-                btypes[i] = basicType(types.get(i));
-            }
-            return btypes;
-        }
         static BasicType[] basicTypes(String types) {
             BasicType[] btypes = new BasicType[types.length()];
             for (int i = 0; i < btypes.length; i++) {
@@ -215,13 +204,19 @@
             }
             return btypes;
         }
-        static byte[] basicTypesOrd(BasicType[] btypes) {
-            byte[] ords = new byte[btypes.length];
-            for (int i = 0; i < btypes.length; i++) {
-                ords[i] = (byte)btypes[i].ordinal();
+
+        static char basicTypeChar(Class<?> type) {
+            return basicType(type).btChar;
+        }
+
+        static byte[] basicTypesOrd(Class<?>[] types) {
+            byte[] ords = new byte[types.length];
+            for (int i = 0; i < ords.length; i++) {
+                ords[i] = (byte)basicType(types[i]).ordinal();
             }
             return ords;
         }
+
         static boolean isBasicTypeChar(char c) {
             return "LIJFDV".indexOf(c) >= 0;
         }
@@ -929,99 +924,6 @@
         return false;
     }
 
-    LambdaForm addArguments(int pos, BasicType... types) {
-        // names array has MH in slot 0; skip it.
-        int argpos = pos + 1;
-        assert(argpos <= arity);
-        int length = names.length;
-        int inTypes = types.length;
-        Name[] names2 = Arrays.copyOf(names, length + inTypes);
-        int arity2 = arity + inTypes;
-        int result2 = result;
-        if (result2 >= argpos)
-            result2 += inTypes;
-        // Note:  The LF constructor will rename names2[argpos...].
-        // Make space for new arguments (shift temporaries).
-        System.arraycopy(names, argpos, names2, argpos + inTypes, length - argpos);
-        for (int i = 0; i < inTypes; i++) {
-            names2[argpos + i] = new Name(types[i]);
-        }
-        return new LambdaForm(debugName, arity2, names2, result2);
-    }
-
-    LambdaForm addArguments(int pos, List<Class<?>> types) {
-        return addArguments(pos, basicTypes(types));
-    }
-
-    LambdaForm permuteArguments(int skip, int[] reorder, BasicType[] types) {
-        // Note:  When inArg = reorder[outArg], outArg is fed by a copy of inArg.
-        // The types are the types of the new (incoming) arguments.
-        int length = names.length;
-        int inTypes = types.length;
-        int outArgs = reorder.length;
-        assert(skip+outArgs == arity);
-        assert(permutedTypesMatch(reorder, types, names, skip));
-        int pos = 0;
-        // skip trivial first part of reordering:
-        while (pos < outArgs && reorder[pos] == pos)  pos += 1;
-        Name[] names2 = new Name[length - outArgs + inTypes];
-        System.arraycopy(names, 0, names2, 0, skip+pos);
-        // copy the body:
-        int bodyLength = length - arity;
-        System.arraycopy(names, skip+outArgs, names2, skip+inTypes, bodyLength);
-        int arity2 = names2.length - bodyLength;
-        int result2 = result;
-        if (result2 >= 0) {
-            if (result2 < skip+outArgs) {
-                // return the corresponding inArg
-                result2 = reorder[result2-skip];
-            } else {
-                result2 = result2 - outArgs + inTypes;
-            }
-        }
-        // rework names in the body:
-        for (int j = pos; j < outArgs; j++) {
-            Name n = names[skip+j];
-            int i = reorder[j];
-            // replace names[skip+j] by names2[skip+i]
-            Name n2 = names2[skip+i];
-            if (n2 == null)
-                names2[skip+i] = n2 = new Name(types[i]);
-            else
-                assert(n2.type == types[i]);
-            for (int k = arity2; k < names2.length; k++) {
-                names2[k] = names2[k].replaceName(n, n2);
-            }
-        }
-        // some names are unused, but must be filled in
-        for (int i = skip+pos; i < arity2; i++) {
-            if (names2[i] == null)
-                names2[i] = argument(i, types[i - skip]);
-        }
-        for (int j = arity; j < names.length; j++) {
-            int i = j - arity + arity2;
-            // replace names2[i] by names[j]
-            Name n = names[j];
-            Name n2 = names2[i];
-            if (n != n2) {
-                for (int k = i+1; k < names2.length; k++) {
-                    names2[k] = names2[k].replaceName(n, n2);
-                }
-            }
-        }
-        return new LambdaForm(debugName, arity2, names2, result2);
-    }
-
-    static boolean permutedTypesMatch(int[] reorder, BasicType[] types, Name[] names, int skip) {
-        int inTypes = types.length;
-        int outArgs = reorder.length;
-        for (int i = 0; i < outArgs; i++) {
-            assert(names[skip+i].isParam());
-            assert(names[skip+i].type == types[reorder[i]]);
-        }
-        return true;
-    }
-
     static class NamedFunction {
         final MemberName member;
         private @Stable MethodHandle resolvedHandle;
@@ -1054,19 +956,15 @@
                    "invokeBasic".equals(member.getName());
         }
 
-        // The next 3 constructors are used to break circular dependencies on MH.invokeStatic, etc.
+        // The next 2 constructors are used to break circular dependencies on MH.invokeStatic, etc.
         // Any LambdaForm containing such a member is not interpretable.
         // This is OK, since all such LFs are prepared with special primitive vmentry points.
         // And even without the resolvedHandle, the name can still be compiled and optimized.
         NamedFunction(Method method) {
             this(new MemberName(method));
         }
-        NamedFunction(Field field) {
-            this(new MemberName(field));
-        }
         NamedFunction(MemberName member) {
-            this.member = member;
-            this.resolvedHandle = null;
+            this(member, null);
         }
 
         MethodHandle resolvedHandle() {
@@ -1408,9 +1306,7 @@
         }
         Name(NamedFunction function, Object... arguments) {
             this(-1, function.returnType(), function, arguments = Arrays.copyOf(arguments, arguments.length, Object[].class));
-            assert(arguments.length == function.arity()) : "arity mismatch: arguments.length=" + arguments.length + " == function.arity()=" + function.arity() + " in " + debugString();
-            for (int i = 0; i < arguments.length; i++)
-                assert(typesMatch(function.parameterType(i), arguments[i])) : "types don't match: function.parameterType(" + i + ")=" + function.parameterType(i) + ", arguments[" + i + "]=" + arguments[i] + " in " + debugString();
+            assert(typesMatch(function, arguments));
         }
         /** Create a raw parameter of the given type, with an expected index. */
         Name(int index, BasicType type) {
@@ -1550,7 +1446,15 @@
             return buf.toString();
         }
 
-        static boolean typesMatch(BasicType parameterType, Object object) {
+        private boolean typesMatch(NamedFunction function, Object ... arguments) {
+            assert(arguments.length == function.arity()) : "arity mismatch: arguments.length=" + arguments.length + " == function.arity()=" + function.arity() + " in " + debugString();
+            for (int i = 0; i < arguments.length; i++) {
+                assert (typesMatch(function.parameterType(i), arguments[i])) : "types don't match: function.parameterType(" + i + ")=" + function.parameterType(i) + ", arguments[" + i + "]=" + arguments[i] + " in " + debugString();
+            }
+            return true;
+        }
+
+        private static boolean typesMatch(BasicType parameterType, Object object) {
             if (object instanceof Name) {
                 return ((Name)object).type == parameterType;
             }
@@ -1630,7 +1534,7 @@
 
     /** Return the number of times n is used as an argument or return value. */
     int useCount(Name n) {
-        int ni = n.index, nmax = names.length;
+        int nmax = names.length;
         int end = lastUseIndex(n);
         if (end < 0)  return 0;
         int count = 0;
@@ -1643,9 +1547,6 @@
         return count;
     }
 
-    static Name argument(int which, char type) {
-        return argument(which, basicType(type));
-    }
     static Name argument(int which, BasicType type) {
         if (which >= INTERNED_ARGUMENT_LIMIT)
             return new Name(which, type);
@@ -1661,28 +1562,7 @@
         int length = types.length();
         Name[] names = new Name[length + extra];
         for (int i = 0; i < length; i++)
-            names[i] = argument(i, types.charAt(i));
-        return names;
-    }
-    static Name[] arguments(int extra, char... types) {
-        int length = types.length;
-        Name[] names = new Name[length + extra];
-        for (int i = 0; i < length; i++)
-            names[i] = argument(i, types[i]);
-        return names;
-    }
-    static Name[] arguments(int extra, List<Class<?>> types) {
-        int length = types.size();
-        Name[] names = new Name[length + extra];
-        for (int i = 0; i < length; i++)
-            names[i] = argument(i, basicType(types.get(i)));
-        return names;
-    }
-    static Name[] arguments(int extra, Class<?>... types) {
-        int length = types.length;
-        Name[] names = new Name[length + extra];
-        for (int i = 0; i < length; i++)
-            names[i] = argument(i, basicType(types[i]));
+            names[i] = argument(i, basicType(types.charAt(i)));
         return names;
     }
     static Name[] arguments(int extra, MethodType types) {
--- a/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Wed Dec 02 09:34:55 2015 -0800
@@ -565,12 +565,12 @@
         if (collectorArity == 1 && !dropResult) {
             return filterArgumentForm(pos, basicType(collectorType.parameterType(0)));
         }
-        BasicType[] newTypes = BasicType.basicTypes(collectorType.parameterList());
+        byte[] newTypes = BasicType.basicTypesOrd(collectorType.parameterArray());
         Transform.Kind kind = (dropResult
                 ? Transform.Kind.COLLECT_ARGS_TO_VOID
                 : Transform.Kind.COLLECT_ARGS);
         if (dropResult && collectorArity == 0)  pos = 1;  // pure side effect
-        Transform key = Transform.of(kind, pos, collectorArity, BasicType.basicTypesOrd(newTypes));
+        Transform key = Transform.of(kind, pos, collectorArity, newTypes);
         LambdaForm form = getInCache(key);
         if (form != null) {
             assert(form.arity == lambdaForm.arity - (dropResult ? 0 : 1) + collectorArity);
@@ -680,9 +680,8 @@
                              combinerArgs, 1, combinerArity);
         } else {
             newParams = new Name[combinerArity];
-            BasicType[] newTypes = basicTypes(combinerType.parameterList());
-            for (int i = 0; i < newTypes.length; i++) {
-                newParams[i] = new Name(pos + i, newTypes[i]);
+            for (int i = 0; i < newParams.length; i++) {
+                newParams[i] = new Name(pos + i, basicType(combinerType.parameterType(i)));
             }
             System.arraycopy(newParams, 0,
                              combinerArgs, 1, combinerArity);
--- a/src/java.base/share/classes/java/lang/invoke/MemberName.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/MemberName.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1077,4 +1077,13 @@
 //        System.out.println("Hello world!  My methods are:");
 //        System.out.println(Factory.INSTANCE.getMethods(MemberName.class, true, null));
 //    }
+
+    static {
+        // Allow privileged classes outside of java.lang
+        jdk.internal.misc.SharedSecrets.setJavaLangInvokeAccess(new jdk.internal.misc.JavaLangInvokeAccess() {
+            public Object newMemberName() {
+                return new MemberName();
+            }
+        });
+    }
 }
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Wed Dec 02 09:34:55 2015 -0800
@@ -938,7 +938,7 @@
         Class<?> arrayElement = arrayType.getComponentType();
         MethodType mtype = type();
         boolean match = true, fail = false;
-        for (int i = pos; i < arrayLength; i++) {
+        for (int i = pos; i < pos + arrayLength; i++) {
             Class<?> ptype = mtype.parameterType(i);
             if (ptype != arrayElement) {
                 match = false;
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java	Wed Dec 02 09:34:55 2015 -0800
@@ -92,33 +92,6 @@
                 TRACE_METHOD_LINKAGE);
     }
 
-    /*non-public*/ static String getNameString(MethodHandle target, MethodType type) {
-        if (type == null)
-            type = target.type();
-        MemberName name = null;
-        if (target != null)
-            name = target.internalMemberName();
-        if (name == null)
-            return "invoke" + type;
-        return name.getName() + type;
-    }
-
-    /*non-public*/ static String getNameString(MethodHandle target, MethodHandle typeHolder) {
-        return getNameString(target, typeHolder == null ? (MethodType) null : typeHolder.type());
-    }
-
-    /*non-public*/ static String getNameString(MethodHandle target) {
-        return getNameString(target, (MethodType) null);
-    }
-
-    /*non-public*/ static String addTypeString(Object obj, MethodHandle target) {
-        String str = String.valueOf(obj);
-        if (target == null)  return str;
-        int paren = str.indexOf('(');
-        if (paren >= 0) str = str.substring(0, paren);
-        return str + target.type();
-    }
-
     // handy shared exception makers (they simplify the common case code)
     /*non-public*/ static InternalError newInternalError(String message) {
         return new InternalError(message);
@@ -150,9 +123,6 @@
         if (ex instanceof RuntimeException)  throw (RuntimeException) ex;
         throw newInternalError("uncaught exception", ex);
     }
-    static Error NYI() {
-        throw new AssertionError("NYI");
-    }
     private static String message(String message, Object obj) {
         if (obj != null)  message = message + ": " + obj;
         return message;
--- a/src/java.base/share/classes/java/lang/invoke/MethodType.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/MethodType.java	Wed Dec 02 09:34:55 2015 -0800
@@ -179,9 +179,11 @@
         checkSlotCount(ptypes.length + slots);
         return slots;
     }
+    static {
+        // MAX_JVM_ARITY must be power of 2 minus 1 for following code trick to work:
+        assert((MAX_JVM_ARITY & (MAX_JVM_ARITY+1)) == 0);
+    }
     static void checkSlotCount(int count) {
-        assert((MAX_JVM_ARITY & (MAX_JVM_ARITY+1)) == 0);
-        // MAX_JVM_ARITY must be power of 2 minus 1 for following code trick to work:
         if ((count & MAX_JVM_ARITY) != count)
             throw newIllegalArgumentException("bad parameter count "+count);
     }
@@ -813,11 +815,6 @@
     boolean isViewableAs(MethodType newType, boolean keepInterfaces) {
         if (!VerifyType.isNullConversion(returnType(), newType.returnType(), keepInterfaces))
             return false;
-        return parametersAreViewableAs(newType, keepInterfaces);
-    }
-    /** True if the new parameters can be viewed (w/o casting) under the old parameter types. */
-    /*non-public*/
-    boolean parametersAreViewableAs(MethodType newType, boolean keepInterfaces) {
         if (form == newType.form && form.erasedType == this)
             return true;  // my reference parameters are all Object
         if (ptypes == newType.ptypes)
@@ -1088,7 +1085,6 @@
             throw newIllegalArgumentException("not a method descriptor: "+descriptor);
         List<Class<?>> types = BytecodeDescriptor.parseMethod(descriptor, loader);
         Class<?> rtype = types.remove(types.size() - 1);
-        checkSlotCount(types.size());
         Class<?>[] ptypes = listToArray(types);
         return makeImpl(rtype, ptypes, true);
     }
--- a/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java	Wed Dec 02 09:34:55 2015 -0800
@@ -52,7 +52,7 @@
     private static final Wrapper[] FROM_WRAPPER_NAME = new Wrapper[16];
 
     // Table of wrappers for primitives, indexed by ASM type sorts
-    private static final Wrapper[] FROM_TYPE_SORT = new Wrapper[16];
+    private static final Wrapper[] FROM_TYPE_SORT = new Wrapper[12];
 
     static {
         for (Wrapper w : Wrapper.values()) {
@@ -63,11 +63,8 @@
             }
         }
 
-        for (int i = 0; i < NUM_WRAPPERS; i++) {
-            for (int j = 0; j < NUM_WRAPPERS; j++) {
-                wideningOpcodes[i][j] = Opcodes.NOP;
-            }
-        }
+        // wideningOpcodes[][] will be NOP-initialized by default
+        assert(Opcodes.NOP == 0);
 
         initWidening(LONG,   Opcodes.I2L, BYTE, SHORT, INT, CHAR);
         initWidening(LONG,   Opcodes.F2L, FLOAT);
@@ -192,10 +189,6 @@
         }
     }
 
-    private boolean isPrimitive(Wrapper w) {
-        return w != OBJECT;
-    }
-
     private Wrapper toWrapper(String desc) {
         char first = desc.charAt(0);
         if (first == '[' || first == '(') {
--- a/src/java.base/share/classes/java/text/DateFormat.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/text/DateFormat.java	Wed Dec 02 09:34:55 2015 -0800
@@ -418,7 +418,7 @@
      *            index information as described above.
      * @return A <code>Date</code> parsed from the string. In case of
      *         error, returns null.
-     * @exception NullPointerException if <code>pos</code> is null.
+     * @throws NullPointerException if {@code source} or {@code pos} is null.
      */
     public Object parseObject(String source, ParsePosition pos) {
         return parse(source, pos);
--- a/src/java.base/share/classes/java/text/Format.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/text/Format.java	Wed Dec 02 09:34:55 2015 -0800
@@ -225,7 +225,7 @@
      *            index information as described above.
      * @return An <code>Object</code> parsed from the string. In case of
      *         error, returns null.
-     * @exception NullPointerException if <code>pos</code> is null.
+     * @throws NullPointerException if {@code source} or {@code pos} is null.
      */
     public abstract Object parseObject (String source, ParsePosition pos);
 
@@ -237,6 +237,7 @@
      * @return An <code>Object</code> parsed from the string.
      * @exception ParseException if the beginning of the specified string
      *            cannot be parsed.
+     * @throws NullPointerException if {@code source} is null.
      */
     public Object parseObject(String source) throws ParseException {
         ParsePosition pos = new ParsePosition(0);
--- a/src/java.base/share/classes/java/text/MessageFormat.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/text/MessageFormat.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1068,7 +1068,7 @@
      *            index information as described above.
      * @return An <code>Object</code> array parsed from the string. In case of
      *         error, returns null.
-     * @exception NullPointerException if <code>pos</code> is null.
+     * @throws NullPointerException if {@code source} or {@code pos} is null.
      */
     public Object parseObject(String source, ParsePosition pos) {
         return parse(source, pos);
--- a/src/java.base/share/classes/java/text/NumberFormat.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/text/NumberFormat.java	Wed Dec 02 09:34:55 2015 -0800
@@ -271,7 +271,7 @@
      *            index information as described above.
      * @return A <code>Number</code> parsed from the string. In case of
      *         error, returns null.
-     * @exception NullPointerException if <code>pos</code> is null.
+     * @throws NullPointerException if {@code source} or {@code pos} is null.
      */
     @Override
     public final Object parseObject(String source, ParsePosition pos) {
--- a/src/java.base/share/classes/java/time/Clock.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/time/Clock.java	Wed Dec 02 09:34:55 2015 -0800
@@ -223,6 +223,7 @@
      *
      * @param zone  the time-zone to use to convert the instant to date-time, not null
      * @return a clock that ticks in whole milliseconds using the specified zone, not null
+     * @since 9
      */
     public static Clock tickMillis(ZoneId zone) {
         return new TickClock(system(zone), NANOS_PER_MILLI);
--- a/src/java.base/share/classes/java/time/LocalDate.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/time/LocalDate.java	Wed Dec 02 09:34:55 2015 -0800
@@ -307,6 +307,7 @@
      * @param zone  the time-zone, which may be an offset, not null
      * @return the local date, not null
      * @throws DateTimeException if the result exceeds the supported range
+     * @since 9
      */
     public static LocalDate ofInstant(Instant instant, ZoneId zone) {
         Objects.requireNonNull(instant, "instant");
--- a/src/java.base/share/classes/java/time/LocalTime.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/time/LocalTime.java	Wed Dec 02 09:34:55 2015 -0800
@@ -354,6 +354,7 @@
      * @param instant  the instant to create the time from, not null
      * @param zone  the time-zone, which may be an offset, not null
      * @return the local time, not null
+     * @since 9
      */
      public static LocalTime ofInstant(Instant instant, ZoneId zone) {
          Objects.requireNonNull(instant, "instant");
--- a/src/java.base/share/classes/java/util/Objects.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/Objects.java	Wed Dec 02 09:34:55 2015 -0800
@@ -27,6 +27,7 @@
 
 import java.util.function.BiFunction;
 import java.util.function.Supplier;
+import jdk.internal.HotSpotIntrinsicCandidate;
 
 /**
  * This class consists of {@code static} utility methods for operating
@@ -420,14 +421,14 @@
      * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
      *         and the exception mapping function is {@code null}
      * @since 9
-     */
-    /*
+     *
+     * @implNote
+     * This method is made intrinsic in optimizing compilers to guide
+     * them to perform unsigned comparisons of the index and length
+     * when it is known the length is a non-negative value (such as
+     * that of an array length or from the upper bound of a loop)
+    */
     @HotSpotIntrinsicCandidate
-    This method will be made intrinsic in C2 to guide HotSpot to perform
-    unsigned comparisons of the index and length when it is known the length is
-    a non-negative value (such as that of an array length or from the upper
-    bound of a loop)
-    */
     public static <T extends RuntimeException>
     int checkIndex(int index, int length,
                    BiFunction<Integer, Integer, T> oobe) throws T, IndexOutOfBoundsException {
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Wed Dec 02 09:34:55 2015 -0800
@@ -596,7 +596,16 @@
     /** Number of CPUS, to place bounds on some sizings */
     static final int NCPU = Runtime.getRuntime().availableProcessors();
 
-    /** For serialization compatibility. */
+    /**
+     * Serialized pseudo-fields, provided only for jdk7 compatibility.
+     * @serialField segments Segment[]
+     *   The segments, each of which is a specialized hash table.
+     * @serialField segmentMask int
+     *   Mask value for indexing into segments. The upper bits of a
+     *   key's hash code are used to choose the segment.
+     * @serialField segmentShift int
+     *   Shift value for indexing within segments.
+     */
     private static final ObjectStreamField[] serialPersistentFields = {
         new ObjectStreamField("segments", Segment[].class),
         new ObjectStreamField("segmentMask", Integer.TYPE),
@@ -1382,8 +1391,8 @@
      * @param s the stream
      * @throws java.io.IOException if an I/O error occurs
      * @serialData
-     * the key (Object) and value (Object)
-     * for each key-value mapping, followed by a null pair.
+     * the serialized fields, followed by the key (Object) and value
+     * (Object) for each key-value mapping, followed by a null pair.
      * The key-value mappings are emitted in no particular order.
      */
     private void writeObject(java.io.ObjectOutputStream s)
@@ -1419,7 +1428,6 @@
         }
         s.writeObject(null);
         s.writeObject(null);
-        segments = null; // throw away
     }
 
     /**
@@ -2550,7 +2558,7 @@
      * A padded cell for distributing counts.  Adapted from LongAdder
      * and Striped64.  See their internal docs for explanation.
      */
-    @sun.misc.Contended static final class CounterCell {
+    @jdk.internal.vm.annotation.Contended static final class CounterCell {
         volatile long value;
         CounterCell(long x) { value = x; }
     }
--- a/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java	Wed Dec 02 09:34:55 2015 -0800
@@ -185,7 +185,7 @@
  *   }
  * }}</pre>
  *
- * As a further improvement, notice that the left task need not even exist.
+ * As a further optimization, notice that the left task need not even exist.
  * Instead of creating a new one, we can iterate using the original task,
  * and add a pending count for each fork.  Additionally, because no task
  * in this tree implements an {@link #onCompletion(CountedCompleter)} method,
@@ -208,7 +208,7 @@
  *   }
  * }}</pre>
  *
- * Additional improvements of such classes might entail precomputing
+ * Additional optimizations of such classes might entail precomputing
  * pending counts so that they can be established in constructors,
  * specializing classes for leaf steps, subdividing by say, four,
  * instead of two per iteration, and using an adaptive threshold
@@ -260,9 +260,9 @@
  * }}</pre>
  *
  * In this example, as well as others in which tasks have no other
- * effects except to compareAndSet a common result, the trailing
- * unconditional invocation of {@code tryComplete} could be made
- * conditional ({@code if (result.get() == null) tryComplete();})
+ * effects except to {@code compareAndSet} a common result, the
+ * trailing unconditional invocation of {@code tryComplete} could be
+ * made conditional ({@code if (result.get() == null) tryComplete();})
  * because no further bookkeeping is required to manage completions
  * once the root task completes.
  *
@@ -624,7 +624,7 @@
      * any one (versus all) of several subtask results are obtained.
      * However, in the common (and recommended) case in which {@code
      * setRawResult} is not overridden, this effect can be obtained
-     * more simply using {@code quietlyCompleteRoot();}.
+     * more simply using {@link #quietlyCompleteRoot()}.
      *
      * @param rawResult the raw result
      */
@@ -639,9 +639,9 @@
 
     /**
      * If this task's pending count is zero, returns this task;
-     * otherwise decrements its pending count and returns {@code
-     * null}. This method is designed to be used with {@link
-     * #nextComplete} in completion traversal loops.
+     * otherwise decrements its pending count and returns {@code null}.
+     * This method is designed to be used with {@link #nextComplete} in
+     * completion traversal loops.
      *
      * @return this task, if pending count was zero, else {@code null}
      */
--- a/src/java.base/share/classes/java/util/concurrent/Exchanger.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/Exchanger.java	Wed Dec 02 09:34:55 2015 -0800
@@ -155,7 +155,7 @@
      * a value that is enough for common platforms.  Additionally,
      * extra care elsewhere is taken to avoid other false/unintended
      * sharing and to enhance locality, including adding padding (via
-     * sun.misc.Contended) to Nodes, embedding "bound" as an Exchanger
+     * jdk.internal.vm.annotation.Contended) to Nodes, embedding "bound" as an Exchanger
      * field, and reworking some park/unpark mechanics compared to
      * LockSupport versions.
      *
@@ -304,10 +304,10 @@
 
     /**
      * Nodes hold partially exchanged data, plus other per-thread
-     * bookkeeping. Padded via @sun.misc.Contended to reduce memory
+     * bookkeeping. Padded via @jdk.internal.vm.annotation.Contended to reduce memory
      * contention.
      */
-    @sun.misc.Contended static final class Node {
+    @jdk.internal.vm.annotation.Contended static final class Node {
         int index;              // Arena index
         int bound;              // Last recorded value of Exchanger.bound
         int collides;           // Number of CAS failures at current bound
--- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Wed Dec 02 09:34:55 2015 -0800
@@ -162,7 +162,7 @@
  * @since 1.7
  * @author Doug Lea
  */
-@sun.misc.Contended
+@jdk.internal.vm.annotation.Contended
 public class ForkJoinPool extends AbstractExecutorService {
 
     /*
@@ -703,7 +703,8 @@
          * Returns a new worker thread operating in the given pool.
          *
          * @param pool the pool this thread works in
-         * @return the new worker thread
+         * @return the new worker thread, or {@code null} if the request
+         *         to create a thread is rejected
          * @throws NullPointerException if the pool is null
          */
         public ForkJoinWorkerThread newThread(ForkJoinPool pool);
@@ -780,7 +781,7 @@
      * arrays sharing cache lines. The @Contended annotation alerts
      * JVMs to try to keep instances apart.
      */
-    @sun.misc.Contended
+    @jdk.internal.vm.annotation.Contended
     static final class WorkQueue {
 
         /**
@@ -818,7 +819,7 @@
         final ForkJoinWorkerThread owner; // owning thread or null if shared
         volatile Thread parker;    // == owner during call to park; else null
         volatile ForkJoinTask<?> currentJoin;  // task being joined in awaitJoin
-        @sun.misc.Contended("group2") // separate from other fields
+        @jdk.internal.vm.annotation.Contended("group2") // separate from other fields
         volatile ForkJoinTask<?> currentSteal; // nonnull when running some task
 
         WorkQueue(ForkJoinPool pool, ForkJoinWorkerThread owner) {
@@ -1053,7 +1054,7 @@
         }
 
         /**
-         * Shared version of pop.
+         * Shared version of tryUnpush.
          */
         final boolean trySharedUnpush(ForkJoinTask<?> task) {
             boolean popped = false;
@@ -1064,7 +1065,8 @@
                 ForkJoinTask<?> t = (ForkJoinTask<?>) U.getObject(a, offset);
                 if (t == task &&
                     U.compareAndSwapInt(this, QLOCK, 0, 1)) {
-                    if (U.compareAndSwapObject(a, offset, task, null)) {
+                    if (top == s + 1 && array == a &&
+                        U.compareAndSwapObject(a, offset, task, null)) {
                         popped = true;
                         top = s;
                     }
@@ -1250,12 +1252,14 @@
                     for (CountedCompleter<?> r = t;;) {
                         if (r == task) {
                             if ((mode & IS_OWNED) == 0) {
-                                boolean popped;
+                                boolean popped = false;
                                 if (U.compareAndSwapInt(this, QLOCK, 0, 1)) {
-                                    if (popped =
+                                    if (top == s && array == a &&
                                         U.compareAndSwapObject(a, offset,
-                                                               t, null))
+                                                               t, null)) {
+                                        popped = true;
                                         top = s - 1;
+                                    }
                                     U.putOrderedInt(this, QLOCK, 0);
                                     if (popped)
                                         return t;
--- a/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java	Wed Dec 02 09:34:55 2015 -0800
@@ -132,11 +132,10 @@
     /*
      * This class specializes ThreadPoolExecutor implementation by
      *
-     * 1. Using a custom task type, ScheduledFutureTask for
-     *    tasks, even those that don't require scheduling (i.e.,
-     *    those submitted using ExecutorService execute, not
-     *    ScheduledExecutorService methods) which are treated as
-     *    delayed tasks with a delay of zero.
+     * 1. Using a custom task type ScheduledFutureTask, even for tasks
+     *    that don't require scheduling because they are submitted
+     *    using ExecutorService rather than ScheduledExecutorService
+     *    methods, which are treated as tasks with a delay of zero.
      *
      * 2. Using a custom queue (DelayedWorkQueue), a variant of
      *    unbounded DelayQueue. The lack of capacity constraint and
@@ -177,24 +176,17 @@
      */
     private static final AtomicLong sequencer = new AtomicLong();
 
-    /**
-     * Returns current nanosecond time.
-     */
-    static final long now() {
-        return System.nanoTime();
-    }
-
     private class ScheduledFutureTask<V>
             extends FutureTask<V> implements RunnableScheduledFuture<V> {
 
         /** Sequence number to break ties FIFO */
         private final long sequenceNumber;
 
-        /** The time the task is enabled to execute in nanoTime units */
+        /** The nanoTime-based time when the task is enabled to execute. */
         private volatile long time;
 
         /**
-         * Period in nanoseconds for repeating tasks.
+         * Period for repeating tasks, in nanoseconds.
          * A positive value indicates fixed-rate execution.
          * A negative value indicates fixed-delay execution.
          * A value of 0 indicates a non-repeating (one-shot) task.
@@ -244,7 +236,7 @@
         }
 
         public long getDelay(TimeUnit unit) {
-            return unit.convert(time - now(), NANOSECONDS);
+            return unit.convert(time - System.nanoTime(), NANOSECONDS);
         }
 
         public int compareTo(Delayed other) {
@@ -287,6 +279,9 @@
         }
 
         public boolean cancel(boolean mayInterruptIfRunning) {
+            // The racy read of heapIndex below is benign:
+            // if heapIndex < 0, then OOTA guarantees that we have surely
+            // been removed; else we recheck under lock in remove()
             boolean cancelled = super.cancel(mayInterruptIfRunning);
             if (cancelled && removeOnCancel && heapIndex >= 0)
                 remove(this);
@@ -528,7 +523,7 @@
      * Returns the nanoTime-based trigger time of a delayed action.
      */
     long triggerTime(long delay) {
-        return now() +
+        return System.nanoTime() +
             ((delay < (Long.MAX_VALUE >> 1)) ? delay : overflowFree(delay));
     }
 
--- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Wed Dec 02 09:34:55 2015 -0800
@@ -975,7 +975,7 @@
      * than users expect.
      */
     @SuppressWarnings("serial")
-    @sun.misc.Contended
+    @jdk.internal.vm.annotation.Contended
     private static final class BufferedSubscription<T>
         implements Flow.Subscription, ForkJoinPool.ManagedBlocker {
         // Order-sensitive field declarations
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Wed Dec 02 09:34:55 2015 -0800
@@ -365,12 +365,17 @@
     /**
      * Standard hotspot implementation using intrinsics.
      */
-    private static class AtomicIntegerFieldUpdaterImpl<T>
-            extends AtomicIntegerFieldUpdater<T> {
+    private static final class AtomicIntegerFieldUpdaterImpl<T>
+        extends AtomicIntegerFieldUpdater<T> {
         private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
+        /**
+         * if field is protected, the subclass constructing updater, else
+         * the same as tclass
+         */
+        private final Class<?> cclass;
+        /** class holding the field */
         private final Class<T> tclass;
-        private final Class<?> cclass;
 
         AtomicIntegerFieldUpdaterImpl(final Class<T> tclass,
                                       final String fieldName,
@@ -399,17 +404,15 @@
                 throw new RuntimeException(ex);
             }
 
-            Class<?> fieldt = field.getType();
-            if (fieldt != int.class)
+            if (field.getType() != int.class)
                 throw new IllegalArgumentException("Must be integer type");
 
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers) &&
-                           caller != tclass) ? caller : null;
+            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
             this.tclass = tclass;
-            offset = U.objectFieldOffset(field);
+            this.offset = U.objectFieldOffset(field);
         }
 
         /**
@@ -428,81 +431,87 @@
             return false;
         }
 
-        private void fullCheck(T obj) {
-            if (!tclass.isInstance(obj))
-                throw new ClassCastException();
-            if (cclass != null)
-                ensureProtectedAccess(obj);
+        /**
+         * Checks that target argument is instance of cclass.  On
+         * failure, throws cause.
+         */
+        private final void accessCheck(T obj) {
+            if (!cclass.isInstance(obj))
+                throwAccessCheckException(obj);
         }
 
-        public boolean compareAndSet(T obj, int expect, int update) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        /**
+         * Throws access exception if accessCheck failed due to
+         * protected access, else ClassCastException.
+         */
+        private final void throwAccessCheckException(T obj) {
+            if (cclass == tclass)
+                throw new ClassCastException();
+            else
+                throw new RuntimeException(
+                    new IllegalAccessException(
+                        "Class " +
+                        cclass.getName() +
+                        " can not access a protected member of class " +
+                        tclass.getName() +
+                        " using an instance of " +
+                        obj.getClass().getName()));
+        }
+
+        public final boolean compareAndSet(T obj, int expect, int update) {
+            accessCheck(obj);
             return U.compareAndSwapInt(obj, offset, expect, update);
         }
 
-        public boolean weakCompareAndSet(T obj, int expect, int update) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final boolean weakCompareAndSet(T obj, int expect, int update) {
+            accessCheck(obj);
             return U.compareAndSwapInt(obj, offset, expect, update);
         }
 
-        public void set(T obj, int newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final void set(T obj, int newValue) {
+            accessCheck(obj);
             U.putIntVolatile(obj, offset, newValue);
         }
 
-        public void lazySet(T obj, int newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final void lazySet(T obj, int newValue) {
+            accessCheck(obj);
             U.putOrderedInt(obj, offset, newValue);
         }
 
         public final int get(T obj) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+            accessCheck(obj);
             return U.getIntVolatile(obj, offset);
         }
 
-        public int getAndSet(T obj, int newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final int getAndSet(T obj, int newValue) {
+            accessCheck(obj);
             return U.getAndSetInt(obj, offset, newValue);
         }
 
-        public int getAndIncrement(T obj) {
+        public final int getAndAdd(T obj, int delta) {
+            accessCheck(obj);
+            return U.getAndAddInt(obj, offset, delta);
+        }
+
+        public final int getAndIncrement(T obj) {
             return getAndAdd(obj, 1);
         }
 
-        public int getAndDecrement(T obj) {
+        public final int getAndDecrement(T obj) {
             return getAndAdd(obj, -1);
         }
 
-        public int getAndAdd(T obj, int delta) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
-            return U.getAndAddInt(obj, offset, delta);
-        }
-
-        public int incrementAndGet(T obj) {
+        public final int incrementAndGet(T obj) {
             return getAndAdd(obj, 1) + 1;
         }
 
-        public int decrementAndGet(T obj) {
+        public final int decrementAndGet(T obj) {
             return getAndAdd(obj, -1) - 1;
         }
 
-        public int addAndGet(T obj, int delta) {
+        public final int addAndGet(T obj, int delta) {
             return getAndAdd(obj, delta) + delta;
         }
 
-        private void ensureProtectedAccess(T obj) {
-            if (cclass.isInstance(obj)) {
-                return;
-            }
-            throw new RuntimeException(
-                new IllegalAccessException("Class " +
-                    cclass.getName() +
-                    " can not access a protected member of class " +
-                    tclass.getName() +
-                    " using an instance of " +
-                    obj.getClass().getName()
-                )
-            );
-        }
     }
 }
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Wed Dec 02 09:34:55 2015 -0800
@@ -365,11 +365,16 @@
         return next;
     }
 
-    private static class CASUpdater<T> extends AtomicLongFieldUpdater<T> {
+    private static final class CASUpdater<T> extends AtomicLongFieldUpdater<T> {
         private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
+        /**
+         * if field is protected, the subclass constructing updater, else
+         * the same as tclass
+         */
+        private final Class<?> cclass;
+        /** class holding the field */
         private final Class<T> tclass;
-        private final Class<?> cclass;
 
         CASUpdater(final Class<T> tclass, final String fieldName,
                    final Class<?> caller) {
@@ -397,103 +402,110 @@
                 throw new RuntimeException(ex);
             }
 
-            Class<?> fieldt = field.getType();
-            if (fieldt != long.class)
+            if (field.getType() != long.class)
                 throw new IllegalArgumentException("Must be long type");
 
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers) &&
-                           caller != tclass) ? caller : null;
+            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
             this.tclass = tclass;
-            offset = U.objectFieldOffset(field);
+            this.offset = U.objectFieldOffset(field);
         }
 
-        private void fullCheck(T obj) {
-            if (!tclass.isInstance(obj))
-                throw new ClassCastException();
-            if (cclass != null)
-                ensureProtectedAccess(obj);
+        /**
+         * Checks that target argument is instance of cclass.  On
+         * failure, throws cause.
+         */
+        private final void accessCheck(T obj) {
+            if (!cclass.isInstance(obj))
+                throwAccessCheckException(obj);
         }
 
-        public boolean compareAndSet(T obj, long expect, long update) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        /**
+         * Throws access exception if accessCheck failed due to
+         * protected access, else ClassCastException.
+         */
+        private final void throwAccessCheckException(T obj) {
+            if (cclass == tclass)
+                throw new ClassCastException();
+            else
+                throw new RuntimeException(
+                    new IllegalAccessException(
+                        "Class " +
+                        cclass.getName() +
+                        " can not access a protected member of class " +
+                        tclass.getName() +
+                        " using an instance of " +
+                        obj.getClass().getName()));
+        }
+
+        public final boolean compareAndSet(T obj, long expect, long update) {
+            accessCheck(obj);
             return U.compareAndSwapLong(obj, offset, expect, update);
         }
 
-        public boolean weakCompareAndSet(T obj, long expect, long update) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final boolean weakCompareAndSet(T obj, long expect, long update) {
+            accessCheck(obj);
             return U.compareAndSwapLong(obj, offset, expect, update);
         }
 
-        public void set(T obj, long newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final void set(T obj, long newValue) {
+            accessCheck(obj);
             U.putLongVolatile(obj, offset, newValue);
         }
 
-        public void lazySet(T obj, long newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final void lazySet(T obj, long newValue) {
+            accessCheck(obj);
             U.putOrderedLong(obj, offset, newValue);
         }
 
-        public long get(T obj) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final long get(T obj) {
+            accessCheck(obj);
             return U.getLongVolatile(obj, offset);
         }
 
-        public long getAndSet(T obj, long newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final long getAndSet(T obj, long newValue) {
+            accessCheck(obj);
             return U.getAndSetLong(obj, offset, newValue);
         }
 
-        public long getAndIncrement(T obj) {
+        public final long getAndAdd(T obj, long delta) {
+            accessCheck(obj);
+            return U.getAndAddLong(obj, offset, delta);
+        }
+
+        public final long getAndIncrement(T obj) {
             return getAndAdd(obj, 1);
         }
 
-        public long getAndDecrement(T obj) {
+        public final long getAndDecrement(T obj) {
             return getAndAdd(obj, -1);
         }
 
-        public long getAndAdd(T obj, long delta) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
-            return U.getAndAddLong(obj, offset, delta);
-        }
-
-        public long incrementAndGet(T obj) {
+        public final long incrementAndGet(T obj) {
             return getAndAdd(obj, 1) + 1;
         }
 
-        public long decrementAndGet(T obj) {
+        public final long decrementAndGet(T obj) {
             return getAndAdd(obj, -1) - 1;
         }
 
-        public long addAndGet(T obj, long delta) {
+        public final long addAndGet(T obj, long delta) {
             return getAndAdd(obj, delta) + delta;
         }
-
-        private void ensureProtectedAccess(T obj) {
-            if (cclass.isInstance(obj)) {
-                return;
-            }
-            throw new RuntimeException(
-                new IllegalAccessException("Class " +
-                    cclass.getName() +
-                    " can not access a protected member of class " +
-                    tclass.getName() +
-                    " using an instance of " +
-                    obj.getClass().getName()
-                )
-            );
-        }
     }
 
-
-    private static class LockedUpdater<T> extends AtomicLongFieldUpdater<T> {
+    private static final class LockedUpdater<T> extends AtomicLongFieldUpdater<T> {
         private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
+        /**
+         * if field is protected, the subclass constructing updater, else
+         * the same as tclass
+         */
+        private final Class<?> cclass;
+        /** class holding the field */
         private final Class<T> tclass;
-        private final Class<?> cclass;
 
         LockedUpdater(final Class<T> tclass, final String fieldName,
                       final Class<?> caller) {
@@ -521,28 +533,46 @@
                 throw new RuntimeException(ex);
             }
 
-            Class<?> fieldt = field.getType();
-            if (fieldt != long.class)
+            if (field.getType() != long.class)
                 throw new IllegalArgumentException("Must be long type");
 
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers) &&
-                           caller != tclass) ? caller : null;
+            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
             this.tclass = tclass;
-            offset = U.objectFieldOffset(field);
+            this.offset = U.objectFieldOffset(field);
         }
 
-        private void fullCheck(T obj) {
-            if (!tclass.isInstance(obj))
-                throw new ClassCastException();
-            if (cclass != null)
-                ensureProtectedAccess(obj);
+        /**
+         * Checks that target argument is instance of cclass.  On
+         * failure, throws cause.
+         */
+        private final void accessCheck(T obj) {
+            if (!cclass.isInstance(obj))
+                throw accessCheckException(obj);
         }
 
-        public boolean compareAndSet(T obj, long expect, long update) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        /**
+         * Returns access exception if accessCheck failed due to
+         * protected access, else ClassCastException.
+         */
+        private final RuntimeException accessCheckException(T obj) {
+            if (cclass == tclass)
+                return new ClassCastException();
+            else
+                return new RuntimeException(
+                    new IllegalAccessException(
+                        "Class " +
+                        cclass.getName() +
+                        " can not access a protected member of class " +
+                        tclass.getName() +
+                        " using an instance of " +
+                        obj.getClass().getName()));
+        }
+
+        public final boolean compareAndSet(T obj, long expect, long update) {
+            accessCheck(obj);
             synchronized (this) {
                 long v = U.getLong(obj, offset);
                 if (v != expect)
@@ -552,42 +582,27 @@
             }
         }
 
-        public boolean weakCompareAndSet(T obj, long expect, long update) {
+        public final boolean weakCompareAndSet(T obj, long expect, long update) {
             return compareAndSet(obj, expect, update);
         }
 
-        public void set(T obj, long newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final void set(T obj, long newValue) {
+            accessCheck(obj);
             synchronized (this) {
                 U.putLong(obj, offset, newValue);
             }
         }
 
-        public void lazySet(T obj, long newValue) {
+        public final void lazySet(T obj, long newValue) {
             set(obj, newValue);
         }
 
-        public long get(T obj) {
-            if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj);
+        public final long get(T obj) {
+            accessCheck(obj);
             synchronized (this) {
                 return U.getLong(obj, offset);
             }
         }
-
-        private void ensureProtectedAccess(T obj) {
-            if (cclass.isInstance(obj)) {
-                return;
-            }
-            throw new RuntimeException(
-                new IllegalAccessException("Class " +
-                    cclass.getName() +
-                    " can not access a protected member of class " +
-                    tclass.getName() +
-                    " using an instance of " +
-                    obj.getClass().getName()
-                )
-            );
-        }
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Wed Dec 02 09:34:55 2015 -0800
@@ -286,9 +286,15 @@
         extends AtomicReferenceFieldUpdater<T,V> {
         private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
+        /**
+         * if field is protected, the subclass constructing updater, else
+         * the same as tclass
+         */
+        private final Class<?> cclass;
+        /** class holding the field */
         private final Class<T> tclass;
+        /** field value type */
         private final Class<V> vclass;
-        private final Class<?> cclass;
 
         /*
          * Internal type checks within all update methods contain
@@ -340,14 +346,10 @@
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers) &&
-                           caller != tclass) ? caller : null;
+            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
             this.tclass = tclass;
-            if (vclass == Object.class)
-                this.vclass = null;
-            else
-                this.vclass = vclass;
-            offset = U.objectFieldOffset(field);
+            this.vclass = vclass;
+            this.offset = U.objectFieldOffset(field);
         }
 
         /**
@@ -366,83 +368,78 @@
             return false;
         }
 
-        void targetCheck(T obj) {
-            if (!tclass.isInstance(obj))
-                throw new ClassCastException();
-            if (cclass != null)
-                ensureProtectedAccess(obj);
+        /**
+         * Checks that target argument is instance of cclass.  On
+         * failure, throws cause.
+         */
+        private final void accessCheck(T obj) {
+            if (!cclass.isInstance(obj))
+                throwAccessCheckException(obj);
         }
 
-        void updateCheck(T obj, V update) {
-            if (!tclass.isInstance(obj) ||
-                (update != null && vclass != null && !vclass.isInstance(update)))
+        /**
+         * Throws access exception if accessCheck failed due to
+         * protected access, else ClassCastException.
+         */
+        private final void throwAccessCheckException(T obj) {
+            if (cclass == tclass)
                 throw new ClassCastException();
-            if (cclass != null)
-                ensureProtectedAccess(obj);
+            else
+                throw new RuntimeException(
+                    new IllegalAccessException(
+                        "Class " +
+                        cclass.getName() +
+                        " can not access a protected member of class " +
+                        tclass.getName() +
+                        " using an instance of " +
+                        obj.getClass().getName()));
         }
 
-        public boolean compareAndSet(T obj, V expect, V update) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (update != null && vclass != null &&
-                 vclass != update.getClass()))
-                updateCheck(obj, update);
+        private final void valueCheck(V v) {
+            if (v != null && !(vclass.isInstance(v)))
+                throwCCE();
+        }
+
+        static void throwCCE() {
+            throw new ClassCastException();
+        }
+
+        public final boolean compareAndSet(T obj, V expect, V update) {
+            accessCheck(obj);
+            valueCheck(update);
             return U.compareAndSwapObject(obj, offset, expect, update);
         }
 
-        public boolean weakCompareAndSet(T obj, V expect, V update) {
+        public final boolean weakCompareAndSet(T obj, V expect, V update) {
             // same implementation as strong form for now
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (update != null && vclass != null &&
-                 vclass != update.getClass()))
-                updateCheck(obj, update);
+            accessCheck(obj);
+            valueCheck(update);
             return U.compareAndSwapObject(obj, offset, expect, update);
         }
 
-        public void set(T obj, V newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (newValue != null && vclass != null &&
-                 vclass != newValue.getClass()))
-                updateCheck(obj, newValue);
+        public final void set(T obj, V newValue) {
+            accessCheck(obj);
+            valueCheck(newValue);
             U.putObjectVolatile(obj, offset, newValue);
         }
 
-        public void lazySet(T obj, V newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (newValue != null && vclass != null &&
-                 vclass != newValue.getClass()))
-                updateCheck(obj, newValue);
+        public final void lazySet(T obj, V newValue) {
+            accessCheck(obj);
+            valueCheck(newValue);
             U.putOrderedObject(obj, offset, newValue);
         }
 
         @SuppressWarnings("unchecked")
-        public V get(T obj) {
-            if (obj == null || obj.getClass() != tclass || cclass != null)
-                targetCheck(obj);
+        public final V get(T obj) {
+            accessCheck(obj);
             return (V)U.getObjectVolatile(obj, offset);
         }
 
         @SuppressWarnings("unchecked")
-        public V getAndSet(T obj, V newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (newValue != null && vclass != null &&
-                 vclass != newValue.getClass()))
-                updateCheck(obj, newValue);
+        public final V getAndSet(T obj, V newValue) {
+            accessCheck(obj);
+            valueCheck(newValue);
             return (V)U.getAndSetObject(obj, offset, newValue);
         }
-
-        private void ensureProtectedAccess(T obj) {
-            if (cclass.isInstance(obj)) {
-                return;
-            }
-            throw new RuntimeException(
-                new IllegalAccessException("Class " +
-                    cclass.getName() +
-                    " can not access a protected member of class " +
-                    tclass.getName() +
-                    " using an instance of " +
-                    obj.getClass().getName()
-                )
-            );
-        }
     }
 }
--- a/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java	Wed Dec 02 09:34:55 2015 -0800
@@ -55,7 +55,7 @@
      * accessed directly by subclasses.
      *
      * Table entries are of class Cell; a variant of AtomicLong padded
-     * (via @sun.misc.Contended) to reduce cache contention. Padding
+     * (via @jdk.internal.vm.annotation.Contended) to reduce cache contention. Padding
      * is overkill for most Atomics because they are usually
      * irregularly scattered in memory and thus don't interfere much
      * with each other. But Atomic objects residing in arrays will
@@ -119,7 +119,7 @@
      * JVM intrinsics note: It would be possible to use a release-only
      * form of CAS here, if it were provided.
      */
-    @sun.misc.Contended static final class Cell {
+    @jdk.internal.vm.annotation.Contended static final class Cell {
         volatile long value;
         Cell(long x) { value = x; }
         final boolean cas(long cmp, long val) {
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Wed Dec 02 09:34:55 2015 -0800
@@ -922,7 +922,7 @@
 
     /**
      * Queries whether any threads have ever contended to acquire this
-     * synchronizer; that is if an acquire method has ever blocked.
+     * synchronizer; that is, if an acquire method has ever blocked.
      *
      * <p>In this implementation, this operation returns in
      * constant time.
@@ -977,13 +977,11 @@
          * guaranteeing termination.
          */
 
-        Node t = tail;
         Thread firstThread = null;
-        while (t != null && t != head) {
-            Thread tt = t.thread;
-            if (tt != null)
-                firstThread = tt;
-            t = t.prev;
+        for (Node p = tail; p != null && p != head; p = p.prev) {
+            Thread t = p.thread;
+            if (t != null)
+                firstThread = t;
         }
         return firstThread;
     }
@@ -1031,8 +1029,8 @@
      * <p>An invocation of this method is equivalent to (but may be
      * more efficient than):
      * <pre> {@code
-     * getFirstQueuedThread() != Thread.currentThread() &&
-     * hasQueuedThreads()}</pre>
+     * getFirstQueuedThread() != Thread.currentThread()
+     *   && hasQueuedThreads()}</pre>
      *
      * <p>Note that because cancellations due to interrupts and
      * timeouts may occur at any time, a {@code true} return does not
@@ -1635,7 +1633,7 @@
                     transferAfterCancelledWait(node);
                     break;
                 }
-                if (nanosTimeout >= SPIN_FOR_TIMEOUT_THRESHOLD)
+                if (nanosTimeout > SPIN_FOR_TIMEOUT_THRESHOLD)
                     LockSupport.parkNanos(this, nanosTimeout);
                 if ((interruptMode = checkInterruptWhileWaiting(node)) != 0)
                     break;
@@ -1723,7 +1721,7 @@
                     timedout = transferAfterCancelledWait(node);
                     break;
                 }
-                if (nanosTimeout >= SPIN_FOR_TIMEOUT_THRESHOLD)
+                if (nanosTimeout > SPIN_FOR_TIMEOUT_THRESHOLD)
                     LockSupport.parkNanos(this, nanosTimeout);
                 if ((interruptMode = checkInterruptWhileWaiting(node)) != 0)
                     break;
@@ -1847,8 +1845,9 @@
      * Initializes head and tail fields on first contention.
      */
     private final void initializeSyncQueue() {
-        if (U.compareAndSwapObject(this, HEAD, null, new Node()))
-            tail = head;
+        Node h;
+        if (U.compareAndSwapObject(this, HEAD, null, (h = new Node())))
+            tail = h;
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1388,7 +1388,7 @@
 
     /**
      * Queries whether any threads have ever contended to acquire this
-     * synchronizer; that is if an acquire method has ever blocked.
+     * synchronizer; that is, if an acquire method has ever blocked.
      *
      * <p>In this implementation, this operation returns in
      * constant time.
@@ -1443,13 +1443,11 @@
          * guaranteeing termination.
          */
 
-        Node t = tail;
         Thread firstThread = null;
-        while (t != null && t != head) {
-            Thread tt = t.thread;
-            if (tt != null)
-                firstThread = tt;
-            t = t.prev;
+        for (Node p = tail; p != null && p != head; p = p.prev) {
+            Thread t = p.thread;
+            if (t != null)
+                firstThread = t;
         }
         return firstThread;
     }
@@ -1497,8 +1495,8 @@
      * <p>An invocation of this method is equivalent to (but may be
      * more efficient than):
      * <pre> {@code
-     * getFirstQueuedThread() != Thread.currentThread() &&
-     * hasQueuedThreads()}</pre>
+     * getFirstQueuedThread() != Thread.currentThread()
+     *   && hasQueuedThreads()}</pre>
      *
      * <p>Note that because cancellations due to interrupts and
      * timeouts may occur at any time, a {@code true} return does not
@@ -2099,7 +2097,7 @@
                     transferAfterCancelledWait(node);
                     break;
                 }
-                if (nanosTimeout >= SPIN_FOR_TIMEOUT_THRESHOLD)
+                if (nanosTimeout > SPIN_FOR_TIMEOUT_THRESHOLD)
                     LockSupport.parkNanos(this, nanosTimeout);
                 if ((interruptMode = checkInterruptWhileWaiting(node)) != 0)
                     break;
@@ -2187,7 +2185,7 @@
                     timedout = transferAfterCancelledWait(node);
                     break;
                 }
-                if (nanosTimeout >= SPIN_FOR_TIMEOUT_THRESHOLD)
+                if (nanosTimeout > SPIN_FOR_TIMEOUT_THRESHOLD)
                     LockSupport.parkNanos(this, nanosTimeout);
                 if ((interruptMode = checkInterruptWhileWaiting(node)) != 0)
                     break;
@@ -2311,8 +2309,9 @@
      * Initializes head and tail fields on first contention.
      */
     private final void initializeSyncQueue() {
-        if (U.compareAndSwapObject(this, HEAD, null, new Node()))
-            tail = head;
+        Node h;
+        if (U.compareAndSwapObject(this, HEAD, null, (h = new Node())))
+            tail = h;
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java	Wed Dec 02 09:34:55 2015 -0800
@@ -81,12 +81,17 @@
  * method is designed for use only in constructions of the form:
  *
  * <pre> {@code
- * while (!canProceed()) { ... LockSupport.park(this); }}</pre>
+ * while (!canProceed()) {
+ *   // ensure request to unpark is visible to other threads
+ *   ...
+ *   LockSupport.park(this);
+ * }}</pre>
  *
- * where neither {@code canProceed} nor any other actions prior to the
- * call to {@code park} entail locking or blocking.  Because only one
- * permit is associated with each thread, any intermediary uses of
- * {@code park} could interfere with its intended effects.
+ * where no actions by the thread publishing a request to unpark,
+ * prior to the call to {@code park}, entail locking or blocking.
+ * Because only one permit is associated with each thread, any
+ * intermediary uses of {@code park}, including implicitly via class
+ * loading, could lead to an unresponsive thread (a "lost unpark").
  *
  * <p><b>Sample Usage.</b> Here is a sketch of a first-in-first-out
  * non-reentrant lock class:
@@ -98,26 +103,33 @@
  *
  *   public void lock() {
  *     boolean wasInterrupted = false;
- *     Thread current = Thread.currentThread();
- *     waiters.add(current);
+ *     // publish current thread for unparkers
+ *     waiters.add(Thread.currentThread());
  *
  *     // Block while not first in queue or cannot acquire lock
- *     while (waiters.peek() != current ||
+ *     while (waiters.peek() != Thread.currentThread() ||
  *            !locked.compareAndSet(false, true)) {
  *       LockSupport.park(this);
- *       if (Thread.interrupted()) // ignore interrupts while waiting
+ *       // ignore interrupts while waiting
+ *       if (Thread.interrupted())
  *         wasInterrupted = true;
  *     }
  *
  *     waiters.remove();
- *     if (wasInterrupted)          // reassert interrupt status on exit
- *       current.interrupt();
+ *     // ensure correct interrupt status on return
+ *     if (wasInterrupted)
+ *       Thread.currentThread().interrupt();
  *   }
  *
  *   public void unlock() {
  *     locked.set(false);
  *     LockSupport.unpark(waiters.peek());
  *   }
+ *
+ *   static {
+ *     // Reduce the risk of "lost unpark" due to classloading
+ *     Class<?> ensureLoaded = LockSupport.class;
+ *   }
  * }}</pre>
  */
 public class LockSupport {
--- a/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Wed Dec 02 09:34:55 2015 -0800
@@ -188,9 +188,9 @@
  *     try { return m.get(key); }
  *     finally { r.unlock(); }
  *   }
- *   public String[] allKeys() {
+ *   public List<String> allKeys() {
  *     r.lock();
- *     try { return m.keySet().toArray(); }
+ *     try { return new ArrayList<>(m.keySet()); }
  *     finally { r.unlock(); }
  *   }
  *   public Data put(String key, Data value) {
--- a/src/java.base/share/classes/javax/net/ssl/SSLEngine.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/javax/net/ssl/SSLEngine.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1253,4 +1253,55 @@
         }
     }
 
+    /**
+     * Returns the most recent application protocol value negotiated for this
+     * connection.
+     * <p>
+     * If supported by the underlying SSL/TLS/DTLS implementation,
+     * application name negotiation mechanisms such as <a
+     * href="http://www.ietf.org/rfc/rfc7301.txt"> RFC 7301 </a>, the
+     * Application-Layer Protocol Negotiation (ALPN), can negotiate
+     * application-level values between peers.
+     * <p>
+     * @implSpec
+     * The implementation in this class throws
+     * {@code UnsupportedOperationException} and performs no other action.
+     *
+     * @return null if it has not yet been determined if application
+     *         protocols might be used for this connection, an empty
+     *         {@code String} if application protocols values will not
+     *         be used, or a non-empty application protocol {@code String}
+     *         if a value was successfully negotiated.
+     * @throws UnsupportedOperationException if the underlying provider
+     *         does not implement the operation.
+     * @since 9
+     */
+    public String getApplicationProtocol() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns the application protocol value negotiated on a SSL/TLS
+     * handshake currently in progress.
+     * <p>
+     * Like {@link #getHandshakeSession()},
+     * a connection may be in the middle of a handshake. The
+     * application protocol may or may not yet be available.
+     * <p>
+     * @implSpec
+     * The implementation in this class throws
+     * {@code UnsupportedOperationException} and performs no other action.
+     *
+     * @return null if it has not yet been determined if application
+     *         protocols might be used for this handshake, an empty
+     *         {@code String} if application protocols values will not
+     *         be used, or a non-empty application protocol {@code String}
+     *         if a value was successfully negotiated.
+     * @throws UnsupportedOperationException if the underlying provider
+     *         does not implement the operation.
+     * @since 9
+     */
+    public String getHandshakeApplicationProtocol() {
+        throw new UnsupportedOperationException();
+    }
 }
--- a/src/java.base/share/classes/javax/net/ssl/SSLParameters.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/javax/net/ssl/SSLParameters.java	Wed Dec 02 09:34:55 2015 -0800
@@ -56,6 +56,17 @@
  * {@link SSLSocket#setSSLParameters SSLSocket.setSSLParameters()} and
  * {@link SSLServerSocket#setSSLParameters SSLServerSocket.setSSLParameters()}
  * and {@link SSLEngine#setSSLParameters SSLEngine.setSSLParameters()}.
+ * <p>
+ * For example:
+ *
+ * <blockquote><pre>
+ *     SSLParameters p = sslSocket.getSSLParameters();
+ *     p.setProtocols(new String[] { "TLSv1.2" });
+ *     p.setCipherSuites(
+ *         new String[] { "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", ... });
+ *     p.setApplicationProtocols(new String[] {"h2", "http/1.1"});
+ *     sslSocket.setSSLParameters(p);
+ * </pre></blockquote>
  *
  * @see SSLSocket
  * @see SSLEngine
@@ -76,6 +87,7 @@
     private boolean preferLocalCipherSuites;
     private boolean enableRetransmissions = true;
     private int maximumPacketSize = 0;
+    private String[] applicationProtocols = new String[0];
 
     /**
      * Constructs SSLParameters.
@@ -480,7 +492,7 @@
      *
      * @see     #getEnableRetransmissions()
      *
-     * @since 1.9
+     * @since 9
      */
     public void setEnableRetransmissions(boolean enableRetransmissions) {
         this.enableRetransmissions = enableRetransmissions;
@@ -495,7 +507,7 @@
      *
      * @see     #setEnableRetransmissions(boolean)
      *
-     * @since 1.9
+     * @since 9
      */
     public boolean getEnableRetransmissions() {
         return enableRetransmissions;
@@ -523,7 +535,7 @@
      *
      * @see     #getMaximumPacketSize()
      *
-     * @since 1.9
+     * @since 9
      */
     public void setMaximumPacketSize(int maximumPacketSize) {
         if (maximumPacketSize < 0) {
@@ -563,11 +575,80 @@
      *
      * @see      #setMaximumPacketSize(int)
      *
-     * @since 1.9
+     * @since 9
      */
     public int getMaximumPacketSize() {
         return maximumPacketSize;
     }
 
+    /**
+     * Returns a prioritized array of application-layer protocol names that
+     * can be negotiated over the SSL/TLS/DTLS protocols.
+     * <p>
+     * The array could be empty (zero-length), in which case protocol
+     * indications will not be used.
+     * <p>
+     * This method will return a new array each time it is invoked.
+     *
+     * @return a non-null, possibly zero-length array of application protocol
+     *         {@code String}s.  The array is ordered based on protocol
+     *         preference, with {@code protocols[0]} being the most preferred.
+     * @see #setApplicationProtocols
+     * @since 9
+     */
+    public String[] getApplicationProtocols() {
+        return applicationProtocols.clone();
+    }
+
+    /**
+     * Sets the prioritized array of application-layer protocol names that
+     * can be negotiated over the SSL/TLS/DTLS protocols.
+     * <p>
+     * If application-layer protocols are supported by the underlying
+     * SSL/TLS implementation, this method configures which values can
+     * be negotiated by protocols such as <a
+     * href="http://www.ietf.org/rfc/rfc7301.txt"> RFC 7301 </a>, the
+     * Application Layer Protocol Negotiation (ALPN).
+     * <p>
+     * If this end of the connection is expected to offer application protocol
+     * values, all protocols configured by this method will be sent to the
+     * peer.
+     * <p>
+     * If this end of the connection is expected to select the application
+     * protocol value, the {@code protocols} configured by this method are
+     * compared with those sent by the peer.  The first matched value becomes
+     * the negotiated value.  If none of the {@code protocols} were actually
+     * requested by the peer, the underlying protocol will determine what
+     * action to take.  (For example, ALPN will send a
+     * {@code "no_application_protocol"} alert and terminate the connection.)
+     * <p>
+     * @implSpec
+     * This method will make a copy of the {@code protocols} array.
+     *
+     * @param protocols   an ordered array of application protocols,
+     *                    with {@code protocols[0]} being the most preferred.
+     *                    If the array is empty (zero-length), protocol
+     *                    indications will not be used.
+     * @throws IllegalArgumentException if protocols is null, or if
+     *                    any element in a non-empty array is null or an
+     *                    empty (zero-length) string
+     * @see #getApplicationProtocols
+     * @since 9
+     */
+    public void setApplicationProtocols(String[] protocols) {
+        if (protocols == null) {
+            throw new IllegalArgumentException("protocols was null");
+        }
+
+        String[] tempProtocols = protocols.clone();
+
+        for (String p : tempProtocols) {
+            if (p == null || p.equals("")) {
+                throw new IllegalArgumentException(
+                    "An element of protocols was null/empty");
+            }
+        }
+        applicationProtocols = tempProtocols;
+    }
 }
 
--- a/src/java.base/share/classes/javax/net/ssl/SSLSocket.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/javax/net/ssl/SSLSocket.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -662,4 +662,55 @@
         }
     }
 
+    /**
+     * Returns the most recent application protocol value negotiated for this
+     * connection.
+     * <p>
+     * If supported by the underlying SSL/TLS/DTLS implementation,
+     * application name negotiation mechanisms such as <a
+     * href="http://www.ietf.org/rfc/rfc7301.txt"> RFC 7301 </a>, the
+     * Application-Layer Protocol Negotiation (ALPN), can negotiate
+     * application-level values between peers.
+     * <p>
+     * @implSpec
+     * The implementation in this class throws
+     * {@code UnsupportedOperationException} and performs no other action.
+     *
+     * @return null if it has not yet been determined if application
+     *         protocols might be used for this connection, an empty
+     *         {@code String} if application protocols values will not
+     *         be used, or a non-empty application protocol {@code String}
+     *         if a value was successfully negotiated.
+     * @throws UnsupportedOperationException if the underlying provider
+     *         does not implement the operation.
+     * @since 9
+     */
+    public String getApplicationProtocol() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns the application protocol value negotiated on a SSL/TLS
+     * handshake currently in progress.
+     * <p>
+     * Like {@link #getHandshakeSession()},
+     * a connection may be in the middle of a handshake. The
+     * application protocol may or may not yet be available.
+     * <p>
+     * @implSpec
+     * The implementation in this class throws
+     * {@code UnsupportedOperationException} and performs no other action.
+     *
+     * @return null if it has not yet been determined if application
+     *         protocols might be used for this handshake, an empty
+     *         {@code String} if application protocols values will not
+     *         be used, or a non-empty application protocol {@code String}
+     *         if a value was successfully negotiated.
+     * @throws UnsupportedOperationException if the underlying provider
+     *         does not implement the operation.
+     * @since 9
+     */
+    public String getHandshakeApplicationProtocol() {
+        throw new UnsupportedOperationException();
+    }
 }
--- a/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java	Wed Dec 02 09:34:55 2015 -0800
@@ -31,13 +31,12 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.time.ZonedDateTime;
+import java.util.Optional;
 import java.util.ResourceBundle;
 import java.util.function.Function;
 import java.lang.System.Logger;
-import java.lang.System.Logger.Level;
+import java.util.function.Predicate;
 import java.util.function.Supplier;
-import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.SharedSecrets;
 import sun.util.logging.PlatformLogger;
 import sun.util.logging.PlatformLogger.ConfigurableBridge.LoggerConfiguration;
 
@@ -169,42 +168,55 @@
     // Returns the caller's class and method's name; best effort
     // if cannot infer, return the logger's name.
     private String getCallerInfo() {
-        String sourceClassName = null;
-        String sourceMethodName = null;
+        Optional<StackWalker.StackFrame> frame = new CallerFinder().get();
+        if (frame.isPresent()) {
+            return frame.get().getClassName() + " " + frame.get().getMethodName();
+        } else {
+            return name;
+        }
+    }
 
-        JavaLangAccess access = SharedSecrets.getJavaLangAccess();
-        Throwable throwable = new Throwable();
-        int depth = access.getStackTraceDepth(throwable);
+    /*
+     * CallerFinder is a stateful predicate.
+     */
+    static final class CallerFinder implements Predicate<StackWalker.StackFrame> {
+        static final StackWalker WALKER = StackWalker.getInstance();
 
-        String logClassName = "sun.util.logging.PlatformLogger";
-        String simpleLoggerClassName = "jdk.internal.logger.SimpleConsoleLogger";
-        boolean lookingForLogger = true;
-        for (int ix = 0; ix < depth; ix++) {
-            // Calling getStackTraceElement directly prevents the VM
-            // from paying the cost of building the entire stack frame.
-            final StackTraceElement frame =
-                access.getStackTraceElement(throwable, ix);
-            final String cname = frame.getClassName();
+        /**
+         * Returns StackFrame of the caller's frame.
+         * @return StackFrame of the caller's frame.
+         */
+        Optional<StackWalker.StackFrame> get() {
+            return WALKER.walk((s) -> s.filter(this).findFirst());
+        }
+
+        private boolean lookingForLogger = true;
+        /**
+         * Returns true if we have found the caller's frame, false if the frame
+         * must be skipped.
+         *
+         * @param t The frame info.
+         * @return true if we have found the caller's frame, false if the frame
+         * must be skipped.
+         */
+        @Override
+        public boolean test(StackWalker.StackFrame t) {
+            final String cname = t.getClassName();
+            // We should skip all frames until we have found the logger,
+            // because these frames could be frames introduced by e.g. custom
+            // sub classes of Handler.
             if (lookingForLogger) {
                 // Skip all frames until we have found the first logger frame.
-                if (cname.equals(logClassName) || cname.equals(simpleLoggerClassName)) {
-                    lookingForLogger = false;
-                }
-            } else {
-                if (skipLoggingFrame(cname)) continue;
-                if (!cname.equals(logClassName) && !cname.equals(simpleLoggerClassName)) {
-                    // We've found the relevant frame.
-                    sourceClassName = cname;
-                    sourceMethodName = frame.getMethodName();
-                    break;
-                }
+                lookingForLogger = !isLoggerImplFrame(cname);
+                return false;
             }
+            // We've found the relevant frame.
+            return !skipLoggingFrame(cname) && !isLoggerImplFrame(cname);
         }
 
-        if (sourceClassName != null) {
-            return sourceClassName + " " + sourceMethodName;
-        } else {
-            return name;
+        private boolean isLoggerImplFrame(String cname) {
+            return (cname.equals("sun.util.logging.PlatformLogger") ||
+                    cname.equals("jdk.internal.logger.SimpleConsoleLogger"));
         }
     }
 
--- a/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Wed Dec 02 09:34:55 2015 -0800
@@ -103,16 +103,6 @@
     void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook);
 
     /**
-     * Returns the number of stack frames represented by the given throwable.
-     */
-    int getStackTraceDepth(Throwable t);
-
-    /**
-     * Returns the ith StackTraceElement for the given throwable.
-     */
-    StackTraceElement getStackTraceElement(Throwable t, int i);
-
-    /**
      * Returns a new string backed by the provided character array. The
      * character array is not copied and must never be modified after the
      * String is created, in order to fulfill String's contract.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.misc;
+
+public interface JavaLangInvokeAccess {
+    /**
+     * Create a new MemberName instance
+     */
+    Object newMemberName();
+}
--- a/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java	Wed Dec 02 09:34:55 2015 -0800
@@ -45,6 +45,7 @@
     private static final Unsafe unsafe = Unsafe.getUnsafe();
     private static JavaUtilJarAccess javaUtilJarAccess;
     private static JavaLangAccess javaLangAccess;
+    private static JavaLangInvokeAccess javaLangInvokeAccess;
     private static JavaLangRefAccess javaLangRefAccess;
     private static JavaIOAccess javaIOAccess;
     private static JavaNetAccess javaNetAccess;
@@ -80,6 +81,20 @@
         return javaLangAccess;
     }
 
+    public static void setJavaLangInvokeAccess(JavaLangInvokeAccess jlia) {
+        javaLangInvokeAccess = jlia;
+    }
+
+    public static JavaLangInvokeAccess getJavaLangInvokeAccess() {
+        if (javaLangInvokeAccess == null) {
+            try {
+                Class<?> c = Class.forName("java.lang.invoke.MemberName");
+                unsafe.ensureClassInitialized(c);
+            } catch (ClassNotFoundException e) {};
+        }
+        return javaLangInvokeAccess;
+    }
+
     public static void setJavaLangRefAccess(JavaLangRefAccess jlra) {
         javaLangRefAccess = jlra;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/jdk/internal/vm/annotation/Contended.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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 jdk.internal.vm.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p>An annotation expressing that objects and/or their fields are
+ * expected to encounter memory contention, generally in the form of
+ * "false sharing". This annotation serves as a hint that such objects
+ * and fields should reside in locations isolated from those of other
+ * objects or fields. Susceptibility to memory contention is a
+ * property of the intended usages of objects and fields, not their
+ * types or qualifiers. The effects of this annotation will nearly
+ * always add significant space overhead to objects. The use of
+ * {@code @Contended} is warranted only when the performance impact of
+ * this time/space tradeoff is intrinsically worthwhile; for example,
+ * in concurrent contexts in which each instance of the annotated
+ * class is often accessed by a different thread.
+ *
+ * <p>A {@code @Contended} field annotation may optionally include a
+ * <i>contention group</i> tag. A contention group defines a set of one
+ * or more fields that collectively must be isolated from all other
+ * contention groups. The fields in the same contention group may not be
+ * pairwise isolated. With no contention group tag (or with the default
+ * empty tag: "") each {@code @Contended} field resides in its own
+ * <i>distinct</i> and <i>anonymous</i> contention group.
+ *
+ * <p>When the annotation is used at the class level, the effect is
+ * equivalent to grouping all the declared fields not already having the
+ * {@code @Contended} annotation into the same anonymous group.
+ * With the class level annotation, implementations may choose different
+ * isolation techniques, such as isolating the entire object, rather than
+ * isolating distinct fields. A contention group tag has no meaning
+ * in a class level {@code @Contended} annotation, and is ignored.
+ *
+ * <p>The class level {@code @Contended} annotation is not inherited and has
+ * no effect on the fields declared in any sub-classes. The effects of all
+ * {@code @Contended} annotations, however, remain in force for all
+ * subclass instances, providing isolation of all the defined contention
+ * groups. Contention group tags are not inherited, and the same tag used
+ * in a superclass and subclass, represent distinct contention groups.
+ *
+ * @since 1.8
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.TYPE})
+public @interface Contended {
+
+    /**
+     * The (optional) contention group tag.
+     * This tag is only meaningful for field level annotations.
+     *
+     * @return contention group tag.
+     */
+    String value() default "";
+}
--- a/src/java.base/share/classes/sun/invoke/util/BytecodeDescriptor.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/invoke/util/BytecodeDescriptor.java	Wed Dec 02 09:34:55 2015 -0800
@@ -113,7 +113,7 @@
     }
 
     public static String unparse(MethodType type) {
-        return unparseMethod(type.returnType(), type.parameterList());
+        return unparseMethod(type.returnType(), type.parameterArray());
     }
 
     public static String unparse(Object type) {
@@ -134,6 +134,16 @@
         return sb.toString();
     }
 
+    public static String unparseMethod(Class<?> rtype, Class<?>[] ptypes) {
+        StringBuilder sb = new StringBuilder();
+        sb.append('(');
+        for (Class<?> pt : ptypes)
+            unparseSig(pt, sb);
+        sb.append(')');
+        unparseSig(rtype, sb);
+        return sb.toString();
+    }
+
     private static void unparseSig(Class<?> t, StringBuilder sb) {
         char c = Wrapper.forBasicType(t).basicTypeChar();
         if (c != 'L') {
--- a/src/java.base/share/classes/sun/misc/Contended.java	Sun Nov 29 20:29:45 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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 sun.misc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>An annotation expressing that objects and/or their fields are
- * expected to encounter memory contention, generally in the form of
- * "false sharing". This annotation serves as a hint that such objects
- * and fields should reside in locations isolated from those of other
- * objects or fields. Susceptibility to memory contention is a
- * property of the intended usages of objects and fields, not their
- * types or qualifiers. The effects of this annotation will nearly
- * always add significant space overhead to objects. The use of
- * {@code @Contended} is warranted only when the performance impact of
- * this time/space tradeoff is intrinsically worthwhile; for example,
- * in concurrent contexts in which each instance of the annotated
- * class is often accessed by a different thread.
- *
- * <p>A {@code @Contended} field annotation may optionally include a
- * <i>contention group</i> tag. A contention group defines a set of one
- * or more fields that collectively must be isolated from all other
- * contention groups. The fields in the same contention group may not be
- * pairwise isolated. With no contention group tag (or with the default
- * empty tag: "") each {@code @Contended} field resides in its own
- * <i>distinct</i> and <i>anonymous</i> contention group.
- *
- * <p>When the annotation is used at the class level, the effect is
- * equivalent to grouping all the declared fields not already having the
- * {@code @Contended} annotation into the same anonymous group.
- * With the class level annotation, implementations may choose different
- * isolation techniques, such as isolating the entire object, rather than
- * isolating distinct fields. A contention group tag has no meaning
- * in a class level {@code @Contended} annotation, and is ignored.
- *
- * <p>The class level {@code @Contended} annotation is not inherited and has
- * no effect on the fields declared in any sub-classes. The effects of all
- * {@code @Contended} annotations, however, remain in force for all
- * subclass instances, providing isolation of all the defined contention
- * groups. Contention group tags are not inherited, and the same tag used
- * in a superclass and subclass, represent distinct contention groups.
- *
- * @since 1.8
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.TYPE})
-public @interface Contended {
-
-    /**
-     * The (optional) contention group tag.
-     * This tag is only meaningful for field level annotations.
-     *
-     * @return contention group tag.
-     */
-    String value() default "";
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/security/ssl/ALPNExtension.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+import java.io.IOException;
+import java.nio.charset.*;
+import java.util.*;
+
+import javax.net.ssl.*;
+
+/*
+ * [RFC 7301]
+ * This TLS extension facilitates the negotiation of application-layer protocols
+ * within the TLS handshake. Clients MAY include an extension of type
+ * "application_layer_protocol_negotiation" in the (extended) ClientHello
+ * message. The "extension_data" field of this extension SHALL contain a
+ * "ProtocolNameList" value:
+ *
+ *     enum {
+ *         application_layer_protocol_negotiation(16), (65535)
+ *     } ExtensionType;
+ *
+ *     opaque ProtocolName<1..2^8-1>;
+ *
+ *     struct {
+ *         ProtocolName protocol_name_list<2..2^16-1>
+ *     } ProtocolNameList;
+ */
+final class ALPNExtension extends HelloExtension {
+
+    final static int ALPN_HEADER_LENGTH = 1;
+    final static int MAX_APPLICATION_PROTOCOL_LENGTH = 255;
+    final static int MAX_APPLICATION_PROTOCOL_LIST_LENGTH = 65535;
+    private int listLength = 0;     // ProtocolNameList length
+    private List<String> protocolNames = null;
+
+    // constructor for ServerHello
+    ALPNExtension(String protocolName) throws SSLException {
+        this(new String[]{ protocolName });
+    }
+
+    // constructor for ClientHello
+    ALPNExtension(String[] protocolNames) throws SSLException {
+        super(ExtensionType.EXT_ALPN);
+        if (protocolNames.length == 0) { // never null, never empty
+            throw new IllegalArgumentException(
+                "The list of application protocols cannot be empty");
+        }
+        this.protocolNames = Arrays.asList(protocolNames);
+        for (String p : protocolNames) {
+            int length = p.getBytes(StandardCharsets.UTF_8).length;
+            if (length == 0) {
+                throw new SSLProtocolException(
+                    "Application protocol name is empty");
+            }
+            if (length <= MAX_APPLICATION_PROTOCOL_LENGTH) {
+                listLength += length + ALPN_HEADER_LENGTH;
+            } else {
+                throw new SSLProtocolException(
+                    "Application protocol name is too long: " + p);
+            }
+            if (listLength > MAX_APPLICATION_PROTOCOL_LIST_LENGTH) {
+                throw new SSLProtocolException(
+                    "Application protocol name list is too long");
+            }
+        }
+    }
+
+    // constructor for ServerHello for parsing ALPN extension
+    ALPNExtension(HandshakeInStream s, int len) throws IOException {
+        super(ExtensionType.EXT_ALPN);
+
+        if (len >= 2) {
+            listLength = s.getInt16(); // list length
+            if (listLength < 2 || listLength + 2 != len) {
+                throw new SSLProtocolException(
+                    "Invalid " + type + " extension: incorrect list length " +
+                    "(length=" + listLength + ")");
+            }
+        } else {
+            throw new SSLProtocolException(
+                "Invalid " + type + " extension: insufficient data " +
+                "(length=" + len + ")");
+        }
+
+        int remaining = listLength;
+        this.protocolNames = new ArrayList<>();
+        while (remaining > 0) {
+            // opaque ProtocolName<1..2^8-1>; // RFC 7301
+            byte[] bytes = s.getBytes8();
+            if (bytes.length == 0) {
+                throw new SSLProtocolException("Invalid " + type +
+                    " extension: empty application protocol name");
+            }
+            String p =
+                new String(bytes, StandardCharsets.UTF_8); // app protocol
+            protocolNames.add(p);
+            remaining -= bytes.length + ALPN_HEADER_LENGTH;
+        }
+
+        if (remaining != 0) {
+            throw new SSLProtocolException(
+                "Invalid " + type + " extension: extra data " +
+                "(length=" + remaining + ")");
+        }
+    }
+
+    List<String> getPeerAPs() {
+        return protocolNames;
+    }
+
+    /*
+     * Return the length in bytes, including extension type and length fields.
+     */
+    @Override
+    int length() {
+        return 6 + listLength;
+    }
+
+    @Override
+    void send(HandshakeOutStream s) throws IOException {
+        s.putInt16(type.id);
+        s.putInt16(listLength + 2); // length of extension_data
+        s.putInt16(listLength);     // length of ProtocolNameList
+
+        for (String p : protocolNames) {
+            s.putBytes8(p.getBytes(StandardCharsets.UTF_8));
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        if (protocolNames == null || protocolNames.isEmpty()) {
+            sb.append("<empty>");
+        } else {
+            for (String protocolName : protocolNames) {
+                sb.append("[" + protocolName + "]");
+            }
+        }
+
+        return "Extension " + type +
+            ", protocol names: " + sb;
+    }
+}
--- a/src/java.base/share/classes/sun/security/ssl/Alerts.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/Alerts.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,6 +83,9 @@
     static final byte           alert_bad_certificate_status_response = 113;
     static final byte           alert_bad_certificate_hash_value = 114;
 
+    // from RFC 7301 (TLS ALPN Extension)
+    static final byte           alert_no_application_protocol = 120;
+
     static String alertDescription(byte code) {
         switch (code) {
 
@@ -144,6 +147,8 @@
             return "bad_certificate_status_response";
         case alert_bad_certificate_hash_value:
             return "bad_certificate_hash_value";
+        case alert_no_application_protocol:
+            return "no_application_protocol";
 
         default:
             return "<UNKNOWN ALERT: " + (code & 0x0ff) + ">";
@@ -189,6 +194,7 @@
         case alert_unrecognized_name:
         case alert_bad_certificate_status_response:
         case alert_bad_certificate_hash_value:
+        case alert_no_application_protocol:
             e = new SSLHandshakeException(reason);
             break;
 
--- a/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Wed Dec 02 09:34:55 2015 -0800
@@ -764,7 +764,7 @@
         final boolean N = (SunJSSE.isFIPS() == false);
 
         /*
-         * TLS Cipher Suite Registry, as of August 2010.
+         * TLS Cipher Suite Registry, as of November 2015.
          *
          * http://www.iana.org/assignments/tls-parameters/tls-parameters.xml
          *
@@ -773,77 +773,77 @@
          * 192-254    Specification Required    Refers to value of first byte
          * 255        Reserved for Private Use  Refers to value of first byte
          *
-         * Value      Description                               Reference
-         * 0x00,0x00  TLS_NULL_WITH_NULL_NULL                   [RFC5246]
-         * 0x00,0x01  TLS_RSA_WITH_NULL_MD5                     [RFC5246]
-         * 0x00,0x02  TLS_RSA_WITH_NULL_SHA                     [RFC5246]
-         * 0x00,0x03  TLS_RSA_EXPORT_WITH_RC4_40_MD5            [RFC4346]
-         * 0x00,0x04  TLS_RSA_WITH_RC4_128_MD5                  [RFC5246]
-         * 0x00,0x05  TLS_RSA_WITH_RC4_128_SHA                  [RFC5246]
-         * 0x00,0x06  TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5        [RFC4346]
-         * 0x00,0x07  TLS_RSA_WITH_IDEA_CBC_SHA                 [RFC5469]
-         * 0x00,0x08  TLS_RSA_EXPORT_WITH_DES40_CBC_SHA         [RFC4346]
-         * 0x00,0x09  TLS_RSA_WITH_DES_CBC_SHA                  [RFC5469]
-         * 0x00,0x0A  TLS_RSA_WITH_3DES_EDE_CBC_SHA             [RFC5246]
-         * 0x00,0x0B  TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA      [RFC4346]
-         * 0x00,0x0C  TLS_DH_DSS_WITH_DES_CBC_SHA               [RFC5469]
-         * 0x00,0x0D  TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA          [RFC5246]
-         * 0x00,0x0E  TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA      [RFC4346]
-         * 0x00,0x0F  TLS_DH_RSA_WITH_DES_CBC_SHA               [RFC5469]
-         * 0x00,0x10  TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA          [RFC5246]
-         * 0x00,0x11  TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA     [RFC4346]
-         * 0x00,0x12  TLS_DHE_DSS_WITH_DES_CBC_SHA              [RFC5469]
-         * 0x00,0x13  TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA         [RFC5246]
-         * 0x00,0x14  TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA     [RFC4346]
-         * 0x00,0x15  TLS_DHE_RSA_WITH_DES_CBC_SHA              [RFC5469]
-         * 0x00,0x16  TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA         [RFC5246]
-         * 0x00,0x17  TLS_DH_anon_EXPORT_WITH_RC4_40_MD5        [RFC4346]
-         * 0x00,0x18  TLS_DH_anon_WITH_RC4_128_MD5              [RFC5246]
-         * 0x00,0x19  TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA     [RFC4346]
-         * 0x00,0x1A  TLS_DH_anon_WITH_DES_CBC_SHA              [RFC5469]
-         * 0x00,0x1B  TLS_DH_anon_WITH_3DES_EDE_CBC_SHA         [RFC5246]
-         * 0x00,0x1C-1D Reserved to avoid conflicts with SSLv3  [RFC5246]
-         * 0x00,0x1E  TLS_KRB5_WITH_DES_CBC_SHA                 [RFC2712]
-         * 0x00,0x1F  TLS_KRB5_WITH_3DES_EDE_CBC_SHA            [RFC2712]
-         * 0x00,0x20  TLS_KRB5_WITH_RC4_128_SHA                 [RFC2712]
-         * 0x00,0x21  TLS_KRB5_WITH_IDEA_CBC_SHA                [RFC2712]
-         * 0x00,0x22  TLS_KRB5_WITH_DES_CBC_MD5                 [RFC2712]
-         * 0x00,0x23  TLS_KRB5_WITH_3DES_EDE_CBC_MD5            [RFC2712]
-         * 0x00,0x24  TLS_KRB5_WITH_RC4_128_MD5                 [RFC2712]
-         * 0x00,0x25  TLS_KRB5_WITH_IDEA_CBC_MD5                [RFC2712]
-         * 0x00,0x26  TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA       [RFC2712]
-         * 0x00,0x27  TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA       [RFC2712]
-         * 0x00,0x28  TLS_KRB5_EXPORT_WITH_RC4_40_SHA           [RFC2712]
-         * 0x00,0x29  TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5       [RFC2712]
-         * 0x00,0x2A  TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5       [RFC2712]
-         * 0x00,0x2B  TLS_KRB5_EXPORT_WITH_RC4_40_MD5           [RFC2712]
-         * 0x00,0x2C  TLS_PSK_WITH_NULL_SHA                     [RFC4785]
-         * 0x00,0x2D  TLS_DHE_PSK_WITH_NULL_SHA                 [RFC4785]
-         * 0x00,0x2E  TLS_RSA_PSK_WITH_NULL_SHA                 [RFC4785]
-         * 0x00,0x2F  TLS_RSA_WITH_AES_128_CBC_SHA              [RFC5246]
-         * 0x00,0x30  TLS_DH_DSS_WITH_AES_128_CBC_SHA           [RFC5246]
-         * 0x00,0x31  TLS_DH_RSA_WITH_AES_128_CBC_SHA           [RFC5246]
-         * 0x00,0x32  TLS_DHE_DSS_WITH_AES_128_CBC_SHA          [RFC5246]
-         * 0x00,0x33  TLS_DHE_RSA_WITH_AES_128_CBC_SHA          [RFC5246]
-         * 0x00,0x34  TLS_DH_anon_WITH_AES_128_CBC_SHA          [RFC5246]
-         * 0x00,0x35  TLS_RSA_WITH_AES_256_CBC_SHA              [RFC5246]
-         * 0x00,0x36  TLS_DH_DSS_WITH_AES_256_CBC_SHA           [RFC5246]
-         * 0x00,0x37  TLS_DH_RSA_WITH_AES_256_CBC_SHA           [RFC5246]
-         * 0x00,0x38  TLS_DHE_DSS_WITH_AES_256_CBC_SHA          [RFC5246]
-         * 0x00,0x39  TLS_DHE_RSA_WITH_AES_256_CBC_SHA          [RFC5246]
-         * 0x00,0x3A  TLS_DH_anon_WITH_AES_256_CBC_SHA          [RFC5246]
-         * 0x00,0x3B  TLS_RSA_WITH_NULL_SHA256                  [RFC5246]
-         * 0x00,0x3C  TLS_RSA_WITH_AES_128_CBC_SHA256           [RFC5246]
-         * 0x00,0x3D  TLS_RSA_WITH_AES_256_CBC_SHA256           [RFC5246]
-         * 0x00,0x3E  TLS_DH_DSS_WITH_AES_128_CBC_SHA256        [RFC5246]
-         * 0x00,0x3F  TLS_DH_RSA_WITH_AES_128_CBC_SHA256        [RFC5246]
-         * 0x00,0x40  TLS_DHE_DSS_WITH_AES_128_CBC_SHA256       [RFC5246]
-         * 0x00,0x41  TLS_RSA_WITH_CAMELLIA_128_CBC_SHA         [RFC5932]
-         * 0x00,0x42  TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA      [RFC5932]
-         * 0x00,0x43  TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA      [RFC5932]
-         * 0x00,0x44  TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA     [RFC5932]
-         * 0x00,0x45  TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA     [RFC5932]
-         * 0x00,0x46  TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA     [RFC5932]
+         * Value      Description                                   Reference
+         * 0x00,0x00  TLS_NULL_WITH_NULL_NULL                       [RFC5246]
+         * 0x00,0x01  TLS_RSA_WITH_NULL_MD5                         [RFC5246]
+         * 0x00,0x02  TLS_RSA_WITH_NULL_SHA                         [RFC5246]
+         * 0x00,0x03  TLS_RSA_EXPORT_WITH_RC4_40_MD5                [RFC4346]
+         * 0x00,0x04  TLS_RSA_WITH_RC4_128_MD5                      [RFC5246]
+         * 0x00,0x05  TLS_RSA_WITH_RC4_128_SHA                      [RFC5246]
+         * 0x00,0x06  TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5            [RFC4346]
+         * 0x00,0x07  TLS_RSA_WITH_IDEA_CBC_SHA                     [RFC5469]
+         * 0x00,0x08  TLS_RSA_EXPORT_WITH_DES40_CBC_SHA             [RFC4346]
+         * 0x00,0x09  TLS_RSA_WITH_DES_CBC_SHA                      [RFC5469]
+         * 0x00,0x0A  TLS_RSA_WITH_3DES_EDE_CBC_SHA                 [RFC5246]
+         * 0x00,0x0B  TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA          [RFC4346]
+         * 0x00,0x0C  TLS_DH_DSS_WITH_DES_CBC_SHA                   [RFC5469]
+         * 0x00,0x0D  TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA              [RFC5246]
+         * 0x00,0x0E  TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA          [RFC4346]
+         * 0x00,0x0F  TLS_DH_RSA_WITH_DES_CBC_SHA                   [RFC5469]
+         * 0x00,0x10  TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA              [RFC5246]
+         * 0x00,0x11  TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA         [RFC4346]
+         * 0x00,0x12  TLS_DHE_DSS_WITH_DES_CBC_SHA                  [RFC5469]
+         * 0x00,0x13  TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA             [RFC5246]
+         * 0x00,0x14  TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA         [RFC4346]
+         * 0x00,0x15  TLS_DHE_RSA_WITH_DES_CBC_SHA                  [RFC5469]
+         * 0x00,0x16  TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA             [RFC5246]
+         * 0x00,0x17  TLS_DH_anon_EXPORT_WITH_RC4_40_MD5            [RFC4346]
+         * 0x00,0x18  TLS_DH_anon_WITH_RC4_128_MD5                  [RFC5246]
+         * 0x00,0x19  TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA         [RFC4346]
+         * 0x00,0x1A  TLS_DH_anon_WITH_DES_CBC_SHA                  [RFC5469]
+         * 0x00,0x1B  TLS_DH_anon_WITH_3DES_EDE_CBC_SHA             [RFC5246]
+         * 0x00,0x1C-1D Reserved to avoid conflicts with SSLv3      [RFC5246]
+         * 0x00,0x1E  TLS_KRB5_WITH_DES_CBC_SHA                     [RFC2712]
+         * 0x00,0x1F  TLS_KRB5_WITH_3DES_EDE_CBC_SHA                [RFC2712]
+         * 0x00,0x20  TLS_KRB5_WITH_RC4_128_SHA                     [RFC2712]
+         * 0x00,0x21  TLS_KRB5_WITH_IDEA_CBC_SHA                    [RFC2712]
+         * 0x00,0x22  TLS_KRB5_WITH_DES_CBC_MD5                     [RFC2712]
+         * 0x00,0x23  TLS_KRB5_WITH_3DES_EDE_CBC_MD5                [RFC2712]
+         * 0x00,0x24  TLS_KRB5_WITH_RC4_128_MD5                     [RFC2712]
+         * 0x00,0x25  TLS_KRB5_WITH_IDEA_CBC_MD5                    [RFC2712]
+         * 0x00,0x26  TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA           [RFC2712]
+         * 0x00,0x27  TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA           [RFC2712]
+         * 0x00,0x28  TLS_KRB5_EXPORT_WITH_RC4_40_SHA               [RFC2712]
+         * 0x00,0x29  TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5           [RFC2712]
+         * 0x00,0x2A  TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5           [RFC2712]
+         * 0x00,0x2B  TLS_KRB5_EXPORT_WITH_RC4_40_MD5               [RFC2712]
+         * 0x00,0x2C  TLS_PSK_WITH_NULL_SHA                         [RFC4785]
+         * 0x00,0x2D  TLS_DHE_PSK_WITH_NULL_SHA                     [RFC4785]
+         * 0x00,0x2E  TLS_RSA_PSK_WITH_NULL_SHA                     [RFC4785]
+         * 0x00,0x2F  TLS_RSA_WITH_AES_128_CBC_SHA                  [RFC5246]
+         * 0x00,0x30  TLS_DH_DSS_WITH_AES_128_CBC_SHA               [RFC5246]
+         * 0x00,0x31  TLS_DH_RSA_WITH_AES_128_CBC_SHA               [RFC5246]
+         * 0x00,0x32  TLS_DHE_DSS_WITH_AES_128_CBC_SHA              [RFC5246]
+         * 0x00,0x33  TLS_DHE_RSA_WITH_AES_128_CBC_SHA              [RFC5246]
+         * 0x00,0x34  TLS_DH_anon_WITH_AES_128_CBC_SHA              [RFC5246]
+         * 0x00,0x35  TLS_RSA_WITH_AES_256_CBC_SHA                  [RFC5246]
+         * 0x00,0x36  TLS_DH_DSS_WITH_AES_256_CBC_SHA               [RFC5246]
+         * 0x00,0x37  TLS_DH_RSA_WITH_AES_256_CBC_SHA               [RFC5246]
+         * 0x00,0x38  TLS_DHE_DSS_WITH_AES_256_CBC_SHA              [RFC5246]
+         * 0x00,0x39  TLS_DHE_RSA_WITH_AES_256_CBC_SHA              [RFC5246]
+         * 0x00,0x3A  TLS_DH_anon_WITH_AES_256_CBC_SHA              [RFC5246]
+         * 0x00,0x3B  TLS_RSA_WITH_NULL_SHA256                      [RFC5246]
+         * 0x00,0x3C  TLS_RSA_WITH_AES_128_CBC_SHA256               [RFC5246]
+         * 0x00,0x3D  TLS_RSA_WITH_AES_256_CBC_SHA256               [RFC5246]
+         * 0x00,0x3E  TLS_DH_DSS_WITH_AES_128_CBC_SHA256            [RFC5246]
+         * 0x00,0x3F  TLS_DH_RSA_WITH_AES_128_CBC_SHA256            [RFC5246]
+         * 0x00,0x40  TLS_DHE_DSS_WITH_AES_128_CBC_SHA256           [RFC5246]
+         * 0x00,0x41  TLS_RSA_WITH_CAMELLIA_128_CBC_SHA             [RFC5932]
+         * 0x00,0x42  TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA          [RFC5932]
+         * 0x00,0x43  TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA          [RFC5932]
+         * 0x00,0x44  TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA         [RFC5932]
+         * 0x00,0x45  TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA         [RFC5932]
+         * 0x00,0x46  TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA         [RFC5932]
          * 0x00,0x47-4F Reserved to avoid conflicts with
          *            deployed implementations                  [Pasi_Eronen]
          * 0x00,0x50-58 Reserved to avoid conflicts             [Pasi Eronen]
@@ -852,143 +852,261 @@
          * 0x00,0x5D-5F Unassigned
          * 0x00,0x60-66 Reserved to avoid conflicts with widely
          *            deployed implementations                  [Pasi_Eronen]
-         * 0x00,0x67  TLS_DHE_RSA_WITH_AES_128_CBC_SHA256       [RFC5246]
-         * 0x00,0x68  TLS_DH_DSS_WITH_AES_256_CBC_SHA256        [RFC5246]
-         * 0x00,0x69  TLS_DH_RSA_WITH_AES_256_CBC_SHA256        [RFC5246]
-         * 0x00,0x6A  TLS_DHE_DSS_WITH_AES_256_CBC_SHA256       [RFC5246]
-         * 0x00,0x6B  TLS_DHE_RSA_WITH_AES_256_CBC_SHA256       [RFC5246]
-         * 0x00,0x6C  TLS_DH_anon_WITH_AES_128_CBC_SHA256       [RFC5246]
-         * 0x00,0x6D  TLS_DH_anon_WITH_AES_256_CBC_SHA256       [RFC5246]
+         * 0x00,0x67  TLS_DHE_RSA_WITH_AES_128_CBC_SHA256           [RFC5246]
+         * 0x00,0x68  TLS_DH_DSS_WITH_AES_256_CBC_SHA256            [RFC5246]
+         * 0x00,0x69  TLS_DH_RSA_WITH_AES_256_CBC_SHA256            [RFC5246]
+         * 0x00,0x6A  TLS_DHE_DSS_WITH_AES_256_CBC_SHA256           [RFC5246]
+         * 0x00,0x6B  TLS_DHE_RSA_WITH_AES_256_CBC_SHA256           [RFC5246]
+         * 0x00,0x6C  TLS_DH_anon_WITH_AES_128_CBC_SHA256           [RFC5246]
+         * 0x00,0x6D  TLS_DH_anon_WITH_AES_256_CBC_SHA256           [RFC5246]
          * 0x00,0x6E-83 Unassigned
-         * 0x00,0x84  TLS_RSA_WITH_CAMELLIA_256_CBC_SHA         [RFC5932]
-         * 0x00,0x85  TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA      [RFC5932]
-         * 0x00,0x86  TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA      [RFC5932]
-         * 0x00,0x87  TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA     [RFC5932]
-         * 0x00,0x88  TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA     [RFC5932]
-         * 0x00,0x89  TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA     [RFC5932]
-         * 0x00,0x8A  TLS_PSK_WITH_RC4_128_SHA                  [RFC4279]
-         * 0x00,0x8B  TLS_PSK_WITH_3DES_EDE_CBC_SHA             [RFC4279]
-         * 0x00,0x8C  TLS_PSK_WITH_AES_128_CBC_SHA              [RFC4279]
-         * 0x00,0x8D  TLS_PSK_WITH_AES_256_CBC_SHA              [RFC4279]
-         * 0x00,0x8E  TLS_DHE_PSK_WITH_RC4_128_SHA              [RFC4279]
-         * 0x00,0x8F  TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA         [RFC4279]
-         * 0x00,0x90  TLS_DHE_PSK_WITH_AES_128_CBC_SHA          [RFC4279]
-         * 0x00,0x91  TLS_DHE_PSK_WITH_AES_256_CBC_SHA          [RFC4279]
-         * 0x00,0x92  TLS_RSA_PSK_WITH_RC4_128_SHA              [RFC4279]
-         * 0x00,0x93  TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA         [RFC4279]
-         * 0x00,0x94  TLS_RSA_PSK_WITH_AES_128_CBC_SHA          [RFC4279]
-         * 0x00,0x95  TLS_RSA_PSK_WITH_AES_256_CBC_SHA          [RFC4279]
-         * 0x00,0x96  TLS_RSA_WITH_SEED_CBC_SHA                 [RFC4162]
-         * 0x00,0x97  TLS_DH_DSS_WITH_SEED_CBC_SHA              [RFC4162]
-         * 0x00,0x98  TLS_DH_RSA_WITH_SEED_CBC_SHA              [RFC4162]
-         * 0x00,0x99  TLS_DHE_DSS_WITH_SEED_CBC_SHA             [RFC4162]
-         * 0x00,0x9A  TLS_DHE_RSA_WITH_SEED_CBC_SHA             [RFC4162]
-         * 0x00,0x9B  TLS_DH_anon_WITH_SEED_CBC_SHA             [RFC4162]
-         * 0x00,0x9C  TLS_RSA_WITH_AES_128_GCM_SHA256           [RFC5288]
-         * 0x00,0x9D  TLS_RSA_WITH_AES_256_GCM_SHA384           [RFC5288]
-         * 0x00,0x9E  TLS_DHE_RSA_WITH_AES_128_GCM_SHA256       [RFC5288]
-         * 0x00,0x9F  TLS_DHE_RSA_WITH_AES_256_GCM_SHA384       [RFC5288]
-         * 0x00,0xA0  TLS_DH_RSA_WITH_AES_128_GCM_SHA256        [RFC5288]
-         * 0x00,0xA1  TLS_DH_RSA_WITH_AES_256_GCM_SHA384        [RFC5288]
-         * 0x00,0xA2  TLS_DHE_DSS_WITH_AES_128_GCM_SHA256       [RFC5288]
-         * 0x00,0xA3  TLS_DHE_DSS_WITH_AES_256_GCM_SHA384       [RFC5288]
-         * 0x00,0xA4  TLS_DH_DSS_WITH_AES_128_GCM_SHA256        [RFC5288]
-         * 0x00,0xA5  TLS_DH_DSS_WITH_AES_256_GCM_SHA384        [RFC5288]
-         * 0x00,0xA6  TLS_DH_anon_WITH_AES_128_GCM_SHA256       [RFC5288]
-         * 0x00,0xA7  TLS_DH_anon_WITH_AES_256_GCM_SHA384       [RFC5288]
-         * 0x00,0xA8  TLS_PSK_WITH_AES_128_GCM_SHA256           [RFC5487]
-         * 0x00,0xA9  TLS_PSK_WITH_AES_256_GCM_SHA384           [RFC5487]
-         * 0x00,0xAA  TLS_DHE_PSK_WITH_AES_128_GCM_SHA256       [RFC5487]
-         * 0x00,0xAB  TLS_DHE_PSK_WITH_AES_256_GCM_SHA384       [RFC5487]
-         * 0x00,0xAC  TLS_RSA_PSK_WITH_AES_128_GCM_SHA256       [RFC5487]
-         * 0x00,0xAD  TLS_RSA_PSK_WITH_AES_256_GCM_SHA384       [RFC5487]
-         * 0x00,0xAE  TLS_PSK_WITH_AES_128_CBC_SHA256           [RFC5487]
-         * 0x00,0xAF  TLS_PSK_WITH_AES_256_CBC_SHA384           [RFC5487]
-         * 0x00,0xB0  TLS_PSK_WITH_NULL_SHA256                  [RFC5487]
-         * 0x00,0xB1  TLS_PSK_WITH_NULL_SHA384                  [RFC5487]
-         * 0x00,0xB2  TLS_DHE_PSK_WITH_AES_128_CBC_SHA256       [RFC5487]
-         * 0x00,0xB3  TLS_DHE_PSK_WITH_AES_256_CBC_SHA384       [RFC5487]
-         * 0x00,0xB4  TLS_DHE_PSK_WITH_NULL_SHA256              [RFC5487]
-         * 0x00,0xB5  TLS_DHE_PSK_WITH_NULL_SHA384              [RFC5487]
-         * 0x00,0xB6  TLS_RSA_PSK_WITH_AES_128_CBC_SHA256       [RFC5487]
-         * 0x00,0xB7  TLS_RSA_PSK_WITH_AES_256_CBC_SHA384       [RFC5487]
-         * 0x00,0xB8  TLS_RSA_PSK_WITH_NULL_SHA256              [RFC5487]
-         * 0x00,0xB9  TLS_RSA_PSK_WITH_NULL_SHA384              [RFC5487]
-         * 0x00,0xBA  TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256      [RFC5932]
-         * 0x00,0xBB  TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256   [RFC5932]
-         * 0x00,0xBC  TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256   [RFC5932]
-         * 0x00,0xBD  TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256  [RFC5932]
-         * 0x00,0xBE  TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256  [RFC5932]
-         * 0x00,0xBF  TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256  [RFC5932]
-         * 0x00,0xC0  TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256      [RFC5932]
-         * 0x00,0xC1  TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256   [RFC5932]
-         * 0x00,0xC2  TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256   [RFC5932]
-         * 0x00,0xC3  TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256  [RFC5932]
-         * 0x00,0xC4  TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256  [RFC5932]
-         * 0x00,0xC5  TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256  [RFC5932]
+         * 0x00,0x84  TLS_RSA_WITH_CAMELLIA_256_CBC_SHA             [RFC5932]
+         * 0x00,0x85  TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA          [RFC5932]
+         * 0x00,0x86  TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA          [RFC5932]
+         * 0x00,0x87  TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA         [RFC5932]
+         * 0x00,0x88  TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA         [RFC5932]
+         * 0x00,0x89  TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA         [RFC5932]
+         * 0x00,0x8A  TLS_PSK_WITH_RC4_128_SHA                      [RFC4279]
+         * 0x00,0x8B  TLS_PSK_WITH_3DES_EDE_CBC_SHA                 [RFC4279]
+         * 0x00,0x8C  TLS_PSK_WITH_AES_128_CBC_SHA                  [RFC4279]
+         * 0x00,0x8D  TLS_PSK_WITH_AES_256_CBC_SHA                  [RFC4279]
+         * 0x00,0x8E  TLS_DHE_PSK_WITH_RC4_128_SHA                  [RFC4279]
+         * 0x00,0x8F  TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA             [RFC4279]
+         * 0x00,0x90  TLS_DHE_PSK_WITH_AES_128_CBC_SHA              [RFC4279]
+         * 0x00,0x91  TLS_DHE_PSK_WITH_AES_256_CBC_SHA              [RFC4279]
+         * 0x00,0x92  TLS_RSA_PSK_WITH_RC4_128_SHA                  [RFC4279]
+         * 0x00,0x93  TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA             [RFC4279]
+         * 0x00,0x94  TLS_RSA_PSK_WITH_AES_128_CBC_SHA              [RFC4279]
+         * 0x00,0x95  TLS_RSA_PSK_WITH_AES_256_CBC_SHA              [RFC4279]
+         * 0x00,0x96  TLS_RSA_WITH_SEED_CBC_SHA                     [RFC4162]
+         * 0x00,0x97  TLS_DH_DSS_WITH_SEED_CBC_SHA                  [RFC4162]
+         * 0x00,0x98  TLS_DH_RSA_WITH_SEED_CBC_SHA                  [RFC4162]
+         * 0x00,0x99  TLS_DHE_DSS_WITH_SEED_CBC_SHA                 [RFC4162]
+         * 0x00,0x9A  TLS_DHE_RSA_WITH_SEED_CBC_SHA                 [RFC4162]
+         * 0x00,0x9B  TLS_DH_anon_WITH_SEED_CBC_SHA                 [RFC4162]
+         * 0x00,0x9C  TLS_RSA_WITH_AES_128_GCM_SHA256               [RFC5288]
+         * 0x00,0x9D  TLS_RSA_WITH_AES_256_GCM_SHA384               [RFC5288]
+         * 0x00,0x9E  TLS_DHE_RSA_WITH_AES_128_GCM_SHA256           [RFC5288]
+         * 0x00,0x9F  TLS_DHE_RSA_WITH_AES_256_GCM_SHA384           [RFC5288]
+         * 0x00,0xA0  TLS_DH_RSA_WITH_AES_128_GCM_SHA256            [RFC5288]
+         * 0x00,0xA1  TLS_DH_RSA_WITH_AES_256_GCM_SHA384            [RFC5288]
+         * 0x00,0xA2  TLS_DHE_DSS_WITH_AES_128_GCM_SHA256           [RFC5288]
+         * 0x00,0xA3  TLS_DHE_DSS_WITH_AES_256_GCM_SHA384           [RFC5288]
+         * 0x00,0xA4  TLS_DH_DSS_WITH_AES_128_GCM_SHA256            [RFC5288]
+         * 0x00,0xA5  TLS_DH_DSS_WITH_AES_256_GCM_SHA384            [RFC5288]
+         * 0x00,0xA6  TLS_DH_anon_WITH_AES_128_GCM_SHA256           [RFC5288]
+         * 0x00,0xA7  TLS_DH_anon_WITH_AES_256_GCM_SHA384           [RFC5288]
+         * 0x00,0xA8  TLS_PSK_WITH_AES_128_GCM_SHA256               [RFC5487]
+         * 0x00,0xA9  TLS_PSK_WITH_AES_256_GCM_SHA384               [RFC5487]
+         * 0x00,0xAA  TLS_DHE_PSK_WITH_AES_128_GCM_SHA256           [RFC5487]
+         * 0x00,0xAB  TLS_DHE_PSK_WITH_AES_256_GCM_SHA384           [RFC5487]
+         * 0x00,0xAC  TLS_RSA_PSK_WITH_AES_128_GCM_SHA256           [RFC5487]
+         * 0x00,0xAD  TLS_RSA_PSK_WITH_AES_256_GCM_SHA384           [RFC5487]
+         * 0x00,0xAE  TLS_PSK_WITH_AES_128_CBC_SHA256               [RFC5487]
+         * 0x00,0xAF  TLS_PSK_WITH_AES_256_CBC_SHA384               [RFC5487]
+         * 0x00,0xB0  TLS_PSK_WITH_NULL_SHA256                      [RFC5487]
+         * 0x00,0xB1  TLS_PSK_WITH_NULL_SHA384                      [RFC5487]
+         * 0x00,0xB2  TLS_DHE_PSK_WITH_AES_128_CBC_SHA256           [RFC5487]
+         * 0x00,0xB3  TLS_DHE_PSK_WITH_AES_256_CBC_SHA384           [RFC5487]
+         * 0x00,0xB4  TLS_DHE_PSK_WITH_NULL_SHA256                  [RFC5487]
+         * 0x00,0xB5  TLS_DHE_PSK_WITH_NULL_SHA384                  [RFC5487]
+         * 0x00,0xB6  TLS_RSA_PSK_WITH_AES_128_CBC_SHA256           [RFC5487]
+         * 0x00,0xB7  TLS_RSA_PSK_WITH_AES_256_CBC_SHA384           [RFC5487]
+         * 0x00,0xB8  TLS_RSA_PSK_WITH_NULL_SHA256                  [RFC5487]
+         * 0x00,0xB9  TLS_RSA_PSK_WITH_NULL_SHA384                  [RFC5487]
+         * 0x00,0xBA  TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256          [RFC5932]
+         * 0x00,0xBB  TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256       [RFC5932]
+         * 0x00,0xBC  TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256       [RFC5932]
+         * 0x00,0xBD  TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256      [RFC5932]
+         * 0x00,0xBE  TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256      [RFC5932]
+         * 0x00,0xBF  TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256      [RFC5932]
+         * 0x00,0xC0  TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256          [RFC5932]
+         * 0x00,0xC1  TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256       [RFC5932]
+         * 0x00,0xC2  TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256       [RFC5932]
+         * 0x00,0xC3  TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256      [RFC5932]
+         * 0x00,0xC4  TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256      [RFC5932]
+         * 0x00,0xC5  TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256      [RFC5932]
          * 0x00,0xC6-FE         Unassigned
-         * 0x00,0xFF  TLS_EMPTY_RENEGOTIATION_INFO_SCSV         [RFC5746]
-         * 0x01-BF,*  Unassigned
-         * 0xC0,0x01  TLS_ECDH_ECDSA_WITH_NULL_SHA              [RFC4492]
-         * 0xC0,0x02  TLS_ECDH_ECDSA_WITH_RC4_128_SHA           [RFC4492]
-         * 0xC0,0x03  TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA      [RFC4492]
-         * 0xC0,0x04  TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA       [RFC4492]
-         * 0xC0,0x05  TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA       [RFC4492]
-         * 0xC0,0x06  TLS_ECDHE_ECDSA_WITH_NULL_SHA             [RFC4492]
-         * 0xC0,0x07  TLS_ECDHE_ECDSA_WITH_RC4_128_SHA          [RFC4492]
-         * 0xC0,0x08  TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA     [RFC4492]
-         * 0xC0,0x09  TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA      [RFC4492]
-         * 0xC0,0x0A  TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA      [RFC4492]
-         * 0xC0,0x0B  TLS_ECDH_RSA_WITH_NULL_SHA                [RFC4492]
-         * 0xC0,0x0C  TLS_ECDH_RSA_WITH_RC4_128_SHA             [RFC4492]
-         * 0xC0,0x0D  TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA        [RFC4492]
-         * 0xC0,0x0E  TLS_ECDH_RSA_WITH_AES_128_CBC_SHA         [RFC4492]
-         * 0xC0,0x0F  TLS_ECDH_RSA_WITH_AES_256_CBC_SHA         [RFC4492]
-         * 0xC0,0x10  TLS_ECDHE_RSA_WITH_NULL_SHA               [RFC4492]
-         * 0xC0,0x11  TLS_ECDHE_RSA_WITH_RC4_128_SHA            [RFC4492]
-         * 0xC0,0x12  TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA       [RFC4492]
-         * 0xC0,0x13  TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA        [RFC4492]
-         * 0xC0,0x14  TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA        [RFC4492]
-         * 0xC0,0x15  TLS_ECDH_anon_WITH_NULL_SHA               [RFC4492]
-         * 0xC0,0x16  TLS_ECDH_anon_WITH_RC4_128_SHA            [RFC4492]
-         * 0xC0,0x17  TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA       [RFC4492]
-         * 0xC0,0x18  TLS_ECDH_anon_WITH_AES_128_CBC_SHA        [RFC4492]
-         * 0xC0,0x19  TLS_ECDH_anon_WITH_AES_256_CBC_SHA        [RFC4492]
-         * 0xC0,0x1A  TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA         [RFC5054]
-         * 0xC0,0x1B  TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA     [RFC5054]
-         * 0xC0,0x1C  TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA     [RFC5054]
-         * 0xC0,0x1D  TLS_SRP_SHA_WITH_AES_128_CBC_SHA          [RFC5054]
-         * 0xC0,0x1E  TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA      [RFC5054]
-         * 0xC0,0x1F  TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA      [RFC5054]
-         * 0xC0,0x20  TLS_SRP_SHA_WITH_AES_256_CBC_SHA          [RFC5054]
-         * 0xC0,0x21  TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA      [RFC5054]
-         * 0xC0,0x22  TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA      [RFC5054]
-         * 0xC0,0x23  TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256   [RFC5289]
-         * 0xC0,0x24  TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384   [RFC5289]
-         * 0xC0,0x25  TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256    [RFC5289]
-         * 0xC0,0x26  TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384    [RFC5289]
-         * 0xC0,0x27  TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256     [RFC5289]
-         * 0xC0,0x28  TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384     [RFC5289]
-         * 0xC0,0x29  TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256      [RFC5289]
-         * 0xC0,0x2A  TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384      [RFC5289]
-         * 0xC0,0x2B  TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256   [RFC5289]
-         * 0xC0,0x2C  TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384   [RFC5289]
-         * 0xC0,0x2D  TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256    [RFC5289]
-         * 0xC0,0x2E  TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384    [RFC5289]
-         * 0xC0,0x2F  TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256     [RFC5289]
-         * 0xC0,0x30  TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384     [RFC5289]
-         * 0xC0,0x31  TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256      [RFC5289]
-         * 0xC0,0x32  TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384      [RFC5289]
-         * 0xC0,0x33  TLS_ECDHE_PSK_WITH_RC4_128_SHA            [RFC5489]
-         * 0xC0,0x34  TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA       [RFC5489]
-         * 0xC0,0x35  TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA        [RFC5489]
-         * 0xC0,0x36  TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA        [RFC5489]
-         * 0xC0,0x37  TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256     [RFC5489]
-         * 0xC0,0x38  TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384     [RFC5489]
-         * 0xC0,0x39  TLS_ECDHE_PSK_WITH_NULL_SHA               [RFC5489]
-         * 0xC0,0x3A  TLS_ECDHE_PSK_WITH_NULL_SHA256            [RFC5489]
-         * 0xC0,0x3B  TLS_ECDHE_PSK_WITH_NULL_SHA384            [RFC5489]
-         * 0xC0,0x3C-FF Unassigned
+         * 0x00,0xFF  TLS_EMPTY_RENEGOTIATION_INFO_SCSV             [RFC5746]
+         * 0x01-55,*  Unassigned
+         * 0x56,0x00  TLS_FALLBACK_SCSV                             [RFC7507]
+         * 0x56,0x01-0xC0,0x00  Unassigned
+         * 0xC0,0x01  TLS_ECDH_ECDSA_WITH_NULL_SHA                  [RFC4492]
+         * 0xC0,0x02  TLS_ECDH_ECDSA_WITH_RC4_128_SHA               [RFC4492]
+         * 0xC0,0x03  TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA          [RFC4492]
+         * 0xC0,0x04  TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA           [RFC4492]
+         * 0xC0,0x05  TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA           [RFC4492]
+         * 0xC0,0x06  TLS_ECDHE_ECDSA_WITH_NULL_SHA                 [RFC4492]
+         * 0xC0,0x07  TLS_ECDHE_ECDSA_WITH_RC4_128_SHA              [RFC4492]
+         * 0xC0,0x08  TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA         [RFC4492]
+         * 0xC0,0x09  TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA          [RFC4492]
+         * 0xC0,0x0A  TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA          [RFC4492]
+         * 0xC0,0x0B  TLS_ECDH_RSA_WITH_NULL_SHA                    [RFC4492]
+         * 0xC0,0x0C  TLS_ECDH_RSA_WITH_RC4_128_SHA                 [RFC4492]
+         * 0xC0,0x0D  TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA            [RFC4492]
+         * 0xC0,0x0E  TLS_ECDH_RSA_WITH_AES_128_CBC_SHA             [RFC4492]
+         * 0xC0,0x0F  TLS_ECDH_RSA_WITH_AES_256_CBC_SHA             [RFC4492]
+         * 0xC0,0x10  TLS_ECDHE_RSA_WITH_NULL_SHA                   [RFC4492]
+         * 0xC0,0x11  TLS_ECDHE_RSA_WITH_RC4_128_SHA                [RFC4492]
+         * 0xC0,0x12  TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA           [RFC4492]
+         * 0xC0,0x13  TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA            [RFC4492]
+         * 0xC0,0x14  TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA            [RFC4492]
+         * 0xC0,0x15  TLS_ECDH_anon_WITH_NULL_SHA                   [RFC4492]
+         * 0xC0,0x16  TLS_ECDH_anon_WITH_RC4_128_SHA                [RFC4492]
+         * 0xC0,0x17  TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA           [RFC4492]
+         * 0xC0,0x18  TLS_ECDH_anon_WITH_AES_128_CBC_SHA            [RFC4492]
+         * 0xC0,0x19  TLS_ECDH_anon_WITH_AES_256_CBC_SHA            [RFC4492]
+         * 0xC0,0x1A  TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA             [RFC5054]
+         * 0xC0,0x1B  TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA         [RFC5054]
+         * 0xC0,0x1C  TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA         [RFC5054]
+         * 0xC0,0x1D  TLS_SRP_SHA_WITH_AES_128_CBC_SHA              [RFC5054]
+         * 0xC0,0x1E  TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA          [RFC5054]
+         * 0xC0,0x1F  TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA          [RFC5054]
+         * 0xC0,0x20  TLS_SRP_SHA_WITH_AES_256_CBC_SHA              [RFC5054]
+         * 0xC0,0x21  TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA          [RFC5054]
+         * 0xC0,0x22  TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA          [RFC5054]
+         * 0xC0,0x23  TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256       [RFC5289]
+         * 0xC0,0x24  TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384       [RFC5289]
+         * 0xC0,0x25  TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256        [RFC5289]
+         * 0xC0,0x26  TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384        [RFC5289]
+         * 0xC0,0x27  TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256         [RFC5289]
+         * 0xC0,0x28  TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384         [RFC5289]
+         * 0xC0,0x29  TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256          [RFC5289]
+         * 0xC0,0x2A  TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384          [RFC5289]
+         * 0xC0,0x2B  TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256       [RFC5289]
+         * 0xC0,0x2C  TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384       [RFC5289]
+         * 0xC0,0x2D  TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256        [RFC5289]
+         * 0xC0,0x2E  TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384        [RFC5289]
+         * 0xC0,0x2F  TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256         [RFC5289]
+         * 0xC0,0x30  TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384         [RFC5289]
+         * 0xC0,0x31  TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256          [RFC5289]
+         * 0xC0,0x32  TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384          [RFC5289]
+         * 0xC0,0x33  TLS_ECDHE_PSK_WITH_RC4_128_SHA                [RFC5489]
+         * 0xC0,0x34  TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA           [RFC5489]
+         * 0xC0,0x35  TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA            [RFC5489]
+         * 0xC0,0x36  TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA            [RFC5489]
+         * 0xC0,0x37  TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256         [RFC5489]
+         * 0xC0,0x38  TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384         [RFC5489]
+         * 0xC0,0x39  TLS_ECDHE_PSK_WITH_NULL_SHA                   [RFC5489]
+         * 0xC0,0x3A  TLS_ECDHE_PSK_WITH_NULL_SHA256                [RFC5489]
+         * 0xC0,0x3B  TLS_ECDHE_PSK_WITH_NULL_SHA384                [RFC5489]
+         * 0xC0,0x3C  TLS_RSA_WITH_ARIA_128_CBC_SHA256              [RFC6209]
+         * 0xC0,0x3D  TLS_RSA_WITH_ARIA_256_CBC_SHA384              [RFC6209]
+         * 0xC0,0x3E  TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256           [RFC6209]
+         * 0xC0,0x3F  TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384           [RFC6209]
+         * 0xC0,0x40  TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256           [RFC6209]
+         * 0xC0,0x41  TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384           [RFC6209]
+         * 0xC0,0x42  TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256          [RFC6209]
+         * 0xC0,0x43  TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384          [RFC6209]
+         * 0xC0,0x44  TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256          [RFC6209]
+         * 0xC0,0x45  TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384          [RFC6209]
+         * 0xC0,0x46  TLS_DH_anon_WITH_ARIA_128_CBC_SHA256          [RFC6209]
+         * 0xC0,0x47  TLS_DH_anon_WITH_ARIA_256_CBC_SHA384          [RFC6209]
+         * 0xC0,0x48  TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256      [RFC6209]
+         * 0xC0,0x49  TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384      [RFC6209]
+         * 0xC0,0x4A  TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256       [RFC6209]
+         * 0xC0,0x4B  TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384       [RFC6209]
+         * 0xC0,0x4C  TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256        [RFC6209]
+         * 0xC0,0x4D  TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384        [RFC6209]
+         * 0xC0,0x4E  TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256         [RFC6209]
+         * 0xC0,0x4F  TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384         [RFC6209]
+         * 0xC0,0x50  TLS_RSA_WITH_ARIA_128_GCM_SHA256              [RFC6209]
+         * 0xC0,0x51  TLS_RSA_WITH_ARIA_256_GCM_SHA384              [RFC6209]
+         * 0xC0,0x52  TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256          [RFC6209]
+         * 0xC0,0x53  TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384          [RFC6209]
+         * 0xC0,0x54  TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256           [RFC6209]
+         * 0xC0,0x55  TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384           [RFC6209]
+         * 0xC0,0x56  TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256          [RFC6209]
+         * 0xC0,0x57  TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384          [RFC6209]
+         * 0xC0,0x58  TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256           [RFC6209]
+         * 0xC0,0x59  TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384           [RFC6209]
+         * 0xC0,0x5A  TLS_DH_anon_WITH_ARIA_128_GCM_SHA256          [RFC6209]
+         * 0xC0,0x5B  TLS_DH_anon_WITH_ARIA_256_GCM_SHA384          [RFC6209]
+         * 0xC0,0x5C  TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256      [RFC6209]
+         * 0xC0,0x5D  TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384      [RFC6209]
+         * 0xC0,0x5E  TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256       [RFC6209]
+         * 0xC0,0x5F  TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384       [RFC6209]
+         * 0xC0,0x60  TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256        [RFC6209]
+         * 0xC0,0x61  TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384        [RFC6209]
+         * 0xC0,0x62  TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256         [RFC6209]
+         * 0xC0,0x63  TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384         [RFC6209]
+         * 0xC0,0x64  TLS_PSK_WITH_ARIA_128_CBC_SHA256              [RFC6209]
+         * 0xC0,0x65  TLS_PSK_WITH_ARIA_256_CBC_SHA384              [RFC6209]
+         * 0xC0,0x66  TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256          [RFC6209]
+         * 0xC0,0x67  TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384          [RFC6209]
+         * 0xC0,0x68  TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256          [RFC6209]
+         * 0xC0,0x69  TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384          [RFC6209]
+         * 0xC0,0x6A  TLS_PSK_WITH_ARIA_128_GCM_SHA256              [RFC6209]
+         * 0xC0,0x6B  TLS_PSK_WITH_ARIA_256_GCM_SHA384              [RFC6209]
+         * 0xC0,0x6C  TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256          [RFC6209]
+         * 0xC0,0x6D  TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384          [RFC6209]
+         * 0xC0,0x6E  TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256          [RFC6209]
+         * 0xC0,0x6F  TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384          [RFC6209]
+         * 0xC0,0x70  TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256        [RFC6209]
+         * 0xC0,0x71  TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384        [RFC6209]
+         * 0xC0,0x72  TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256  [RFC6367]
+         * 0xC0,0x73  TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384  [RFC6367]
+         * 0xC0,0x74  TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256   [RFC6367]
+         * 0xC0,0x75  TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384   [RFC6367]
+         * 0xC0,0x76  TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256    [RFC6367]
+         * 0xC0,0x77  TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384    [RFC6367]
+         * 0xC0,0x78  TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256     [RFC6367]
+         * 0xC0,0x79  TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384     [RFC6367]
+         * 0xC0,0x7A  TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256          [RFC6367]
+         * 0xC0,0x7B  TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384          [RFC6367]
+         * 0xC0,0x7C  TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256      [RFC6367]
+         * 0xC0,0x7D  TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384      [RFC6367]
+         * 0xC0,0x7E  TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256       [RFC6367]
+         * 0xC0,0x7F  TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384       [RFC6367]
+         * 0xC0,0x80  TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256      [RFC6367]
+         * 0xC0,0x81  TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384      [RFC6367]
+         * 0xC0,0x82  TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256       [RFC6367]
+         * 0xC0,0x83  TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384       [RFC6367]
+         * 0xC0,0x84  TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256      [RFC6367]
+         * 0xC0,0x85  TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384      [RFC6367]
+         * 0xC0,0x86  TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256  [RFC6367]
+         * 0xC0,0x87  TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384  [RFC6367]
+         * 0xC0,0x88  TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256   [RFC6367]
+         * 0xC0,0x89  TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384   [RFC6367]
+         * 0xC0,0x8A  TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256    [RFC6367]
+         * 0xC0,0x8B  TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384    [RFC6367]
+         * 0xC0,0x8C  TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256     [RFC6367]
+         * 0xC0,0x8D  TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384     [RFC6367]
+         * 0xC0,0x8E  TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256          [RFC6367]
+         * 0xC0,0x8F  TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384          [RFC6367]
+         * 0xC0,0x90  TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256      [RFC6367]
+         * 0xC0,0x91  TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384      [RFC6367]
+         * 0xC0,0x92  TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256      [RFC6367]
+         * 0xC0,0x93  TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384      [RFC6367]
+         * 0xC0,0x94  TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256          [RFC6367]
+         * 0xC0,0x95  TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384          [RFC6367]
+         * 0xC0,0x96  TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256      [RFC6367]
+         * 0xC0,0x97  TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384      [RFC6367]
+         * 0xC0,0x98  TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256      [RFC6367]
+         * 0xC0,0x99  TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384      [RFC6367]
+         * 0xC0,0x9A  TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256    [RFC6367]
+         * 0xC0,0x9B  TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384    [RFC6367]
+         * 0xC0,0x9C  TLS_RSA_WITH_AES_128_CCM                      [RFC6655]
+         * 0xC0,0x9D  TLS_RSA_WITH_AES_256_CCM                      [RFC6655]
+         * 0xC0,0x9E  TLS_DHE_RSA_WITH_AES_128_CCM                  [RFC6655]
+         * 0xC0,0x9F  TLS_DHE_RSA_WITH_AES_256_CCM                  [RFC6655]
+         * 0xC0,0xA0  TLS_RSA_WITH_AES_128_CCM_8                    [RFC6655]
+         * 0xC0,0xA1  TLS_RSA_WITH_AES_256_CCM_8                    [RFC6655]
+         * 0xC0,0xA2  TLS_DHE_RSA_WITH_AES_128_CCM_8                [RFC6655]
+         * 0xC0,0xA3  TLS_DHE_RSA_WITH_AES_256_CCM_8                [RFC6655]
+         * 0xC0,0xA4  TLS_PSK_WITH_AES_128_CCM                      [RFC6655]
+         * 0xC0,0xA5  TLS_PSK_WITH_AES_256_CCM                      [RFC6655]
+         * 0xC0,0xA6  TLS_DHE_PSK_WITH_AES_128_CCM                  [RFC6655]
+         * 0xC0,0xA7  TLS_DHE_PSK_WITH_AES_256_CCM                  [RFC6655]
+         * 0xC0,0xA8  TLS_PSK_WITH_AES_128_CCM_8                    [RFC6655]
+         * 0xC0,0xA9  TLS_PSK_WITH_AES_256_CCM_8                    [RFC6655]
+         * 0xC0,0xAA  TLS_PSK_DHE_WITH_AES_128_CCM_8                [RFC6655]
+         * 0xC0,0xAB  TLS_PSK_DHE_WITH_AES_256_CCM_8                [RFC6655]
+         * 0xC0,0xAC  TLS_ECDHE_ECDSA_WITH_AES_128_CCM              [RFC7251]
+         * 0xC0,0xAD  TLS_ECDHE_ECDSA_WITH_AES_256_CCM              [RFC7251]
+         * 0xC0,0xAE  TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8            [RFC7251]
+         * 0xC0,0xAF  TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8            [RFC7251]
+         * 0xC0,0xB0-FF  Unassigned
          * 0xC1-FD,*  Unassigned
          * 0xFE,0x00-FD Unassigned
          * 0xFE,0xFE-FF Reserved to avoid conflicts with widely
@@ -1289,149 +1407,276 @@
         // the debug output.
 
         // remaining unsupported ciphersuites defined in RFC2246.
-        add("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5",          0x0006);
-        add("SSL_RSA_WITH_IDEA_CBC_SHA",                   0x0007);
-        add("SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA",        0x000b);
-        add("SSL_DH_DSS_WITH_DES_CBC_SHA",                 0x000c);
-        add("SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA",            0x000d);
-        add("SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA",        0x000e);
-        add("SSL_DH_RSA_WITH_DES_CBC_SHA",                 0x000f);
-        add("SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA",            0x0010);
+        add("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5",           0x0006);
+        add("SSL_RSA_WITH_IDEA_CBC_SHA",                    0x0007);
+        add("SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA",         0x000b);
+        add("SSL_DH_DSS_WITH_DES_CBC_SHA",                  0x000c);
+        add("SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA",             0x000d);
+        add("SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA",         0x000e);
+        add("SSL_DH_RSA_WITH_DES_CBC_SHA",                  0x000f);
+        add("SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA",             0x0010);
 
         // SSL 3.0 Fortezza ciphersuites
-        add("SSL_FORTEZZA_DMS_WITH_NULL_SHA",              0x001c);
-        add("SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA",      0x001d);
+        add("SSL_FORTEZZA_DMS_WITH_NULL_SHA",               0x001c);
+        add("SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA",       0x001d);
 
         // 1024/56 bit exportable ciphersuites from expired internet draft
-        add("SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA",         0x0062);
-        add("SSL_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA",     0x0063);
-        add("SSL_RSA_EXPORT1024_WITH_RC4_56_SHA",          0x0064);
-        add("SSL_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA",      0x0065);
-        add("SSL_DHE_DSS_WITH_RC4_128_SHA",                0x0066);
+        add("SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA",          0x0062);
+        add("SSL_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA",      0x0063);
+        add("SSL_RSA_EXPORT1024_WITH_RC4_56_SHA",           0x0064);
+        add("SSL_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA",       0x0065);
+        add("SSL_DHE_DSS_WITH_RC4_128_SHA",                 0x0066);
 
         // Netscape old and new SSL 3.0 FIPS ciphersuites
         // see http://www.mozilla.org/projects/security/pki/nss/ssl/fips-ssl-ciphersuites.html
-        add("NETSCAPE_RSA_FIPS_WITH_3DES_EDE_CBC_SHA",     0xffe0);
-        add("NETSCAPE_RSA_FIPS_WITH_DES_CBC_SHA",          0xffe1);
-        add("SSL_RSA_FIPS_WITH_DES_CBC_SHA",               0xfefe);
-        add("SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA",          0xfeff);
+        add("NETSCAPE_RSA_FIPS_WITH_3DES_EDE_CBC_SHA",      0xffe0);
+        add("NETSCAPE_RSA_FIPS_WITH_DES_CBC_SHA",           0xffe1);
+        add("SSL_RSA_FIPS_WITH_DES_CBC_SHA",                0xfefe);
+        add("SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA",           0xfeff);
 
         // Unsupported Kerberos cipher suites from RFC 2712
-        add("TLS_KRB5_WITH_IDEA_CBC_SHA",                  0x0021);
-        add("TLS_KRB5_WITH_IDEA_CBC_MD5",                  0x0025);
-        add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA",         0x0027);
-        add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5",         0x002a);
+        add("TLS_KRB5_WITH_IDEA_CBC_SHA",                   0x0021);
+        add("TLS_KRB5_WITH_IDEA_CBC_MD5",                   0x0025);
+        add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA",          0x0027);
+        add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5",          0x002a);
 
         // Unsupported cipher suites from RFC 4162
-        add("TLS_RSA_WITH_SEED_CBC_SHA",                   0x0096);
-        add("TLS_DH_DSS_WITH_SEED_CBC_SHA",                0x0097);
-        add("TLS_DH_RSA_WITH_SEED_CBC_SHA",                0x0098);
-        add("TLS_DHE_DSS_WITH_SEED_CBC_SHA",               0x0099);
-        add("TLS_DHE_RSA_WITH_SEED_CBC_SHA",               0x009a);
-        add("TLS_DH_anon_WITH_SEED_CBC_SHA",               0x009b);
+        add("TLS_RSA_WITH_SEED_CBC_SHA",                    0x0096);
+        add("TLS_DH_DSS_WITH_SEED_CBC_SHA",                 0x0097);
+        add("TLS_DH_RSA_WITH_SEED_CBC_SHA",                 0x0098);
+        add("TLS_DHE_DSS_WITH_SEED_CBC_SHA",                0x0099);
+        add("TLS_DHE_RSA_WITH_SEED_CBC_SHA",                0x009a);
+        add("TLS_DH_anon_WITH_SEED_CBC_SHA",                0x009b);
 
         // Unsupported cipher suites from RFC 4279
-        add("TLS_PSK_WITH_RC4_128_SHA",                    0x008a);
-        add("TLS_PSK_WITH_3DES_EDE_CBC_SHA",               0x008b);
-        add("TLS_PSK_WITH_AES_128_CBC_SHA",                0x008c);
-        add("TLS_PSK_WITH_AES_256_CBC_SHA",                0x008d);
-        add("TLS_DHE_PSK_WITH_RC4_128_SHA",                0x008e);
-        add("TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA",           0x008f);
-        add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA",            0x0090);
-        add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA",            0x0091);
-        add("TLS_RSA_PSK_WITH_RC4_128_SHA",                0x0092);
-        add("TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA",           0x0093);
-        add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA",            0x0094);
-        add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA",            0x0095);
+        add("TLS_PSK_WITH_RC4_128_SHA",                     0x008a);
+        add("TLS_PSK_WITH_3DES_EDE_CBC_SHA",                0x008b);
+        add("TLS_PSK_WITH_AES_128_CBC_SHA",                 0x008c);
+        add("TLS_PSK_WITH_AES_256_CBC_SHA",                 0x008d);
+        add("TLS_DHE_PSK_WITH_RC4_128_SHA",                 0x008e);
+        add("TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA",            0x008f);
+        add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA",             0x0090);
+        add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA",             0x0091);
+        add("TLS_RSA_PSK_WITH_RC4_128_SHA",                 0x0092);
+        add("TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA",            0x0093);
+        add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA",             0x0094);
+        add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA",             0x0095);
 
         // Unsupported cipher suites from RFC 4785
-        add("TLS_PSK_WITH_NULL_SHA",                       0x002c);
-        add("TLS_DHE_PSK_WITH_NULL_SHA",                   0x002d);
-        add("TLS_RSA_PSK_WITH_NULL_SHA",                   0x002e);
+        add("TLS_PSK_WITH_NULL_SHA",                        0x002c);
+        add("TLS_DHE_PSK_WITH_NULL_SHA",                    0x002d);
+        add("TLS_RSA_PSK_WITH_NULL_SHA",                    0x002e);
 
         // Unsupported cipher suites from RFC 5246
-        add("TLS_DH_DSS_WITH_AES_128_CBC_SHA",             0x0030);
-        add("TLS_DH_RSA_WITH_AES_128_CBC_SHA",             0x0031);
-        add("TLS_DH_DSS_WITH_AES_256_CBC_SHA",             0x0036);
-        add("TLS_DH_RSA_WITH_AES_256_CBC_SHA",             0x0037);
-        add("TLS_DH_DSS_WITH_AES_128_CBC_SHA256",          0x003e);
-        add("TLS_DH_RSA_WITH_AES_128_CBC_SHA256",          0x003f);
-        add("TLS_DH_DSS_WITH_AES_256_CBC_SHA256",          0x0068);
-        add("TLS_DH_RSA_WITH_AES_256_CBC_SHA256",          0x0069);
+        add("TLS_DH_DSS_WITH_AES_128_CBC_SHA",              0x0030);
+        add("TLS_DH_RSA_WITH_AES_128_CBC_SHA",              0x0031);
+        add("TLS_DH_DSS_WITH_AES_256_CBC_SHA",              0x0036);
+        add("TLS_DH_RSA_WITH_AES_256_CBC_SHA",              0x0037);
+        add("TLS_DH_DSS_WITH_AES_128_CBC_SHA256",           0x003e);
+        add("TLS_DH_RSA_WITH_AES_128_CBC_SHA256",           0x003f);
+        add("TLS_DH_DSS_WITH_AES_256_CBC_SHA256",           0x0068);
+        add("TLS_DH_RSA_WITH_AES_256_CBC_SHA256",           0x0069);
 
         // Unsupported cipher suites from RFC 5288
-        add("TLS_DH_RSA_WITH_AES_128_GCM_SHA256",          0x00a0);
-        add("TLS_DH_RSA_WITH_AES_256_GCM_SHA384",          0x00a1);
-        add("TLS_DH_DSS_WITH_AES_128_GCM_SHA256",          0x00a4);
-        add("TLS_DH_DSS_WITH_AES_256_GCM_SHA384",          0x00a5);
+        add("TLS_DH_RSA_WITH_AES_128_GCM_SHA256",           0x00a0);
+        add("TLS_DH_RSA_WITH_AES_256_GCM_SHA384",           0x00a1);
+        add("TLS_DH_DSS_WITH_AES_128_GCM_SHA256",           0x00a4);
+        add("TLS_DH_DSS_WITH_AES_256_GCM_SHA384",           0x00a5);
 
         // Unsupported cipher suites from RFC 5487
-        add("TLS_PSK_WITH_AES_128_GCM_SHA256",             0x00a8);
-        add("TLS_PSK_WITH_AES_256_GCM_SHA384",             0x00a9);
-        add("TLS_DHE_PSK_WITH_AES_128_GCM_SHA256",         0x00aa);
-        add("TLS_DHE_PSK_WITH_AES_256_GCM_SHA384",         0x00ab);
-        add("TLS_RSA_PSK_WITH_AES_128_GCM_SHA256",         0x00ac);
-        add("TLS_RSA_PSK_WITH_AES_256_GCM_SHA384",         0x00ad);
-        add("TLS_PSK_WITH_AES_128_CBC_SHA256",             0x00ae);
-        add("TLS_PSK_WITH_AES_256_CBC_SHA384",             0x00af);
-        add("TLS_PSK_WITH_NULL_SHA256",                    0x00b0);
-        add("TLS_PSK_WITH_NULL_SHA384",                    0x00b1);
-        add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA256",         0x00b2);
-        add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA384",         0x00b3);
-        add("TLS_DHE_PSK_WITH_NULL_SHA256",                0x00b4);
-        add("TLS_DHE_PSK_WITH_NULL_SHA384",                0x00b5);
-        add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA256",         0x00b6);
-        add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA384",         0x00b7);
-        add("TLS_RSA_PSK_WITH_NULL_SHA256",                0x00b8);
-        add("TLS_RSA_PSK_WITH_NULL_SHA384",                0x00b9);
+        add("TLS_PSK_WITH_AES_128_GCM_SHA256",              0x00a8);
+        add("TLS_PSK_WITH_AES_256_GCM_SHA384",              0x00a9);
+        add("TLS_DHE_PSK_WITH_AES_128_GCM_SHA256",          0x00aa);
+        add("TLS_DHE_PSK_WITH_AES_256_GCM_SHA384",          0x00ab);
+        add("TLS_RSA_PSK_WITH_AES_128_GCM_SHA256",          0x00ac);
+        add("TLS_RSA_PSK_WITH_AES_256_GCM_SHA384",          0x00ad);
+        add("TLS_PSK_WITH_AES_128_CBC_SHA256",              0x00ae);
+        add("TLS_PSK_WITH_AES_256_CBC_SHA384",              0x00af);
+        add("TLS_PSK_WITH_NULL_SHA256",                     0x00b0);
+        add("TLS_PSK_WITH_NULL_SHA384",                     0x00b1);
+        add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA256",          0x00b2);
+        add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA384",          0x00b3);
+        add("TLS_DHE_PSK_WITH_NULL_SHA256",                 0x00b4);
+        add("TLS_DHE_PSK_WITH_NULL_SHA384",                 0x00b5);
+        add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA256",          0x00b6);
+        add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA384",          0x00b7);
+        add("TLS_RSA_PSK_WITH_NULL_SHA256",                 0x00b8);
+        add("TLS_RSA_PSK_WITH_NULL_SHA384",                 0x00b9);
 
         // Unsupported cipher suites from RFC 5932
-        add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA",           0x0041);
-        add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA",        0x0042);
-        add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA",        0x0043);
-        add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA",       0x0044);
-        add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA",       0x0045);
-        add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA",       0x0046);
-        add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA",           0x0084);
-        add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA",        0x0085);
-        add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA",        0x0086);
-        add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA",       0x0087);
-        add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA",       0x0088);
-        add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA",       0x0089);
-        add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256",        0x00ba);
-        add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256",     0x00bb);
-        add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256",     0x00bc);
-        add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256",    0x00bd);
-        add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256",    0x00be);
-        add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256",    0x00bf);
-        add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256",        0x00c0);
-        add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256",     0x00c1);
-        add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256",     0x00c2);
-        add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256",    0x00c3);
-        add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256",    0x00c4);
-        add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256",    0x00c5);
+        add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA",            0x0041);
+        add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA",         0x0042);
+        add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA",         0x0043);
+        add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA",        0x0044);
+        add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA",        0x0045);
+        add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA",        0x0046);
+        add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA",            0x0084);
+        add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA",         0x0085);
+        add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA",         0x0086);
+        add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA",        0x0087);
+        add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA",        0x0088);
+        add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA",        0x0089);
+        add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256",         0x00ba);
+        add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256",      0x00bb);
+        add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256",      0x00bc);
+        add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256",     0x00bd);
+        add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256",     0x00be);
+        add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256",     0x00bf);
+        add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256",         0x00c0);
+        add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256",      0x00c1);
+        add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256",      0x00c2);
+        add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256",     0x00c3);
+        add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256",     0x00c4);
+        add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256",     0x00c5);
+
+        // TLS Fallback Signaling Cipher Suite Value (SCSV) RFC 7507
+        add("TLS_FALLBACK_SCSV", 0x5600);
 
         // Unsupported cipher suites from RFC 5054
-        add("TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA",           0xc01a);
-        add("TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA",       0xc01b);
-        add("TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA",       0xc01c);
-        add("TLS_SRP_SHA_WITH_AES_128_CBC_SHA",            0xc01d);
-        add("TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA",        0xc01e);
-        add("TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA",        0xc01f);
-        add("TLS_SRP_SHA_WITH_AES_256_CBC_SHA",            0xc020);
-        add("TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA",        0xc021);
-        add("TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA",        0xc022);
+        add("TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA",            0xc01a);
+        add("TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA",        0xc01b);
+        add("TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA",        0xc01c);
+        add("TLS_SRP_SHA_WITH_AES_128_CBC_SHA",             0xc01d);
+        add("TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA",         0xc01e);
+        add("TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA",         0xc01f);
+        add("TLS_SRP_SHA_WITH_AES_256_CBC_SHA",             0xc020);
+        add("TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA",         0xc021);
+        add("TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA",         0xc022);
 
         // Unsupported cipher suites from RFC 5489
-        add("TLS_ECDHE_PSK_WITH_RC4_128_SHA",              0xc033);
-        add("TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA",         0xc034);
-        add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA",          0xc035);
-        add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA",          0xc036);
-        add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256",       0xc037);
-        add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384",       0xc038);
-        add("TLS_ECDHE_PSK_WITH_NULL_SHA",                 0xc039);
-        add("TLS_ECDHE_PSK_WITH_NULL_SHA256",              0xc03a);
-        add("TLS_ECDHE_PSK_WITH_NULL_SHA384",              0xc03b);
+        add("TLS_ECDHE_PSK_WITH_RC4_128_SHA",               0xc033);
+        add("TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA",          0xc034);
+        add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA",           0xc035);
+        add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA",           0xc036);
+        add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256",        0xc037);
+        add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384",        0xc038);
+        add("TLS_ECDHE_PSK_WITH_NULL_SHA",                  0xc039);
+        add("TLS_ECDHE_PSK_WITH_NULL_SHA256",               0xc03a);
+        add("TLS_ECDHE_PSK_WITH_NULL_SHA384",               0xc03b);
+
+        // Unsupported cipher suites from RFC 6209
+        add("TLS_RSA_WITH_ARIA_128_CBC_SHA256",             0xc03c);
+        add("TLS_RSA_WITH_ARIA_256_CBC_SHA384",             0xc03d);
+        add("TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256",          0xc03e);
+        add("TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384",          0xc03f);
+        add("TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256",          0xc040);
+        add("TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384",          0xc041);
+        add("TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256",         0xc042);
+        add("TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384",         0xc043);
+        add("TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256",         0xc044);
+        add("TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384",         0xc045);
+        add("TLS_DH_anon_WITH_ARIA_128_CBC_SHA256",         0xc046);
+        add("TLS_DH_anon_WITH_ARIA_256_CBC_SHA384",         0xc047);
+        add("TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256",     0xc048);
+        add("TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384",     0xc049);
+        add("TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256",      0xc04a);
+        add("TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384",      0xc04b);
+        add("TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256",       0xc04c);
+        add("TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384",       0xc04d);
+        add("TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256",        0xc04e);
+        add("TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384",        0xc04f);
+        add("TLS_RSA_WITH_ARIA_128_GCM_SHA256",             0xc050);
+        add("TLS_RSA_WITH_ARIA_256_GCM_SHA384",             0xc051);
+        add("TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256",         0xc052);
+        add("TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384",         0xc053);
+        add("TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256",          0xc054);
+        add("TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384",          0xc055);
+        add("TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256",         0xc056);
+        add("TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384",         0xc057);
+        add("TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256",          0xc058);
+        add("TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384",          0xc059);
+        add("TLS_DH_anon_WITH_ARIA_128_GCM_SHA256",         0xc05a);
+        add("TLS_DH_anon_WITH_ARIA_256_GCM_SHA384",         0xc05b);
+        add("TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256",     0xc05c);
+        add("TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384",     0xc05d);
+        add("TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256",      0xc05e);
+        add("TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384",      0xc05f);
+        add("TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256",       0xc060);
+        add("TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384",       0xc061);
+        add("TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256",        0xc062);
+        add("TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384",        0xc063);
+        add("TLS_PSK_WITH_ARIA_128_CBC_SHA256",             0xc064);
+        add("TLS_PSK_WITH_ARIA_256_CBC_SHA384",             0xc065);
+        add("TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256",         0xc066);
+        add("TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384",         0xc067);
+        add("TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256",         0xc068);
+        add("TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384",         0xc069);
+        add("TLS_PSK_WITH_ARIA_128_GCM_SHA256",             0xc06a);
+        add("TLS_PSK_WITH_ARIA_256_GCM_SHA384",             0xc06b);
+        add("TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256",         0xc06c);
+        add("TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384",         0xc06d);
+        add("TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256",         0xc06e);
+        add("TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384",         0xc06f);
+        add("TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256",       0xc070);
+        add("TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384",       0xc071);
+
+        // Unsupported cipher suites from RFC 6367
+        add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", 0xc072);
+        add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", 0xc073);
+        add("TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256",  0xc074);
+        add("TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384",  0xc075);
+        add("TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256",   0xc076);
+        add("TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384",   0xc077);
+        add("TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256",    0xc078);
+        add("TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384",    0xc079);
+        add("TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256",         0xc07a);
+        add("TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384",         0xc07b);
+        add("TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256",     0xc07c);
+        add("TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384",     0xc07d);
+        add("TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256",      0xc07e);
+        add("TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384",      0xc07f);
+        add("TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256",     0xc080);
+        add("TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384",     0xc081);
+        add("TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256",      0xc082);
+        add("TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384",      0xc083);
+        add("TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256",     0xc084);
+        add("TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384",     0xc085);
+        add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc086);
+        add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc087);
+        add("TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256",  0xc088);
+        add("TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384",  0xc089);
+        add("TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256",   0xc08a);
+        add("TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384",   0xc08b);
+        add("TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256",    0xc08c);
+        add("TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384",    0xc08d);
+        add("TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256",         0xc08e);
+        add("TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384",         0xc08f);
+        add("TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256",     0xc090);
+        add("TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384",     0xc091);
+        add("TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256",     0xc092);
+        add("TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384",     0xc093);
+        add("TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256",         0xc094);
+        add("TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384",         0xc095);
+        add("TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256",     0xc096);
+        add("TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384",     0xc097);
+        add("TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256",     0xc098);
+        add("TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384",     0xc099);
+        add("TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256",   0xc09a);
+        add("TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384",   0xc09b);
+
+        // Unsupported cipher suites from RFC 6655
+        add("TLS_RSA_WITH_AES_128_CCM",                     0xc09c);
+        add("TLS_RSA_WITH_AES_256_CCM",                     0xc09d);
+        add("TLS_DHE_RSA_WITH_AES_128_CCM",                 0xc09e);
+        add("TLS_DHE_RSA_WITH_AES_256_CCM",                 0xc09f);
+        add("TLS_RSA_WITH_AES_128_CCM_8",                   0xc0A0);
+        add("TLS_RSA_WITH_AES_256_CCM_8",                   0xc0A1);
+        add("TLS_DHE_RSA_WITH_AES_128_CCM_8",               0xc0A2);
+        add("TLS_DHE_RSA_WITH_AES_256_CCM_8",               0xc0A3);
+        add("TLS_PSK_WITH_AES_128_CCM",                     0xc0A4);
+        add("TLS_PSK_WITH_AES_256_CCM",                     0xc0A5);
+        add("TLS_DHE_PSK_WITH_AES_128_CCM",                 0xc0A6);
+        add("TLS_DHE_PSK_WITH_AES_256_CCM",                 0xc0A7);
+        add("TLS_PSK_WITH_AES_128_CCM_8",                   0xc0A8);
+        add("TLS_PSK_WITH_AES_256_CCM_8",                   0xc0A9);
+        add("TLS_PSK_DHE_WITH_AES_128_CCM_8",               0xc0Aa);
+        add("TLS_PSK_DHE_WITH_AES_256_CCM_8",               0xc0Ab);
+
+        // Unsupported cipher suites from RFC 7251
+        add("TLS_ECDHE_ECDSA_WITH_AES_128_CCM",             0xc0Ac);
+        add("TLS_ECDHE_ECDSA_WITH_AES_256_CCM",             0xc0Ad);
+        add("TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8",           0xc0Ae);
+        add("TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8",           0xc0Af);
     }
 
     // ciphersuite SSL_NULL_WITH_NULL_NULL
--- a/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Dec 02 09:34:55 2015 -0800
@@ -151,6 +151,9 @@
     private static final boolean enableMFLExtension =
             Debug.getBooleanProperty("jsse.enableMFLExtension", false);
 
+    // Whether an ALPN extension was sent in the ClientHello
+    private boolean alpnActive = false;
+
     private List<SNIServerName> requestedServerNames =
             Collections.<SNIServerName>emptyList();
 
@@ -700,6 +703,44 @@
         }   // Otherwise, using the value negotiated during the original
             // session initiation
 
+        // check the ALPN extension
+        ALPNExtension serverHelloALPN =
+            (ALPNExtension) mesg.extensions.get(ExtensionType.EXT_ALPN);
+
+        if (serverHelloALPN != null) {
+            // Check whether an ALPN extension was sent in ClientHello message
+            if (!alpnActive) {
+                fatalSE(Alerts.alert_unsupported_extension,
+                    "Server sent " + ExtensionType.EXT_ALPN +
+                    " extension when not requested by client");
+            }
+
+            List<String> protocols = serverHelloALPN.getPeerAPs();
+            // Only one application protocol name should be present
+            String p;
+            if ((protocols.size() == 1) &&
+                    !((p = protocols.get(0)).isEmpty())) {
+                int i;
+                for (i = 0; i < localApl.length; i++) {
+                    if (localApl[i].equals(p)) {
+                        break;
+                    }
+                }
+                if (i == localApl.length) {
+                    fatalSE(Alerts.alert_handshake_failure,
+                        "Server has selected an application protocol name " +
+                        "which was not offered by the client: " + p);
+                }
+                applicationProtocol = p;
+            } else {
+                fatalSE(Alerts.alert_handshake_failure,
+                    "Incorrect data in ServerHello " + ExtensionType.EXT_ALPN +
+                    " message");
+            }
+        } else {
+            applicationProtocol = "";
+        }
+
         if (resumingSession && session != null) {
             setHandshakeSessionSE(session);
             // Reserve the handshake state if this is a session-resumption
@@ -729,6 +770,7 @@
             } else if ((type != ExtensionType.EXT_ELLIPTIC_CURVES)
                     && (type != ExtensionType.EXT_EC_POINT_FORMATS)
                     && (type != ExtensionType.EXT_SERVER_NAME)
+                    && (type != ExtensionType.EXT_ALPN)
                     && (type != ExtensionType.EXT_RENEGOTIATION_INFO)
                     && (type != ExtensionType.EXT_STATUS_REQUEST)
                     && (type != ExtensionType.EXT_STATUS_REQUEST_V2)) {
@@ -1525,6 +1567,12 @@
             clientHelloMessage.addCertStatusRequestExtension();
         }
 
+        // Add ALPN extension
+        if (localApl != null && localApl.length > 0) {
+            clientHelloMessage.addALPNExtension(localApl);
+            alpnActive = true;
+        }
+
         // reset the client random cookie
         clnt_random = clientHelloMessage.clnt_random;
 
--- a/src/java.base/share/classes/sun/security/ssl/ExtensionType.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/ExtensionType.java	Wed Dec 02 09:34:55 2015 -0800
@@ -43,8 +43,7 @@
         return name;
     }
 
-    static List<ExtensionType> knownExtensions =
-            new ArrayList<ExtensionType>(14);
+    static List<ExtensionType> knownExtensions = new ArrayList<>(15);
 
     static ExtensionType get(int id) {
         for (ExtensionType ext : knownExtensions) {
@@ -97,6 +96,11 @@
     static final ExtensionType EXT_SIGNATURE_ALGORITHMS =
             e(0x000D, "signature_algorithms");   // IANA registry value: 13
 
+    // extension defined in RFC 7301 (ALPN)
+    static final ExtensionType EXT_ALPN =
+            e(0x0010, "application_layer_protocol_negotiation");
+                                                 // IANA registry value: 16
+
     // extensions defined in RFC 6961
     static final ExtensionType EXT_STATUS_REQUEST_V2 =
             e(0x0011, "status_request_v2");      // IANA registry value: 17
--- a/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java	Wed Dec 02 09:34:55 2015 -0800
@@ -412,6 +412,11 @@
         extensions.add(new CertStatusReqListV2Extension(itemList));
     }
 
+    // add application_layer_protocol_negotiation extension
+    void addALPNExtension(String[] applicationProtocols) throws SSLException {
+        extensions.add(new ALPNExtension(applicationProtocols));
+    }
+
     @Override
     int messageType() { return ht_client_hello; }
 
--- a/src/java.base/share/classes/sun/security/ssl/Handshaker.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/Handshaker.java	Wed Dec 02 09:34:55 2015 -0800
@@ -116,6 +116,12 @@
     List<SNIServerName> serverNames = Collections.<SNIServerName>emptyList();
     Collection<SNIMatcher> sniMatchers = Collections.<SNIMatcher>emptyList();
 
+    // List of local ApplicationProtocols
+    String[] localApl = null;
+
+    // Negotiated ALPN value
+    String applicationProtocol = null;
+
     // The maximum expected network packet size for SSL/TLS/DTLS records.
     int                         maximumPacketSize = 0;
 
@@ -481,6 +487,20 @@
     }
 
     /**
+     * Sets the Application Protocol list.
+     */
+    void setApplicationProtocols(String[] apl) {
+        this.localApl = apl;
+    }
+
+    /**
+     * Gets the "negotiated" ALPN value.
+     */
+    String getHandshakeApplicationProtocol() {
+        return applicationProtocol;
+    }
+
+    /**
      * Sets the cipher suites preference.
      */
     void setUseCipherSuitesOrder(boolean on) {
--- a/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java	Wed Dec 02 09:34:55 2015 -0800
@@ -33,8 +33,8 @@
 /**
  * This file contains all the classes relevant to TLS Extensions for the
  * ClientHello and ServerHello messages. The extension mechanism and
- * several extensions are defined in RFC 3546. Additional extensions are
- * defined in the ECC RFC 4492.
+ * several extensions are defined in RFC 6066. Additional extensions are
+ * defined in the ECC RFC 4492 and the ALPN extension is defined in RFC 7301.
  *
  * Currently, only the two ECC extensions are fully supported.
  *
@@ -52,6 +52,7 @@
  *  . SupportedEllipticCurvesExtension: the ECC supported curves extension.
  *  . SupportedEllipticPointFormatsExtension: the ECC supported point formats
  *      (compressed/uncompressed) extension.
+ *  . ALPNExtension: the application_layer_protocol_negotiation extension.
  *
  * @since   1.6
  * @author  Andreas Sterbenz
@@ -85,6 +86,8 @@
                         new SupportedEllipticPointFormatsExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_RENEGOTIATION_INFO) {
                 extension = new RenegotiationInfoExtension(s, extlen);
+            } else if (extType == ExtensionType.EXT_ALPN) {
+                extension = new ALPNExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_MAX_FRAGMENT_LENGTH) {
                 extension = new MaxFragmentLengthExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_STATUS_REQUEST) {
--- a/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,6 +198,14 @@
     Collection<SNIMatcher>      sniMatchers =
                                     Collections.<SNIMatcher>emptyList();
 
+    // Configured application protocol values
+    String[] applicationProtocols = new String[0];
+
+    // Negotiated application protocol value.
+    //
+    // The value under negotiation will be obtained from handshaker.
+    String applicationProtocol = null;
+
     // Have we been told whether we're client or server?
     private boolean                     serverModeSet = false;
     private boolean                     roleIsServer;
@@ -413,6 +421,7 @@
         } else { // cs_DATA
             connectionState = cs_RENEGOTIATE;
         }
+
         if (roleIsServer) {
             handshaker = new ServerHandshaker(this, sslContext,
                     enabledProtocols, doClientAuth,
@@ -432,6 +441,7 @@
         handshaker.setMaximumPacketSize(maximumPacketSize);
         handshaker.setEnabledCipherSuites(enabledCipherSuites);
         handshaker.setEnableSessionCreation(enableSessionCreation);
+        handshaker.setApplicationProtocols(applicationProtocols);
 
         outputRecord.initHandshaker();
     }
@@ -1055,6 +1065,9 @@
                                 handshaker.isSecureRenegotiation();
                     clientVerifyData = handshaker.getClientVerifyData();
                     serverVerifyData = handshaker.getServerVerifyData();
+                    // set connection ALPN value
+                    applicationProtocol =
+                        handshaker.getHandshakeApplicationProtocol();
 
                     sess = handshaker.getSession();
                     handshakeSession = null;
@@ -2140,6 +2153,7 @@
         params.setUseCipherSuitesOrder(preferLocalCipherSuites);
         params.setEnableRetransmissions(enableRetransmissions);
         params.setMaximumPacketSize(maximumPacketSize);
+        params.setApplicationProtocols(applicationProtocols);
 
         return params;
     }
@@ -2174,11 +2188,13 @@
         if (matchers != null) {
             sniMatchers = matchers;
         }
+        applicationProtocols = params.getApplicationProtocols();
 
         if ((handshaker != null) && !handshaker.started()) {
             handshaker.setIdentificationProtocol(identificationProtocol);
             handshaker.setAlgorithmConstraints(algorithmConstraints);
             handshaker.setMaximumPacketSize(maximumPacketSize);
+            handshaker.setApplicationProtocols(applicationProtocols);
             if (roleIsServer) {
                 handshaker.setSNIMatchers(sniMatchers);
                 handshaker.setUseCipherSuitesOrder(preferLocalCipherSuites);
@@ -2188,6 +2204,19 @@
         }
     }
 
+    @Override
+    public synchronized String getApplicationProtocol() {
+        return applicationProtocol;
+    }
+
+    @Override
+    public synchronized String getHandshakeApplicationProtocol() {
+        if ((handshaker != null) && !handshaker.started()) {
+            return handshaker.getHandshakeApplicationProtocol();
+        }
+        return null;
+    }
+
     /**
      * Returns a printable representation of this end of the connection.
      */
--- a/src/java.base/share/classes/sun/security/ssl/SSLServerSocketImpl.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/SSLServerSocketImpl.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,6 +92,9 @@
     Collection<SNIMatcher>      sniMatchers =
                                     Collections.<SNIMatcher>emptyList();
 
+    // Configured application protocol values
+    String[] applicationProtocols = new String[0];
+
     /*
      * Whether local cipher suites preference in server side should be
      * honored during handshaking?
@@ -311,7 +314,7 @@
         params.setAlgorithmConstraints(algorithmConstraints);
         params.setSNIMatchers(sniMatchers);
         params.setUseCipherSuitesOrder(preferLocalCipherSuites);
-
+        params.setApplicationProtocols(applicationProtocols);
 
         return params;
     }
@@ -331,6 +334,7 @@
         if (matchers != null) {
             sniMatchers = params.getSNIMatchers();
         }
+        applicationProtocols = params.getApplicationProtocols();
     }
 
     /**
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Wed Dec 02 09:34:55 2015 -0800
@@ -210,6 +210,14 @@
     Collection<SNIMatcher>      sniMatchers =
                                     Collections.<SNIMatcher>emptyList();
 
+    // Configured application protocol values
+    String[] applicationProtocols = new String[0];
+
+    // Negotiated application protocol value.
+    //
+    // The value under negotiation will be obtained from handshaker.
+    String applicationProtocol = null;
+
     /*
      * READ ME * READ ME * READ ME * READ ME * READ ME * READ ME *
      * IMPORTANT STUFF TO UNDERSTANDING THE SYNCHRONIZATION ISSUES.
@@ -1116,6 +1124,9 @@
                                     handshaker.isSecureRenegotiation();
                     clientVerifyData = handshaker.getClientVerifyData();
                     serverVerifyData = handshaker.getServerVerifyData();
+                    // set connection ALPN value
+                    applicationProtocol =
+                        handshaker.getHandshakeApplicationProtocol();
 
                     sess = handshaker.getSession();
                     handshakeSession = null;
@@ -1314,6 +1325,7 @@
         } else { // cs_DATA
             connectionState = cs_RENEGOTIATE;
         }
+
         if (roleIsServer) {
             handshaker = new ServerHandshaker(this, sslContext,
                     enabledProtocols, doClientAuth,
@@ -1331,6 +1343,7 @@
         handshaker.setMaximumPacketSize(maximumPacketSize);
         handshaker.setEnabledCipherSuites(enabledCipherSuites);
         handshaker.setEnableSessionCreation(enableSessionCreation);
+        handshaker.setApplicationProtocols(applicationProtocols);
     }
 
     /**
@@ -2511,6 +2524,7 @@
         params.setServerNames(serverNames);
         params.setUseCipherSuitesOrder(preferLocalCipherSuites);
         params.setMaximumPacketSize(maximumPacketSize);
+        params.setApplicationProtocols(applicationProtocols);
 
         // DTLS handshake retransmissions parameter does not apply here.
 
@@ -2549,10 +2563,13 @@
             sniMatchers = matchers;
         }
 
+        applicationProtocols = params.getApplicationProtocols();
+
         if ((handshaker != null) && !handshaker.started()) {
             handshaker.setIdentificationProtocol(identificationProtocol);
             handshaker.setAlgorithmConstraints(algorithmConstraints);
             handshaker.setMaximumPacketSize(maximumPacketSize);
+            handshaker.setApplicationProtocols(applicationProtocols);
             if (roleIsServer) {
                 handshaker.setSNIMatchers(sniMatchers);
                 handshaker.setUseCipherSuitesOrder(preferLocalCipherSuites);
@@ -2562,6 +2579,19 @@
         }
     }
 
+    @Override
+    public synchronized String getApplicationProtocol() {
+        return applicationProtocol;
+    }
+
+    @Override
+    public synchronized String getHandshakeApplicationProtocol() {
+        if ((handshaker != null) && !handshaker.started()) {
+            return handshaker.getHandshakeApplicationProtocol();
+        }
+        return null;
+    }
+
     //
     // We allocate a separate thread to deliver handshake completion
     // events.  This ensures that the notifications don't block the
--- a/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Dec 02 09:34:55 2015 -0800
@@ -528,6 +528,36 @@
             }
         }
 
+        // check the ALPN extension
+        ALPNExtension clientHelloALPN = (ALPNExtension)
+            mesg.extensions.get(ExtensionType.EXT_ALPN);
+
+        if ((clientHelloALPN != null) && (localApl.length > 0)) {
+
+            // Intersect the requested and the locally supported,
+            // and save for later.
+            String negotiatedValue = null;
+            List<String> protocols = clientHelloALPN.getPeerAPs();
+
+            // Use server preference order
+            for (String ap : localApl) {
+                if (protocols.contains(ap)) {
+                    negotiatedValue = ap;
+                    break;
+                }
+            }
+
+            if (negotiatedValue == null) {
+                fatalSE(Alerts.alert_no_application_protocol,
+                    new SSLHandshakeException(
+                        "No matching ALPN values"));
+            }
+            applicationProtocol = negotiatedValue;
+
+        } else {
+            applicationProtocol = "";
+        }
+
         // cookie exchange
         if (isDTLS) {
              HelloCookieManager hcMgr = sslContext.getHelloCookieManager();
@@ -921,6 +951,11 @@
             }
         }
 
+        // Prepare the ALPN response
+        if (applicationProtocol != null && !applicationProtocol.isEmpty()) {
+            m1.extensions.add(new ALPNExtension(applicationProtocol));
+        }
+
         if (debug != null && Debug.isOn("handshake")) {
             m1.print(System.out);
             System.out.println("Cipher suite:  " + session.getSuite());
@@ -1415,8 +1450,8 @@
                 }
             }
 
-            // need EC cert signed using EC
-            if (setupPrivateKeyAndChain("EC_EC") == false) {
+            // need EC cert
+            if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
             if (setupEphemeralECDHKeys() == false) {
@@ -1424,15 +1459,15 @@
             }
             break;
         case K_ECDH_RSA:
-            // need EC cert signed using RSA
-            if (setupPrivateKeyAndChain("EC_RSA") == false) {
+            // need EC cert
+            if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
             setupStaticECDHKeys();
             break;
         case K_ECDH_ECDSA:
-            // need EC cert signed using EC
-            if (setupPrivateKeyAndChain("EC_EC") == false) {
+            // need EC cert
+            if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
             setupStaticECDHKeys();
--- a/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java	Wed Dec 02 09:34:55 2015 -0800
@@ -38,6 +38,7 @@
 
 import java.security.KeyStore;
 
+import java.security.cert.X509Certificate;
 import java.text.Collator;
 
 import java.util.ArrayList;
@@ -68,6 +69,25 @@
     };
 
     /**
+     * Returns true if the certificate is self-signed, false otherwise.
+     */
+    public static boolean isSelfSigned(X509Certificate cert) {
+        return signedBy(cert, cert);
+    }
+
+    public static boolean signedBy(X509Certificate end, X509Certificate ca) {
+        if (!ca.getSubjectX500Principal().equals(end.getIssuerX500Principal())) {
+            return false;
+        }
+        try {
+            end.verify(ca.getPublicKey());
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
      * Returns true if KeyStore has a password. This is true except for
      * MSCAPI KeyStores
      */
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1297,7 +1297,7 @@
         for (Certificate ca: keyStore.getCertificateChain(alias)) {
             if (ca instanceof X509Certificate) {
                 X509Certificate xca = (X509Certificate)ca;
-                if (!isSelfSigned(xca)) {
+                if (!KeyStoreUtil.isSelfSigned(xca)) {
                     dumpCert(xca, out);
                 }
             }
@@ -1857,8 +1857,8 @@
                 } else {
                     // Print the digest of the user cert only
                     out.println
-                        (rb.getString("Certificate.fingerprint.SHA1.") +
-                        getCertFingerPrint("SHA1", chain[0]));
+                        (rb.getString("Certificate.fingerprint.SHA.256.") +
+                        getCertFingerPrint("SHA-256", chain[0]));
                 }
             }
         } else if (keyStore.entryInstanceOf(alias,
@@ -1878,8 +1878,8 @@
                 out.println(cert.toString());
             } else {
                 out.println("trustedCertEntry, ");
-                out.println(rb.getString("Certificate.fingerprint.SHA1.")
-                            + getCertFingerPrint("SHA1", cert));
+                out.println(rb.getString("Certificate.fingerprint.SHA.256.")
+                            + getCertFingerPrint("SHA-256", cert));
             }
         } else {
             out.println(rb.getString("Unknown.Entry.Type"));
@@ -2705,7 +2705,7 @@
 
         // if certificate is self-signed, make sure it verifies
         boolean selfSigned = false;
-        if (isSelfSigned(cert)) {
+        if (KeyStoreUtil.isSelfSigned(cert)) {
             cert.verify(cert.getPublicKey());
             selfSigned = true;
         }
@@ -2907,23 +2907,6 @@
     private void printX509Cert(X509Certificate cert, PrintStream out)
         throws Exception
     {
-        /*
-        out.println("Owner: "
-                    + cert.getSubjectDN().toString()
-                    + "\n"
-                    + "Issuer: "
-                    + cert.getIssuerDN().toString()
-                    + "\n"
-                    + "Serial number: " + cert.getSerialNumber().toString(16)
-                    + "\n"
-                    + "Valid from: " + cert.getNotBefore().toString()
-                    + " until: " + cert.getNotAfter().toString()
-                    + "\n"
-                    + "Certificate fingerprints:\n"
-                    + "\t MD5:  " + getCertFingerPrint("MD5", cert)
-                    + "\n"
-                    + "\t SHA1: " + getCertFingerPrint("SHA1", cert));
-        */
 
         MessageFormat form = new MessageFormat
                 (rb.getString(".PATTERN.printX509Cert"));
@@ -2933,8 +2916,7 @@
                         cert.getSerialNumber().toString(16),
                         cert.getNotBefore().toString(),
                         cert.getNotAfter().toString(),
-                        getCertFingerPrint("MD5", cert),
-                        getCertFingerPrint("SHA1", cert),
+                        getCertFingerPrint("SHA-1", cert),
                         getCertFingerPrint("SHA-256", cert),
                         cert.getSigAlgName(),
                         pkey.getAlgorithm(),
@@ -2983,25 +2965,6 @@
     }
 
     /**
-     * Returns true if the certificate is self-signed, false otherwise.
-     */
-    private boolean isSelfSigned(X509Certificate cert) {
-        return signedBy(cert, cert);
-    }
-
-    private boolean signedBy(X509Certificate end, X509Certificate ca) {
-        if (!ca.getSubjectDN().equals(end.getIssuerDN())) {
-            return false;
-        }
-        try {
-            end.verify(ca.getPublicKey());
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-    /**
      * Locates a signer for a given certificate from a given keystore and
      * returns the signer's certificate.
      * @param cert the certificate whose signer is searched, not null
@@ -3338,7 +3301,7 @@
             // find a cert in the reply who signs thisCert
             int j;
             for (j=i; j<replyCerts.length; j++) {
-                if (signedBy(thisCert, (X509Certificate)replyCerts[j])) {
+                if (KeyStoreUtil.signedBy(thisCert, (X509Certificate)replyCerts[j])) {
                     tmpCert = replyCerts[i];
                     replyCerts[i] = replyCerts[j];
                     replyCerts[j] = tmpCert;
@@ -3469,7 +3432,7 @@
                         Vector<Certificate> chain,
                         Hashtable<Principal, Vector<Certificate>> certs) {
         Principal issuer = certToVerify.getIssuerDN();
-        if (isSelfSigned(certToVerify)) {
+        if (KeyStoreUtil.isSelfSigned(certToVerify)) {
             // reached self-signed root cert;
             // no verification needed because it's trusted.
             chain.addElement(certToVerify);
--- a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Wed Dec 02 09:34:55 2015 -0800
@@ -307,7 +307,7 @@
         {"Entry.type.type.", "Entry type: {0}"},
         {"Certificate.chain.length.", "Certificate chain length: "},
         {"Certificate.i.1.", "Certificate[{0,number,integer}]:"},
-        {"Certificate.fingerprint.SHA1.", "Certificate fingerprint (SHA1): "},
+        {"Certificate.fingerprint.SHA.256.", "Certificate fingerprint (SHA-256): "},
         {"Keystore.type.", "Keystore type: "},
         {"Keystore.provider.", "Keystore provider: "},
         {"Your.keystore.contains.keyStore.size.entry",
@@ -347,7 +347,7 @@
         {".RETURN.if.same.as.for.otherAlias.",
                 "\t(RETURN if same as for <{0}>)"},
         {".PATTERN.printX509Cert",
-                "Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t MD5:  {5}\n\t SHA1: {6}\n\t SHA256: {7}\nSignature algorithm name: {8}\nSubject Public Key Algorithm: {9} ({10,number,#})\nVersion: {11}"},
+                "Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t SHA1: {5}\n\t SHA256: {6}\nSignature algorithm name: {7}\nSubject Public Key Algorithm: {8} ({9,number,#})\nVersion: {10}"},
         {"What.is.your.first.and.last.name.",
                 "What is your first and last name?"},
         {"What.is.the.name.of.your.organizational.unit.",
--- a/src/java.base/share/native/include/jvm.h	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/native/include/jvm.h	Wed Dec 02 09:34:55 2015 -0800
@@ -178,6 +178,37 @@
 JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index);
 
 /*
+ * java.lang.StackWalker
+ */
+enum {
+  JVM_STACKWALK_FILL_CLASS_REFS_ONLY       = 0x2,
+  JVM_STACKWALK_FILTER_FILL_IN_STACK_TRACE = 0x10,
+  JVM_STACKWALK_SHOW_HIDDEN_FRAMES         = 0x20,
+  JVM_STACKWALK_FILL_LIVE_STACK_FRAMES     = 0x100
+};
+
+JNIEXPORT jobject JNICALL
+JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
+                  jint skip_frames, jint frame_count, jint start_index,
+                  jobjectArray classes,
+                  jobjectArray frames);
+
+JNIEXPORT jint JNICALL
+JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
+                  jint frame_count, jint start_index,
+                  jobjectArray classes,
+                  jobjectArray frames);
+
+JNIEXPORT void JNICALL
+JVM_FillStackFrames(JNIEnv* env, jclass cls,
+                    jint start_index,
+                    jobjectArray stackFrames,
+                    jint from_index, jint toIndex);
+
+JNIEXPORT void JNICALL
+JVM_SetMethodInfo(JNIEnv* env, jobject frame);
+
+/*
  * java.lang.Thread
  */
 JNIEXPORT void JNICALL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/native/libjava/StackFrameInfo.c	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ *      Implementation of class StackFrameInfo
+ */
+
+#include <stdio.h>
+#include <signal.h>
+
+#include "jni.h"
+#include "jvm.h"
+
+#include "java_lang_StackFrameInfo.h"
+
+
+/*
+ * Class:     java_lang_StackFrameInfo
+ * Method:    fillInStackFrames
+ * Signature: (I[Ljava/lang/Object;[Ljava/lang/Object;II)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_StackFrameInfo_fillInStackFrames
+  (JNIEnv *env, jclass dummy, jint startIndex,
+   jobjectArray stackFrames, jint fromIndex, jint toIndex) {
+    JVM_FillStackFrames(env, dummy, startIndex,
+                        stackFrames, fromIndex, toIndex);
+}
+
+/*
+ * Class:     java_lang_StackFrameInfo
+ * Method:    setMethodInfo
+ * Signature: (Ljava/lang/Class;)V
+ */
+JNIEXPORT void JNICALL Java_java_lang_StackFrameInfo_setMethodInfo
+  (JNIEnv *env, jobject stackframeinfo) {
+     JVM_SetMethodInfo(env, stackframeinfo);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/native/libjava/StackStreamFactory.c	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ *      Implementation of class StackStreamfactory and AbstractStackWalker
+ */
+
+#include <stdio.h>
+#include <signal.h>
+
+#include "jni.h"
+#include "jvm.h"
+
+#include "java_lang_StackStreamFactory.h"
+#include "java_lang_StackStreamFactory_AbstractStackWalker.h"
+
+/*
+ * Class:     java_lang_StackStreamFactory
+ * Method:    checkStackWalkModes
+ * Signature: ()
+ */
+JNIEXPORT jboolean JNICALL Java_java_lang_StackStreamFactory_checkStackWalkModes
+  (JNIEnv *env, jclass dummy)
+{
+   return JVM_STACKWALK_FILL_CLASS_REFS_ONLY == java_lang_StackStreamFactory_FILL_CLASS_REFS_ONLY &&
+          JVM_STACKWALK_FILTER_FILL_IN_STACK_TRACE == java_lang_StackStreamFactory_FILTER_FILL_IN_STACKTRACE &&
+          JVM_STACKWALK_SHOW_HIDDEN_FRAMES == java_lang_StackStreamFactory_SHOW_HIDDEN_FRAMES &&
+          JVM_STACKWALK_FILL_LIVE_STACK_FRAMES == java_lang_StackStreamFactory_FILL_LIVE_STACK_FRAMES;
+}
+
+/*
+ * Class:     java_lang_StackStreamFactory_AbstractStackWalker
+ * Method:    callStackWalk
+ * Signature: (JIII[Ljava/lang/Class;[Ljava/lang/StackWalker/StackFrame;)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_java_lang_StackStreamFactory_00024AbstractStackWalker_callStackWalk
+  (JNIEnv *env, jobject stackstream, jlong mode, jint skipFrames, jint batchSize, jint startIndex,
+   jobjectArray classes, jobjectArray frames)
+{
+    return JVM_CallStackWalk(env, stackstream, mode, skipFrames, batchSize,
+                             startIndex, classes, frames);
+}
+
+/*
+ * Class:     java_lang_StackStreamFactory_AbstractStackWalker
+ * Method:    fetchStackFrames
+ * Signature: (JJII[Ljava/lang/Class;[Ljava/lang/StackWalker/StackFrame;)I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_StackStreamFactory_00024AbstractStackWalker_fetchStackFrames
+  (JNIEnv *env, jobject stackstream, jlong mode, jlong anchor,
+   jint batchSize, jint startIndex,
+   jobjectArray classes, jobjectArray frames)
+{
+    return JVM_MoreStackWalk(env, stackstream, mode, anchor, batchSize,
+                             startIndex, classes, frames);
+}
--- a/src/java.base/share/native/libjimage/imageFile.cpp	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/share/native/libjimage/imageFile.cpp	Wed Dec 02 09:34:55 2015 -0800
@@ -291,13 +291,10 @@
 
 // Remove an image entry from the table.
 void ImageFileReaderTable::remove(ImageFileReader* image) {
-    s4 last = _count - 1;
-    for (s4 i = 0; _count; i++) {
+    for (u4 i = 0; i < _count; i++) {
         if (_table[i] == image) {
-            if (i != last) {
-                _table[i] = _table[last];
-                _count = last;
-            }
+            // Swap the last element into the found slot
+            _table[i] = _table[--_count];
             break;
         }
     }
@@ -310,7 +307,7 @@
 
 // Determine if image entry is in table.
 bool ImageFileReaderTable::contains(ImageFileReader* image) {
-    for (s4 i = 0; _count; i++) {
+    for (u4 i = 0; i < _count; i++) {
         if (_table[i] == image) {
             return true;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Dec 02 09:34:55 2015 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.nio.ch;
+
+import java.nio.channels.spi.SelectorProvider;
+
+/**
+ * Creates this platform's default SelectorProvider
+ */
+
+public class DefaultSelectorProvider {
+
+    /**
+     * Prevent instantiation.
+     */
+    private DefaultSelectorProvider() { }
+
+    /**
+     * Returns the default SelectorProvider.
+     */
+    public static SelectorProvider create() {
+        return new sun.nio.ch.DevPollSelectorProvider();
+    }
+
+}
--- a/src/java.base/unix/classes/sun/nio/ch/DefaultSelectorProvider.java	Sun Nov 29 20:29:45 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.nio.ch;
-
-import java.nio.channels.spi.SelectorProvider;
-import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
-
-/**
- * Creates this platform's default SelectorProvider
- */
-
-public class DefaultSelectorProvider {
-
-    /**
-     * Prevent instantiation.
-     */
-    private DefaultSelectorProvider() { }
-
-    @SuppressWarnings("unchecked")
-    private static SelectorProvider createProvider(String cn) {
-        Class<SelectorProvider> c;
-        try {
-            c = (Class<SelectorProvider>)Class.forName(cn);
-        } catch (ClassNotFoundException x) {
-            throw new AssertionError(x);
-        }
-        try {
-            return c.newInstance();
-        } catch (IllegalAccessException | InstantiationException x) {
-            throw new AssertionError(x);
-        }
-
-    }
-
-    /**
-     * Returns the default SelectorProvider.
-     */
-    public static SelectorProvider create() {
-        String osname = AccessController
-            .doPrivileged(new GetPropertyAction("os.name"));
-        if (osname.equals("SunOS"))
-            return createProvider("sun.nio.ch.DevPollSelectorProvider");
-        if (osname.equals("Linux"))
-            return createProvider("sun.nio.ch.EPollSelectorProvider");
-        return new sun.nio.ch.PollSelectorProvider();
-    }
-
-}
--- a/src/java.base/windows/native/libjava/ProcessHandleImpl_win.c	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.base/windows/native/libjava/ProcessHandleImpl_win.c	Wed Dec 02 09:34:55 2015 -0800
@@ -184,7 +184,14 @@
         // Now walk the snapshot of processes, and
         do {
             if (wpid == pe32.th32ProcessID) {
-                ppid = pe32.th32ParentProcessID;
+                // The parent PID may be stale if that process has exited
+                // and may have been reused.
+                // A valid parent's start time is the same or before the child's
+                jlong ppStartTime = Java_java_lang_ProcessHandleImpl_isAlive0(env,
+                        clazz, pe32.th32ParentProcessID);
+                if (ppStartTime > 0 && ppStartTime <= startTime) {
+                    ppid = pe32.th32ParentProcessID;
+                }
                 break;
             }
         } while (Process32Next(hProcessSnap, &pe32));
--- a/src/java.logging/share/classes/java/util/logging/LogRecord.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.logging/share/classes/java/util/logging/LogRecord.java	Wed Dec 02 09:34:55 2015 -0800
@@ -30,9 +30,8 @@
 import java.util.concurrent.atomic.AtomicLong;
 import java.io.*;
 import java.time.Clock;
+import java.util.function.Predicate;
 
-import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.SharedSecrets;
 import static jdk.internal.logger.SimpleConsoleLogger.skipLoggingFrame;
 
 /**
@@ -661,42 +660,58 @@
     //
     private void inferCaller() {
         needToInferCaller = false;
-        JavaLangAccess access = SharedSecrets.getJavaLangAccess();
-        Throwable throwable = new Throwable();
-        int depth = access.getStackTraceDepth(throwable);
+        // Skip all frames until we have found the first logger frame.
+        Optional<StackWalker.StackFrame> frame = new CallerFinder().get();
+        frame.ifPresent(f -> {
+            setSourceClassName(f.getClassName());
+            setSourceMethodName(f.getMethodName());
+        });
 
-        boolean lookingForLogger = true;
-        for (int ix = 0; ix < depth; ix++) {
-            // Calling getStackTraceElement directly prevents the VM
-            // from paying the cost of building the entire stack frame.
-            StackTraceElement frame =
-                access.getStackTraceElement(throwable, ix);
-            String cname = frame.getClassName();
-            boolean isLoggerImpl = isLoggerImplFrame(cname);
-            if (lookingForLogger) {
-                // Skip all frames until we have found the first logger frame.
-                if (isLoggerImpl) {
-                    lookingForLogger = false;
-                }
-            } else {
-                if (!isLoggerImpl) {
-                    // skip logging/logger infrastructure and reflection calls
-                    if (!skipLoggingFrame(cname)) {
-                       // We've found the relevant frame.
-                       setSourceClassName(cname);
-                       setSourceMethodName(frame.getMethodName());
-                       return;
-                    }
-                }
-            }
-        }
         // We haven't found a suitable frame, so just punt.  This is
         // OK as we are only committed to making a "best effort" here.
     }
 
-    private boolean isLoggerImplFrame(String cname) {
-        // the log record could be created for a platform logger
-        return (cname.equals("java.util.logging.Logger") ||
-                cname.startsWith("sun.util.logging.PlatformLogger"));
+    /*
+     * CallerFinder is a stateful predicate.
+     */
+    static final class CallerFinder implements Predicate<StackWalker.StackFrame> {
+        static final StackWalker WALKER = StackWalker.getInstance();
+
+        /**
+         * Returns StackFrame of the caller's frame.
+         * @return StackFrame of the caller's frame.
+         */
+        Optional<StackWalker.StackFrame> get() {
+            return WALKER.walk((s) -> s.filter(this).findFirst());
+        }
+
+        private boolean lookingForLogger = true;
+        /**
+         * Returns true if we have found the caller's frame, false if the frame
+         * must be skipped.
+         *
+         * @param t The frame info.
+         * @return true if we have found the caller's frame, false if the frame
+         * must be skipped.
+         */
+        @Override
+        public boolean test(StackWalker.StackFrame t) {
+            final String cname = t.getClassName();
+            // We should skip all frames until we have found the logger,
+            // because these frames could be frames introduced by e.g. custom
+            // sub classes of Handler.
+            if (lookingForLogger) {
+                // the log record could be created for a platform logger
+                lookingForLogger = !isLoggerImplFrame(cname);
+                return false;
+            }
+            // skip logging/logger infrastructure and reflection calls
+            return !skipLoggingFrame(cname);
+        }
+
+        private boolean isLoggerImplFrame(String cname) {
+            return (cname.equals("java.util.logging.Logger") ||
+                    cname.startsWith("sun.util.logging.PlatformLogger"));
+        }
     }
 }
--- a/src/java.sql/share/classes/java/sql/Connection.java	Sun Nov 29 20:29:45 2015 -0800
+++ b/src/java.sql/share/classes/java/sql/Connection.java	Wed Dec 02 09:34:55 2015 -0800
@@ -1587,4 +1587,119 @@
     default void endRequest() throws SQLException {
             // Default method takes no action
     }
+
+    /**
+     * Sets and validates the sharding keys for this connection.
+     * @implSpec
+     * The default implementation will throw a
+     * {@code SQLFeatureNotSupportedException}.
+     *
+     * @apiNote
+     * This method validates that the sharding keys are valid for the
+     * {@code Connection}. The timeout value indicates how long the driver
+     * should wait for the {@code Connection} to verify that the sharding key
+     * is valid before {@code setShardingKeyIfValid} returns false.
+     * @param shardingKey the sharding key to be validated against this connection
+     * @param superShardingKey the super sharding key to be validated against this
+     * connection. The super sharding key may be {@code null}.
+     * @param timeout time in seconds before which the validation process is expected to
+     * be completed, otherwise the validation process is aborted. A value of 0 indicates
+     * the validation process will not time out.
+     * @return true if the connection is valid and the sharding keys are valid
+     * and set on this connection; false if the sharding keys are not valid or
+     * the timeout period expires before the operation completes.
+     * @throws SQLException if an error occurs while performing this validation;
+     * the {@code shardingkey} is {@code null}; a {@code superSharedingKey} is specified
+     * without a {@code shardingKey};
+     * this method is called on a closed {@code connection}; or
+     * the {@code timeout} value is less than 0.
+     * @throws SQLFeatureNotSupportedException if the driver does not support sharding
+     * @since 1.9
+     * @see ShardingKey
+     * @see ShardingKeyBuilder
+     */
+    default boolean setShardingKeyIfValid(ShardingKey shardingKey,
+            ShardingKey superShardingKey, int timeout)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("setShardingKeyIfValid not implemented");
+    }
+
+    /**
+     * Sets and validates the sharding key for this connection.
+     * @implSpec
+     * The default implementation will throw a
+     * {@code SQLFeatureNotSupportedException}.
+     * @apiNote
+     * This method validates  that the sharding key is valid for the
+     * {@code Connection}. The timeout value indicates how long the driver
+     * should wait for the {@code Connection} to verify that the sharding key
+     * is valid before {@code setShardingKeyIfValid} returns false.
+     * @param shardingKey the sharding key to be validated against this connection
+     * @param timeout time in seconds before which the validation process is expected to
+     * be completed,else the validation process is aborted. A value of 0 indicates
+     * the validation process will not time out.
+     * @return true if the connection is valid and the sharding key is valid to be
+     * set on this connection; false if the sharding key is not valid or
+     * the timeout period expires before the operation completes.
+     * @throws SQLException if there is an error while performing this validation;
+     * this method is called on a closed {@code connection}; the {@code shardingkey}
+     * is {@code null}; or the {@code timeout} value is less than 0.
+     * @throws SQLFeatureNotSupportedException if the driver does not support sharding
+     * @since 1.9
+     * @see ShardingKey
+     * @see ShardingKeyBuilder
+     */
+    default boolean setShardingKeyIfValid(ShardingKey shardingKey, int timeout)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("setShardingKeyIfValid not implemented");
+    }
+
+    /**
+     * Specifies a shardingKey and superShardingKey to use with this Connection
+     * @implSpec
+     * The default implementation will throw a
+     * {@code SQLFeatureNotSupportedException}.
+     * @apiNote
+     * This method sets the specified sharding keys but does not require a
+     * round trip to the database to validate that the sharding keys are valid
+     * for the {@code Connection}.
+     * @param shardingKey the sharding key to set on this connection.
+     * @param superShardingKey the super sharding key to set on this connection.
+     * The super sharding key may be {@code null}
+     * @throws SQLException if an error  occurs setting the sharding keys;
+     * this method is called on a closed {@code connection};
+     * the {@code shardingkey} is {@code null}; or
+     * a {@code superSharedingKey} is specified without a {@code shardingKey}
+     * @throws SQLFeatureNotSupportedException if the driver does not support sharding
+     * @since 1.9
+     * @see ShardingKey
+     * @see ShardingKeyBuilder
+     */
+    default void setShardingKey(ShardingKey shardingKey, ShardingKey superShardingKey)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("setShardingKey not implemented");
+    }
+
+    /**
+     * Specifies a shardingKey to use with this Connection
+     * @implSpec
+     * The default implementation will throw a
+     * {@code SQLFeatureNotSupportedException}.
+     * @apiNote
+     * This method sets the specified sharding key but does not require a
+     * round trip to the database to validate that the sharding key is valid
+     * for the {@code Connection}.
+     * @param shardingKey the sharding key to set on this connection.
+     * @throws SQLException if an error