changeset 10504:3565c755c49f

Merge
author jlaskey
date Fri, 15 Mar 2013 11:51:02 -0300
parents 46ad8dfabd5f (diff) 364e0871f7a3 (current diff)
children 8c223a4f906a
files makefiles/CreateJars.gmk
diffstat 137 files changed, 4634 insertions(+), 4050 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sat Mar 02 11:06:58 2013 -0400
+++ b/.hgtags	Fri Mar 15 11:51:02 2013 -0300
@@ -199,3 +199,5 @@
 4a67fdb752b7d6329d9be9c28d3f9d6cf7eb9a3c jdk8-b75
 3a263052866137b645ab86498a43693ff5c19e69 jdk8-b76
 b2fc8e31cecc35b76188e821d4c5dc0e0b74ac24 jdk8-b77
+00b7535d743f83eda763c10b3c9ea19ba4b67f55 jdk8-b78
+c933505d75c2a0a671f06d6dac5d2237a9228d2d jdk8-b79
--- a/make/common/Defs-macosx.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/common/Defs-macosx.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -406,10 +406,16 @@
 
 LIB_LOCATION ?= $(LIBDIR)
 
-# Adding these macros will make it an error to link to mac APIs newer than OS version 10.7
-ifeq ($(MACOSX_REQUIRED_VERSION),)
-  MACOSX_REQUIRED_VERSION:=1070
+# Setting these parameters makes it an error to link to macosx APIs that are 
+# newer than the given OS version and makes the linked binaries compatible even
+# if built on a newer version of the OS.
+# The expected format is X.Y.Z
+ifeq ($(MACOSX_VERSION_MIN),)
+  MACOSX_VERSION_MIN=10.7.0
 endif
-MACOSX_OS_VERSION_CFLAGS := -DMAC_OS_X_VERSION_MAX_ALLOWED=$(MACOSX_REQUIRED_VERSION) -DMAC_OS_X_VERSION_MIN_REQUIRED=$(MACOSX_REQUIRED_VERSION)
+# The macro takes the version with no dots, ex: 1070
+MACOSX_OS_VERSION_CFLAGS := -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \
+			    -mmacosx-version-min=$(MACOSX_VERSION_MIN)
 OTHER_CFLAGS += $(MACOSX_OS_VERSION_CFLAGS)
 OTHER_CXXFLAGS += $(MACOSX_OS_VERSION_CFLAGS)
+OTHER_LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
--- a/make/common/Release.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/common/Release.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -348,7 +348,6 @@
 	sun/tools/serialver	\
 	sun/tools/tree		\
 	sun/tools/util		\
-	sun/security/tools/jarsigner/JarBASE64Encoder.class \
 	sun/security/tools/jarsigner/Main.class \
 	sun/security/tools/jarsigner/JarSignerParameters.class \
 	sun/security/tools/jarsigner/Resources.class \
@@ -576,7 +575,6 @@
 	$(ECHO) "sun/tools/serialver/" >> $@
 	$(ECHO) "sun/tools/tree/" >> $@
 	$(ECHO) "sun/tools/util/" >> $@
-	$(ECHO) "sun/security/tools/jarsigner/JarBASE64Encoder.class" >> $@
 	$(ECHO) "sun/security/tools/jarsigner/Main.class" >> $@
 	$(ECHO) "sun/security/tools/jarsigner/JarSignerParameters.class" >> $@
 	$(ECHO) "sun/security/tools/jarsigner/Resources.class" >> $@
--- a/make/common/shared/Compiler-msvc.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/common/shared/Compiler-msvc.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -28,6 +28,7 @@
 #
 
 ifeq ($(PLATFORM), windows)
+ifndef CONFIGURE_BUILD
   CC           = $(COMPILER_PATH)cl
   CPP          = $(COMPILER_PATH)cl
   CXX          = $(COMPILER_PATH)cl
@@ -36,7 +37,7 @@
   LINK         = $(COMPILER_PATH)link
   LINK32       = $(LINK)
   DUMPBIN      = $(COMPILER_PATH)dumpbin.exe
- 
+
   # Fill in unknown values
   COMPILER_NAME=Unknown MSVC Compiler
   COMPILER_VERSION=
@@ -87,6 +88,6 @@
   SHARED_LIBRARY_FLAG = -LD
   # RSC is always same as RC (Not sure who uses this RSC variable)
   RSC = $(RC)
-
+endif 
 endif
 
--- a/make/common/shared/Defs-utils.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/common/shared/Defs-utils.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 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
@@ -82,7 +82,9 @@
   MCS            = $(COMPILER_PATH)mcs
   NM             = $(COMPILER_PATH)nm
   STRIP          = $(COMPILER_PATH)strip
-else
+endif
+
+ifeq ($(PLATFORM),solaris)
   AR             = $(UTILS_CCS_BIN_PATH)ar
   AS             = $(UTILS_CCS_BIN_PATH)as
   LD             = $(UTILS_CCS_BIN_PATH)ld
--- a/make/java/java/FILES_java.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/java/java/FILES_java.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -209,6 +209,7 @@
             sun/util/locale/provider/CalendarDataProviderImpl.java \
             sun/util/locale/provider/CalendarDataUtility.java \
             sun/util/locale/provider/CalendarNameProviderImpl.java \
+            sun/util/locale/provider/CalendarProviderImpl.java \
             sun/util/locale/provider/CollationRules.java \
             sun/util/locale/provider/CollatorProviderImpl.java \
             sun/util/locale/provider/CurrencyNameProviderImpl.java \
@@ -232,6 +233,7 @@
             sun/util/locale/provider/SPILocaleProviderAdapter.java \
             sun/util/locale/provider/TimeZoneNameProviderImpl.java \
             sun/util/locale/provider/TimeZoneNameUtility.java \
+	sun/util/spi/CalendarProvider.java \
     java/util/LocaleISOData.java \
         sun/util/cldr/CLDRLocaleProviderAdapter.java \
     java/util/MissingResourceException.java \
@@ -257,6 +259,7 @@
         sun/util/calendar/ZoneInfoFile.java \
     java/util/TooManyListenersException.java \
     java/util/Comparator.java \
+    java/util/Comparators.java \
     java/util/Collections.java \
     java/util/Iterator.java \
     java/util/ListIterator.java \
--- a/make/java/java/mapfile-vers	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/java/java/mapfile-vers	Fri Mar 15 11:51:02 2013 -0300
@@ -133,6 +133,7 @@
 		Java_java_lang_ClassLoader_00024NativeLibrary_find;
 		Java_java_lang_ClassLoader_00024NativeLibrary_load;
 		Java_java_lang_ClassLoader_00024NativeLibrary_unload;
+		Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib;
 		Java_java_lang_ClassLoader_getCaller; 
 		Java_java_lang_ClassLoader_registerNatives;
 		Java_java_lang_Compiler_registerNatives;
--- a/make/java/nio/Makefile	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/java/nio/Makefile	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 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
@@ -384,9 +384,7 @@
 ifeq ($(PLATFORM),windows)
   OTHER_LDLIBS += $(JVMLIB) ws2_32.lib \
      -libpath:$(LIBDIR) java.lib \
-     $(OBJDIR)/../../../../sun/java.net/net/$(OBJDIRNAME)/net.lib \
-     $(OBJDIR)/../../../java.lang/java/$(OBJDIRNAME)/io_util.obj \
-     $(OBJDIR)/../../../java.lang/java/$(OBJDIRNAME)/FileDescriptor_md.obj
+     $(OBJDIR)/../../../../sun/java.net/net/$(OBJDIRNAME)/net.lib
 endif
 ifeq ($(PLATFORM), linux)
 OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread $(LIBDL)
--- a/make/java/zip/Makefile	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/java/zip/Makefile	Fri Mar 15 11:51:02 2013 -0300
@@ -68,6 +68,16 @@
     FILES_reorder += reorder-$(ARCH)
   endif
 endif
+
+#
+# Use mapfile unconditionally (even with fastdebug).
+# JDK's internal zlib is incompatible with stock zlib, because the
+# size of struct z_stream has been changed, so internal zlib
+# implementation must not be allowed to leak outside of libzip.so,
+# else you get hard to debug failures with fastdebug jdk when user
+# native code includes stock zlib.
+#
+FILES_m = mapfile-vers
 include $(BUILDDIR)/common/Mapfile-vers.gmk
 include $(BUILDDIR)/common/Library.gmk
 
--- a/make/sun/lwawt/FILES_export_macosx.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/make/sun/lwawt/FILES_export_macosx.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -122,7 +122,6 @@
         sun/lwawt/macosx/CTextPipe.java \
         sun/lwawt/macosx/CDesktopPeer.java \
         sun/java2d/CRenderer.java \
-        sun/lwawt/macosx/EventDispatchAccess.java \
         sun/lwawt/macosx/NSPrintInfo.java \
         sun/lwawt/macosx/CAccessibility.java \
         sun/lwawt/macosx/CAccessible.java \
--- a/makefiles/CompileNativeLibraries.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/CompileNativeLibraries.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -1957,8 +1957,6 @@
 				        -lsendfile -ljava -lnet -lc,\
 		LDFLAGS_SUFFIX_windows:=jvm.lib ws2_32.lib $(WIN_JAVA_LIB) \
 					$(JDK_OUTPUTDIR)/objs/libnet/net.lib \
-                                        $(JDK_OUTPUTDIR)/objs/libjava/io_util.obj \
-		                        $(JDK_OUTPUTDIR)/objs/libjava/FileDescriptor_md.obj \
 					advapi32.lib,\
 		LDFLAGS_SUFFIX_macosx:=-ljava -lnet -pthread -framework CoreFoundation,\
 		LDFLAGS_SUFFIX:=,\
--- a/makefiles/CreateJars.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/CreateJars.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -213,28 +213,28 @@
 	org/relaxng/datatype \
 	sun/awt/HKSCS.class \
 	sun/awt/motif/X11GB2312.class \
-	sun/awt/motif/X11GB2312\$$Decoder.class \
-	sun/awt/motif/X11GB2312\$$Encoder.class \
+	sun/awt/motif/X11GB2312\$$$$Decoder.class \
+	sun/awt/motif/X11GB2312\$$$$Encoder.class \
 	sun/awt/motif/X11GBK.class \
-	sun/awt/motif/X11GBK\$$Encoder.class \
+	sun/awt/motif/X11GBK\$$$$Encoder.class \
 	sun/awt/motif/X11KSC5601.class \
-	sun/awt/motif/X11KSC5601\$$Decoder.class \
-	sun/awt/motif/X11KSC5601\$$Encoder.class \
+	sun/awt/motif/X11KSC5601\$$$$Decoder.class \
+	sun/awt/motif/X11KSC5601\$$$$Encoder.class \
 	sun/jvmstat \
 	sun/net/spi/nameservice/dns \
 	sun/nio/cs/ext \
 	sun/rmi/rmic \
 	sun/security/ec/ECDHKeyAgreement.class \
 	sun/security/ec/ECDSASignature.class \
-	sun/security/ec/ECDSASignature\$$Raw.class \
-	sun/security/ec/ECDSASignature\$$SHA1.class \
-	sun/security/ec/ECDSASignature\$$SHA224.class \
-	sun/security/ec/ECDSASignature\$$SHA256.class \
-	sun/security/ec/ECDSASignature\$$SHA384.class \
-	sun/security/ec/ECDSASignature\$$SHA512.class \
+	sun/security/ec/ECDSASignature\$$$$Raw.class \
+	sun/security/ec/ECDSASignature\$$$$SHA1.class \
+	sun/security/ec/ECDSASignature\$$$$SHA224.class \
+	sun/security/ec/ECDSASignature\$$$$SHA256.class \
+	sun/security/ec/ECDSASignature\$$$$SHA384.class \
+	sun/security/ec/ECDSASignature\$$$$SHA512.class \
 	sun/security/ec/ECKeyFactory.class \
 	sun/security/ec/ECKeyPairGenerator.class \
-	sun/security/ec/SunEC\$$1.class \
+	sun/security/ec/SunEC\$$$$1.class \
 	sun/security/ec/SunEC.class \
 	sun/security/ec/SunECEntries.class \
 	sun/security/internal \
@@ -357,23 +357,25 @@
 
 
 # Support for removing the addPropertyChangeListener and removePropertyChangeListener
-# methods from classes that only go into the profile builds. For now the Pack200.Packer
-# and Packer200.Unpacker classes have special handling because of the $ in the file
-# name.
+# methods from classes that only go into the profile builds. 
 BEANLESS_CLASSES = $(IMAGES_OUTPUTDIR)/beanless
 
+# When there are $ characters in filenames we have some very subtle interactions between
+# make expansion and shell expansion. In this particular case $< will contain a single $ while
+# $@ will contain \$. So we have to pass $< in single-quotes to avoid shell expansion
 $(BEANLESS_CLASSES)/%: $(JDK_OUTPUTDIR)/classes/%
 	$(MKDIR) -p $(@D)
-	$(TOOL_REMOVEMETHODS) $< $@ addPropertyChangeListener removePropertyChangeListener
+	$(TOOL_REMOVEMETHODS) '$<' $@ addPropertyChangeListener removePropertyChangeListener
 
 CLASSES_TO_DEBEAN = \
     java/util/logging/LogManager.class \
+    java/util/jar/Pack200\$$Packer.class \
+    java/util/jar/Pack200\$$Unpacker.class \
     com/sun/java/util/jar/pack/PackerImpl.class \
-    com/sun/java/util/jar/pack/UnpackerImpl.class
+    com/sun/java/util/jar/pack/UnpackerImpl.class 
 
-BEANLESS_CLASSES_TARGETS =
 ifneq ($(PROFILE),)
-    BEANLESS_CLASSES_TARGETS := $(foreach c, $(CLASSES_TO_DEBEAN), $(BEANLESS_CLASSES)/$c)
+    BEANLESS_CLASSES_TARGETS := $(addprefix $(BEANLESS_CLASSES)/, $(CLASSES_TO_DEBEAN))
 endif
 
 
@@ -400,13 +402,8 @@
 	      $(ECHO)  Updating rt.jar $(PROFILE) && \
 	      $(CD) $(patsubst %$(VERSION_CLASS_PATH),%,$(CLASS_FILE)) && \
                 $(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(VERSION_CLASS_PATH); \
-	      $(MKDIR) -p $(BEANLESS_CLASSES)/java/util/jar; \
-	      $(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Packer.class \
-		$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Packer.class addPropertyChangeListener removePropertyChangeListener; \
-	      $(TOOL_REMOVEMETHODS) $(JDK_OUTPUTDIR)/classes/java/util/jar/Pack200\$$Unpacker.class \
-		$(BEANLESS_CLASSES)/java/util/jar/Pack200\$$Unpacker.class addPropertyChangeListener removePropertyChangeListener; \
 	      $(CD) $(BEANLESS_CLASSES) && \
-		$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(CLASSES_TO_DEBEAN) java/util/jar/* ; \
+		$(JAR) $(RT_JAR_UPDATE_OPTIONS) $@.tmp $(CLASSES_TO_DEBEAN); \
             fi
 	$(MV) $@.tmp $@
 
--- a/makefiles/Images.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/Images.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -59,7 +59,7 @@
 	$(ECHO) $(LOG_INFO) Processing $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 	$(MKDIR) -p $(@D)
 	$(RM) $@
-	$(SED) 's/$$//g' $< > $@
+	LC_ALL=C $(SED) 's/$$//g' $< > $@
 	$(CHMOD) 444 $@
 endef
 
--- a/makefiles/ProfileNames.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/ProfileNames.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -30,9 +30,8 @@
 
 PROFILE_NAMES := compact1 compact2 compact3
 
-# The include files use 1,2,3,4 for simplicity and conciseness. Internally we
-# use profile_1, profile_2 and profile_3. Note that profile_4 is a full JRE so
-# we never have to use it directly.
+# The include files use 1,2,3 for simplicity and conciseness. Internally we
+# use profile_1, profile_2 and profile_3. 
 
 ALL_PROFILES := profile_1 profile_2 profile_3
 
--- a/makefiles/Profiles.gmk	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/Profiles.gmk	Fri Mar 15 11:51:02 2013 -0300
@@ -74,11 +74,11 @@
     $(PROFILE_2_JARS)
 
 ifdef OPENJDK
-  PROFILE_4_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(PROFILE_4_JRE_JAR_FILES))
+  FULL_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(FULL_JRE_JAR_FILES))
 endif
 
-PROFILE_4_JARS := \
-    $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_4_JRE_JAR_FILES)) \
+FULL_JRE_JARS := \
+    $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(FULL_JRE_JAR_FILES)) \
     $(PROFILE_3_JARS)
 
 # The full set of "jar" files needed for a complete JDK (ct.sym and src.zip
@@ -86,7 +86,7 @@
 # Note we need to add back the regular form of all the custom profile jars e.g.
 # rt.jar and resources.jar
 
-ALL_JARS := $(PROFILE_4_JARS) \
+ALL_JARS := $(FULL_JRE_JARS) \
         $(IMAGES_OUTPUTDIR)/lib/rt.jar \
         $(IMAGES_OUTPUTDIR)/lib/resources.jar \
         $(IMAGES_OUTPUTDIR)/lib/jconsole.jar \
@@ -140,7 +140,7 @@
    $(PROFILE_1_JRE_BIN_FILES) \
    $(PROFILE_2_JRE_BIN_FILES) \
    $(PROFILE_3_JRE_BIN_FILES) \
-   $(PROFILE_4_JRE_BIN_FILES) 
+   $(FULL_JRE_BIN_FILES) 
 
 NOT_JRE_BIN_FILES := $(filter-out $(ALL_JRE_BIN_FILES), $(NEW_ALL_BIN_LIST))
 
@@ -149,18 +149,18 @@
     NOT_JRE_BIN_FILES += \
         $(PROFILE_2_JRE_BIN_FILES) \
         $(PROFILE_3_JRE_BIN_FILES) \
-        $(PROFILE_4_JRE_BIN_FILES) 
+        $(FULL_JRE_BIN_FILES) 
 endif
 
 ifeq ($(PROFILE), profile_2)
     NOT_JRE_BIN_FILES += \
         $(PROFILE_3_JRE_BIN_FILES) \
-        $(PROFILE_4_JRE_BIN_FILES) 
+        $(FULL_JRE_BIN_FILES) 
 endif
 
 ifeq ($(PROFILE), profile_3)
     NOT_JRE_BIN_FILES += \
-        $(PROFILE_4_JRE_BIN_FILES) 
+        $(FULL_JRE_BIN_FILES) 
 endif
 
 NOT_JRE_BIN_FILES := $(addprefix $(JDK_OUTPUTDIR)/bin/, $(NOT_JRE_BIN_FILES))
@@ -173,7 +173,7 @@
    $(PROFILE_1_JRE_LIB_FILES) \
    $(PROFILE_2_JRE_LIB_FILES) \
    $(PROFILE_3_JRE_LIB_FILES) \
-   $(PROFILE_4_JRE_LIB_FILES) 
+   $(FULL_JRE_LIB_FILES) 
 
 NOT_JRE_LIB_FILES := $(filter-out $(ALL_JRE_LIB_FILES), $(NEW_ALL_LIB_LIST))
 
@@ -189,18 +189,18 @@
     NOT_JRE_LIB_FILES += \
         $(PROFILE_2_JRE_LIB_FILES) \
         $(PROFILE_3_JRE_LIB_FILES) \
-        $(PROFILE_4_JRE_LIB_FILES) 
+        $(FULL_JRE_LIB_FILES) 
 endif
 
 ifeq ($(PROFILE), profile_2)
     NOT_JRE_LIB_FILES += \
         $(PROFILE_3_JRE_LIB_FILES) \
-        $(PROFILE_4_JRE_LIB_FILES) 
+        $(FULL_JRE_LIB_FILES) 
 endif
 
 ifeq ($(PROFILE), profile_3)
     NOT_JRE_LIB_FILES += \
-        $(PROFILE_4_JRE_LIB_FILES) 
+        $(FULL_JRE_LIB_FILES) 
 endif
 
 # Exclude the custom jar files as these will be added back via a special rule
@@ -279,13 +279,13 @@
 
 ifeq ($(PROFILE), profile_1)
   RT_JAR_EXCLUDES += \
-    $(PROFILE_1_RTJAR_EXCLUDE_TYPES) \
+    $(call class_list, $(PROFILE_1_RTJAR_EXCLUDE_TYPES)) \
     $(PROFILE_2_RTJAR_INCLUDE_PACKAGES) \
     $(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \
     $(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
     $(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
-    $(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
-    $(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
+    $(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
   RT_JAR_INCLUDE_TYPES := \
 	$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES))
   PROFILE_INCLUDE_METAINF_SERVICES := \
@@ -293,11 +293,11 @@
 endif
 ifeq ($(PROFILE), profile_2)
   RT_JAR_EXCLUDES += \
-    $(PROFILE_2_RTJAR_EXCLUDE_TYPES) \
+    $(call class_list, $(PROFILE_2_RTJAR_EXCLUDE_TYPES)) \
     $(PROFILE_3_RTJAR_INCLUDE_PACKAGES) \
     $(call class_list, $(PROFILE_3_RTJAR_INCLUDE_TYPES)) \
-    $(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
-    $(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
+    $(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
   RT_JAR_INCLUDE_TYPES := \
 	$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
 	$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES))
@@ -307,9 +307,9 @@
 endif
 ifeq ($(PROFILE), profile_3)
   RT_JAR_EXCLUDES += \
-    $(PROFILE_3_RTJAR_EXCLUDE_TYPES) \
-    $(PROFILE_4_RTJAR_INCLUDE_PACKAGES) \
-    $(call class_list, $(PROFILE_4_RTJAR_INCLUDE_TYPES))
+    $(call class_list, $(PROFILE_3_RTJAR_EXCLUDE_TYPES)) \
+    $(FULL_JRE_RTJAR_INCLUDE_PACKAGES) \
+    $(call class_list, $(FULL_JRE_RTJAR_INCLUDE_TYPES))
   RT_JAR_INCLUDE_TYPES := \
 	$(call class_list, $(PROFILE_1_RTJAR_INCLUDE_TYPES)) \
 	$(call class_list, $(PROFILE_2_RTJAR_INCLUDE_TYPES)) \
--- a/makefiles/mapfiles/libjava/mapfile-vers	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/mapfiles/libjava/mapfile-vers	Fri Mar 15 11:51:02 2013 -0300
@@ -133,6 +133,7 @@
 		Java_java_lang_ClassLoader_00024NativeLibrary_find;
 		Java_java_lang_ClassLoader_00024NativeLibrary_load;
 		Java_java_lang_ClassLoader_00024NativeLibrary_unload;
+		Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib;
 		Java_java_lang_ClassLoader_getCaller; 
 		Java_java_lang_ClassLoader_registerNatives;
 		Java_java_lang_Compiler_registerNatives;
--- a/makefiles/profile-includes.txt	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/profile-includes.txt	Fri Mar 15 11:51:02 2013 -0300
@@ -142,7 +142,7 @@
     management-agent.jar
 
 
-PROFILE_4_JRE_BIN_FILES := \
+FULL_JRE_BIN_FILES := \
     orbd$(EXE_SUFFIX) \
     pack200$(EXE_SUFFIX) \
     policytool$(EXE_SUFFIX) \
@@ -150,7 +150,7 @@
     tnameserv$(EXE_SUFFIX) \
     unpack200$(EXE_SUFFIX)
 
-PROFILE_4_JRE_LIB_FILES := \
+FULL_JRE_LIB_FILES := \
     $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt$(SHARED_LIBRARY_SUFFIX) \
     $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX) \
     $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)awt_xawt$(SHARED_LIBRARY_SUFFIX) \
@@ -222,7 +222,7 @@
     servicetag/jdk_header.png \
     sound.properties
 
-PROFILE_4_JRE_OTHER_FILES := \
+FULL_JRE_OTHER_FILES := \
     man/ja_JP.UTF-8/man1/java.1 \
     man/ja_JP.UTF-8/man1/javaws.1 \
     man/ja_JP.UTF-8/man1/keytool.1 \
@@ -246,7 +246,7 @@
     man/man1/tnameserv.1 \
     man/man1/unpack200.1
 
-PROFILE_4_JRE_JAR_FILES := \
+FULL_JRE_JAR_FILES := \
     alt-rt.jar \
     charsets.jar \
     ext/cldrdata.jar \
--- a/makefiles/profile-rtjar-includes.txt	Sat Mar 02 11:06:58 2013 -0400
+++ b/makefiles/profile-rtjar-includes.txt	Fri Mar 15 11:51:02 2013 -0300
@@ -22,119 +22,55 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
+
+# Included or excluded types must take one of two forms
+# - *.class   to indicate all classes; or else
+# - a full single type name e.g.
+#      com/sun/security/auth/callback/DialogCallbackHandler$$1.class
+# You can not use arbitrary wildcards like DialogCallbackHandler*.class.
+#
+# Notes:
+#  -  Nested types must use $$ in place of $ as $ is the make meta-character
+#  -  If a package is not listed in any profile's inclusion list then it will
+#     not appear in any profile. But if a package is also missing from the
+#     full JRE's inclusion list then it will still be part of the full JRE.
+#     This is because the full JRE's inclusion lists are only used to define
+#     the exclusion lists for profiles; they are not used to define the full
+#     JRE contents - that is still done with the pre-profile legacy mechanism
+#     (all packagesthat can be found, less those not intended for rt.jar).
+#     This was done to minimize the impact of profiles on the regular
+#     non-profile build.
+#
 PROFILE_1_RTJAR_INCLUDE_PACKAGES := \
     com/sun/demo/jvmti/hprof \
     com/sun/java/util/jar/pack \
     com/sun/net/ssl \
-    com/sun/net/ssl/internal/www/protocol/https \
     com/sun/nio/file \
     com/sun/security/cert/internal/x509 \
     java/io \
     java/lang \
-    java/lang/annotation \
-    java/lang/invoke \
-    java/lang/ref \
-    java/lang/reflect \
     java/math \
     java/net \
     java/nio \
-    java/nio/channels \
-    java/nio/channels/spi \
-    java/nio/charset \
-    java/nio/charset/spi \
-    java/nio/file \
-    java/nio/file/attribute \
-    java/nio/file/spi \
     java/security \
-    java/security/cert \
-    java/security/interfaces \
-    java/security/spec \
     java/text \
-    java/text/spi \
     java/time \
     java/util \
-    java/util/concurrent \
-    java/util/concurrent/atomic \
-    java/util/concurrent/locks \
-    java/util/function \
-    java/util/jar \
-    java/util/logging \
-    java/util/regex \
-    java/util/spi \
-    java/util/zip \
     javax/net \
-    javax/net/ssl \
-    javax/security/auth \
-    javax/security/auth/callback \
-    javax/security/auth/login \
-    javax/security/auth/spi \
-    javax/security/auth/x500 \
-    javax/security/cert \
-    jdk/internal \
+    javax/security \
+    jdk \
     sun/invoke \
-    sun/invoke/anon \
-    sun/invoke/empty \
-    sun/invoke/util \
     sun/launcher \
-    sun/launcher/resources \
     sun/misc \
-    sun/misc/resources \
     sun/net/ \
-    sun/net/idn \
-    sun/net/sdp \
-    sun/net/spi \
-    sun/net/spi/nameservice \
-    sun/net/util \
-    sun/net/www \
-    sun/net/www/http \
-    sun/net/www/protocol/file \
-    sun/net/www/protocol/http/ \
-    sun/net/www/protocol/http/logging \
-    sun/net/www/protocol/https \
-    sun/net/www/protocol/jar \
     sun/nio \
-    sun/nio/ch \
-    sun/nio/cs \
-    sun/nio/fs \
     sun/reflect \
-    sun/reflect/annotation \
-    sun/reflect/generics/factory \
-    sun/reflect/generics/parser \
-    sun/reflect/generics/reflectiveObjects \
-    sun/reflect/generics/repository \
-    sun/reflect/generics/scope \
-    sun/reflect/generics/tree \
-    sun/reflect/generics/visitor \
-    sun/reflect/misc \
-    sun/security/action \
-    sun/security/ec \
-    sun/security/jca \
-    sun/security/pkcs \
-    sun/security/pkcs10 \
-    sun/security/pkcs12 \
-    sun/security/provider \
-    sun/security/provider/certpath \
-    sun/security/provider/certpath/ssl \
-    sun/security/rsa \
-    sun/security/timestamp \
-    sun/security/tools \
-    sun/security/tools/keytool \
-    sun/security/util \
-    sun/security/validator \
-    sun/security/x509 \
+    sun/security \
     sun/text \
-    sun/text/bidi \
-    sun/text/normalizer \
-    sun/text/resources \
     sun/usagetracker \
-    sun/util \
-    sun/util/calendar \
-    sun/util/locale \
-    sun/util/logging \
-    sun/util/logging/resources \
-    sun/util/resources
+    sun/util
 
-PROFILE_1_RTJAR_INCLUDE_TYPES :=
+PROFILE_1_RTJAR_INCLUDE_TYPES := 
 
 PROFILE_1_RTJAR_EXCLUDE_TYPES := 
 
@@ -144,139 +80,19 @@
 PROFILE_2_RTJAR_INCLUDE_PACKAGES := \
     com/sun/java_cup/internal/runtime \
     com/sun/net/httpserver \
-    com/sun/net/httpserver/spi \
-    com/sun/org/apache/bcel/internal \
-    com/sun/org/apache/bcel/internal/classfile \
-    com/sun/org/apache/bcel/internal/generic \
-    com/sun/org/apache/bcel/internal/util \
-    com/sun/org/apache/regexp/internal \
-    com/sun/org/apache/xalan/internal \
-    com/sun/org/apache/xalan/internal/extensions \
-    com/sun/org/apache/xalan/internal/lib \
-    com/sun/org/apache/xalan/internal/res \
-    com/sun/org/apache/xalan/internal/templates \
-    com/sun/org/apache/xalan/internal/utils \
-    com/sun/org/apache/xalan/internal/xslt \
-    com/sun/org/apache/xalan/internal/xsltc \
-    com/sun/org/apache/xalan/internal/xsltc/cmdline \
-    com/sun/org/apache/xalan/internal/xsltc/cmdline/getopt \
-    com/sun/org/apache/xalan/internal/xsltc/compiler \
-    com/sun/org/apache/xalan/internal/xsltc/compiler/util \
-    com/sun/org/apache/xalan/internal/xsltc/dom \
-    com/sun/org/apache/xalan/internal/xsltc/runtime \
-    com/sun/org/apache/xalan/internal/xsltc/runtime/output \
-    com/sun/org/apache/xalan/internal/xsltc/trax \
-    com/sun/org/apache/xalan/internal/xsltc/util \
-    com/sun/org/apache/xerces/internal/dom \
-    com/sun/org/apache/xerces/internal/dom/events \
-    com/sun/org/apache/xerces/internal/impl \
-    com/sun/org/apache/xerces/internal/impl/dtd \
-    com/sun/org/apache/xerces/internal/impl/dtd/models \
-    com/sun/org/apache/xerces/internal/impl/dv \
-    com/sun/org/apache/xerces/internal/impl/dv/dtd \
-    com/sun/org/apache/xerces/internal/impl/dv/util \
-    com/sun/org/apache/xerces/internal/impl/dv/xs \
-    com/sun/org/apache/xerces/internal/impl/io \
-    com/sun/org/apache/xerces/internal/impl/msg \
-    com/sun/org/apache/xerces/internal/impl/validation \
-    com/sun/org/apache/xerces/internal/impl/xpath \
-    com/sun/org/apache/xerces/internal/impl/xpath/regex \
-    com/sun/org/apache/xerces/internal/impl/xs \
-    com/sun/org/apache/xerces/internal/impl/xs/identity \
-    com/sun/org/apache/xerces/internal/impl/xs/models \
-    com/sun/org/apache/xerces/internal/impl/xs/opti \
-    com/sun/org/apache/xerces/internal/impl/xs/traversers \
-    com/sun/org/apache/xerces/internal/impl/xs/util \
-    com/sun/org/apache/xerces/internal/jaxp \
-    com/sun/org/apache/xerces/internal/jaxp/datatype \
-    com/sun/org/apache/xerces/internal/jaxp/validation \
-    com/sun/org/apache/xerces/internal/parsers \
-    com/sun/org/apache/xerces/internal/util \
-    com/sun/org/apache/xerces/internal/utils \
-    com/sun/org/apache/xerces/internal/xinclude \
-    com/sun/org/apache/xerces/internal/xni \
-    com/sun/org/apache/xerces/internal/xni/grammars \
-    com/sun/org/apache/xerces/internal/xni/parser \
-    com/sun/org/apache/xerces/internal/xpointer \
-    com/sun/org/apache/xerces/internal/xs \
-    com/sun/org/apache/xerces/internal/xs/datatypes \
-    com/sun/org/apache/xml/internal/dtm \
-    com/sun/org/apache/xml/internal/dtm/ref \
-    com/sun/org/apache/xml/internal/dtm/ref/dom2dtm \
-    com/sun/org/apache/xml/internal/dtm/ref/sax2dtm \
-    com/sun/org/apache/xml/internal/res \
-    com/sun/org/apache/xml/internal/resolver \
-    com/sun/org/apache/xml/internal/resolver/helpers \
-    com/sun/org/apache/xml/internal/resolver/readers \
-    com/sun/org/apache/xml/internal/resolver/tools \
-    com/sun/org/apache/xml/internal/serialize \
-    com/sun/org/apache/xml/internal/serializer \
-    com/sun/org/apache/xml/internal/serializer/utils \
-    com/sun/org/apache/xml/internal/utils \
-    com/sun/org/apache/xml/internal/utils/res \
-    com/sun/org/apache/xpath/internal \
-    com/sun/org/apache/xpath/internal/axes \
-    com/sun/org/apache/xpath/internal/compiler \
-    com/sun/org/apache/xpath/internal/domapi \
-    com/sun/org/apache/xpath/internal/functions \
-    com/sun/org/apache/xpath/internal/jaxp \
-    com/sun/org/apache/xpath/internal/objects \
-    com/sun/org/apache/xpath/internal/operations \
-    com/sun/org/apache/xpath/internal/patterns \
-    com/sun/org/apache/xpath/internal/res \
+    com/sun/org/apache \
     com/sun/rmi/rmid \
-    com/sun/xml/internal/stream/ \
-    com/sun/xml/internal/stream/dtd \
-    com/sun/xml/internal/stream/dtd/nonvalidating \
-    com/sun/xml/internal/stream/events \
-    com/sun/xml/internal/stream/util \
-    com/sun/xml/internal/stream/writers \
+    com/sun/xml/internal/stream \
     java/rmi \
-    java/rmi/activation \
-    java/rmi/dgc \
-    java/rmi/registry \
-    java/rmi/server \
     java/sql \
     javax/rmi/ssl \
     javax/sql \
     javax/transaction \
-    javax/transaction/xa \
     javax/xml \
-    javax/xml/datatype \
-    javax/xml/namespace \
-    javax/xml/parsers \
-    javax/xml/stream \
-    javax/xml/stream/events \
-    javax/xml/stream/util \
-    javax/xml/transform \
-    javax/xml/transform/dom \
-    javax/xml/transform/sax \
-    javax/xml/transform/stax \
-    javax/xml/transform/stream \
-    javax/xml/validation \
-    javax/xml/xpath \
-    org/w3c/dom \
-    org/w3c/dom/bootstrap \
-    org/w3c/dom/css \
-    org/w3c/dom/events \
-    org/w3c/dom/html \
-    org/w3c/dom/ls \
-    org/w3c/dom/ranges \
-    org/w3c/dom/stylesheets \
-    org/w3c/dom/traversal \
-    org/w3c/dom/views \
-    org/w3c/dom/xpath \
+    org/w3c \
     org/xml/sax \
-    org/xml/sax/ext \
-    org/xml/sax/helpers \
     sun/net/httpserver \
-    sun/rmi/log \
-    sun/rmi/registry \
-    sun/rmi/runtime \
-    sun/rmi/server \
-    sun/rmi/transport \
-    sun/rmi/transport/proxy \
-    sun/rmi/transport/tcp \
+    sun/rmi \
     sun/util/xml
 
 PROFILE_2_RTJAR_INCLUDE_TYPES := 
@@ -284,287 +100,83 @@
 PROFILE_2_RTJAR_EXCLUDE_TYPES := 
 
 PROFILE_2_INCLUDE_METAINF_SERVICES := \
-    META-INF/services/sun.util.spi.XmlPropertiesProvider
+    META-INF/services/sun.util.spi.XmlPropertiesProvider 
 
 
 PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
-    com/sun/jmx/defaults \
-    com/sun/jmx/interceptor \
-    com/sun/jmx/mbeanserver \
-    com/sun/jmx/remote/internal \
-    com/sun/jmx/remote/protocol/rmi \
-    com/sun/jmx/remote/security \
-    com/sun/jmx/remote/util \
-    com/sun/jmx/snmp \
-    com/sun/jmx/snmp/IPAcl \
-    com/sun/jmx/snmp/agent \
-    com/sun/jmx/snmp/daemon \
-    com/sun/jmx/snmp/defaults \
-    com/sun/jmx/snmp/internal \
-    com/sun/jmx/snmp/mpm \
-    com/sun/jmx/snmp/tasks \
-    com/sun/jmx/trace \
-    com/sun/jndi/dns \
-    com/sun/jndi/ldap \
-    com/sun/jndi/ldap/ext \
-    com/sun/jndi/ldap/pool \
-    com/sun/jndi/ldap/sasl \
-    com/sun/jndi/rmi/registry \
-    com/sun/jndi/toolkit/ctx \
-    com/sun/jndi/toolkit/dir \
-    com/sun/jndi/toolkit/url \
-    com/sun/jndi/url/dns \
-    com/sun/jndi/url/ldap \
-    com/sun/jndi/url/ldaps \
-    com/sun/jndi/url/rmi \
+    com/sun/jmx \
+    com/sun/jndi \
     com/sun/management \
-    com/sun/management/jmx \
     com/sun/naming/internal \
     com/sun/nio/sctp \
     com/sun/org/apache/xml/internal/security \
-    com/sun/org/apache/xml/internal/security/algorithms \
-    com/sun/org/apache/xml/internal/security/algorithms/implementations \
-    com/sun/org/apache/xml/internal/security/c14n \
-    com/sun/org/apache/xml/internal/security/c14n/helper \
-    com/sun/org/apache/xml/internal/security/c14n/implementations \
-    com/sun/org/apache/xml/internal/security/encryption \
-    com/sun/org/apache/xml/internal/security/exceptions \
-    com/sun/org/apache/xml/internal/security/keys \
-    com/sun/org/apache/xml/internal/security/keys/content \
-    com/sun/org/apache/xml/internal/security/keys/content/keyvalues \
-    com/sun/org/apache/xml/internal/security/keys/content/x509 \
-    com/sun/org/apache/xml/internal/security/keys/keyresolver \
-    com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations \
-    com/sun/org/apache/xml/internal/security/keys/storage \
-    com/sun/org/apache/xml/internal/security/keys/storage/implementations \
-    com/sun/org/apache/xml/internal/security/signature \
-    com/sun/org/apache/xml/internal/security/transforms \
-    com/sun/org/apache/xml/internal/security/transforms/implementations \
-    com/sun/org/apache/xml/internal/security/transforms/params \
-    com/sun/org/apache/xml/internal/security/utils \
-    com/sun/org/apache/xml/internal/security/utils/resolver \
-    com/sun/org/apache/xml/internal/security/utils/resolver/implementations \
     com/sun/rowset \
-    com/sun/rowset/internal \
-    com/sun/rowset/providers \
-    com/sun/script/javascript \
-    com/sun/script/util \
+    com/sun/script \
     com/sun/security/auth \
-    com/sun/security/auth/callback \
-    com/sun/security/auth/login \
-    com/sun/security/auth/module \
     com/sun/security/jgss \
     com/sun/security/ntlm \
     com/sun/security/sasl \
-    com/sun/security/sasl/digest \
-    com/sun/security/sasl/gsskerb \
-    com/sun/security/sasl/ntlm \
-    com/sun/security/sasl/util \
     com/sun/tracing \
-    com/sun/tracing/dtrace \
     java/lang/instrument \
     java/lang/management \
     java/security/acl \
     java/util/prefs \
     javax/annotation/processing \
     javax/lang/model \
-    javax/lang/model/element \
-    javax/lang/model/type \
-    javax/lang/model/util \
     javax/management \
-    javax/management/loading \
-    javax/management/modelmbean \
-    javax/management/monitor \
-    javax/management/openmbean \
-    javax/management/relation \
-    javax/management/remote \
-    javax/management/remote/rmi \
-    javax/management/timer \
     javax/naming \
-    javax/naming/directory \
-    javax/naming/event \
-    javax/naming/ldap \
-    javax/naming/spi \
     javax/script \
     javax/security/auth/kerberos \
     javax/security/sasl \
     javax/smartcardio \
     javax/sql/rowset \
-    javax/sql/rowset/serial \
-    javax/sql/rowset/spi \
     javax/tools \
-    javax/tools/annotation \
     javax/xml/crypto \
-    javax/xml/crypto/dom \
-    javax/xml/crypto/dsig \
-    javax/xml/crypto/dsig/dom \
-    javax/xml/crypto/dsig/keyinfo \
-    javax/xml/crypto/dsig/spec \
     org/ietf/jgss \
-    org/jcp/xml/dsig/internal \
-    org/jcp/xml/dsig/internal/dom \
+    org/jcp/xml \
     sun/instrument \
     sun/management \
-    sun/management/counter \
-    sun/management/counter/perf \
-    sun/management/jmxremote \
-    sun/management/resources \
-    sun/management/snmp \
-    sun/management/snmp/jvminstr \
-    sun/management/snmp/jvmmib \
-    sun/management/snmp/util \
     sun/net/dns \
     sun/net/www/protocol/http/ntlm \
     sun/net/www/protocol/http/spnego \
     sun/nio/ch/sctp \
-    sun/org/mozilla/classfile/internal \
-    sun/org/mozilla/javascript/internal \
-    sun/org/mozilla/javascript/internal/annotations \
-    sun/org/mozilla/javascript/internal/ast \
-    sun/org/mozilla/javascript/internal/debug \
-    sun/org/mozilla/javascript/internal/jdk13 \
-    sun/org/mozilla/javascript/internal/jdk15 \
-    sun/org/mozilla/javascript/internal/json \
-    sun/org/mozilla/javascript/internal/optimizer \
-    sun/org/mozilla/javascript/internal/regexp \
-    sun/org/mozilla/javascript/internal/serialize \
-    sun/org/mozilla/javascript/internal/xml \
-    sun/org/mozilla/javascript/internal/xmlimpl \
+    sun/org/mozilla \
     sun/security/acl \
     sun/security/jgss \
-    sun/security/jgss/krb5 \
-    sun/security/jgss/spi \
-    sun/security/jgss/spnego \
-    sun/security/jgss/wrapper \
     sun/security/krb5 \
-    sun/security/krb5/internal \
-    sun/security/krb5/internal/ccache \
-    sun/security/krb5/internal/crypto \
-    sun/security/krb5/internal/crypto/dk \
-    sun/security/krb5/internal/ktab \
-    sun/security/krb5/internal/rcache \
-    sun/security/krb5/internal/util \
     sun/security/provider/certpath/ldap \
     sun/security/smartcardio \
-    sun/tracing \
-    sun/tracing/dtrace
+    sun/tracing
 
-PROFILE_3_RTJAR_INCLUDE_TYPES :=
+PROFILE_3_RTJAR_INCLUDE_TYPES := 
 
 PROFILE_3_RTJAR_EXCLUDE_TYPES := \
+    com/sun/security/auth/callback/DialogCallbackHandler$$1.class \
+    com/sun/security/auth/callback/DialogCallbackHandler$$2.class \
+    com/sun/security/auth/callback/DialogCallbackHandler$$Action.class \
+    com/sun/security/auth/callback/DialogCallbackHandler$$ConfirmationInfo.class \
+    com/sun/security/auth/callback/DialogCallbackHandler.class \
     javax/management/remote/rmi/_RMIConnectionImpl_Tie.class \
     javax/management/remote/rmi/_RMIConnection_Stub.class \
     javax/management/remote/rmi/_RMIServerImpl_Tie.class \
-    javax/management/remote/rmi/_RMIServer_Stub.class \
-    com/sun/security/auth/callback/DialogCallbackHandler.class \
-    com/sun/security/auth/callback/DialogCallbackHandler\$$1.class \
-    com/sun/security/auth/callback/DialogCallbackHandler\$$2.class \
-    com/sun/security/auth/callback/DialogCallbackHandler\$$Action.class \
-    com/sun/security/auth/callback/DialogCallbackHandler\$$ConfirmationInfo.class
+    javax/management/remote/rmi/_RMIServer_Stub.class
 
 PROFILE_3_INCLUDE_METAINF_SERVICES := \
     META-INF/services/javax.script.ScriptEngineFactory 
 
 
-PROFILE_4_RTJAR_INCLUDE_PACKAGES := \
-    com/oracle/net \
-    com/oracle/nio \
-    com/oracle/util \
+FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
+    com/oracle \
     com/sun/accessibility/internal/resources \
     com/sun/activation/registries \
     com/sun/awt \
     com/sun/beans \
-    com/sun/beans/decoder \
-    com/sun/beans/finder \
-    com/sun/corba/se/impl/activation \
-    com/sun/corba/se/impl/copyobject \
-    com/sun/corba/se/impl/corba \
-    com/sun/corba/se/impl/dynamicany \
-    com/sun/corba/se/impl/encoding \
-    com/sun/corba/se/impl/interceptors \
-    com/sun/corba/se/impl/io \
-    com/sun/corba/se/impl/ior \
-    com/sun/corba/se/impl/ior/iiop \
-    com/sun/corba/se/impl/javax/rmi \
-    com/sun/corba/se/impl/javax/rmi/CORBA \
-    com/sun/corba/se/impl/legacy/connection \
-    com/sun/corba/se/impl/logging \
-    com/sun/corba/se/impl/monitoring \
-    com/sun/corba/se/impl/naming/cosnaming \
-    com/sun/corba/se/impl/naming/namingutil \
-    com/sun/corba/se/impl/naming/pcosnaming \
-    com/sun/corba/se/impl/oa \
-    com/sun/corba/se/impl/oa/poa \
-    com/sun/corba/se/impl/oa/toa \
-    com/sun/corba/se/impl/orb \
-    com/sun/corba/se/impl/orbutil \
-    com/sun/corba/se/impl/orbutil/closure \
-    com/sun/corba/se/impl/orbutil/concurrent \
-    com/sun/corba/se/impl/orbutil/fsm \
-    com/sun/corba/se/impl/orbutil/graph \
-    com/sun/corba/se/impl/orbutil/threadpool \
-    com/sun/corba/se/impl/presentation/rmi \
-    com/sun/corba/se/impl/protocol \
-    com/sun/corba/se/impl/protocol/giopmsgheaders \
-    com/sun/corba/se/impl/resolver \
-    com/sun/corba/se/impl/transport \
-    com/sun/corba/se/impl/util \
-    com/sun/corba/se/internal/CosNaming \
-    com/sun/corba/se/internal/Interceptors \
-    com/sun/corba/se/internal/POA \
-    com/sun/corba/se/internal/corba \
-    com/sun/corba/se/internal/iiop \
-    com/sun/corba/se/org/omg/CORBA \
-    com/sun/corba/se/pept/broker \
-    com/sun/corba/se/pept/encoding \
-    com/sun/corba/se/pept/protocol \
-    com/sun/corba/se/pept/transport \
-    com/sun/corba/se/spi/activation \
-    com/sun/corba/se/spi/activation/InitialNameServicePackage \
-    com/sun/corba/se/spi/activation/LocatorPackage \
-    com/sun/corba/se/spi/activation/RepositoryPackage \
-    com/sun/corba/se/spi/copyobject \
-    com/sun/corba/se/spi/encoding \
-    com/sun/corba/se/spi/extension \
-    com/sun/corba/se/spi/ior \
-    com/sun/corba/se/spi/ior/iiop \
-    com/sun/corba/se/spi/legacy/connection \
-    com/sun/corba/se/spi/legacy/interceptor \
-    com/sun/corba/se/spi/logging \
-    com/sun/corba/se/spi/monitoring \
-    com/sun/corba/se/spi/oa \
-    com/sun/corba/se/spi/orb \
-    com/sun/corba/se/spi/orbutil/closure \
-    com/sun/corba/se/spi/orbutil/fsm \
-    com/sun/corba/se/spi/orbutil/proxy \
-    com/sun/corba/se/spi/orbutil/threadpool \
-    com/sun/corba/se/spi/presentation/rmi \
-    com/sun/corba/se/spi/protocol \
-    com/sun/corba/se/spi/resolver \
-    com/sun/corba/se/spi/servicecontext \
-    com/sun/corba/se/spi/transport \
+    com/sun/corba \
     com/sun/image/codec/jpeg \
-    com/sun/imageio/plugins/bmp \
-    com/sun/imageio/plugins/common \
-    com/sun/imageio/plugins/gif \
-    com/sun/imageio/plugins/jpeg \
-    com/sun/imageio/plugins/png \
-    com/sun/imageio/plugins/wbmp \
-    com/sun/imageio/spi \
-    com/sun/imageio/stream \
-    com/sun/istack/internal \
-    com/sun/istack/internal/localization \
-    com/sun/istack/internal/logging \
-    com/sun/java/browser/dom \
-    com/sun/java/browser/net \
+    com/sun/imageio \
+    com/sun/istack \
+    com/sun/java/browser \
     com/sun/java/swing \
-    com/sun/java/swing/plaf/gtk \
-    com/sun/java/swing/plaf/gtk/resources \
-    com/sun/java/swing/plaf/motif \
-    com/sun/java/swing/plaf/motif/resources \
-    com/sun/java/swing/plaf/nimbus \
-    com/sun/java/swing/plaf/windows \
-    com/sun/java/swing/plaf/windows/resources \
     com/sun/jmx/remote/protocol/iiop \
     com/sun/jndi/cosnaming \
     com/sun/jndi/toolkit/corba \
@@ -572,313 +184,41 @@
     com/sun/jndi/url/iiop \
     com/sun/jndi/url/iiopname \
     com/sun/media/sound \
-    com/sun/org/glassfish/external/amx \
-    com/sun/org/glassfish/external/arc \
-    com/sun/org/glassfish/external/probe/provider \
-    com/sun/org/glassfish/external/probe/provider/annotations \
-    com/sun/org/glassfish/external/statistics \
-    com/sun/org/glassfish/external/statistics/annotations \
-    com/sun/org/glassfish/external/statistics/impl \
-    com/sun/org/glassfish/gmbal \
-    com/sun/org/glassfish/gmbal/util \
-    com/sun/org/omg/CORBA \
-    com/sun/org/omg/CORBA/ValueDefPackage \
-    com/sun/org/omg/CORBA/portable \
-    com/sun/org/omg/SendingContext \
-    com/sun/org/omg/SendingContext/CodeBasePackage \
+    com/sun/org/glassfish \
+    com/sun/org/omg \
     com/sun/servicetag \
-    com/sun/swing/internal/plaf/basic/resources \
-    com/sun/swing/internal/plaf/metal/resources \
-    com/sun/swing/internal/plaf/synth/resources \
+    com/sun/swing \
     com/sun/xml/internal/bind \
-    com/sun/xml/internal/bind/annotation \
-    com/sun/xml/internal/bind/api \
-    com/sun/xml/internal/bind/api/impl \
-    com/sun/xml/internal/bind/marshaller \
-    com/sun/xml/internal/bind/unmarshaller \
-    com/sun/xml/internal/bind/util \
-    com/sun/xml/internal/bind/v2 \
-    com/sun/xml/internal/bind/v2/bytecode \
-    com/sun/xml/internal/bind/v2/model/annotation \
-    com/sun/xml/internal/bind/v2/model/core \
-    com/sun/xml/internal/bind/v2/model/impl \
-    com/sun/xml/internal/bind/v2/model/nav \
-    com/sun/xml/internal/bind/v2/model/runtime \
-    com/sun/xml/internal/bind/v2/runtime \
-    com/sun/xml/internal/bind/v2/runtime/output \
-    com/sun/xml/internal/bind/v2/runtime/property \
-    com/sun/xml/internal/bind/v2/runtime/reflect \
-    com/sun/xml/internal/bind/v2/runtime/reflect/opt \
-    com/sun/xml/internal/bind/v2/runtime/unmarshaller \
-    com/sun/xml/internal/bind/v2/schemagen \
-    com/sun/xml/internal/bind/v2/schemagen/episode \
-    com/sun/xml/internal/bind/v2/schemagen/xmlschema \
-    com/sun/xml/internal/bind/v2/util \
     com/sun/xml/internal/fastinfoset \
-    com/sun/xml/internal/fastinfoset/algorithm \
-    com/sun/xml/internal/fastinfoset/alphabet \
-    com/sun/xml/internal/fastinfoset/dom \
-    com/sun/xml/internal/fastinfoset/org/apache/xerces/util \
-    com/sun/xml/internal/fastinfoset/sax \
-    com/sun/xml/internal/fastinfoset/stax \
-    com/sun/xml/internal/fastinfoset/stax/events \
-    com/sun/xml/internal/fastinfoset/stax/factory \
-    com/sun/xml/internal/fastinfoset/stax/util \
-    com/sun/xml/internal/fastinfoset/tools \
-    com/sun/xml/internal/fastinfoset/util \
-    com/sun/xml/internal/fastinfoset/vocab \
-    com/sun/xml/internal/messaging/saaj \
-    com/sun/xml/internal/messaging/saaj/client/p2p \
-    com/sun/xml/internal/messaging/saaj/packaging/mime \
-    com/sun/xml/internal/messaging/saaj/packaging/mime/internet \
-    com/sun/xml/internal/messaging/saaj/packaging/mime/util \
-    com/sun/xml/internal/messaging/saaj/soap \
-    com/sun/xml/internal/messaging/saaj/soap/dynamic \
-    com/sun/xml/internal/messaging/saaj/soap/impl \
-    com/sun/xml/internal/messaging/saaj/soap/name \
-    com/sun/xml/internal/messaging/saaj/soap/ver1_1 \
-    com/sun/xml/internal/messaging/saaj/soap/ver1_2 \
-    com/sun/xml/internal/messaging/saaj/util \
-    com/sun/xml/internal/messaging/saaj/util/transform \
-    com/sun/xml/internal/org/jvnet/fastinfoset \
-    com/sun/xml/internal/org/jvnet/fastinfoset/sax \
-    com/sun/xml/internal/org/jvnet/fastinfoset/sax/helpers \
-    com/sun/xml/internal/org/jvnet/fastinfoset/stax \
-    com/sun/xml/internal/org/jvnet/mimepull \
-    com/sun/xml/internal/org/jvnet/staxex \
-    com/sun/xml/internal/org/jvnet/ws \
-    com/sun/xml/internal/org/jvnet/ws/databinding \
-    com/sun/xml/internal/org/jvnet/ws/message \
+    com/sun/xml/internal/messaging \
+    com/sun/xml/internal/org \
     com/sun/xml/internal/stream/buffer \
-    com/sun/xml/internal/stream/buffer/sax \
-    com/sun/xml/internal/stream/buffer/stax \
     com/sun/xml/internal/txw2 \
-    com/sun/xml/internal/txw2/annotation \
-    com/sun/xml/internal/txw2/output \
-    com/sun/xml/internal/ws/addressing \
-    com/sun/xml/internal/ws/addressing/model \
-    com/sun/xml/internal/ws/addressing/policy \
-    com/sun/xml/internal/ws/addressing/v200408 \
-    com/sun/xml/internal/ws/api \
-    com/sun/xml/internal/ws/api/addressing \
-    com/sun/xml/internal/ws/api/client \
-    com/sun/xml/internal/ws/api/config/management \
-    com/sun/xml/internal/ws/api/config/management/policy \
-    com/sun/xml/internal/ws/api/databinding \
-    com/sun/xml/internal/ws/api/fastinfoset \
-    com/sun/xml/internal/ws/api/ha \
-    com/sun/xml/internal/ws/api/handler \
-    com/sun/xml/internal/ws/api/message \
-    com/sun/xml/internal/ws/api/message/saaj \
-    com/sun/xml/internal/ws/api/message/stream \
-    com/sun/xml/internal/ws/api/model \
-    com/sun/xml/internal/ws/api/model/soap \
-    com/sun/xml/internal/ws/api/model/wsdl \
-    com/sun/xml/internal/ws/api/pipe \
-    com/sun/xml/internal/ws/api/pipe/helper \
-    com/sun/xml/internal/ws/api/policy \
-    com/sun/xml/internal/ws/api/policy/subject \
-    com/sun/xml/internal/ws/api/server \
-    com/sun/xml/internal/ws/api/streaming \
-    com/sun/xml/internal/ws/api/wsdl/parser \
-    com/sun/xml/internal/ws/api/wsdl/writer \
-    com/sun/xml/internal/ws/binding \
-    com/sun/xml/internal/ws/client \
-    com/sun/xml/internal/ws/client/dispatch \
-    com/sun/xml/internal/ws/client/sei \
-    com/sun/xml/internal/ws/config/management/policy \
-    com/sun/xml/internal/ws/db \
-    com/sun/xml/internal/ws/db/glassfish \
-    com/sun/xml/internal/ws/developer \
-    com/sun/xml/internal/ws/encoding \
-    com/sun/xml/internal/ws/encoding/fastinfoset \
-    com/sun/xml/internal/ws/encoding/policy \
-    com/sun/xml/internal/ws/encoding/soap \
-    com/sun/xml/internal/ws/encoding/soap/streaming \
-    com/sun/xml/internal/ws/encoding/xml \
-    com/sun/xml/internal/ws/fault \
-    com/sun/xml/internal/ws/handler \
-    com/sun/xml/internal/ws/message \
-    com/sun/xml/internal/ws/message/jaxb \
-    com/sun/xml/internal/ws/message/saaj \
-    com/sun/xml/internal/ws/message/source \
-    com/sun/xml/internal/ws/message/stream \
-    com/sun/xml/internal/ws/model \
-    com/sun/xml/internal/ws/model/soap \
-    com/sun/xml/internal/ws/model/wsdl \
-    com/sun/xml/internal/ws/org/objectweb/asm \
-    com/sun/xml/internal/ws/policy \
-    com/sun/xml/internal/ws/policy/jaxws \
-    com/sun/xml/internal/ws/policy/jaxws/spi \
-    com/sun/xml/internal/ws/policy/privateutil \
-    com/sun/xml/internal/ws/policy/sourcemodel \
-    com/sun/xml/internal/ws/policy/sourcemodel/attach \
-    com/sun/xml/internal/ws/policy/sourcemodel/wspolicy \
-    com/sun/xml/internal/ws/policy/spi \
-    com/sun/xml/internal/ws/policy/subject \
-    com/sun/xml/internal/ws/protocol/soap \
-    com/sun/xml/internal/ws/protocol/xml \
-    com/sun/xml/internal/ws/resources \
-    com/sun/xml/internal/ws/server \
-    com/sun/xml/internal/ws/server/provider \
-    com/sun/xml/internal/ws/server/sei \
-    com/sun/xml/internal/ws/spi \
-    com/sun/xml/internal/ws/spi/db \
-    com/sun/xml/internal/ws/streaming \
-    com/sun/xml/internal/ws/transport \
-    com/sun/xml/internal/ws/transport/http \
-    com/sun/xml/internal/ws/transport/http/client \
-    com/sun/xml/internal/ws/transport/http/server \
-    com/sun/xml/internal/ws/util \
-    com/sun/xml/internal/ws/util/exception \
-    com/sun/xml/internal/ws/util/localization \
-    com/sun/xml/internal/ws/util/pipe \
-    com/sun/xml/internal/ws/util/xml \
-    com/sun/xml/internal/ws/wsdl \
-    com/sun/xml/internal/ws/wsdl/parser \
-    com/sun/xml/internal/ws/wsdl/writer \
-    com/sun/xml/internal/ws/wsdl/writer/document \
-    com/sun/xml/internal/ws/wsdl/writer/document/http \
-    com/sun/xml/internal/ws/wsdl/writer/document/soap \
-    com/sun/xml/internal/ws/wsdl/writer/document/soap12 \
-    com/sun/xml/internal/ws/wsdl/writer/document/xsd \
+    com/sun/xml/internal/ws \
     java/applet \
     java/awt \
-    java/awt/color \
-    java/awt/datatransfer \
-    java/awt/dnd \
-    java/awt/dnd/peer \
-    java/awt/event \
-    java/awt/font \
-    java/awt/geom \
-    java/awt/im \
-    java/awt/im/spi \
-    java/awt/image \
-    java/awt/image/renderable \
-    java/awt/peer \
-    java/awt/print \
     java/beans \
     javax/accessibility \
     javax/activation \
     javax/activity \
     javax/imageio \
-    javax/imageio/event \
-    javax/imageio/metadata \
-    javax/imageio/plugins/bmp \
-    javax/imageio/plugins/jpeg \
-    javax/imageio/spi \
-    javax/imageio/stream \
     javax/jws \
-    javax/jws/soap \
     javax/print \
-    javax/print/attribute \
-    javax/print/attribute/standard \
-    javax/print/event \
     javax/rmi/CORBA \
-    javax/sound/midi \
-    javax/sound/midi/spi \
-    javax/sound/sampled \
-    javax/sound/sampled/spi \
+    javax/sound \
     javax/swing \
-    javax/swing/border \
-    javax/swing/colorchooser \
-    javax/swing/event \
-    javax/swing/filechooser \
-    javax/swing/plaf \
-    javax/swing/plaf/basic \
-    javax/swing/plaf/metal \
-    javax/swing/plaf/multi \
-    javax/swing/plaf/nimbus \
-    javax/swing/plaf/synth \
-    javax/swing/table \
-    javax/swing/text \
-    javax/swing/text/html \
-    javax/swing/text/html/parser \
-    javax/swing/text/rtf \
-    javax/swing/tree \
-    javax/swing/undo \
     javax/xml/bind \
-    javax/xml/bind/annotation \
-    javax/xml/bind/annotation/adapters \
-    javax/xml/bind/attachment \
-    javax/xml/bind/helpers \
-    javax/xml/bind/util \
     javax/xml/soap \
     javax/xml/ws \
-    javax/xml/ws/handler \
-    javax/xml/ws/handler/soap \
-    javax/xml/ws/http \
-    javax/xml/ws/soap \
-    javax/xml/ws/spi \
-    javax/xml/ws/spi/http \
-    javax/xml/ws/wsaddressing \
-    org/omg/CORBA \
-    org/omg/CORBA/DynAnyPackage \
-    org/omg/CORBA/ORBPackage \
-    org/omg/CORBA/TypeCodePackage \
-    org/omg/CORBA/portable \
-    org/omg/CORBA_2_3 \
-    org/omg/CORBA_2_3/portable \
-    org/omg/CosNaming \
-    org/omg/CosNaming/NamingContextExtPackage \
-    org/omg/CosNaming/NamingContextPackage \
-    org/omg/Dynamic \
-    org/omg/DynamicAny \
-    org/omg/DynamicAny/DynAnyFactoryPackage \
-    org/omg/DynamicAny/DynAnyPackage \
-    org/omg/IOP \
-    org/omg/IOP/CodecFactoryPackage \
-    org/omg/IOP/CodecPackage \
-    org/omg/Messaging \
-    org/omg/PortableInterceptor \
-    org/omg/PortableInterceptor/ORBInitInfoPackage \
-    org/omg/PortableServer \
-    org/omg/PortableServer/CurrentPackage \
-    org/omg/PortableServer/POAManagerPackage \
-    org/omg/PortableServer/POAPackage \
-    org/omg/PortableServer/ServantLocatorPackage \
-    org/omg/PortableServer/portable \
-    org/omg/SendingContext \
-    org/omg/stub/java/rmi \
-    org/omg/stub/javax/management/remote/rmi \
+    org/omg \
     sun/applet \
-    sun/applet/resources \
     sun/audio \
     sun/awt \
-    sun/awt/X11 \
-    sun/awt/datatransfer \
-    sun/awt/dnd \
-    sun/awt/event \
-    sun/awt/geom \
-    sun/awt/im \
-    sun/awt/image \
-    sun/awt/image/codec \
-    sun/awt/motif \
-    sun/awt/resources \
-    sun/awt/shell \
-    sun/awt/util \
-    sun/awt/windows \
-    sun/beans/editors \
-    sun/beans/infos \
     sun/corba \
     sun/dc \
-    sun/dc/path \
-    sun/dc/pr \
     sun/font \
     sun/java2d \
-    sun/java2d/cmm \
-    sun/java2d/cmm/kcms \
-    sun/java2d/cmm/lcms \
-    sun/java2d/jules \
-    sun/java2d/loops \
-    sun/java2d/opengl \
-    sun/java2d/pipe \
-    sun/java2d/pipe/hw \
-    sun/java2d/pisces \
-    sun/java2d/x11 \
-    sun/java2d/xr \
     sun/net/ftp \
-    sun/net/ftp/impl \
     sun/net/smtp \
     sun/net/www/content/audio \
     sun/net/www/content/image \
@@ -887,27 +227,26 @@
     sun/net/www/protocol/mailto \
     sun/net/www/protocol/netdoc \
     sun/print \
-    sun/print/resources \
     sun/security/tools/policytool \
     sun/swing \
-    sun/swing/icon \
-    sun/swing/plaf \
-    sun/swing/plaf/synth \
-    sun/swing/plaf/windows \
-    sun/swing/table \
-    sun/swing/text \
-    sun/swing/text/html \
-    sun/tools/jar \
-    sun/tools/jar/resources
+    sun/tools/jar
 
-PROFILE_4_RTJAR_INCLUDE_TYPES := \
-    com/sun/xml/internal/ws/*.class \
+FULL_JRE_RTJAR_INCLUDE_TYPES := \
+    com/sun/security/auth/callback/DialogCallbackHandler$$1.class \
+    com/sun/security/auth/callback/DialogCallbackHandler$$2.class \
+    com/sun/security/auth/callback/DialogCallbackHandler$$Action.class \
+    com/sun/security/auth/callback/DialogCallbackHandler$$ConfirmationInfo.class \
+    com/sun/security/auth/callback/DialogCallbackHandler.class \
     javax/annotation/*.class \
+    javax/management/remote/rmi/_RMIConnectionImpl_Tie.class \
+    javax/management/remote/rmi/_RMIConnection_Stub.class \
+    javax/management/remote/rmi/_RMIServerImpl_Tie.class \
+    javax/management/remote/rmi/_RMIServer_Stub.class \
     javax/rmi/*.class
 
-PROFILE_4_RTJAR_EXCLUDE_TYPES := 
+FULL_JRE_RTJAR_EXCLUDE_TYPES := 
 
-PROFILE_4_INCLUDE_METAINF_SERVICES := \
+FULL_JRE_INCLUDE_METAINF_SERVICES := \
     META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin  \
     META-INF/services/com.sun.tools.internal.xjc.Plugin  \
     META-INF/services/javax.print.PrintServiceLookup  \
--- a/src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -32,11 +32,13 @@
 import java.text.spi.DecimalFormatSymbolsProvider;
 import java.text.spi.NumberFormatProvider;
 import java.util.Collections;
+import java.util.Calendar;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle.Control;
 import java.util.Set;
+import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicReferenceArray;
@@ -45,6 +47,7 @@
 import java.util.spi.CurrencyNameProvider;
 import java.util.spi.LocaleNameProvider;
 import java.util.spi.TimeZoneNameProvider;
+import sun.util.spi.CalendarProvider;
 
 /**
  * LocaleProviderAdapter implementation for the Mac OS X locale data
@@ -94,17 +97,56 @@
 
     private static final Set<Locale> supportedLocaleSet;
     static {
-        Set<Locale> tmpSet = new HashSet<Locale>();
+        Set<Locale> tmpSet = new HashSet<>();
         // Assuming the default locales do not include any extensions, so
         // no stripping is needed here.
-        Locale l = Locale.forLanguageTag(getDefaultLocale(CAT_FORMAT).replaceAll("_","-"));
+        Locale l = convertMacOSXLocaleToJavaLocale(getDefaultLocale(CAT_FORMAT));
         tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
-        l = Locale.forLanguageTag(getDefaultLocale(CAT_DISPLAY).replaceAll("_","-"));
+        l = convertMacOSXLocaleToJavaLocale(getDefaultLocale(CAT_DISPLAY));
         tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
         supportedLocaleSet = Collections.unmodifiableSet(tmpSet);
     }
     private final static Locale[] supportedLocale = supportedLocaleSet.toArray(new Locale[0]);
 
+    @SuppressWarnings("fallthrough")
+    private static Locale convertMacOSXLocaleToJavaLocale(String macosxloc) {
+        // MacOSX may return ICU notation, here is the quote from CFLocale doc:
+        // "The corresponding value is a CFString containing the POSIX locale
+        // identifier as used by ICU, such as "ja_JP". If you have a variant
+        // locale or a different currency or calendar, it can be as complex as
+        // "en_US_POSIX@calendar=japanese;currency=EUR" or
+        // "az_Cyrl_AZ@calendar=buddhist;currency=JPY".
+        String[] tmp = macosxloc.split("@");
+        String langTag = tmp[0].replace('_', '-');
+        if (tmp.length > 1) {
+            String[] ext = tmp[1].split(";");
+            for (String keyval : ext) {
+                // We are only interested in "calendar" value for now.
+                if (keyval.startsWith("calendar=")) {
+                    String calid = keyval.substring(keyval.indexOf('=')+1);
+                    switch (calid) {
+                        case "gregorian":
+                            langTag += "-u-ca-gregory";
+                            break;
+                        case "japanese":
+                            // Tweak for ja_JP_JP
+                            if (tmp[0].equals("ja_JP")) {
+                                return JRELocaleConstants.JA_JP_JP;
+                            }
+
+                            // fall through
+
+                        default:
+                            langTag += "-u-ca-" + calid;
+                            break;
+                    }
+                }
+            }
+        }
+
+        return Locale.forLanguageTag(langTag);
+    }
+
     public static DateFormatProvider getDateFormatProvider() {
         return new DateFormatProvider() {
 
@@ -170,9 +212,8 @@
                 if (isSupportedLocale(Locale.getDefault(Locale.Category.FORMAT))) {
                     return supportedLocale;
                 }
-
-                        return new Locale[0];
-                    }
+                return new Locale[0];
+            }
 
             @Override
             public boolean isSupportedLocale(Locale locale) {
@@ -362,6 +403,30 @@
         };
     }
 
+    public static CalendarProvider getCalendarProvider() {
+        return new CalendarProvider() {
+            @Override
+            public Locale[] getAvailableLocales() {
+                return getSupportedCalendarLocales();
+            }
+
+            @Override
+            public boolean isSupportedLocale(Locale locale) {
+                return isSupportedCalendarLocale(locale);
+            }
+
+            @Override
+            public Calendar getInstance(TimeZone zone, Locale locale) {
+                return new Calendar.Builder()
+                             .setLocale(locale)
+                             .setCalendarType(getCalendarID(locale.toLanguageTag()))
+                             .setTimeZone(zone)
+                             .setInstant(System.currentTimeMillis())
+                             .build();
+            }
+        };
+    }
+
     public static CurrencyNameProvider getCurrencyNameProvider() {
         return new CurrencyNameProvider() {
             @Override
@@ -455,23 +520,20 @@
     }
 
     private static boolean isSupportedCalendarLocale(Locale locale) {
-        // special case for ja_JP_JP
-        if (JRELocaleConstants.JA_JP_JP.equals(locale)) {
-            return isJapaneseCalendar();
-        }
-
         Locale base = locale.stripExtensions();
         if (!supportedLocaleSet.contains(base)) {
             return false;
         }
 
-        String caltype = locale.getUnicodeLocaleType("ca");
-        if (caltype == null) {
-            return true;
+        String requestedCalType = locale.getUnicodeLocaleType("ca");
+        String nativeCalType =
+            getCalendarID(locale.toLanguageTag()).replaceFirst("gregorian", "gregory");
+
+        if (requestedCalType == null) {
+            return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
+        } else {
+            return requestedCalType.equals(nativeCalType);
         }
-
-        return caltype.replaceFirst("gregory", "gregorian").equals(
-                getCalendarID(locale.toLanguageTag()));
     }
 
     private static boolean isJapaneseCalendar() {
@@ -479,18 +541,15 @@
     }
 
     private static Locale getCalendarLocale(Locale locale) {
-        Locale.Builder lb = new Locale.Builder().setLocale(locale);
-        String calid = getCalendarID(locale.toLanguageTag());
-        switch (calid) {
-            case "gregorian":
-                calid = "gregory";
-                // FALL THROUGH!
-            case "japanese":
-            case "buddhist":
-                lb.setUnicodeLocaleKeyword("ca", calid);
-                return lb.build();
-            default:
-                return locale;
+        String nativeCalType = getCalendarID(locale.toLanguageTag())
+                     .replaceFirst("gregorian", "gregory");
+        if (Calendar.getAvailableCalendarTypes().contains(nativeCalType)) {
+            return new Locale.Builder()
+                           .setLocale(locale)
+                           .setUnicodeLocaleKeyword("ca", nativeCalType)
+                           .build();
+        } else {
+            return locale;
         }
     }
 
--- a/src/share/back/transport.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/back/transport.c	Fri Mar 15 11:51:02 2013 -0300
@@ -117,6 +117,9 @@
 
     /* Construct library name (simple name or full path) */
     dbgsysBuildLibName(libname, sizeof(libname), plibdir, name);
+    if (strlen(libname) == 0) {
+        return NULL;
+    }
 
     /* dlopen (unix) / LoadLibrary (windows) the transport library */
     handle = dbgsysLoadLibrary(libname, buf, sizeof(buf));
--- a/src/share/classes/com/sun/crypto/provider/TlsKeyMaterialGenerator.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/crypto/provider/TlsKeyMaterialGenerator.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -165,18 +165,16 @@
         // partition keyblock into individual secrets
 
         int ofs = 0;
-        if (macLength != 0) {
-            byte[] tmp = new byte[macLength];
+        byte[] tmp = new byte[macLength];
 
-            // mac keys
-            System.arraycopy(keyBlock, ofs, tmp, 0, macLength);
-            ofs += macLength;
-            clientMacKey = new SecretKeySpec(tmp, "Mac");
+        // mac keys
+        System.arraycopy(keyBlock, ofs, tmp, 0, macLength);
+        ofs += macLength;
+        clientMacKey = new SecretKeySpec(tmp, "Mac");
 
-            System.arraycopy(keyBlock, ofs, tmp, 0, macLength);
-            ofs += macLength;
-            serverMacKey = new SecretKeySpec(tmp, "Mac");
-        }
+        System.arraycopy(keyBlock, ofs, tmp, 0, macLength);
+        ofs += macLength;
+        serverMacKey = new SecretKeySpec(tmp, "Mac");
 
         if (keyLength == 0) { // SSL_RSA_WITH_NULL_* ciphersuites
             return new TlsKeyMaterialSpec(clientMacKey, serverMacKey);
@@ -200,7 +198,7 @@
 
             // IV keys if needed.
             if (ivLength != 0) {
-                byte[] tmp = new byte[ivLength];
+                tmp = new byte[ivLength];
 
                 System.arraycopy(keyBlock, ofs, tmp, 0, ivLength);
                 ofs += ivLength;
@@ -222,8 +220,8 @@
                 // TLS 1.0
                 byte[] seed = concat(clientRandom, serverRandom);
 
-                byte[] tmp = doTLS10PRF(clientKeyBytes,
-                    LABEL_CLIENT_WRITE_KEY, seed, expandedKeyLength, md5, sha);
+                tmp = doTLS10PRF(clientKeyBytes, LABEL_CLIENT_WRITE_KEY, seed,
+                            expandedKeyLength, md5, sha);
                 clientCipherKey = new SecretKeySpec(tmp, alg);
 
                 tmp = doTLS10PRF(serverKeyBytes, LABEL_SERVER_WRITE_KEY, seed,
@@ -241,7 +239,7 @@
                 }
             } else {
                 // SSLv3
-                byte[] tmp = new byte[expandedKeyLength];
+                tmp = new byte[expandedKeyLength];
 
                 md5.update(clientKeyBytes);
                 md5.update(clientRandom);
--- a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java	Fri Mar 15 11:51:02 2013 -0300
@@ -564,7 +564,7 @@
         code.bytes = new byte[readInt()];
         in.readFully(code.bytes);
         Entry[] cpMap = cls.getCPMap();
-        Instruction.opcodeChecker(code.bytes, cpMap);
+        Instruction.opcodeChecker(code.bytes, cpMap, this.cls.version);
         int nh = readUnsignedShort();
         code.setHandlerCount(nh);
         for (int i = 0; i < nh; i++) {
--- a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java	Fri Mar 15 11:51:02 2013 -0300
@@ -207,6 +207,10 @@
             return tag;
         }
 
+        public final boolean tagEquals(int tag) {
+            return getTag() == tag;
+        }
+
         public Entry getRef(int i) {
             return null;
         }
--- a/src/share/classes/com/sun/java/util/jar/pack/Constants.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/java/util/jar/pack/Constants.java	Fri Mar 15 11:51:02 2013 -0300
@@ -479,4 +479,10 @@
     public final static int _qldc   = _xldc_op+7;
     public final static int _qldc_w = _xldc_op+8;
     public final static int _xldc_limit = _xldc_op+9;
+
+    // handling of InterfaceMethodRef
+    public final static int _invoke_int_op = _xldc_limit;
+    public final static int _invokespecial_int = _invoke_int_op+0;
+    public final static int _invokestatic_int = _invoke_int_op+1;
+    public final static int _invoke_int_limit = _invoke_int_op+2;
 }
--- a/src/share/classes/com/sun/java/util/jar/pack/Instruction.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/java/util/jar/pack/Instruction.java	Fri Mar 15 11:51:02 2013 -0300
@@ -446,12 +446,14 @@
     public static boolean isCPRefOp(int bc) {
         if (bc < BC_INDEX[0].length && BC_INDEX[0][bc] > 0)  return true;
         if (bc >= _xldc_op && bc < _xldc_limit)  return true;
+        if (bc == _invokespecial_int || bc == _invokestatic_int) return true;
         return false;
     }
 
     public static byte getCPRefOpTag(int bc) {
         if (bc < BC_INDEX[0].length && BC_INDEX[0][bc] > 0)  return BC_TAG[0][bc];
         if (bc >= _xldc_op && bc < _xldc_limit)  return CONSTANT_LoadableValue;
+        if (bc == _invokestatic_int || bc == _invokespecial_int) return CONSTANT_InterfaceMethodref;
         return CONSTANT_None;
     }
 
@@ -647,7 +649,8 @@
         }
     }
 
-    public static void opcodeChecker(byte[] code, ConstantPool.Entry[] cpMap) throws FormatException {
+    public static void opcodeChecker(byte[] code, ConstantPool.Entry[] cpMap,
+            Package.Version clsVersion) throws FormatException {
         Instruction i = at(code, 0);
         while (i != null) {
             int opcode = i.getBC();
@@ -658,10 +661,17 @@
             ConstantPool.Entry e = i.getCPRef(cpMap);
             if (e != null) {
                 byte tag = i.getCPTag();
-                if (!e.tagMatches(tag)) {
-                    String message = "illegal reference, expected type=" +
-                                     ConstantPool.tagName(tag) + ": " +
-                                     i.toString(cpMap);
+                boolean match = e.tagMatches(tag);
+                if (!match &&
+                        (i.bc == _invokespecial || i.bc == _invokestatic) &&
+                        e.tagMatches(CONSTANT_InterfaceMethodref) &&
+                        clsVersion.greaterThan(Constants.JAVA7_MAX_CLASS_VERSION)) {
+                    match = true;
+                }
+                if (!match) {
+                    String message = "illegal reference, expected type="
+                            + ConstantPool.tagName(tag) + ": "
+                            + i.toString(cpMap);
                     throw new FormatException(message);
                 }
             }
--- a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Fri Mar 15 11:51:02 2013 -0300
@@ -2256,6 +2256,12 @@
                         int origBC = bc;
                         int size = 2;
                         switch (bc) {
+                        case _invokestatic_int:
+                            origBC = _invokestatic;
+                            break;
+                        case _invokespecial_int:
+                            origBC = _invokespecial;
+                            break;
                         case _ildc:
                         case _cldc:
                         case _fldc:
--- a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1409,6 +1409,10 @@
         int bc = i.getBC();
         if (!(bc >= _first_linker_op && bc <= _last_linker_op))  return -1;
         MemberEntry ref = (MemberEntry) i.getCPRef(curCPMap);
+        // do not optimize this case, simply fall back to regular coding
+        if ((bc == _invokespecial || bc == _invokestatic) &&
+                ref.tagEquals(CONSTANT_InterfaceMethodref))
+            return -1;
         ClassEntry refClass = ref.classRef;
         int self_bc = _self_linker_op + (bc - _first_linker_op);
         if (refClass == curClass.thisClass)
@@ -1609,7 +1613,16 @@
                 case CONSTANT_Fieldref:
                     bc_which = bc_fieldref; break;
                 case CONSTANT_Methodref:
-                    bc_which = bc_methodref; break;
+                    if (ref.tagEquals(CONSTANT_InterfaceMethodref)) {
+                        if (bc == _invokespecial)
+                            vbc = _invokespecial_int;
+                        if (bc == _invokestatic)
+                            vbc = _invokestatic_int;
+                        bc_which = bc_imethodref;
+                    } else {
+                        bc_which = bc_methodref;
+                    }
+                    break;
                 case CONSTANT_InterfaceMethodref:
                     bc_which = bc_imethodref; break;
                 case CONSTANT_InvokeDynamic:
--- a/src/share/classes/com/sun/tools/script/shell/init.js	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/com/sun/tools/script/shell/init.js	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,7 +28,7 @@
  */
 
 /**
- * Creates an object that delegates all method calls on 
+ * Creates an object that delegates all method calls on
  * it to the 'invoke' method on the given delegate object.<br>
  *
  * Example:
@@ -43,13 +43,13 @@
  * @constructor
  */
 function JSInvoker(obj) {
-	return new JSAdapter({
-			__get__ : function(name) {
-				return function() {
-					return obj.invoke(name, arguments);
-				}
-			}
-		});
+    return new JSAdapter({
+        __get__ : function(name) {
+            return function() {
+                return obj.invoke(name, arguments);
+            }
+        }
+    });
 }
 
 /**
@@ -58,24 +58,24 @@
  * example, env.PATH will return PATH value configured.
  */
 var env = new JSAdapter({
-	__get__ : function (name) {
-		return java.lang.System.getenv(name);
-	},
-	__has__ : function (name) {
-		return java.lang.System.getenv().containsKey(name);
-	},
-	__getIds__ : function() {
-		return java.lang.System.getenv().keySet().toArray();
-	},
-	__delete__ : function(name) {
-		println("can't delete env item");
-	},
-	__put__ : function (name, value) {
-		println("can't change env item");
-	},			
-	toString: function() {
-		return java.lang.System.getenv().toString();
-	}		
+    __get__ : function (name) {
+        return java.lang.System.getenv(name);
+    },
+    __has__ : function (name) {
+        return java.lang.System.getenv().containsKey(name);
+    },
+    __getIds__ : function() {
+        return java.lang.System.getenv().keySet().toArray();
+    },
+    __delete__ : function(name) {
+        println("can't delete env item");
+    },
+    __put__ : function (name, value) {
+        println("can't change env item");
+    },
+    toString: function() {
+        return java.lang.System.getenv().toString();
+    }
 });
 
 /**
@@ -91,36 +91,36 @@
  *     delete y['java.class.path']; // remove java.class.path System property
  * </code>
  * </pre>
- * 
+ *
  * @param map java.util.Map instance that will be wrapped
  * @constructor
  */
-function jmap(map) {	
-	return new JSAdapter({
-		__get__ : function(name) {
-			if (map.containsKey(name)) {
-				return map.get(name);
-			} else {
-				return undefined;
-			}
-   		  },
-		__has__ :  function(name) {
-				return map.containsKey(name);
-			},
+function jmap(map) {
+    return new JSAdapter({
+        __get__ : function(name) {
+            if (map.containsKey(name)) {
+                return map.get(name);
+            } else {
+                return undefined;
+            }
+        },
+        __has__ :  function(name) {
+            return map.containsKey(name);
+        },
 
-		__delete__ : function (name) {
-				return map.remove(name);
-			},
-		__put__ : function(name, value) {
-				map.put(name, value);
-			},
-		__getIds__ : function() {
-				return map.keySet().toArray();		
-			},
-		toString: function() {
-				return map.toString();
-		}
-	});
+        __delete__ : function (name) {
+            return map.remove(name);
+        },
+        __put__ : function(name, value) {
+            map.put(name, value);
+        },
+        __getIds__ : function() {
+            return map.keySet().toArray();
+        },
+        toString: function() {
+            return map.toString();
+        }
+    });
 }
 
 /**
@@ -146,52 +146,72 @@
  * @constructor
  */
 function jlist(list) {
-	function isValid(index) {
-		return typeof(index) == 'number' &&
-			index > -1 && index < list.size();
-	}
-	return new JSAdapter({
-		__get__ :  function(name) {
-			if (isValid(name)) {
-				return list.get(name);
-			} else if (name == 'length') {
-				return list.size();
-			} else {
-				return undefined;
-			}
-		},
-		__has__ : function (name) {
-			return isValid(name) || name == 'length';
-		},
-		__delete__ : function(name) {				
-			if (isValid(name)) {
-				list.remove(name);	
-			}
-		},
-		__put__ : function(name, value) {
-			if (isValid(name)) {
-				list.set(name, value);
-			}
-		},
-		__getIds__: function() {
-			var res = new Array(list.size());
-			for (var i = 0; i < res.length; i++) {
-				res[i] = i;
-			}
-			return res;
-		},
-		toString: function() {
-			return list.toString();
-		}				
-	});
+    function isValid(index) {
+        return typeof(index) == 'number' &&
+            index > -1 && index < list.size();
+    }
+    return new JSAdapter({
+        __get__ :  function(name) {
+            if (isValid(name)) {
+                return list.get(name);
+            } else if (name == 'length') {
+                return list.size();
+            } else {
+                return undefined;
+            }
+        },
+        __has__ : function (name) {
+            return isValid(name) || name == 'length';
+        },
+        __delete__ : function(name) {
+            if (isValid(name)) {
+                list.remove(name);
+            }
+        },
+        __put__ : function(name, value) {
+            if (isValid(name)) {
+                list.set(name, value);
+            }
+        },
+        __getIds__: function() {
+            var res = new Array(list.size());
+            for (var i = 0; i < res.length; i++) {
+                res[i] = i;
+            }
+            return res;
+        },
+        toString: function() {
+            return list.toString();
+        }
+    });
 }
 
 /**
- * This is java.lang.System properties wrapped by jmap.
+ * This is java.lang.System properties wrapped by JSAdapter.
  * For eg. to access java.class.path property, you can use
  * the syntax sysProps["java.class.path"]
  */
-var sysProps = jmap(java.lang.System.getProperties());
+var sysProps = new JSAdapter({
+    __get__ : function (name) {
+        return java.lang.System.getProperty(name);
+    },
+    __has__ : function (name) {
+        return java.lang.System.getProperty(name) != null;
+    },
+    __getIds__ : function() {
+        return java.lang.System.getProperties().keySet().toArray();
+    },
+    __delete__ : function(name) {
+        java.lang.System.clearProperty(name);
+        return true;
+    },
+    __put__ : function (name, value) {
+        java.lang.System.setProperty(name, value);
+    },
+    toString: function() {
+        return "<system properties>";
+    }
+});
 
 // stdout, stderr & stdin
 var out = java.lang.System.out;
@@ -199,76 +219,85 @@
 // can't use 'in' because it is a JavaScript keyword :-(
 var inp = java.lang.System["in"];
 
-// useful imports for often used io, net classes
-importPackage(java.io);
-importPackage(java.net);
+var BufferedInputStream = java.io.BufferedInputStream;
+var BufferedOutputStream = java.io.BufferedOutputStream;
+var BufferedReader = java.io.BufferedReader;
+var DataInputStream = java.io.DataInputStream;
+var File = java.io.File;
+var FileInputStream = java.io.FileInputStream;
+var FileOutputStream = java.io.FileOutputStream;
+var InputStream = java.io.InputStream;
+var InputStreamReader = java.io.InputStreamReader;
+var OutputStream = java.io.OutputStream;
+var Reader = java.io.Reader;
+var URL = java.net.URL;
 
 /**
  * Generic any object to input stream mapper
- * @param str input file name, URL or InputStream 
+ * @param str input file name, URL or InputStream
  * @return InputStream object
  * @private
  */
 function inStream(str) {
-	if (typeof(str) == "string") {
-		// '-' means standard input
-		if (str == '-') {
-			return java.lang.System["in"];
-		}
-		// try file first
-		var file = null;
-		try {
-			file = pathToFile(str);
-		} catch (e) {
-		}		
-		if (file && file.exists()) {
-			return new FileInputStream(file);
-		} else {
-			try {
-				// treat the string as URL
-				return new URL(str).openStream();
-			} catch (e) {
-				throw 'file or URL ' + str + ' not found';
-			}
-		}
-	} else {
-		if (str instanceof InputStream) {
-			return str;
-		} else if (str instanceof URL) {
-			return str.openStream();
-		} else if (str instanceof File) {
-			return new FileInputStream(str);
-		}
-	}
-	// everything failed, just give input stream
-	return java.lang.System["in"];
+    if (typeof(str) == "string") {
+        // '-' means standard input
+        if (str == '-') {
+            return java.lang.System["in"];
+        }
+        // try file first
+        var file = null;
+        try {
+            file = pathToFile(str);
+        } catch (e) {
+        }
+        if (file && file.exists()) {
+            return new FileInputStream(file);
+        } else {
+            try {
+                // treat the string as URL
+                return new URL(str).openStream();
+            } catch (e) {
+                throw 'file or URL ' + str + ' not found';
+            }
+        }
+    } else {
+        if (str instanceof InputStream) {
+            return str;
+        } else if (str instanceof URL) {
+            return str.openStream();
+        } else if (str instanceof File) {
+            return new FileInputStream(str);
+        }
+    }
+    // everything failed, just give input stream
+    return java.lang.System["in"];
 }
 
 /**
  * Generic any object to output stream mapper
- * 
+ *
  * @param out output file name or stream
  * @return OutputStream object
  * @private
  */
 function outStream(out) {
-	if (typeof(out) == "string") {
-		if (out == '>') {
-			return java.lang.System.out;
-		} else {
-			// treat it as file			
-			return new FileOutputStream(pathToFile(out));
-		}
-	} else {
-		if (out instanceof OutputStream) {
-			return out;
-		} else if (out instanceof File) {
-			return new FileOutputStream(out);
-		}
-	}
+    if (typeof(out) == "string") {
+        if (out == '>') {
+            return java.lang.System.out;
+        } else {
+            // treat it as file
+            return new FileOutputStream(pathToFile(out));
+        }
+    } else {
+        if (out instanceof OutputStream) {
+            return out;
+        } else if (out instanceof File) {
+            return new FileOutputStream(out);
+        }
+    }
 
-	// everything failed, just return System.out
-	return java.lang.System.out;
+    // everything failed, just return System.out
+    return java.lang.System.out;
 }
 
 /**
@@ -276,17 +305,17 @@
  * @private
  */
 function streamClose(stream) {
-	if (stream) {
-		if (stream != java.lang.System["in"] &&
-			stream != java.lang.System.out &&
-			stream != java.lang.System.err) {
-			try {
-				stream.close();
-			} catch (e) {
-				println(e);
-			}
-		}
-	}
+    if (stream) {
+        if (stream != java.lang.System["in"] &&
+            stream != java.lang.System.out &&
+            stream != java.lang.System.err) {
+            try {
+                stream.close();
+            } catch (e) {
+                println(e);
+            }
+        }
+    }
 }
 
 /**
@@ -302,18 +331,20 @@
  *
  * @param str input from which script is loaded and evaluated
  */
-function load(str) {
-	var stream = inStream(str);
-	var bstream = new BufferedInputStream(stream);
-	var reader = new BufferedReader(new InputStreamReader(bstream));
-	var oldFilename = engine.get(engine.FILENAME);
-	engine.put(engine.FILENAME, str);	
-	try {
-		engine.eval(reader);
-	} finally {
-		engine.put(engine.FILENAME, oldFilename);
-	        streamClose(stream);
-	}
+if (typeof(load) == 'undefined') {
+    var load = function(str) {
+        var stream = inStream(str);
+        var bstream = new BufferedInputStream(stream);
+        var reader = new BufferedReader(new InputStreamReader(bstream));
+        var oldFilename = engine.get(engine.FILENAME);
+        engine.put(engine.FILENAME, str);
+        try {
+            engine.eval(reader);
+        } finally {
+            engine.put(engine.FILENAME, oldFilename);
+            streamClose(stream);
+        }
+    }
 }
 
 // file system utilities
@@ -324,7 +355,7 @@
  * @private
  */
 function javaByteArray(len) {
-	return java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, len);
+    return java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, len);
 }
 
 var curDir = new File('.');
@@ -333,7 +364,7 @@
  * Print present working directory
  */
 function pwd() {
-	println(curDir.getAbsolutePath());
+    println(curDir.getAbsolutePath());
 }
 
 /**
@@ -341,17 +372,17 @@
  * @param target directory to change to. optional, defaults to user's HOME
  */
 function cd(target) {
-	if (target == undefined) {
-		target = sysProps["user.home"];
-	}
-	if (!(target instanceof File)) {
-		target = pathToFile(target);
-	}
-	if (target.exists() && target.isDirectory()) {
-		curDir = target;
-	} else {
-		println(target + " is not a directory");
-	}
+    if (target == undefined) {
+        target = sysProps["user.home"];
+    }
+    if (!(target instanceof File)) {
+        target = pathToFile(target);
+    }
+    if (target.exists() && target.isDirectory()) {
+        curDir = target;
+    } else {
+        println(target + " is not a directory");
+    }
 }
 
 /**
@@ -361,15 +392,15 @@
  * @private
  */
 function pathToFile(pathname) {
-	var tmp = pathname;
-	if (!(tmp instanceof File)) {
-		tmp = new File(tmp);
-	}
-	if (!tmp.isAbsolute()) {
-		return new File(curDir, pathname);
-	} else {
-		return tmp;
-	}
+    var tmp = pathname;
+    if (!(tmp instanceof File)) {
+        tmp = new File(tmp);
+    }
+    if (!tmp.isAbsolute()) {
+        return new File(curDir, pathname);
+    } else {
+        return tmp;
+    }
 }
 
 /**
@@ -379,22 +410,22 @@
  * @param to output stream or file
  */
 function cp(from, to) {
-	if (from == to) {
-		println("file " + from + " cannot be copied onto itself!");
-		return;
-	}
-	var inp = inStream(from);
-	var out = outStream(to);
-	var binp = new BufferedInputStream(inp);
-	var bout = new BufferedOutputStream(out);
-	var buff = javaByteArray(1024);
-	var len;
-	while ((len = binp.read(buff)) > 0 )
-		bout.write(buff, 0, len);
+    if (from == to) {
+        println("file " + from + " cannot be copied onto itself!");
+        return;
+    }
+    var inp = inStream(from);
+    var out = outStream(to);
+    var binp = new BufferedInputStream(inp);
+    var bout = new BufferedOutputStream(out);
+    var buff = javaByteArray(1024);
+    var len;
+    while ((len = binp.read(buff)) > 0 )
+        bout.write(buff, 0, len);
 
-	bout.flush();
-	streamClose(inp);
-	streamClose(out);	
+    bout.flush();
+    streamClose(inp);
+    streamClose(out);
 }
 
 /**
@@ -403,37 +434,37 @@
  * <pre>
  * <code>
  *    cat('test.txt'); // show test.txt file contents
- *    cat('http://java.net'); // show the contents from the URL http://java.net 
+ *    cat('http://java.net'); // show the contents from the URL http://java.net
  * </code>
  * </pre>
  * @param obj input to show
  * @param pattern optional. show only the lines matching the pattern
  */
 function cat(obj, pattern) {
-	if (obj instanceof File && obj.isDirectory()) {
-		ls(obj);
-		return;
-	}
-	
-	var inp = null;
-	if (!(obj instanceof Reader)) {
-		inp = inStream(obj);
-		obj = new BufferedReader(new InputStreamReader(inp));
-	}
-	var line;
-	if (pattern) {
-		var count = 1;
-		while ((line=obj.readLine()) != null) {
-			if (line.match(pattern)) {
-				println(count + "\t: " + line);
-			}
-			count++;
-		}
-	} else {
-		while ((line=obj.readLine()) != null) {
-			println(line);
-		}
-	}
+    if (obj instanceof File && obj.isDirectory()) {
+        ls(obj);
+        return;
+    }
+
+    var inp = null;
+    if (!(obj instanceof Reader)) {
+        inp = inStream(obj);
+        obj = new BufferedReader(new InputStreamReader(inp));
+    }
+    var line;
+    if (pattern) {
+        var count = 1;
+        while ((line=obj.readLine()) != null) {
+            if (line.match(pattern)) {
+                println(count + "\t: " + line);
+            }
+            count++;
+        }
+    } else {
+        while ((line=obj.readLine()) != null) {
+            println(line);
+        }
+    }
 }
 
 /**
@@ -443,13 +474,13 @@
  * @return directory part of the given file name
  */
 function dirname(pathname) {
-	var dirName = ".";
-	// Normalize '/' to local file separator before work.
-	var i = pathname.replace('/', File.separatorChar ).lastIndexOf( 
-		File.separator );
-	if ( i != -1 )
-		dirName = pathname.substring(0, i);
-	return dirName;
+    var dirName = ".";
+    // Normalize '/' to local file separator before work.
+    var i = pathname.replace('/', File.separatorChar ).lastIndexOf(
+        File.separator );
+    if ( i != -1 )
+        dirName = pathname.substring(0, i);
+    return dirName;
 }
 
 /**
@@ -458,34 +489,34 @@
  * @param dir name of the new directory
  */
 function mkdir(dir) {
-	var dir = pathToFile(dir);
-	println(dir.mkdir()? "created" : "can not create dir");
+    dir = pathToFile(dir);
+    println(dir.mkdir()? "created" : "can not create dir");
 }
 
 /**
- * Creates the directory named by given pathname, including 
+ * Creates the directory named by given pathname, including
  * any necessary but nonexistent parent directories.
  *
  * @param dir input path name
  */
 function mkdirs(dir) {
-	var dir = pathToFile(dir);
-	println(dir.mkdirs()? "created" : "can not create dirs");
+    dir = pathToFile(dir);
+    println(dir.mkdirs()? "created" : "can not create dirs");
 }
-	
+
 /**
- * Removes a given file 
+ * Removes a given file
  *
- * @param pathname name of the file 
+ * @param pathname name of the file
  */
 function rm(pathname) {
-    	file = pathToFile(pathname);
-	if (!file.exists()) {
-		println("file not found: " + pathname);
-		return false;
-	}
-	// note that delete is a keyword in JavaScript!
-	println(file["delete"]()? "deleted" : "can not delete");
+    var file = pathToFile(pathname);
+    if (!file.exists()) {
+        println("file not found: " + pathname);
+        return false;
+    }
+    // note that delete is a keyword in JavaScript!
+    println(file["delete"]()? "deleted" : "can not delete");
 }
 
 /**
@@ -494,14 +525,14 @@
  * @param pathname name of the directory
  */
 function rmdir(pathname) {
-	rm(pathname);
+    rm(pathname);
 }
 
 /**
  * Synonym for 'rm'
  */
 function del(pathname) {
-	rm(pathname);
+    rm(pathname);
 }
 
 /**
@@ -511,62 +542,62 @@
  * @param to new name for the file
  */
 function mv(from, to) {
-	println(pathToFile(from).renameTo(pathToFile(to))? 
-		"moved" : "can not move");
+    println(pathToFile(from).renameTo(pathToFile(to))?
+        "moved" : "can not move");
 }
 
 /**
  * Synonym for 'mv'.
  */
 function ren(from, to) {
-	mv(from, to);
+    mv(from, to);
 }
 
-var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
-		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
+var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
 
 /**
  * Helper function called by ls
  * @private
- */	
+ */
 function printFile(f) {
-	var sb = new java.lang.StringBuffer();
-	sb.append(f.isDirectory()? "d" : "-");
-	sb.append(f.canRead() ? "r": "-" );
-	sb.append(f.canWrite() ? "w": "-" );		
-	sb.append(" ");
+    var sb = new java.lang.StringBuffer();
+    sb.append(f.isDirectory()? "d" : "-");
+    sb.append(f.canRead() ? "r": "-" );
+    sb.append(f.canWrite() ? "w": "-" );
+    sb.append(" ");
 
-	var d = new java.util.Date(f.lastModified());
-	var c = new java.util.GregorianCalendar();
-	c.setTime(d);
-	var day	= c.get(java.util.Calendar.DAY_OF_MONTH);
-	sb.append(months[c.get(java.util.Calendar.MONTH)]
-		 + " " + day );
-	if (day < 10) {
-		sb.append(" ");
-	}
+    var d = new java.util.Date(f.lastModified());
+    var c = new java.util.GregorianCalendar();
+    c.setTime(d);
+    var day    = c.get(java.util.Calendar.DAY_OF_MONTH);
+    sb.append(months[c.get(java.util.Calendar.MONTH)]
+         + " " + day );
+    if (day < 10) {
+        sb.append(" ");
+    }
 
-	// to get fixed length 'length' field
-	var fieldlen = 8;
-	var len = new java.lang.StringBuffer();
-	for(var j=0; j<fieldlen; j++)
-		len.append(" ");
-	len.insert(0, java.lang.Long.toString(f.length()));
-	len.setLength(fieldlen);
-	// move the spaces to the front
-	var si = len.toString().indexOf(" ");
-	if ( si != -1 ) {
-		var pad = len.toString().substring(si);
-		len.setLength(si);
-		len.insert(0, pad);
-	}
-	sb.append(len.toString());
-	sb.append(" ");
-	sb.append(f.getName());
-	if (f.isDirectory()) {
-		sb.append('/');
-	}
-	println(sb.toString());
+    // to get fixed length 'length' field
+    var fieldlen = 8;
+    var len = new java.lang.StringBuffer();
+    for(var j=0; j<fieldlen; j++)
+        len.append(" ");
+    len.insert(0, java.lang.Long.toString(f.length()));
+    len.setLength(fieldlen);
+    // move the spaces to the front
+    var si = len.toString().indexOf(" ");
+    if ( si != -1 ) {
+        var pad = len.toString().substring(si);
+        len.setLength(si);
+        len.insert(0, pad);
+    }
+    sb.append(len.toString());
+    sb.append(" ");
+    sb.append(f.getName());
+    if (f.isDirectory()) {
+        sb.append('/');
+    }
+    println(sb.toString());
 }
 
 /**
@@ -576,32 +607,32 @@
  * @param filter pattern to filter the files listed. optional, default is '.'.
  */
 function ls(dir, filter) {
-	if (dir) {
-		dir = pathToFile(dir);		
-	} else {
-		dir = curDir;
-	}
-	if (dir.isDirectory()) {
-		var files = dir.listFiles();
-		for (var i in files) {
-			var f = files[i];
-			if (filter) {			
-				if(!f.getName().match(filter)) {
-					continue;
-				}
-			}
-			printFile(f);
-		}
-	} else {
-		printFile(dir);
-	}
+    if (dir) {
+        dir = pathToFile(dir);
+    } else {
+        dir = curDir;
+    }
+    if (dir.isDirectory()) {
+        var files = dir.listFiles();
+        for (var i in files) {
+            var f = files[i];
+            if (filter) {
+                if(!f.getName().match(filter)) {
+                    continue;
+                }
+            }
+            printFile(f);
+        }
+    } else {
+        printFile(dir);
+    }
 }
 
 /**
  * Synonym for 'ls'.
  */
 function dir(d, filter) {
-	ls(d, filter);
+    ls(d, filter);
 }
 
 /**
@@ -611,24 +642,24 @@
  * @param files one or more files
  */
 function grep(pattern, files /*, one or more files */) {
-	if (arguments.length < 2) return;
-	for (var i = 1; i < arguments.length; i++) {
-		println(arguments[i] + ":");
-		cat(arguments[i], pattern);
-	}
+    if (arguments.length < 2) return;
+    for (var i = 1; i < arguments.length; i++) {
+        println(arguments[i] + ":");
+        cat(arguments[i], pattern);
+    }
 }
 
 /**
  * Find in files. Calls arbitrary callback function
  * for each matching file.<br>
  *
- * Examples: 
+ * Examples:
  * <pre>
  * <code>
- *    find('.') 
- *    find('.', '.*\.class', rm);  // remove all .class files 
- *    find('.', '.*\.java');       // print fullpath of each .java file 
- *    find('.', '.*\.java', cat);  // print all .java files 
+ *    find('.')
+ *    find('.', '.*\.class', rm);  // remove all .class files
+ *    find('.', '.*\.java');       // print fullpath of each .java file
+ *    find('.', '.*\.java', cat);  // print all .java files
  * </code>
  * </pre>
  *
@@ -637,23 +668,23 @@
  * @param callback function to call for matching files
  */
 function find(dir, pattern, callback) {
-	dir = pathToFile(dir);
-	if (!callback) callback = print;
-	var files = dir.listFiles();
-	for (var f in files) {
-		var file = files[f];
-		if (file.isDirectory()) {
-			find(file, pattern, callback);
-		} else {
-			if (pattern) {
-				if (file.getName().match(pattern)) {
-					callback(file);
-				}
-			} else {
-				callback(file);
-			}
-		}
-	}	
+    dir = pathToFile(dir);
+    if (!callback) callback = print;
+    var files = dir.listFiles();
+    for (var f in files) {
+        var file = files[f];
+        if (file.isDirectory()) {
+            find(file, pattern, callback);
+        } else {
+            if (pattern) {
+                if (file.getName().match(pattern)) {
+                    callback(file);
+                }
+            } else {
+                callback(file);
+            }
+        }
+    }
 }
 
 // process utilities
@@ -664,40 +695,44 @@
  * @param cmd command to execute in child process
  */
 function exec(cmd) {
-	var process = java.lang.Runtime.getRuntime().exec(cmd);
-	var inp = new DataInputStream(process.getInputStream());
-	var line = null;
-	while ((line = inp.readLine()) != null) {
-		println(line);
-	}
-	process.waitFor();
-	$exit = process.exitValue();
+    var process = java.lang.Runtime.getRuntime().exec(cmd);
+    var inp = new DataInputStream(process.getInputStream());
+    var line = null;
+    while ((line = inp.readLine()) != null) {
+        println(line);
+    }
+    process.waitFor();
+    $exit = process.exitValue();
 }
 
-/**
- * Exit the shell program.
- *
- * @param exitCode integer code returned to OS shell.
- * optional, defaults to 0
- */
-function exit(code) {
-	if (code) {
-		java.lang.System.exit(code + 0);		
-	} else {
-		java.lang.System.exit(0);		
-	}
+if (typeof(exit) == 'undefined') {
+    /**
+     * Exit the shell program.
+     *
+     * @param exitCode integer code returned to OS shell.
+     * optional, defaults to 0
+     */
+    var exit = function (code) {
+        if (code) {
+            java.lang.System.exit(code + 0);
+        } else {
+            java.lang.System.exit(0);
+        }
+    }
 }
 
-/**
- * synonym for exit
- */
-function quit(code) {
-	exit(code);
+if (typeof(quit) == 'undefined') {
+    /**
+     * synonym for exit
+     */
+    var quit = function (code) {
+        exit(code);
+    }
 }
 
 // XML utilities
 
-/** 
+/**
  * Converts input to DOM Document object
  *
  * @param inp file or reader. optional, without this param,
@@ -705,17 +740,17 @@
  * @return returns a DOM Document object
  */
 function XMLDocument(inp) {
-	var factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
-	var builder = factory.newDocumentBuilder();
-	if (inp) {
-		if (typeof(inp) == "string") {
-			return builder.parse(pathToFile(inp));
-		} else {
-			return builder.parse(inp);
-		}
-	} else {
-		return builder.newDocument();
-	}
+    var factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
+    var builder = factory.newDocumentBuilder();
+    if (inp) {
+        if (typeof(inp) == "string") {
+            return builder.parse(pathToFile(inp));
+        } else {
+            return builder.parse(inp);
+        }
+    } else {
+        return builder.newDocument();
+    }
 }
 
 /**
@@ -725,14 +760,14 @@
  * @return XMLSource object
  */
 function XMLSource(inp) {
-	if (inp instanceof javax.xml.transform.Source) {
-		return inp;
-	} else if (inp instanceof Packages.org.w3c.dom.Document) {
-		return new javax.xml.transform.dom.DOMSource(inp);
-	} else {
-		inp = new BufferedInputStream(inStream(inp));
-		return new javax.xml.transform.stream.StreamSource(inp);
-	}
+    if (inp instanceof javax.xml.transform.Source) {
+        return inp;
+    } else if (inp instanceof Packages.org.w3c.dom.Document) {
+        return new javax.xml.transform.dom.DOMSource(inp);
+    } else {
+        inp = new BufferedInputStream(inStream(inp));
+        return new javax.xml.transform.stream.StreamSource(inp);
+    }
 }
 
 /**
@@ -742,73 +777,73 @@
  * @return XMLResult object
  */
 function XMLResult(out) {
-	if (out instanceof javax.xml.transform.Result) {
-		return out;
-	} else if (out instanceof Packages.org.w3c.dom.Document) {
-		return new javax.xml.transform.dom.DOMResult(out);
-	} else {
-		out = new BufferedOutputStream(outStream(out));
-		return new javax.xml.transform.stream.StreamResult(out);
-	}
+    if (out instanceof javax.xml.transform.Result) {
+        return out;
+    } else if (out instanceof Packages.org.w3c.dom.Document) {
+        return new javax.xml.transform.dom.DOMResult(out);
+    } else {
+        out = new BufferedOutputStream(outStream(out));
+        return new javax.xml.transform.stream.StreamResult(out);
+    }
 }
 
 /**
- * Perform XSLT transform 
+ * Perform XSLT transform
  *
  * @param inp Input XML to transform (URL, File or InputStream)
  * @param style XSL Stylesheet to be used (URL, File or InputStream). optional.
  * @param out Output XML (File or OutputStream
  */
 function XSLTransform(inp, style, out) {
-	switch (arguments.length) {
-	case 2:
-		inp = arguments[0];
-		out = arguments[1];
-		break;
-	case 3:
-		inp = arguments[0];
-		style = arguments[1];
-		out = arguments[2];
-		break;
-	default:
-		println("XSL tranform requires 2 or 3 arguments");
-		return;
-	}
+    switch (arguments.length) {
+    case 2:
+        inp = arguments[0];
+        out = arguments[1];
+        break;
+    case 3:
+        inp = arguments[0];
+        style = arguments[1];
+        out = arguments[2];
+        break;
+    default:
+        println("XSL tranform requires 2 or 3 arguments");
+        return;
+    }
 
-	var factory = javax.xml.transform.TransformerFactory.newInstance();
-	var tranformer;
-	if (style) {		
-		transformer = factory.newTransformer(XMLSource(style));	
-	} else {
-		transformer = factory.newTransformer();
-	}
-	var source = XMLSource(inp);
-	var result = XMLResult(out);
-	transformer.transform(source, result);
-	if (source.getInputStream) {
-		streamClose(source.getInputStream());
-	}
-	if (result.getOutputStream) {
-		streamClose(result.getOutputStream());
-	}
+    var factory = javax.xml.transform.TransformerFactory.newInstance();
+    var transformer;
+    if (style) {
+        transformer = factory.newTransformer(XMLSource(style));
+    } else {
+        transformer = factory.newTransformer();
+    }
+    var source = XMLSource(inp);
+    var result = XMLResult(out);
+    transformer.transform(source, result);
+    if (source.getInputStream) {
+        streamClose(source.getInputStream());
+    }
+    if (result.getOutputStream) {
+        streamClose(result.getOutputStream());
+    }
 }
 
 // miscellaneous utilities
 
 /**
- * Prints which command is selected from PATH 
+ * Prints which command is selected from PATH
  *
  * @param cmd name of the command searched from PATH
  */
 function which(cmd) {
-	var st = new java.util.StringTokenizer(env.PATH, File.pathSeparator);
-	while (st.hasMoreTokens()) {
-		var file = new File(st.nextToken(), cmd);
-		if (file.exists()) {
-			println(file.getAbsolutePath());
-			return;
-		}
-	}
+    var st = new java.util.StringTokenizer(env.PATH, File.pathSeparator);
+    while (st.hasMoreTokens()) {
+        var file = new File(st.nextToken(), cmd);
+        if (file.exists()) {
+            println(file.getAbsolutePath());
+            return;
+        }
+    }
 }
 
 /**
@@ -817,41 +852,43 @@
  * @param name domain name
  */
 function ip(name) {
-	var addrs = InetAddress.getAllByName(name);	
-	for (var i in addrs) {
-		println(addrs[i]);
-	}
+    var addrs = InetAddress.getAllByName(name);
+    for (var i in addrs) {
+        println(addrs[i]);
+    }
 }
 
 /**
  * Prints current date in current locale
  */
 function date() {
-	println(new Date().toLocaleString());
+    println(new Date().toLocaleString());
 }
 
 /**
  * Echoes the given string arguments
  */
 function echo(x) {
-	for (var i = 0; i < arguments.length; i++) {
-		println(arguments[i]);
-	}
+    for (var i = 0; i < arguments.length; i++) {
+        println(arguments[i]);
+    }
 }
 
-/**
- * This is C-like printf 
- *
- * @param format string to format the rest of the print items
- * @param args variadic argument list
- */
-function printf(format, args/*, more args*/) {	
-	var array = java.lang.reflect.Array.newInstance(java.lang.Object, 
-			arguments.length - 1);
-	for (var i = 0; i < array.length; i++) {
-		array[i] = arguments[i+1];
-	}
-	return java.lang.System.out.printf(format, array);
+if (typeof(printf) == 'undefined') {
+    /**
+     * This is C-like printf 
+     *
+     * @param format string to format the rest of the print items
+     * @param args variadic argument list
+     */
+    var printf = function (format, args/*, more args*/) {  
+        var array = java.lang.reflect.Array.newInstance(java.lang.Object, 
+                    arguments.length - 1);
+        for (var i = 0; i < array.length; i++) {
+            array[i] = arguments[i+1];
+        }
+        java.lang.System.out.printf(format, array);
+    }
 }
 
 /**
@@ -861,24 +898,48 @@
  * @param multiline to tell whether to read single line or multiple lines
  */
 function read(prompt, multiline) {
-	if (!prompt) {
-		prompt = '>';
-	}	
-	var inp = java.lang.System["in"];
-	var reader = new BufferedReader(new InputStreamReader(inp));
-	if (multiline) {
-		var line = '';
-		while (true) {
-			java.lang.System.err.print(prompt);
-			java.lang.System.err.flush();
-			var tmp = reader.readLine();
-			if (tmp == '' || tmp == null) break;
-			line += tmp + '\n';
-		}
-		return line;
-	} else {
-		java.lang.System.err.print(prompt);
-		java.lang.System.err.flush();	
-		return reader.readLine();
-	}
+    if (!prompt) {
+        prompt = '>';
+    }
+    var inp = java.lang.System["in"];
+    var reader = new BufferedReader(new InputStreamReader(inp));
+    if (multiline) {
+        var line = '';
+        while (true) {
+            java.lang.System.err.print(prompt);
+            java.lang.System.err.flush();
+            var tmp = reader.readLine();
+            if (tmp == '' || tmp == null) break;
+            line += tmp + '\n';
+        }
+        return line;
+    } else {
+        java.lang.System.err.print(prompt);
+        java.lang.System.err.flush();
+        return reader.readLine();
+    }
 }
+
+if (typeof(println) == 'undefined') {
+    var print = function(str, newline) {
+        if (typeof(str) == 'undefined') {
+            str = 'undefined';
+        } else if (str == null) {
+            str = 'null';
+        }
+
+        if (!(out instanceof java.io.PrintWriter)) {
+            out = new java.io.PrintWriter(out);
+        }
+
+        out.print(String(str));
+        if (newline) {
+            out.print('\n');
+        }
+        out.flush();
+    }
+
+    var println = function(str) {
+        print(str, true);
+    };
+}
--- a/src/share/classes/java/lang/Class.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/Class.java	Fri Mar 15 11:51:02 2013 -0300
@@ -25,6 +25,7 @@
 
 package java.lang;
 
+import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Array;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Member;
@@ -3084,6 +3085,16 @@
     }
 
     /**
+     * {@inheritDoc}
+     * @throws NullPointerException {@inheritDoc}
+     * @since 1.5
+     */
+    @Override
+    public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+        return AnnotatedElement.super.isAnnotationPresent(annotationClass);
+    }
+
+    /**
      * @throws NullPointerException {@inheritDoc}
      * @since 1.8
      */
--- a/src/share/classes/java/lang/ClassLoader.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/ClassLoader.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -51,7 +51,6 @@
 import java.util.Hashtable;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
-import sun.misc.ClassFileTransformer;
 import sun.misc.CompoundEnumeration;
 import sun.misc.Resource;
 import sun.misc.URLClassPath;
@@ -669,41 +668,6 @@
         return source;
     }
 
-    private Class<?> defineTransformedClass(String name, byte[] b, int off, int len,
-                                            ProtectionDomain pd,
-                                            ClassFormatError cfe, String source)
-      throws ClassFormatError
-    {
-        // Class format error - try to transform the bytecode and
-        // define the class again
-        //
-        ClassFileTransformer[] transformers =
-            ClassFileTransformer.getTransformers();
-        Class<?> c = null;
-
-        if (transformers != null) {
-            for (ClassFileTransformer transformer : transformers) {
-                try {
-                    // Transform byte code using transformer
-                    byte[] tb = transformer.transform(b, off, len);
-                    c = defineClass1(name, tb, 0, tb.length,
-                                     pd, source);
-                    break;
-                } catch (ClassFormatError cfe2)     {
-                    // If ClassFormatError occurs, try next transformer
-                }
-            }
-        }
-
-        // Rethrow original ClassFormatError if unable to transform
-        // bytecode to well-formed
-        //
-        if (c == null)
-            throw cfe;
-
-        return c;
-    }
-
     private void postDefineClass(Class<?> c, ProtectionDomain pd)
     {
         if (pd.getCodeSource() != null) {
@@ -783,17 +747,8 @@
         throws ClassFormatError
     {
         protectionDomain = preDefineClass(name, protectionDomain);
-
-        Class<?> c = null;
         String source = defineClassSourceLocation(protectionDomain);
-
-        try {
-            c = defineClass1(name, b, off, len, protectionDomain, source);
-        } catch (ClassFormatError cfe) {
-            c = defineTransformedClass(name, b, off, len, protectionDomain, cfe,
-                                       source);
-        }
-
+        Class<?> c = defineClass1(name, b, off, len, protectionDomain, source);
         postDefineClass(c, protectionDomain);
         return c;
     }
@@ -881,20 +836,8 @@
         }
 
         protectionDomain = preDefineClass(name, protectionDomain);
-
-        Class<?> c = null;
         String source = defineClassSourceLocation(protectionDomain);
-
-        try {
-            c = defineClass2(name, b, b.position(), len, protectionDomain,
-                             source);
-        } catch (ClassFormatError cfe) {
-            byte[] tb = new byte[len];
-            b.get(tb);  // get bytes out of byte buffer.
-            c = defineTransformedClass(name, tb, 0, len, protectionDomain, cfe,
-                                       source);
-        }
-
+        Class<?> c = defineClass2(name, b, b.position(), len, protectionDomain, source);
         postDefineClass(c, protectionDomain);
         return c;
     }
@@ -1740,22 +1683,29 @@
         private int jniVersion;
         // the class from which the library is loaded, also indicates
         // the loader this native library belongs.
-        private Class<?> fromClass;
+        private final Class<?> fromClass;
         // the canonicalized name of the native library.
+        // or static library name
         String name;
+        // Indicates if the native library is linked into the VM
+        boolean isBuiltin;
+        // Indicates if the native library is loaded
+        boolean loaded;
+        native void load(String name, boolean isBuiltin);
 
-        native void load(String name);
         native long find(String name);
-        native void unload();
+        native void unload(String name, boolean isBuiltin);
+        static native String findBuiltinLib(String name);
 
-        public NativeLibrary(Class<?> fromClass, String name) {
+        public NativeLibrary(Class<?> fromClass, String name, boolean isBuiltin) {
             this.name = name;
             this.fromClass = fromClass;
+            this.isBuiltin = isBuiltin;
         }
 
         protected void finalize() {
             synchronized (loadedLibraryNames) {
-                if (fromClass.getClassLoader() != null && handle != 0) {
+                if (fromClass.getClassLoader() != null && loaded) {
                     /* remove the native library name */
                     int size = loadedLibraryNames.size();
                     for (int i = 0; i < size; i++) {
@@ -1767,7 +1717,7 @@
                     /* unload the library. */
                     ClassLoader.nativeLibraryContext.push(this);
                     try {
-                        unload();
+                        unload(name, isBuiltin);
                     } finally {
                         ClassLoader.nativeLibraryContext.pop();
                     }
@@ -1887,20 +1837,24 @@
     }
 
     private static boolean loadLibrary0(Class<?> fromClass, final File file) {
-        boolean exists = AccessController.doPrivileged(
-            new PrivilegedAction<Object>() {
-                public Object run() {
-                    return file.exists() ? Boolean.TRUE : null;
-                }})
-            != null;
-        if (!exists) {
-            return false;
-        }
-        String name;
-        try {
-            name = file.getCanonicalPath();
-        } catch (IOException e) {
-            return false;
+        // Check to see if we're attempting to access a static library
+        String name = NativeLibrary.findBuiltinLib(file.getName());
+        boolean isBuiltin = (name != null);
+        if (!isBuiltin) {
+            boolean exists = AccessController.doPrivileged(
+                new PrivilegedAction<Object>() {
+                    public Object run() {
+                        return file.exists() ? Boolean.TRUE : null;
+                    }})
+                != null;
+            if (!exists) {
+                return false;
+            }
+            try {
+                name = file.getCanonicalPath();
+            } catch (IOException e) {
+                return false;
+            }
         }
         ClassLoader loader =
             (fromClass == null) ? null : fromClass.getClassLoader();
@@ -1948,14 +1902,14 @@
                         }
                     }
                 }
-                NativeLibrary lib = new NativeLibrary(fromClass, name);
+                NativeLibrary lib = new NativeLibrary(fromClass, name, isBuiltin);
                 nativeLibraryContext.push(lib);
                 try {
-                    lib.load(name);
+                    lib.load(name, isBuiltin);
                 } finally {
                     nativeLibraryContext.pop();
                 }
-                if (lib.handle != 0) {
+                if (lib.loaded) {
                     loadedLibraryNames.addElement(name);
                     libs.addElement(lib);
                     return true;
--- a/src/share/classes/java/lang/Package.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/Package.java	Fri Mar 15 11:51:02 2013 -0300
@@ -25,6 +25,7 @@
 
 package java.lang;
 
+import java.lang.reflect.AnnotatedElement;
 import java.io.InputStream;
 import java.util.Enumeration;
 
@@ -386,6 +387,16 @@
     }
 
     /**
+     * {@inheritDoc}
+     * @throws NullPointerException {@inheritDoc}
+     * @since 1.5
+     */
+    @Override
+    public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+        return AnnotatedElement.super.isAnnotationPresent(annotationClass);
+    }
+
+    /**
      * @throws NullPointerException {@inheritDoc}
      * @since 1.8
      */
--- a/src/share/classes/java/lang/Runtime.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/Runtime.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -749,10 +749,21 @@
     public native void traceMethodCalls(boolean on);
 
     /**
-     * Loads the specified filename as a dynamic library. The filename
-     * argument must be a complete path name,
+     * Loads the native library specified by the filename argument.  The filename
+     * argument must be an absolute path name.
      * (for example
      * <code>Runtime.getRuntime().load("/home/avh/lib/libX11.so");</code>).
+     *
+     * If the filename argument, when stripped of any platform-specific library
+     * prefix, path, and file extension, indicates a library whose name is,
+     * for example, L, and a native library called L is statically linked
+     * with the VM, then the JNI_OnLoad_L function exported by the library
+     * is invoked rather than attempting to load a dynamic library.
+     * A filename matching the argument does not have to exist in the file
+     * system. See the JNI Specification for more details.
+     *
+     * Otherwise, the filename argument is mapped to a native library image in
+     * an implementation-dependent manner.
      * <p>
      * First, if there is a security manager, its <code>checkLink</code>
      * method is called with the <code>filename</code> as its argument.
@@ -769,7 +780,10 @@
      * @exception  SecurityException  if a security manager exists and its
      *             <code>checkLink</code> method doesn't allow
      *             loading of the specified dynamic library
-     * @exception  UnsatisfiedLinkError  if the file does not exist.
+     * @exception  UnsatisfiedLinkError  if either the filename is not an
+     *             absolute path name, the native library is not statically
+     *             linked with the VM, or the library cannot be mapped to
+     *             a native library image by the host system.
      * @exception  NullPointerException if <code>filename</code> is
      *             <code>null</code>
      * @see        java.lang.Runtime#getRuntime()
@@ -793,12 +807,16 @@
     }
 
     /**
-     * Loads the dynamic library with the specified library name.
-     * A file containing native code is loaded from the local file system
-     * from a place where library files are conventionally obtained. The
-     * details of this process are implementation-dependent. The
-     * mapping from a library name to a specific filename is done in a
-     * system-specific manner.
+     * Loads the native library specified by the <code>libname</code>
+     * argument.  The <code>libname</code> argument must not contain any platform
+     * specific prefix, file extension or path. If a native library
+     * called <code>libname</code> is statically linked with the VM, then the
+     * JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
+     * See the JNI Specification for more details.
+     *
+     * Otherwise, the libname argument is loaded from a system library
+     * location and mapped to a native library image in an implementation-
+     * dependent manner.
      * <p>
      * First, if there is a security manager, its <code>checkLink</code>
      * method is called with the <code>libname</code> as its argument.
@@ -823,7 +841,10 @@
      * @exception  SecurityException  if a security manager exists and its
      *             <code>checkLink</code> method doesn't allow
      *             loading of the specified dynamic library
-     * @exception  UnsatisfiedLinkError  if the library does not exist.
+     * @exception  UnsatisfiedLinkError if either the libname argument
+     *             contains a file path, the native library is not statically
+     *             linked with the VM,  or the library cannot be mapped to a
+     *             native library image by the host system.
      * @exception  NullPointerException if <code>libname</code> is
      *             <code>null</code>
      * @see        java.lang.SecurityException
--- a/src/share/classes/java/lang/System.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/System.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1037,9 +1037,21 @@
     }
 
     /**
-     * Loads a code file with the specified filename from the local file
-     * system as a dynamic library. The filename
-     * argument must be a complete path name.
+     * Loads the native library specified by the filename argument.  The filename
+     * argument must be an absolute path name.
+     *
+     * If the filename argument, when stripped of any platform-specific library
+     * prefix, path, and file extension, indicates a library whose name is,
+     * for example, L, and a native library called L is statically linked
+     * with the VM, then the JNI_OnLoad_L function exported by the library
+     * is invoked rather than attempting to load a dynamic library.
+     * A filename matching the argument does not have to exist in the
+     * file system.
+     * See the JNI Specification for more details.
+     *
+     * Otherwise, the filename argument is mapped to a native library image in
+     * an implementation-dependent manner.
+     *
      * <p>
      * The call <code>System.load(name)</code> is effectively equivalent
      * to the call:
@@ -1051,7 +1063,10 @@
      * @exception  SecurityException  if a security manager exists and its
      *             <code>checkLink</code> method doesn't allow
      *             loading of the specified dynamic library
-     * @exception  UnsatisfiedLinkError  if the file does not exist.
+     * @exception  UnsatisfiedLinkError  if either the filename is not an
+     *             absolute path name, the native library is not statically
+     *             linked with the VM, or the library cannot be mapped to
+     *             a native library image by the host system.
      * @exception  NullPointerException if <code>filename</code> is
      *             <code>null</code>
      * @see        java.lang.Runtime#load(java.lang.String)
@@ -1062,9 +1077,16 @@
     }
 
     /**
-     * Loads the system library specified by the <code>libname</code>
-     * argument. The manner in which a library name is mapped to the
-     * actual system library is system dependent.
+     * Loads the native library specified by the <code>libname</code>
+     * argument.  The <code>libname</code> argument must not contain any platform
+     * specific prefix, file extension or path. If a native library
+     * called <code>libname</code> is statically linked with the VM, then the
+     * JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
+     * See the JNI Specification for more details.
+     *
+     * Otherwise, the libname argument is loaded from a system library
+     * location and mapped to a native library image in an implementation-
+     * dependent manner.
      * <p>
      * The call <code>System.loadLibrary(name)</code> is effectively
      * equivalent to the call
@@ -1076,7 +1098,10 @@
      * @exception  SecurityException  if a security manager exists and its
      *             <code>checkLink</code> method doesn't allow
      *             loading of the specified dynamic library
-     * @exception  UnsatisfiedLinkError  if the library does not exist.
+     * @exception  UnsatisfiedLinkError if either the libname argument
+     *             contains a file path, the native library is not statically
+     *             linked with the VM,  or the library cannot be mapped to a
+     *             native library image by the host system.
      * @exception  NullPointerException if <code>libname</code> is
      *             <code>null</code>
      * @see        java.lang.Runtime#loadLibrary(java.lang.String)
--- a/src/share/classes/java/lang/reflect/AccessibleObject.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/reflect/AccessibleObject.java	Fri Mar 15 11:51:02 2013 -0300
@@ -181,6 +181,16 @@
     }
 
     /**
+     * {@inheritDoc}
+     * @throws NullPointerException {@inheritDoc}
+     * @since 1.5
+     */
+    @Override
+    public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+        return AnnotatedElement.super.isAnnotationPresent(annotationClass);
+    }
+
+   /**
      * @throws NullPointerException {@inheritDoc}
      * @since 1.8
      */
--- a/src/share/classes/java/lang/reflect/Constructor.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/reflect/Constructor.java	Fri Mar 15 11:51:02 2013 -0300
@@ -532,6 +532,7 @@
      * {@inheritDoc}
      * @since 1.8
      */
+    @Override
     public AnnotatedType getAnnotatedReturnType() {
         return getAnnotatedReturnType0(getDeclaringClass());
     }
--- a/src/share/classes/java/lang/reflect/Executable.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/reflect/Executable.java	Fri Mar 15 11:51:02 2013 -0300
@@ -476,6 +476,20 @@
         return declaredAnnotations;
     }
 
+    /**
+     * Returns an AnnotatedType object that represents the potentially
+     * annotated return type of the method/constructor represented by this
+     * Executable.
+     *
+     * If this Executable represents a constructor, the AnnotatedType object
+     * represents the type of the constructed object.
+     *
+     * If this Executable represents a method, the AnnotatedType object
+     * represents the use of a type to specify the return type of the method.
+     *
+     * @since 1.8
+     */
+    public abstract AnnotatedType getAnnotatedReturnType();
 
     /* Helper for subclasses of Executable.
      *
--- a/src/share/classes/java/lang/reflect/Method.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/lang/reflect/Method.java	Fri Mar 15 11:51:02 2013 -0300
@@ -629,6 +629,7 @@
      * {@inheritDoc}
      * @since 1.8
      */
+    @Override
     public AnnotatedType getAnnotatedReturnType() {
         return getAnnotatedReturnType0(getGenericReturnType());
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/net/HttpConnectSocketImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2010, 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 java.net;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Basic SocketImpl that relies on the internal HTTP protocol handler
+ * implementation to perform the HTTP tunneling and authentication. The
+ * sockets impl is swapped out and replaced with the socket from the HTTP
+ * handler after the tunnel is successfully setup.
+ *
+ * @since 1.8
+ */
+
+/*package*/ class HttpConnectSocketImpl extends PlainSocketImpl {
+
+    private static final String httpURLClazzStr =
+                                  "sun.net.www.protocol.http.HttpURLConnection";
+    private static final String netClientClazzStr = "sun.net.NetworkClient";
+    private static final String doTunnelingStr = "doTunneling";
+    private static final Field httpField;
+    private static final Field serverSocketField;
+    private static final Method doTunneling;
+
+    private final String server;
+    private InetSocketAddress external_address;
+    private HashMap<Integer, Object> optionsMap = new HashMap<>();
+
+    static  {
+        try {
+            Class<?> httpClazz = Class.forName(httpURLClazzStr, true, null);
+            httpField = httpClazz.getDeclaredField("http");
+            doTunneling = httpClazz.getDeclaredMethod(doTunnelingStr);
+            Class<?> netClientClazz = Class.forName(netClientClazzStr, true, null);
+            serverSocketField = netClientClazz.getDeclaredField("serverSocket");
+
+            java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<Void>() {
+                    public Void run() {
+                        httpField.setAccessible(true);
+                        serverSocketField.setAccessible(true);
+                        return null;
+                }
+            });
+        } catch (ReflectiveOperationException x) {
+            throw new InternalError("Should not reach here", x);
+        }
+    }
+
+    HttpConnectSocketImpl(String server, int port) {
+        this.server = server;
+        this.port = port;
+    }
+
+    HttpConnectSocketImpl(Proxy proxy) {
+        SocketAddress a = proxy.address();
+        if ( !(a instanceof InetSocketAddress) )
+            throw new IllegalArgumentException("Unsupported address type");
+
+        InetSocketAddress ad = (InetSocketAddress) a;
+        server = ad.getHostString();
+        port = ad.getPort();
+    }
+
+    @Override
+    protected void connect(SocketAddress endpoint, int timeout)
+        throws IOException
+    {
+        if (endpoint == null || !(endpoint instanceof InetSocketAddress))
+            throw new IllegalArgumentException("Unsupported address type");
+        final InetSocketAddress epoint = (InetSocketAddress)endpoint;
+        final String destHost = epoint.isUnresolved() ? epoint.getHostName()
+                                                      : epoint.getAddress().getHostAddress();
+        final int destPort = epoint.getPort();
+
+        SecurityManager security = System.getSecurityManager();
+        if (security != null)
+            security.checkConnect(destHost, destPort);
+
+        // Connect to the HTTP proxy server
+        String urlString = "http://" + destHost + ":" + destPort;
+        Socket httpSocket = privilegedDoTunnel(urlString, timeout);
+
+        // Success!
+        external_address = epoint;
+
+        // close the original socket impl and release its descriptor
+        close();
+
+        // update the Sockets impl to the impl from the http Socket
+        AbstractPlainSocketImpl psi = (AbstractPlainSocketImpl) httpSocket.impl;
+        this.getSocket().impl = psi;
+
+        // best effort is made to try and reset options previously set
+        Set<Map.Entry<Integer,Object>> options = optionsMap.entrySet();
+        try {
+            for(Map.Entry<Integer,Object> entry : options) {
+                psi.setOption(entry.getKey(), entry.getValue());
+            }
+        } catch (IOException x) {  /* gulp! */  }
+    }
+
+    @Override
+    public void setOption(int opt, Object val) throws SocketException {
+        super.setOption(opt, val);
+
+        if (external_address != null)
+            return;  // we're connected, just return
+
+        // store options so that they can be re-applied to the impl after connect
+        optionsMap.put(opt, val);
+    }
+
+    private Socket privilegedDoTunnel(final String urlString,
+                                      final int timeout)
+        throws IOException
+    {
+        try {
+            return java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedExceptionAction<Socket>() {
+                    public Socket run() throws IOException {
+                        return doTunnel(urlString, timeout);
+                }
+            });
+        } catch (java.security.PrivilegedActionException pae) {
+            throw (IOException) pae.getException();
+        }
+    }
+
+    private Socket doTunnel(String urlString, int connectTimeout)
+        throws IOException
+    {
+        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(server, port));
+        URL destURL = new URL(urlString);
+        HttpURLConnection conn = (HttpURLConnection) destURL.openConnection(proxy);
+        conn.setConnectTimeout(connectTimeout);
+        conn.setReadTimeout(this.timeout);
+        conn.connect();
+        doTunneling(conn);
+        try {
+            Object httpClient = httpField.get(conn);
+            return (Socket) serverSocketField.get(httpClient);
+        } catch (IllegalAccessException x) {
+            throw new InternalError("Should not reach here", x);
+        }
+    }
+
+    private void doTunneling(HttpURLConnection conn) {
+        try {
+            doTunneling.invoke(conn);
+        } catch (ReflectiveOperationException x) {
+            throw new InternalError("Should not reach here", x);
+        }
+    }
+
+    @Override
+    protected InetAddress getInetAddress() {
+        if (external_address != null)
+            return external_address.getAddress();
+        else
+            return super.getInetAddress();
+    }
+
+    @Override
+    protected int getPort() {
+        if (external_address != null)
+            return external_address.getPort();
+        else
+            return super.getPort();
+    }
+
+    @Override
+    protected int getLocalPort() {
+        if (socket != null)
+            return super.getLocalPort();
+        if (external_address != null)
+            return external_address.getPort();
+        else
+            return super.getLocalPort();
+    }
+}
--- a/src/share/classes/java/net/Socket.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/net/Socket.java	Fri Mar 15 11:51:02 2013 -0300
@@ -117,8 +117,10 @@
         if (proxy == null) {
             throw new IllegalArgumentException("Invalid Proxy");
         }
-        Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : sun.net.ApplicationProxy.create(proxy);
-        if (p.type() == Proxy.Type.SOCKS) {
+        Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY
+                                          : sun.net.ApplicationProxy.create(proxy);
+        Proxy.Type type = p.type();
+        if (type == Proxy.Type.SOCKS || type == Proxy.Type.HTTP) {
             SecurityManager security = System.getSecurityManager();
             InetSocketAddress epoint = (InetSocketAddress) p.address();
             if (epoint.getAddress() != null) {
@@ -133,7 +135,8 @@
                     security.checkConnect(epoint.getAddress().getHostAddress(),
                                   epoint.getPort());
             }
-            impl = new SocksSocketImpl(p);
+            impl = type == Proxy.Type.SOCKS ? new SocksSocketImpl(p)
+                                            : new HttpConnectSocketImpl(p);
             impl.setSocket(this);
         } else {
             if (p == Proxy.NO_PROXY) {
--- a/src/share/classes/java/net/URL.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/net/URL.java	Fri Mar 15 11:51:02 2013 -0300
@@ -661,8 +661,8 @@
      * @param file the file on the host
      * @param ref the internal reference in the URL
      */
-    protected void set(String protocol, String host,
-                       int port, String file, String ref) {
+    void set(String protocol, String host, int port,
+             String file, String ref) {
         synchronized (this) {
             this.protocol = protocol;
             this.host = host;
@@ -698,9 +698,9 @@
      * @param query the query part of this URL
      * @since 1.3
      */
-    protected void set(String protocol, String host, int port,
-                       String authority, String userInfo, String path,
-                       String query, String ref) {
+    void set(String protocol, String host, int port,
+             String authority, String userInfo, String path,
+             String query, String ref) {
         synchronized (this) {
             this.protocol = protocol;
             this.host = host;
--- a/src/share/classes/java/net/URLStreamHandler.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/net/URLStreamHandler.java	Fri Mar 15 11:51:02 2013 -0300
@@ -509,8 +509,8 @@
 
     /**
      * Sets the fields of the <code>URL</code> argument to the indicated values.
-     * Only classes derived from URLStreamHandler are supposed to be able
-     * to call the set method on a URL.
+     * Only classes derived from URLStreamHandler are able
+     * to use this method to set the values of the URL fields.
      *
      * @param   u         the URL to modify.
      * @param   protocol  the protocol name.
@@ -539,8 +539,8 @@
 
     /**
      * Sets the fields of the <code>URL</code> argument to the indicated values.
-     * Only classes derived from URLStreamHandler are supposed to be able
-     * to call the set method on a URL.
+     * Only classes derived from URLStreamHandler are able
+     * to use this method to set the values of the URL fields.
      *
      * @param   u         the URL to modify.
      * @param   protocol  the protocol name. This value is ignored since 1.2.
--- a/src/share/classes/java/util/Calendar.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/util/Calendar.java	Fri Mar 15 11:51:02 2013 -0300
@@ -57,6 +57,8 @@
 import sun.util.BuddhistCalendar;
 import sun.util.calendar.ZoneInfo;
 import sun.util.locale.provider.CalendarDataUtility;
+import sun.util.locale.provider.LocaleProviderAdapter;
+import sun.util.spi.CalendarProvider;
 
 /**
  * The <code>Calendar</code> class is an abstract class that provides methods
@@ -1608,9 +1610,7 @@
      */
     public static Calendar getInstance()
     {
-        Calendar cal = createCalendar(TimeZone.getDefaultRef(), Locale.getDefault(Locale.Category.FORMAT));
-        cal.sharedZone = true;
-        return cal;
+        return createCalendar(TimeZone.getDefault(), Locale.getDefault(Locale.Category.FORMAT));
     }
 
     /**
@@ -1637,9 +1637,7 @@
      */
     public static Calendar getInstance(Locale aLocale)
     {
-        Calendar cal = createCalendar(TimeZone.getDefaultRef(), aLocale);
-        cal.sharedZone = true;
-        return cal;
+        return createCalendar(TimeZone.getDefault(), aLocale);
     }
 
     /**
@@ -1660,6 +1658,17 @@
     private static Calendar createCalendar(TimeZone zone,
                                            Locale aLocale)
     {
+        CalendarProvider provider =
+            LocaleProviderAdapter.getAdapter(CalendarProvider.class, aLocale)
+                                 .getCalendarProvider();
+        if (provider != null) {
+            try {
+                return provider.getInstance(zone, aLocale);
+            } catch (IllegalArgumentException iae) {
+                // fall back to the default instantiation
+            }
+        }
+
         Calendar cal = null;
 
         if (aLocale.hasExtensions()) {
--- a/src/share/classes/java/util/Collections.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/util/Collections.java	Fri Mar 15 11:51:02 2013 -0300
@@ -3759,7 +3759,7 @@
             return c2.compareTo(c1);
         }
 
-        private Object readResolve() { return reverseOrder(); }
+        private Object readResolve() { return Collections.reverseOrder(); }
     }
 
     /**
--- a/src/share/classes/java/util/Comparator.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/util/Comparator.java	Fri Mar 15 11:51:02 2013 -0300
@@ -25,6 +25,11 @@
 
 package java.util;
 
+import java.util.function.Function;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+import java.util.function.ToDoubleFunction;
+
 /**
  * A comparison function, which imposes a <i>total ordering</i> on some
  * collection of objects.  Comparators can be passed to a sort method (such
@@ -165,4 +170,93 @@
      * @see Object#hashCode()
      */
     boolean equals(Object obj);
+
+    /**
+     * Returns a comparator that imposes the reverse ordering of this
+     * comparator.
+     *
+     * @return A comparator that imposes the reverse ordering of this
+     *         comparator.
+     * @since 1.8
+     */
+    default Comparator<T> reverseOrder() {
+        return Collections.reverseOrder(this);
+    }
+
+    /**
+     * Constructs a lexicographic order comparator with another comparator.
+     * For example, a {@code Comparator<Person> byLastName} can be composed
+     * with another {@code Comparator<Person> byFirstName}, then {@code
+     * byLastName.thenComparing(byFirstName)} creates a {@code
+     * Comparator<Person>} which sorts by last name, and for equal last names
+     * sorts by first name.
+     *
+     * @param other the other comparator used when equals on this.
+     * @throws NullPointerException if the argument is null.
+     * @since 1.8
+     */
+    default Comparator<T> thenComparing(Comparator<? super T> other) {
+        return Comparators.compose(this, other);
+    }
+
+    /**
+     * Constructs a lexicographic order comparator with a function that
+     * extracts a {@code Comparable} key.  This default implementation calls
+     * {@code thenComparing(this, Comparators.comparing(keyExtractor))}.
+     *
+     * @param <U> the {@link Comparable} type for comparison
+     * @param keyExtractor the function used to extract the {@link Comparable} sort key
+     * @throws NullPointerException if the argument is null.
+     * @see Comparators#comparing(Function)
+     * @see #thenComparing(Comparator)
+     * @since 1.8
+     */
+    default <U extends Comparable<? super U>> Comparator<T> thenComparing(Function<? super T, ? extends U> keyExtractor) {
+        return thenComparing(Comparators.comparing(keyExtractor));
+    }
+
+    /**
+     * Constructs a lexicographic order comparator with a function that
+     * extracts a {@code int} value.  This default implementation calls {@code
+     * thenComparing(this, Comparators.comparing(keyExtractor))}.
+     *
+     * @param keyExtractor the function used to extract the integer value
+     * @throws NullPointerException if the argument is null.
+     * @see Comparators#comparing(ToIntFunction)
+     * @see #thenComparing(Comparator)
+     * @since 1.8
+     */
+    default Comparator<T> thenComparing(ToIntFunction<? super T> keyExtractor) {
+        return thenComparing(Comparators.comparing(keyExtractor));
+    }
+
+    /**
+     * Constructs a lexicographic order comparator with a function that
+     * extracts a {@code long} value.  This default implementation calls
+     * {@code thenComparing(this, Comparators.comparing(keyExtractor))}.
+     *
+     * @param keyExtractor the function used to extract the long value
+     * @throws NullPointerException if the argument is null.
+     * @see Comparators#comparing(ToLongFunction)
+     * @see #thenComparing(Comparator)
+     * @since 1.8
+     */
+    default Comparator<T> thenComparing(ToLongFunction<? super T> keyExtractor) {
+        return thenComparing(Comparators.comparing(keyExtractor));
+    }
+
+    /**
+     * Constructs a lexicographic order comparator with a function that
+     * extracts a {@code double} value.  This default implementation calls
+     * {@code thenComparing(this, Comparators.comparing(keyExtractor))}.
+     *
+     * @param keyExtractor the function used to extract the double value
+     * @throws NullPointerException if the argument is null.
+     * @see Comparators#comparing(ToDoubleFunction)
+     * @see #thenComparing(Comparator)
+     * @since 1.8
+     */
+    default Comparator<T> thenComparing(ToDoubleFunction<? super T> keyExtractor) {
+        return thenComparing(Comparators.comparing(keyExtractor));
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/Comparators.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util;
+
+import java.io.Serializable;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.function.ToDoubleFunction;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+/**
+ * This class consists of {@code static} utility methods for comparators. Mostly
+ * factory method that returns a {@link Comparator}.
+ *
+ * <p> Unless otherwise noted, passing a {@code null} argument to a method in
+ * this class will cause a {@link NullPointerException} to be thrown.
+ *
+ * @see Comparator
+ * @since 1.8
+ */
+public class Comparators {
+    private Comparators() {
+        throw new AssertionError("no instances");
+    }
+
+    /**
+     * Compares {@link Comparable} objects in natural order.
+     *
+     * @see Comparable
+     */
+    private enum NaturalOrderComparator implements Comparator<Comparable<Object>> {
+        INSTANCE;
+
+        @Override
+        public int compare(Comparable<Object> c1, Comparable<Object> c2) {
+            return c1.compareTo(c2);
+        }
+    }
+
+    /**
+     * Returns a comparator that imposes the reverse of the <em>natural
+     * ordering</em>.
+     *
+     * <p>The returned comparator is serializable.
+     *
+     * @param <T> {@link Comparable} type
+     *
+     * @return A comparator that imposes the reverse of the <i>natural
+     *         ordering</i> on a collection of objects that implement
+     *         the {@link Comparable} interface.
+     * @see Comparable
+     */
+    public static <T extends Comparable<? super T>> Comparator<T> reverseOrder() {
+        return Collections.reverseOrder();
+    }
+
+    /**
+     * Returns a comparator that imposes the reverse ordering of the specified
+     * {@link Comparator}.
+     *
+     * <p>The returned comparator is serializable (assuming the specified
+     * comparator is also serializable).
+     *
+     * @param <T> the element type to be compared
+     * @param cmp a comparator whose ordering is to be reversed by the returned
+     *            comparator
+     * @return A comparator that imposes the reverse ordering of the
+     *         specified comparator.
+     */
+    public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) {
+        Objects.requireNonNull(cmp);
+        return Collections.reverseOrder(cmp);
+    }
+
+    /**
+     * Gets a comparator compares {@link Comparable} type in natural order.
+     *
+     * @param <T> {@link Comparable} type
+     */
+    public static <T extends Comparable<? super T>> Comparator<T> naturalOrder() {
+        return (Comparator<T>) NaturalOrderComparator.INSTANCE;
+    }
+
+    /**
+     * Gets a comparator compares {@link Map.Entry} in natural order on key.
+     *
+     * @param <K> {@link Comparable} key type
+     * @param <V> value type
+     */
+    public static <K extends Comparable<? super K>, V> Comparator<Map.Entry<K,V>> naturalOrderKeys() {
+        return (Comparator<Map.Entry<K, V>> & Serializable)
+            (c1, c2) -> c1.getKey().compareTo(c2.getKey());
+    }
+
+    /**
+     * Gets a comparator compares {@link Map.Entry} in natural order on value.
+     *
+     * @param <K> key type
+     * @param <V> {@link Comparable} value type
+     */
+    public static <K, V extends Comparable<? super V>> Comparator<Map.Entry<K,V>> naturalOrderValues() {
+        return (Comparator<Map.Entry<K, V>> & Serializable)
+            (c1, c2) -> c1.getValue().compareTo(c2.getValue());
+    }
+
+    /**
+     * Gets a comparator compares {@link Map.Entry} by key using the given
+     * {@link Comparator}.
+     *
+     * <p>The returned comparator is serializable assuming the specified
+     * comparators are also serializable.
+     *
+     * @param <K> key type
+     * @param <V> value type
+     * @param cmp the key {@link Comparator}
+     */
+    public static <K, V> Comparator<Map.Entry<K, V>> byKey(Comparator<? super K> cmp) {
+        Objects.requireNonNull(cmp);
+        return (Comparator<Map.Entry<K, V>> & Serializable)
+            (c1, c2) -> cmp.compare(c1.getKey(), c2.getKey());
+    }
+
+    /**
+     * Gets a comparator compares {@link Map.Entry} by value using the given
+     * {@link Comparator}.
+     *
+     * @param <K> key type
+     * @param <V> value type
+     * @param cmp the value {@link Comparator}
+     */
+    public static <K, V> Comparator<Map.Entry<K, V>> byValue(Comparator<? super V> cmp) {
+        Objects.requireNonNull(cmp);
+        return (Comparator<Map.Entry<K, V>> & Serializable)
+            (c1, c2) -> cmp.compare(c1.getValue(), c2.getValue());
+    }
+
+    /**
+     * Accepts a function that extracts a {@link java.lang.Comparable
+     * Comparable} sort key from a type {@code T}, and returns a {@code
+     * Comparator<T>} that compares by that sort key.  For example, if a class
+     * {@code Person} has a {@code String}-valued getter {@code getLastName},
+     * then {@code comparing(Person::getLastName)} would return a {@code
+     * Comparator<Person>} that compares {@code Person} objects by their last
+     * name.
+     *
+     * @param <T> the original element type
+     * @param <U> the {@link Comparable} type for comparison
+     * @param keyExtractor the function used to extract the {@link Comparable} sort key
+     */
+    public static <T, U extends Comparable<? super U>> Comparator<T> comparing(Function<? super T, ? extends U> keyExtractor) {
+        Objects.requireNonNull(keyExtractor);
+        return (Comparator<T> & Serializable)
+            (c1, c2) -> keyExtractor.apply(c1).compareTo(keyExtractor.apply(c2));
+    }
+
+    /**
+     * Accepts a function that extracts an {@code int} value from a type {@code
+     * T}, and returns a {@code Comparator<T>} that compares by that value.
+     *
+     * <p>The returned comparator is serializable assuming the specified
+     * function is also serializable.
+     *
+     * @see #comparing(Function)
+     * @param <T> the original element type
+     * @param keyExtractor the function used to extract the integer value
+     */
+    public static <T> Comparator<T> comparing(ToIntFunction<? super T> keyExtractor) {
+        Objects.requireNonNull(keyExtractor);
+        return (Comparator<T> & Serializable)
+            (c1, c2) -> Integer.compare(keyExtractor.applyAsInt(c1), keyExtractor.applyAsInt(c2));
+    }
+
+    /**
+     * Accepts a function that extracts a {@code long} value from a type {@code
+     * T}, and returns a {@code Comparator<T>} that compares by that value.
+     *
+     * <p>The returned comparator is serializable assuming the specified
+     * function is also serializable.
+     *
+     * @see #comparing(Function)
+     * @param <T> the original element type
+     * @param keyExtractor the function used to extract the long value
+     */
+    public static <T> Comparator<T> comparing(ToLongFunction<? super T> keyExtractor) {
+        Objects.requireNonNull(keyExtractor);
+        return (Comparator<T> & Serializable)
+            (c1, c2) -> Long.compare(keyExtractor.applyAsLong(c1), keyExtractor.applyAsLong(c2));
+    }
+
+    /**
+     * Accepts a function that extracts a {@code double} value from a type
+     * {@code T}, and returns a {@code Comparator<T>} that compares by that
+     * value.
+     *
+     * <p>The returned comparator is serializable assuming the specified
+     * function is also serializable.
+     *
+     * @see #comparing(Function)
+     * @param <T> the original element type
+     * @param keyExtractor the function used to extract the double value
+     */
+    public static<T> Comparator<T> comparing(ToDoubleFunction<? super T> keyExtractor) {
+        Objects.requireNonNull(keyExtractor);
+        return (Comparator<T> & Serializable)
+            (c1, c2) -> Double.compare(keyExtractor.applyAsDouble(c1), keyExtractor.applyAsDouble(c2));
+    }
+
+    /**
+     * Constructs a lexicographic order from two {@link Comparator}s.  For
+     * example, if you have comparators {@code byLastName} and {@code
+     * byFirstName}, each of type {@code Comparator<Person>}, then {@code
+     * compose(byLastName, byFirstName)} creates a {@code Comparator<Person>}
+     * which sorts by last name, and for equal last names sorts by first name.
+     *
+     * <p>The returned comparator is serializable assuming the specified
+     * comparators are also serializable.
+     *
+     * @param <T> the element type to be compared
+     * @param first the first comparator
+     * @param second the secondary comparator used when equals on the first
+     */
+    public static<T> Comparator<T> compose(Comparator<? super T> first, Comparator<? super T> second) {
+        Objects.requireNonNull(first);
+        Objects.requireNonNull(second);
+        return (Comparator<T> & Serializable) (c1, c2) -> {
+            int res = first.compare(c1, c2);
+            return (res != 0) ? res : second.compare(c1, c2);
+        };
+    }
+
+    /**
+     * Constructs a {@link BinaryOperator} which returns the lesser of two elements
+     * according to the specified {@code Comparator}
+     *
+     * @param comparator A {@code Comparator} for comparing the two values
+     * @param <T> the type of the elements to be compared
+     * @return a {@code BinaryOperator} which returns the lesser of its operands,
+     * according to the supplied {@code Comparator}
+     */
+    public static<T> BinaryOperator<T> lesserOf(Comparator<? super T> comparator) {
+        return (a, b) -> comparator.compare(a, b) <= 0 ? a : b;
+    }
+
+    /**
+     * Constructs a {@link BinaryOperator} which returns the greater of two elements
+     * according to the specified {@code Comparator}
+     *
+     * @param comparator A {@code Comparator} for comparing the two values
+     * @param <T> the type of the elements to be compared
+     * @return a {@code BinaryOperator} which returns the greater of its operands,
+     * according to the supplied {@code Comparator}
+     */
+    public static<T> BinaryOperator<T> greaterOf(Comparator<? super T> comparator) {
+        return (a, b) -> comparator.compare(a, b) >= 0 ? a : b;
+    }
+}
--- a/src/share/classes/java/util/logging/Logger.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/java/util/logging/Logger.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -26,10 +26,13 @@
 
 package java.util.logging;
 
-import java.util.*;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
 import java.util.concurrent.CopyOnWriteArrayList;
-import java.security.*;
-import java.lang.ref.WeakReference;
 import java.util.function.Supplier;
 
 /**
@@ -104,7 +107,7 @@
  * unnecessary message construction. For example, if the developer wants to
  * log system health status for diagnosis, with the String-accepting version,
  * the code would look like:
- <code><pre>
+ <pre><code>
 
    class DiagnosisMessages {
      static String systemHealthStatus() {
@@ -114,26 +117,20 @@
    }
    ...
    logger.log(Level.FINER, DiagnosisMessages.systemHealthStatus());
- </pre></code>
+</code></pre>
  * With the above code, the health status is collected unnecessarily even when
  * the log level FINER is disabled. With the Supplier-accepting version as
  * below, the status will only be collected when the log level FINER is
  * enabled.
- <code><pre>
+ <pre><code>
 
    logger.log(Level.FINER, DiagnosisMessages::systemHealthStatus);
- </pre></code>
+</code></pre>
  * <p>
  * When mapping ResourceBundle names to ResourceBundles, the Logger
  * will first try to use the Thread's ContextClassLoader.  If that
- * is null it will try the SystemClassLoader instead.  As a temporary
- * transition feature in the initial implementation, if the Logger is
- * unable to locate a ResourceBundle from the ContextClassLoader or
- * SystemClassLoader the Logger will also search up the class stack
- * and use successive calling ClassLoaders to try to locate a ResourceBundle.
- * (This call stack search is to allow containers to transition to
- * using ContextClassLoaders and is likely to be removed in future
- * versions.)
+ * is null it will try the
+ * {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader} instead.
  * <p>
  * Formatting (including localization) is the responsibility of
  * the output Handler, which will typically call a Formatter.
@@ -1541,12 +1538,16 @@
         return useParentHandlers;
     }
 
-    // Private utility method to map a resource bundle name to an
-    // actual resource bundle, using a simple one-entry cache.
-    // Returns null for a null name.
-    // May also return null if we can't find the resource bundle and
-    // there is no suitable previous cached value.
-
+    /**
+     * Private utility method to map a resource bundle name to an
+     * actual resource bundle, using a simple one-entry cache.
+     * Returns null for a null name.
+     * May also return null if we can't find the resource bundle and
+     * there is no suitable previous cached value.
+     *
+     * @param name the ResourceBundle to locate
+     * @return ResourceBundle specified by name or null if not found
+     */
     private synchronized ResourceBundle findResourceBundle(String name) {
         // Return a null bundle for a null name.
         if (name == null) {
@@ -1556,13 +1557,13 @@
         Locale currentLocale = Locale.getDefault();
 
         // Normally we should hit on our simple one entry cache.
-        if (catalog != null && currentLocale == catalogLocale
-                                        && name == catalogName) {
+        if (catalog != null && currentLocale.equals(catalogLocale)
+                && name.equals(catalogName)) {
             return catalog;
         }
 
-        // Use the thread's context ClassLoader.  If there isn't one,
-        // use the SystemClassloader.
+        // Use the thread's context ClassLoader.  If there isn't one, use the
+        // {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader}.
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         if (cl == null) {
             cl = ClassLoader.getSystemClassLoader();
@@ -1573,45 +1574,8 @@
             catalogLocale = currentLocale;
             return catalog;
         } catch (MissingResourceException ex) {
-            // Woops.  We can't find the ResourceBundle in the default
-            // ClassLoader.  Drop through.
+            return null;
         }
-
-
-        // Fall back to searching up the call stack and trying each
-        // calling ClassLoader.
-        for (int ix = 0; ; ix++) {
-            Class clz = sun.reflect.Reflection.getCallerClass(ix);
-            if (clz == null) {
-                break;
-            }
-            ClassLoader cl2 = clz.getClassLoader();
-            if (cl2 == null) {
-                cl2 = ClassLoader.getSystemClassLoader();
-            }
-            if (cl == cl2) {
-                // We've already checked this classloader.
-                continue;
-            }
-            cl = cl2;
-            try {
-                catalog = ResourceBundle.getBundle(name, currentLocale, cl);
-                catalogName = name;
-                catalogLocale = currentLocale;
-                return catalog;
-            } catch (MissingResourceException ex) {
-                // Ok, this one didn't work either.
-                // Drop through, and try the next one.
-            }
-        }
-
-        if (name.equals(catalogName)) {
-            // Return the previous cached value for that name.
-            // This may be null.
-            return catalog;
-        }
-        // Sorry, we're out of luck.
-        return null;
     }
 
     // Private utility method to initialize our one entry
@@ -1638,8 +1602,7 @@
                 resourceBundleName + " != " + name);
         }
 
-        ResourceBundle rb = findResourceBundle(name);
-        if (rb == null) {
+        if (findResourceBundle(name) == null) {
             // We've failed to find an expected ResourceBundle.
             throw new MissingResourceException("Can't find " + name + " bundle", name, "");
         }
--- a/src/share/classes/sun/misc/ClassFileTransformer.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/misc/ClassFileTransformer.java	Fri Mar 15 11:51:02 2013 -0300
@@ -25,43 +25,31 @@
 package sun.misc;
 
 import java.util.ArrayList;
+import java.util.List;
 
 /**
- * This is an abstract base class which is called by java.lang.ClassLoader
- * when ClassFormatError is thrown inside defineClass().
- *
- * The purpose of this class is to allow applications (e.g. Java Plug-in)
- * to have a chance to transform the byte code from one form to another
- * if necessary.
- *
- * One application of this class is used by Java Plug-in to transform
- * malformed JDK 1.1 class file into a well-formed Java 2 class file
- * on-the-fly, so JDK 1.1 applets with malformed class file in the
- * Internet may run in Java 2 after transformation.
+ * This is an abstract base class originally intended to be called by
+ * {@code java.lang.ClassLoader} when {@code ClassFormatError} is
+ * thrown inside {@code defineClass()}. It is no longer hooked into
+ * {@code ClassLoader} and will be removed in a future release.
  *
  * @author      Stanley Man-Kit Ho
  */
 
-public abstract class ClassFileTransformer
-{
-    // Singleton of ClassFileTransformer
-    //
-    private static ArrayList<ClassFileTransformer> transformerList
+@Deprecated
+public abstract class ClassFileTransformer {
+
+    private static final List<ClassFileTransformer> transformers
         = new ArrayList<ClassFileTransformer>();
-    private static ClassFileTransformer[] transformers
-        = new ClassFileTransformer[0];
 
     /**
      * Add the class file transformer object.
      *
      * @param t Class file transformer instance
      */
-    public static void add(ClassFileTransformer t)
-    {
-        synchronized(transformerList)
-        {
-            transformerList.add(t);
-            transformers = transformerList.toArray(new ClassFileTransformer[0]);
+    public static void add(ClassFileTransformer t) {
+        synchronized (transformers) {
+            transformers.add(t);
         }
     }
 
@@ -70,13 +58,11 @@
      *
      * @return ClassFileTransformer object array
      */
-    public static ClassFileTransformer[] getTransformers()
-    {
-        // transformers is not intended to be changed frequently,
-        // so it is okay to not put synchronized block here
-        // to speed up performance.
-        //
-        return transformers;
+    public static ClassFileTransformer[] getTransformers() {
+        synchronized (transformers) {
+            ClassFileTransformer[] result = new ClassFileTransformer[transformers.size()];
+            return transformers.toArray(result);
+        }
     }
 
 
@@ -89,5 +75,5 @@
      * @return Transformed byte array
      */
     public abstract byte[] transform(byte[] b, int off, int len)
-                           throws ClassFormatError;
+        throws ClassFormatError;
 }
--- a/src/share/classes/sun/net/www/http/HttpClient.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/net/www/http/HttpClient.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -121,7 +121,14 @@
     public boolean reuse = false;
 
     // Traffic capture tool, if configured. See HttpCapture class for info
-     private HttpCapture capture = null;
+    private HttpCapture capture = null;
+
+    private static final PlatformLogger logger = HttpURLConnection.getHttpLogger();
+    private static void logFinest(String msg) {
+        if (logger.isLoggable(PlatformLogger.FINEST)) {
+            logger.finest(msg);
+        }
+    }
 
     /**
      * A NOP method kept for backwards binary compatibility
@@ -266,8 +273,11 @@
             if (ret != null && httpuc != null &&
                 httpuc.streaming() &&
                 httpuc.getRequestMethod() == "POST") {
-                if (!ret.available())
+                if (!ret.available()) {
+                    ret.inCache = false;
+                    ret.closeServer();
                     ret = null;
+                }
             }
 
             if (ret != null) {
@@ -279,10 +289,7 @@
                         ret.inCache = false;
                         if (httpuc != null && ret.needsTunneling())
                             httpuc.setTunnelState(TUNNELING);
-                        PlatformLogger logger = HttpURLConnection.getHttpLogger();
-                        if (logger.isLoggable(PlatformLogger.FINEST)) {
-                            logger.finest("KeepAlive stream retrieved from the cache, " + ret);
-                        }
+                        logFinest("KeepAlive stream retrieved from the cache, " + ret);
                     }
                 } else {
                     // We cannot return this connection to the cache as it's
@@ -360,30 +367,33 @@
         }
     }
 
-    protected synchronized boolean available() throws IOException {
+    protected synchronized boolean available() {
         boolean available = true;
-        int old = serverSocket.getSoTimeout();
-        serverSocket.setSoTimeout(1);
-        BufferedInputStream tmpbuf =
-            new BufferedInputStream(serverSocket.getInputStream());
+        int old = -1;
 
-        PlatformLogger logger = HttpURLConnection.getHttpLogger();
         try {
-            int r = tmpbuf.read();
-            if (r == -1) {
-                if (logger.isLoggable(PlatformLogger.FINEST)) {
-                    logger.finest("HttpClient.available(): " +
-                        "read returned -1: not available");
+            try {
+                old = serverSocket.getSoTimeout();
+                serverSocket.setSoTimeout(1);
+                BufferedInputStream tmpbuf =
+                        new BufferedInputStream(serverSocket.getInputStream());
+                int r = tmpbuf.read();
+                if (r == -1) {
+                    logFinest("HttpClient.available(): " +
+                            "read returned -1: not available");
+                    available = false;
                 }
-                available = false;
+            } catch (SocketTimeoutException e) {
+                logFinest("HttpClient.available(): " +
+                        "SocketTimeout: its available");
+            } finally {
+                if (old != -1)
+                    serverSocket.setSoTimeout(old);
             }
-        } catch (SocketTimeoutException e) {
-            if (logger.isLoggable(PlatformLogger.FINEST)) {
-                logger.finest("HttpClient.available(): " +
-                    "SocketTimeout: its available");
-            }
-        } finally {
-            serverSocket.setSoTimeout(old);
+        } catch (IOException e) {
+            logFinest("HttpClient.available(): " +
+                        "SocketException: not available");
+            available = false;
         }
         return available;
     }
@@ -865,10 +875,7 @@
 
             if (isKeepingAlive())   {
                 // Wrap KeepAliveStream if keep alive is enabled.
-                PlatformLogger logger = HttpURLConnection.getHttpLogger();
-                if (logger.isLoggable(PlatformLogger.FINEST)) {
-                    logger.finest("KeepAlive stream used: " + url);
-                }
+                logFinest("KeepAlive stream used: " + url);
                 serverInput = new KeepAliveStream(serverInput, pi, cl, this);
                 failedOnce = false;
             }
--- a/src/share/classes/sun/security/internal/spec/TlsKeyMaterialParameterSpec.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/internal/spec/TlsKeyMaterialParameterSpec.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, 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
@@ -212,6 +212,12 @@
      *     generated.
      */
     public int getIvLength() {
+        // TLS v1.1 or later uses an explicit IV to protect against
+        // the CBC attacks.
+        if (majorVersion >= 0x03 && minorVersion >= 0x02) {
+            return 0;
+        }
+
         return ivLength;
     }
 
--- a/src/share/classes/sun/security/internal/spec/TlsKeyMaterialSpec.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/internal/spec/TlsKeyMaterialSpec.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,8 +58,9 @@
      * <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey,
      * null, null, null, null)</code>.
      *
-     * @param clientMacKey the client MAC key (or null)
-     * @param serverMacKey the server MAC key (or null)
+     * @param clientMacKey the client MAC key
+     * @param serverMacKey the server MAC key
+     * @throws NullPointerException if clientMacKey or serverMacKey is null
      */
     public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey) {
         this(clientMacKey, serverMacKey, null, null, null, null);
@@ -72,10 +73,11 @@
      * <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey,
      * clientCipherKey, serverCipherKey, null, null)</code>.
      *
-     * @param clientMacKey the client MAC key (or null)
-     * @param serverMacKey the server MAC key (or null)
+     * @param clientMacKey the client MAC key
+     * @param serverMacKey the server MAC key
      * @param clientCipherKey the client cipher key (or null)
      * @param serverCipherKey the server cipher key (or null)
+     * @throws NullPointerException if clientMacKey or serverMacKey is null
      */
     public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey,
             SecretKey clientCipherKey, SecretKey serverCipherKey) {
@@ -88,17 +90,21 @@
      * keys, client and server cipher keys, and client and server
      * initialization vectors.
      *
-     * @param clientMacKey the client MAC key (or null)
-     * @param serverMacKey the server MAC key (or null)
+     * @param clientMacKey the client MAC key
+     * @param serverMacKey the server MAC key
      * @param clientCipherKey the client cipher key (or null)
      * @param clientIv the client initialization vector (or null)
      * @param serverCipherKey the server cipher key (or null)
      * @param serverIv the server initialization vector (or null)
+     *
+     * @throws NullPointerException if clientMacKey or serverMacKey is null
      */
     public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey,
             SecretKey clientCipherKey, IvParameterSpec clientIv,
             SecretKey serverCipherKey, IvParameterSpec serverIv) {
-
+        if ((clientMacKey == null) || (serverMacKey == null)) {
+            throw new NullPointerException("MAC keys must not be null");
+        }
         this.clientMacKey = clientMacKey;
         this.serverMacKey = serverMacKey;
         this.clientCipherKey = clientCipherKey;
@@ -137,7 +143,7 @@
     /**
      * Returns the client MAC key.
      *
-     * @return the client MAC key (or null).
+     * @return the client MAC key.
      */
     public SecretKey getClientMacKey() {
         return clientMacKey;
@@ -146,7 +152,7 @@
     /**
      * Return the server MAC key.
      *
-     * @return the server MAC key (or null).
+     * @return the server MAC key.
      */
     public SecretKey getServerMacKey() {
         return serverMacKey;
--- a/src/share/classes/sun/security/jgss/GSSCredentialImpl.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/jgss/GSSCredentialImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -29,6 +29,7 @@
 import sun.security.jgss.spi.*;
 import java.util.*;
 import com.sun.security.jgss.*;
+import sun.security.jgss.spnego.SpNegoCredElement;
 
 public class GSSCredentialImpl implements ExtendedGSSCredential {
 
@@ -87,6 +88,7 @@
             throw new GSSException(GSSException.NO_CRED);
     }
 
+    // Wrap a mech cred into a GSS cred
     public GSSCredentialImpl(GSSManagerImpl gssManager,
                       GSSCredentialSpi mechElement) throws GSSException {
 
@@ -103,6 +105,11 @@
                                         usage);
         tempCred = mechElement;
         hashtable.put(key, tempCred);
+        // More mechs that can use this cred, say, SPNEGO
+        if (!GSSUtil.isSpNegoMech(mechElement.getMechanism())) {
+            key = new SearchKey(GSSUtil.GSS_SPNEGO_MECH_OID, usage);
+            hashtable.put(key, new SpNegoCredElement(mechElement));
+        }
     }
 
     void init(GSSManagerImpl gssManager) {
--- a/src/share/classes/sun/security/jgss/spnego/SpNegoCredElement.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/jgss/spnego/SpNegoCredElement.java	Fri Mar 15 11:51:02 2013 -0300
@@ -44,7 +44,7 @@
 
     private GSSCredentialSpi cred = null;
 
-    SpNegoCredElement(GSSCredentialSpi cred) throws GSSException {
+    public SpNegoCredElement(GSSCredentialSpi cred) throws GSSException {
         this.cred = cred;
     }
 
--- a/src/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2007, 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
@@ -168,22 +168,10 @@
             // Note that the MAC keys do not inherit all attributes from the
             // template, but they do inherit the sensitive/extractable/token
             // flags, which is all P11Key cares about.
-            SecretKey clientMacKey, serverMacKey;
-
-            // The MAC size may be zero for GCM mode.
-            //
-            // PKCS11 does not support GCM mode as the author made the comment,
-            // so the macBits is unlikely to be zero. It's only a place holder.
-            if (macBits != 0) {
-                clientMacKey = P11Key.secretKey
+            SecretKey clientMacKey = P11Key.secretKey
                     (session, out.hClientMacSecret, "MAC", macBits, attributes);
-                serverMacKey = P11Key.secretKey
+            SecretKey serverMacKey = P11Key.secretKey
                     (session, out.hServerMacSecret, "MAC", macBits, attributes);
-            } else {
-                clientMacKey = null;
-                serverMacKey = null;
-            }
-
             SecretKey clientCipherKey, serverCipherKey;
             if (keyBits != 0) {
                 clientCipherKey = P11Key.secretKey(session, out.hClientKey,
--- a/src/share/classes/sun/security/ssl/Authenticator.java	Sat Mar 02 11:06:58 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.ssl;
-
-import java.util.Arrays;
-
-/**
- * This class represents an SSL/TLS message authentication token,
- * which encapsulates a sequence number and ensures that attempts to
- * delete or reorder messages can be detected.
- *
- * Each SSL/TLS connection state contains a sequence number, which
- * is maintained separately for read and write states.  The sequence
- * number MUST be set to zero whenever a connection state is made the
- * active state.  Sequence numbers are of type uint64 and may not
- * exceed 2^64-1.  Sequence numbers do not wrap.  If a SSL/TLS
- * implementation would need to wrap a sequence number, it must
- * renegotiate instead.  A sequence number is incremented after each
- * record: specifically, the first record transmitted under a
- * particular connection state MUST use sequence number 0.
- */
-class Authenticator {
-
-    // byte array containing the additional authentication information for
-    // each record
-    private final byte[] block;
-
-    // the block size of SSL v3.0:
-    // sequence number + record type + + record length
-    private static final int BLOCK_SIZE_SSL = 8 + 1 + 2;
-
-    // the block size of TLS v1.0 and later:
-    // sequence number + record type + protocol version + record length
-    private static final int BLOCK_SIZE_TLS = 8 + 1 + 2 + 2;
-
-    /**
-     * Default construct, no message authentication token is initialized.
-     *
-     * Note that this construct can only be called for null MAC
-     */
-    Authenticator() {
-        block = new byte[0];
-    }
-
-    /**
-     * Constructs the message authentication token for the specified
-     * SSL/TLS protocol.
-     */
-    Authenticator(ProtocolVersion protocolVersion) {
-        if (protocolVersion.v >= ProtocolVersion.TLS10.v) {
-            block = new byte[BLOCK_SIZE_TLS];
-            block[9] = protocolVersion.major;
-            block[10] = protocolVersion.minor;
-        } else {
-            block = new byte[BLOCK_SIZE_SSL];
-        }
-    }
-
-    /**
-     * Checks whether the sequence number is close to wrap.
-     *
-     * Sequence numbers are of type uint64 and may not exceed 2^64-1.
-     * Sequence numbers do not wrap. When the sequence number is near
-     * to wrap, we need to close the connection immediately.
-     *
-     * @return true if the sequence number is close to wrap
-     */
-    final boolean seqNumOverflow() {
-        /*
-         * Conservatively, we don't allow more records to be generated
-         * when there are only 2^8 sequence numbers left.
-         */
-        return (block.length != 0 &&
-                block[0] == (byte)0xFF && block[1] == (byte)0xFF &&
-                block[2] == (byte)0xFF && block[3] == (byte)0xFF &&
-                block[4] == (byte)0xFF && block[5] == (byte)0xFF &&
-                block[6] == (byte)0xFF);
-    }
-
-    /**
-     * Checks whether the sequence number close to renew.
-     *
-     * Sequence numbers are of type uint64 and may not exceed 2^64-1.
-     * Sequence numbers do not wrap.  If a TLS
-     * implementation would need to wrap a sequence number, it must
-     * renegotiate instead.
-     *
-     * @return true if the sequence number is huge enough to renew
-     */
-    final boolean seqNumIsHuge() {
-        /*
-         * Conservatively, we should ask for renegotiation when there are
-         * only 2^48 sequence numbers left.
-         */
-        return (block.length != 0 &&
-                block[0] == (byte)0xFF && block[1] == (byte)0xFF);
-    }
-
-    /**
-     * Gets the current sequence number.
-     *
-     * @return the byte array of the current sequence number
-     */
-    final byte[] sequenceNumber() {
-        return Arrays.copyOf(block, 8);
-    }
-
-    /**
-     * Acquires the current message authentication information with the
-     * specified record type and fragment length, and then increases the
-     * sequence number.
-     *
-     * @param  type the record type
-     * @param  length the fragment of the record
-     * @return the byte array of the current message authentication information
-     */
-    final byte[] acquireAuthenticationBytes(byte type, int length) {
-        byte[] copy = block.clone();
-
-        if (block.length != 0) {
-            copy[8] = type;
-            copy[copy.length - 2] = (byte)(length >> 8);
-            copy[copy.length - 1] = (byte)(length);
-
-            /*
-             * Increase the sequence number in the block array
-             * it is a 64-bit number stored in big-endian format
-             */
-            int k = 7;
-            while ((k >= 0) && (++block[k] == 0)) {
-                k--;
-            }
-        }
-
-        return copy;
-    }
-
-}
--- a/src/share/classes/sun/security/ssl/CipherBox.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/CipherBox.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,18 +29,15 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.Hashtable;
-import java.util.Arrays;
 
 import java.security.*;
 import javax.crypto.*;
 import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.GCMParameterSpec;
 
 import java.nio.*;
 
 import sun.security.ssl.CipherSuite.*;
 import static sun.security.ssl.CipherSuite.*;
-import static sun.security.ssl.CipherSuite.CipherType.*;
 
 import sun.misc.HexDumpEncoder;
 
@@ -105,40 +102,19 @@
     private final Cipher cipher;
 
     /**
+     * Cipher blocksize, 0 for stream ciphers
+     */
+    private int blockSize;
+
+    /**
      * secure random
      */
     private SecureRandom random;
 
     /**
-     * fixed IV, the implicit nonce of AEAD cipher suite, only apply to
-     * AEAD cipher suites
-     */
-    private final byte[] fixedIv;
-
-    /**
-     * the key, reserved only for AEAD cipher initialization
-     */
-    private final Key key;
-
-    /**
-     * the operation mode, reserved for AEAD cipher initialization
+     * Is the cipher of CBC mode?
      */
-    private final int mode;
-
-    /**
-     * the authentication tag size, only apply to AEAD cipher suites
-     */
-    private final int tagSize;
-
-    /**
-     * the record IV length, only apply to AEAD cipher suites
-     */
-    private final int recordIvSize;
-
-    /**
-     * cipher type
-     */
-    private final CipherType cipherType;
+    private final boolean isCBCMode;
 
     /**
      * Fixed masks of various block size, as the initial decryption IVs
@@ -156,13 +132,7 @@
     private CipherBox() {
         this.protocolVersion = ProtocolVersion.DEFAULT;
         this.cipher = null;
-        this.cipherType = STREAM_CIPHER;
-        this.fixedIv = new byte[0];
-        this.key = null;
-        this.mode = Cipher.ENCRYPT_MODE;    // choose at random
-        this.random = null;
-        this.tagSize = 0;
-        this.recordIvSize = 0;
+        this.isCBCMode = false;
     }
 
     /**
@@ -177,13 +147,13 @@
         try {
             this.protocolVersion = protocolVersion;
             this.cipher = JsseJce.getCipher(bulkCipher.transformation);
-            this.mode = encrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE;
+            int mode = encrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE;
 
             if (random == null) {
                 random = JsseJce.getSecureRandom();
             }
             this.random = random;
-            this.cipherType = bulkCipher.cipherType;
+            this.isCBCMode = bulkCipher.isCBCMode;
 
             /*
              * RFC 4346 recommends two algorithms used to generated the
@@ -201,40 +171,14 @@
                 iv = getFixedMask(bulkCipher.ivSize);
             }
 
-            if (cipherType == AEAD_CIPHER) {
-                // AEAD must completely initialize the cipher for each packet,
-                // and so we save initialization parameters for packet
-                // processing time.
-
-                // Set the tag size for AEAD cipher
-                tagSize = bulkCipher.tagSize;
-
-                // Reserve the key for AEAD cipher initialization
-                this.key = key;
-
-                fixedIv = iv.getIV();
-                if (fixedIv == null ||
-                        fixedIv.length != bulkCipher.fixedIvSize) {
-                    throw new RuntimeException("Improper fixed IV for AEAD");
-                }
+            cipher.init(mode, key, iv, random);
 
-                // Set the record IV length for AEAD cipher
-                recordIvSize = bulkCipher.ivSize - bulkCipher.fixedIvSize;
-
-                // DON'T initialize the cipher for AEAD!
-            } else {
-                // CBC only requires one initialization during its lifetime
-                // (future packets/IVs set the proper CBC state), so we can
-                // initialize now.
-
-                // Zeroize the variables that only apply to AEAD cipher
-                this.tagSize = 0;
-                this.fixedIv = new byte[0];
-                this.recordIvSize = 0;
-                this.key = null;
-
-                // Initialize the cipher
-                cipher.init(mode, key, iv, random);
+            // Do not call getBlockSize until after init()
+            // otherwise we would disrupt JCE delayed provider selection
+            blockSize = cipher.getBlockSize();
+            // some providers implement getBlockSize() incorrectly
+            if (blockSize == 1) {
+                blockSize = 0;
             }
         } catch (NoSuchAlgorithmException e) {
             throw e;
@@ -291,11 +235,26 @@
         }
 
         try {
-            int blockSize = cipher.getBlockSize();
-            if (cipherType == BLOCK_CIPHER) {
+            if (blockSize != 0) {
+                // TLSv1.1 needs a IV block
+                if (protocolVersion.v >= ProtocolVersion.TLS11.v) {
+                    // generate a random number
+                    byte[] prefix = new byte[blockSize];
+                    random.nextBytes(prefix);
+
+                    // move forward the plaintext
+                    System.arraycopy(buf, offset,
+                                     buf, offset + prefix.length, len);
+
+                    // prefix the plaintext
+                    System.arraycopy(prefix, 0,
+                                     buf, offset, prefix.length);
+
+                    len += prefix.length;
+                }
+
                 len = addPadding(buf, offset, len, blockSize);
             }
-
             if (debug != null && Debug.isOn("plaintext")) {
                 try {
                     HexDumpEncoder hd = new HexDumpEncoder();
@@ -308,28 +267,14 @@
                         System.out);
                 } catch (IOException e) { }
             }
-
-
-            if (cipherType == AEAD_CIPHER) {
-                try {
-                    return cipher.doFinal(buf, offset, len, buf, offset);
-                } catch (IllegalBlockSizeException | BadPaddingException ibe) {
-                    // unlikely to happen
-                    throw new RuntimeException(
-                        "Cipher error in AEAD mode in JCE provider " +
-                        cipher.getProvider().getName(), ibe);
-                }
-            } else {
-                int newLen = cipher.update(buf, offset, len, buf, offset);
-                if (newLen != len) {
-                    // catch BouncyCastle buffering error
-                    throw new RuntimeException("Cipher buffering error " +
-                        "in JCE provider " + cipher.getProvider().getName());
-                }
-                return newLen;
+            int newLen = cipher.update(buf, offset, len, buf, offset);
+            if (newLen != len) {
+                // catch BouncyCastle buffering error
+                throw new RuntimeException("Cipher buffering error " +
+                    "in JCE provider " + cipher.getProvider().getName());
             }
+            return newLen;
         } catch (ShortBufferException e) {
-            // unlikely to happen, we should have enough buffer space here
             throw new ArrayIndexOutOfBoundsException(e.toString());
         }
     }
@@ -343,7 +288,7 @@
      * set to last position padded/encrypted.  The limit may have changed
      * because of the added padding bytes.
      */
-    int encrypt(ByteBuffer bb, int outLimit) {
+    int encrypt(ByteBuffer bb) {
 
         int len = bb.remaining();
 
@@ -352,71 +297,66 @@
             return len;
         }
 
-        int pos = bb.position();
+        try {
+            int pos = bb.position();
 
-        int blockSize = cipher.getBlockSize();
-        if (cipherType == BLOCK_CIPHER) {
-            // addPadding adjusts pos/limit
-            len = addPadding(bb, blockSize);
-            bb.position(pos);
-        }
+            if (blockSize != 0) {
+                // TLSv1.1 needs a IV block
+                if (protocolVersion.v >= ProtocolVersion.TLS11.v) {
+                    // generate a random number
+                    byte[] prefix = new byte[blockSize];
+                    random.nextBytes(prefix);
 
-        if (debug != null && Debug.isOn("plaintext")) {
-            try {
-                HexDumpEncoder hd = new HexDumpEncoder();
-
-                System.out.println(
-                    "Padded plaintext before ENCRYPTION:  len = "
-                    + len);
-                hd.encodeBuffer(bb.duplicate(), System.out);
-
-            } catch (IOException e) { }
-        }
+                    // move forward the plaintext
+                    byte[] buf = null;
+                    int limit = bb.limit();
+                    if (bb.hasArray()) {
+                        int arrayOffset = bb.arrayOffset();
+                        buf = bb.array();
+                        System.arraycopy(buf, arrayOffset + pos,
+                            buf, arrayOffset + pos + prefix.length,
+                            limit - pos);
+                        bb.limit(limit + prefix.length);
+                    } else {
+                        buf = new byte[limit - pos];
+                        bb.get(buf, 0, limit - pos);
+                        bb.position(pos + prefix.length);
+                        bb.limit(limit + prefix.length);
+                        bb.put(buf);
+                    }
+                    bb.position(pos);
 
-        /*
-         * Encrypt "in-place".  This does not add its own padding.
-         */
-        ByteBuffer dup = bb.duplicate();
-        if (cipherType == AEAD_CIPHER) {
-            try {
-                int outputSize = cipher.getOutputSize(dup.remaining());
-                if (outputSize > bb.remaining()) {
-                    // need to expand the limit of the output buffer for
-                    // the authentication tag.
-                    //
-                    // DON'T worry about the buffer's capacity, we have
-                    // reserved space for the authentication tag.
-                    if (outLimit < pos + outputSize) {
-                        // unlikely to happen
-                        throw new ShortBufferException(
-                                    "need more space in output buffer");
-                    }
-                    bb.limit(pos + outputSize);
+                    // prefix the plaintext
+                    bb.put(prefix);
+                    bb.position(pos);
                 }
-                int newLen = cipher.doFinal(dup, bb);
-                if (newLen != outputSize) {
-                    throw new RuntimeException(
-                            "Cipher buffering error in JCE provider " +
-                            cipher.getProvider().getName());
-                }
-                return newLen;
-            } catch (IllegalBlockSizeException |
-                           BadPaddingException | ShortBufferException ibse) {
-                // unlikely to happen
-                throw new RuntimeException(
-                        "Cipher error in AEAD mode in JCE provider " +
-                        cipher.getProvider().getName(), ibse);
+
+                // addPadding adjusts pos/limit
+                len = addPadding(bb, blockSize);
+                bb.position(pos);
             }
-        } else {
-            int newLen;
-            try {
-                newLen = cipher.update(dup, bb);
-            } catch (ShortBufferException sbe) {
-                // unlikely to happen
-                throw new RuntimeException("Cipher buffering error " +
-                    "in JCE provider " + cipher.getProvider().getName());
+            if (debug != null && Debug.isOn("plaintext")) {
+                try {
+                    HexDumpEncoder hd = new HexDumpEncoder();
+
+                    System.out.println(
+                        "Padded plaintext before ENCRYPTION:  len = "
+                        + len);
+                    hd.encodeBuffer(bb, System.out);
+
+                } catch (IOException e) { }
+                /*
+                 * reset back to beginning
+                 */
+                bb.position(pos);
             }
 
+            /*
+             * Encrypt "in-place".  This does not add its own padding.
+             */
+            ByteBuffer dup = bb.duplicate();
+            int newLen = cipher.update(dup, bb);
+
             if (bb.position() != dup.position()) {
                 throw new RuntimeException("bytebuffer padding error");
             }
@@ -427,6 +367,10 @@
                     "in JCE provider " + cipher.getProvider().getName());
             }
             return newLen;
+        } catch (ShortBufferException e) {
+            RuntimeException exc = new RuntimeException(e.toString());
+            exc.initCause(e);
+            throw exc;
         }
     }
 
@@ -454,23 +398,11 @@
         }
 
         try {
-            int newLen;
-            if (cipherType == AEAD_CIPHER) {
-                try {
-                    newLen = cipher.doFinal(buf, offset, len, buf, offset);
-                } catch (IllegalBlockSizeException ibse) {
-                    // unlikely to happen
-                    throw new RuntimeException(
-                        "Cipher error in AEAD mode in JCE provider " +
-                        cipher.getProvider().getName(), ibse);
-                }
-            } else {
-                newLen = cipher.update(buf, offset, len, buf, offset);
-                if (newLen != len) {
-                    // catch BouncyCastle buffering error
-                    throw new RuntimeException("Cipher buffering error " +
-                        "in JCE provider " + cipher.getProvider().getName());
-                }
+            int newLen = cipher.update(buf, offset, len, buf, offset);
+            if (newLen != len) {
+                // catch BouncyCastle buffering error
+                throw new RuntimeException("Cipher buffering error " +
+                    "in JCE provider " + cipher.getProvider().getName());
             }
             if (debug != null && Debug.isOn("plaintext")) {
                 try {
@@ -484,9 +416,7 @@
                         System.out);
                 } catch (IOException e) { }
             }
-
-            if (cipherType == BLOCK_CIPHER) {
-                int blockSize = cipher.getBlockSize();
+            if (blockSize != 0) {
                 newLen = removePadding(buf, offset, newLen,
                              blockSize, protocolVersion);
 
@@ -494,11 +424,16 @@
                     if (newLen < blockSize) {
                         throw new BadPaddingException("invalid explicit IV");
                     }
+
+                    // discards the first cipher block, the IV component.
+                    System.arraycopy(buf, offset + blockSize,
+                                     buf, offset, newLen - blockSize);
+
+                    newLen -= blockSize;
                 }
             }
             return newLen;
         } catch (ShortBufferException e) {
-            // unlikely to happen, we should have enough buffer space here
             throw new ArrayIndexOutOfBoundsException(e.toString());
         }
     }
@@ -528,29 +463,15 @@
              */
             int pos = bb.position();
             ByteBuffer dup = bb.duplicate();
-            int newLen;
-            if (cipherType == AEAD_CIPHER) {
-                try {
-                    newLen = cipher.doFinal(dup, bb);
-                } catch (IllegalBlockSizeException ibse) {
-                    // unlikely to happen
-                    throw new RuntimeException(
-                        "Cipher error in AEAD mode \"" + ibse.getMessage() +
-                        " \"in JCE provider " + cipher.getProvider().getName());
-                }
-            } else {
-                newLen = cipher.update(dup, bb);
-                if (newLen != len) {
-                    // catch BouncyCastle buffering error
-                    throw new RuntimeException("Cipher buffering error " +
-                        "in JCE provider " + cipher.getProvider().getName());
-                }
+            int newLen = cipher.update(dup, bb);
+            if (newLen != len) {
+                // catch BouncyCastle buffering error
+                throw new RuntimeException("Cipher buffering error " +
+                    "in JCE provider " + cipher.getProvider().getName());
             }
 
-            // reset the limit to the end of the decryted data
-            bb.limit(pos + newLen);
-
             if (debug != null && Debug.isOn("plaintext")) {
+                bb.position(pos);
                 try {
                     HexDumpEncoder hd = new HexDumpEncoder();
 
@@ -558,33 +479,50 @@
                         "Padded plaintext after DECRYPTION:  len = "
                         + newLen);
 
-                    hd.encodeBuffer(
-                        (ByteBuffer)bb.duplicate().position(pos), System.out);
+                    hd.encodeBuffer(bb, System.out);
                 } catch (IOException e) { }
             }
 
             /*
              * Remove the block padding.
              */
-            if (cipherType == BLOCK_CIPHER) {
-                int blockSize = cipher.getBlockSize();
+            if (blockSize != 0) {
                 bb.position(pos);
                 newLen = removePadding(bb, blockSize, protocolVersion);
 
-                // check the explicit IV of TLS v1.1 or later
                 if (protocolVersion.v >= ProtocolVersion.TLS11.v) {
                     if (newLen < blockSize) {
                         throw new BadPaddingException("invalid explicit IV");
                     }
 
+                    // discards the first cipher block, the IV component.
+                    byte[] buf = null;
+                    int limit = bb.limit();
+                    if (bb.hasArray()) {
+                        int arrayOffset = bb.arrayOffset();
+                        buf = bb.array();
+                        System.arraycopy(buf, arrayOffset + pos + blockSize,
+                            buf, arrayOffset + pos, limit - pos - blockSize);
+                        bb.limit(limit - blockSize);
+                    } else {
+                        buf = new byte[limit - pos - blockSize];
+                        bb.position(pos + blockSize);
+                        bb.get(buf);
+                        bb.position(pos);
+                        bb.put(buf);
+                        bb.limit(limit - blockSize);
+                    }
+
                     // reset the position to the end of the decrypted data
-                    bb.position(bb.limit());
+                    limit = bb.limit();
+                    bb.position(limit);
                 }
             }
             return newLen;
         } catch (ShortBufferException e) {
-            // unlikely to happen, we should have enough buffer space here
-            throw new ArrayIndexOutOfBoundsException(e.toString());
+            RuntimeException exc = new RuntimeException(e.toString());
+            exc.initCause(e);
+            throw exc;
         }
     }
 
@@ -757,8 +695,8 @@
                 // ignore return value.
                 cipher.doFinal();
             }
-        } catch (Exception e) {
-            // swallow all types of exceptions.
+        } catch (GeneralSecurityException e) {
+            // swallow for now.
         }
     }
 
@@ -768,234 +706,6 @@
      * @return true if the cipher use CBC mode, false otherwise.
      */
     boolean isCBCMode() {
-        return cipherType == BLOCK_CIPHER;
-    }
-
-    /*
-     * Does the cipher use AEAD mode?
-     *
-     * @return true if the cipher use AEAD mode, false otherwise.
-     */
-    boolean isAEADMode() {
-        return cipherType == AEAD_CIPHER;
-    }
-
-    /*
-     * Is the cipher null?
-     *
-     * @return true if the cipher is null, false otherwise.
-     */
-    boolean isNullCipher() {
-        return cipher == null;
-    }
-
-    /*
-     * Gets the explicit nonce/IV size of the cipher.
-     *
-     * The returned value is the SecurityParameters.record_iv_length in
-     * RFC 4346/5246.  It is the size of explicit IV for CBC mode, and the
-     * size of explicit nonce for AEAD mode.
-     *
-     * @return the explicit nonce size of the cipher.
-     */
-    int getExplicitNonceSize() {
-        switch (cipherType) {
-            case BLOCK_CIPHER:
-                // For block ciphers, the explicit IV length is of length
-                // SecurityParameters.record_iv_length, which is equal to
-                // the SecurityParameters.block_size.
-                if (protocolVersion.v >= ProtocolVersion.TLS11.v) {
-                    return cipher.getBlockSize();
-                }
-                break;
-            case AEAD_CIPHER:
-                return recordIvSize;
-                        // It is also the length of sequence number, which is
-                        // used as the nonce_explicit for AEAD cipher suites.
-        }
-
-        return 0;
-    }
-
-    /*
-     * Applies the explicit nonce/IV to this cipher. This method is used to
-     * decrypt an SSL/TLS input record.
-     *
-     * The returned value is the SecurityParameters.record_iv_length in
-     * RFC 4346/5246.  It is the size of explicit IV for CBC mode, and the
-     * size of explicit nonce for AEAD mode.
-     *
-     * @param  authenticator the authenticator to get the additional
-     *         authentication data
-     * @param  contentType the content type of the input record
-     * @param  bb the byte buffer to get the explicit nonce from
-     *
-     * @return the explicit nonce size of the cipher.
-     */
-    int applyExplicitNonce(Authenticator authenticator, byte contentType,
-            ByteBuffer bb) throws BadPaddingException {
-        switch (cipherType) {
-            case BLOCK_CIPHER:
-                // For block ciphers, the explicit IV length is of length
-                // SecurityParameters.record_iv_length, which is equal to
-                // the SecurityParameters.block_size.
-                if (protocolVersion.v >= ProtocolVersion.TLS11.v) {
-                    return cipher.getBlockSize();
-                }
-                break;
-            case AEAD_CIPHER:
-                if (bb.remaining() < (recordIvSize + tagSize)) {
-                    throw new BadPaddingException(
-                                        "invalid AEAD cipher fragment");
-                }
-
-                // initialize the AEAD cipher for the unique IV
-                byte[] iv = Arrays.copyOf(fixedIv,
-                                    fixedIv.length + recordIvSize);
-                bb.get(iv, fixedIv.length, recordIvSize);
-                bb.position(bb.position() - recordIvSize);
-                GCMParameterSpec spec = new GCMParameterSpec(tagSize * 8, iv);
-                try {
-                    cipher.init(mode, key, spec, random);
-                } catch (InvalidKeyException |
-                            InvalidAlgorithmParameterException ikae) {
-                    // unlikely to happen
-                    throw new RuntimeException(
-                                "invalid key or spec in GCM mode", ikae);
-                }
-
-                // update the additional authentication data
-                byte[] aad = authenticator.acquireAuthenticationBytes(
-                        contentType, bb.remaining() - recordIvSize - tagSize);
-                cipher.updateAAD(aad);
-
-                return recordIvSize;
-                        // It is also the length of sequence number, which is
-                        // used as the nonce_explicit for AEAD cipher suites.
-        }
-
-       return 0;
-    }
-
-    /*
-     * Applies the explicit nonce/IV to this cipher. This method is used to
-     * decrypt an SSL/TLS input record.
-     *
-     * The returned value is the SecurityParameters.record_iv_length in
-     * RFC 4346/5246.  It is the size of explicit IV for CBC mode, and the
-     * size of explicit nonce for AEAD mode.
-     *
-     * @param  authenticator the authenticator to get the additional
-     *         authentication data
-     * @param  contentType the content type of the input record
-     * @param  buf the byte array to get the explicit nonce from
-     * @param  offset the offset of the byte buffer
-     * @param  cipheredLength the ciphered fragment length of the output
-     *         record, it is the TLSCiphertext.length in RFC 4346/5246.
-     *
-     * @return the explicit nonce size of the cipher.
-     */
-    int applyExplicitNonce(Authenticator authenticator,
-            byte contentType, byte[] buf, int offset,
-            int cipheredLength) throws BadPaddingException {
-
-        ByteBuffer bb = ByteBuffer.wrap(buf, offset, cipheredLength);
-
-        return applyExplicitNonce(authenticator, contentType, bb);
-    }
-
-    /*
-     * Creates the explicit nonce/IV to this cipher. This method is used to
-     * encrypt an SSL/TLS output record.
-     *
-     * The size of the returned array is the SecurityParameters.record_iv_length
-     * in RFC 4346/5246.  It is the size of explicit IV for CBC mode, and the
-     * size of explicit nonce for AEAD mode.
-     *
-     * @param  authenticator the authenticator to get the additional
-     *         authentication data
-     * @param  contentType the content type of the input record
-     * @param  fragmentLength the fragment length of the output record, it is
-     *         the TLSCompressed.length in RFC 4346/5246.
-     *
-     * @return the explicit nonce of the cipher.
-     */
-    byte[] createExplicitNonce(Authenticator authenticator,
-            byte contentType, int fragmentLength) {
-
-        byte[] nonce = new byte[0];
-        switch (cipherType) {
-            case BLOCK_CIPHER:
-                if (protocolVersion.v >= ProtocolVersion.TLS11.v) {
-                    // For block ciphers, the explicit IV length is of length
-                    // SecurityParameters.record_iv_length, which is equal to
-                    // the SecurityParameters.block_size.
-                    //
-                    // Generate a random number as the explicit IV parameter.
-                    nonce = new byte[cipher.getBlockSize()];
-                    random.nextBytes(nonce);
-                }
-                break;
-            case AEAD_CIPHER:
-                // To be unique and aware of overflow-wrap, sequence number
-                // is used as the nonce_explicit of AEAD cipher suites.
-                nonce = authenticator.sequenceNumber();
-
-                // initialize the AEAD cipher for the unique IV
-                byte[] iv = Arrays.copyOf(fixedIv,
-                                            fixedIv.length + nonce.length);
-                System.arraycopy(nonce, 0, iv, fixedIv.length, nonce.length);
-                GCMParameterSpec spec = new GCMParameterSpec(tagSize * 8, iv);
-                try {
-                    cipher.init(mode, key, spec, random);
-                } catch (InvalidKeyException |
-                            InvalidAlgorithmParameterException ikae) {
-                    // unlikely to happen
-                    throw new RuntimeException(
-                                "invalid key or spec in GCM mode", ikae);
-                }
-
-                // update the additional authentication data
-                byte[] aad = authenticator.acquireAuthenticationBytes(
-                                                contentType, fragmentLength);
-                cipher.updateAAD(aad);
-                break;
-        }
-
-        return nonce;
-    }
-
-    /*
-     * Is this cipher available?
-     *
-     * This method can only be called by CipherSuite.BulkCipher.isAvailable()
-     * to test the availability of a cipher suites.  Please DON'T use it in
-     * other places, otherwise, the behavior may be unexpected because we may
-     * initialize AEAD cipher improperly in the method.
-     */
-    Boolean isAvailable() {
-        // We won't know whether a cipher for a particular key size is
-        // available until the cipher is successfully initialized.
-        //
-        // We do not initialize AEAD cipher in the constructor.  Need to
-        // initialize the cipher to ensure that the AEAD mode for a
-        // particular key size is supported.
-        if (cipherType == AEAD_CIPHER) {
-            try {
-                Authenticator authenticator =
-                    new Authenticator(protocolVersion);
-                byte[] nonce = authenticator.sequenceNumber();
-                byte[] iv = Arrays.copyOf(fixedIv,
-                                            fixedIv.length + nonce.length);
-                System.arraycopy(nonce, 0, iv, fixedIv.length, nonce.length);
-                GCMParameterSpec spec = new GCMParameterSpec(tagSize * 8, iv);
-
-                cipher.init(mode, key, spec, random);
-            } catch (Exception e) {
-                return Boolean.FALSE;
-            }
-        }   // Otherwise, we have initialized the cipher in the constructor.
-
-        return Boolean.TRUE;
+        return isCBCMode;
     }
 }
--- a/src/share/classes/sun/security/ssl/CipherSuite.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/CipherSuite.java	Fri Mar 15 11:51:02 2013 -0300
@@ -33,14 +33,12 @@
 import java.security.SecureRandom;
 import java.security.KeyManagementException;
 
-import javax.crypto.Cipher;
 import javax.crypto.SecretKey;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 
 import static sun.security.ssl.CipherSuite.KeyExchange.*;
 import static sun.security.ssl.CipherSuite.PRF.*;
-import static sun.security.ssl.CipherSuite.CipherType.*;
 import static sun.security.ssl.JsseJce.*;
 
 /**
@@ -137,9 +135,7 @@
         this.keyExchange = keyExchange;
         this.cipher = cipher;
         this.exportable = cipher.exportable;
-        if (cipher.cipherType == CipherType.AEAD_CIPHER) {
-            macAlg = M_NULL;
-        } else if (name.endsWith("_MD5")) {
+        if (name.endsWith("_MD5")) {
             macAlg = M_MD5;
         } else if (name.endsWith("_SHA")) {
             macAlg = M_SHA;
@@ -389,12 +385,6 @@
         }
     }
 
-    static enum CipherType {
-        STREAM_CIPHER,         // null or stream cipher
-        BLOCK_CIPHER,          // block cipher in CBC mode
-        AEAD_CIPHER            // AEAD cipher
-    }
-
     /**
      * An SSL/TLS bulk cipher algorithm. One instance per combination of
      * cipher and key length.
@@ -427,26 +417,14 @@
         // for non-exportable ciphers, this is the same as keySize
         final int expandedKeySize;
 
-        // size of the IV
+        // size of the IV (also block size)
         final int ivSize;
 
-        // size of fixed IV
-        //
-        // record_iv_length = ivSize - fixedIvSize
-        final int fixedIvSize;
-
         // exportable under 512/40 bit rules
         final boolean exportable;
 
         // Is the cipher algorithm of Cipher Block Chaining (CBC) mode?
-        final CipherType cipherType;
-
-        // size of the authentication tag, only applicable to cipher suites in
-        // Galois Counter Mode (GCM)
-        //
-        // As far as we know, all supported GCM cipher suites use 128-bits
-        // authentication tags.
-        final int tagSize = 16;
+        final boolean isCBCMode;
 
         // The secure random used to detect the cipher availability.
         private final static SecureRandom secureRandom;
@@ -459,34 +437,32 @@
             }
         }
 
-        BulkCipher(String transformation, CipherType cipherType, int keySize,
-                int expandedKeySize, int ivSize,
-                int fixedIvSize, boolean allowed) {
-
+        BulkCipher(String transformation, int keySize,
+                int expandedKeySize, int ivSize, boolean allowed) {
             this.transformation = transformation;
             String[] splits = transformation.split("/");
             this.algorithm = splits[0];
-            this.cipherType = cipherType;
+            this.isCBCMode =
+                splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
             this.description = this.algorithm + "/" + (keySize << 3);
             this.keySize = keySize;
             this.ivSize = ivSize;
-            this.fixedIvSize = fixedIvSize;
             this.allowed = allowed;
 
             this.expandedKeySize = expandedKeySize;
             this.exportable = true;
         }
 
-        BulkCipher(String transformation, CipherType cipherType, int keySize,
-                int ivSize, int fixedIvSize, boolean allowed) {
+        BulkCipher(String transformation, int keySize,
+                int ivSize, boolean allowed) {
             this.transformation = transformation;
             String[] splits = transformation.split("/");
             this.algorithm = splits[0];
-            this.cipherType = cipherType;
+            this.isCBCMode =
+                splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
             this.description = this.algorithm + "/" + (keySize << 3);
             this.keySize = keySize;
             this.ivSize = ivSize;
-            this.fixedIvSize = fixedIvSize;
             this.allowed = allowed;
 
             this.expandedKeySize = keySize;
@@ -510,20 +486,16 @@
          * Test if this bulk cipher is available. For use by CipherSuite.
          *
          * Currently all supported ciphers except AES are always available
-         * via the JSSE internal implementations. We also assume AES/128 of
-         * CBC mode is always available since it is shipped with the SunJCE
-         * provider.  However, AES/256 is unavailable when the default JCE
-         * policy jurisdiction files are installed because of key length
-         * restrictions, and AEAD is unavailable when the underlying providers
-         * do not support AEAD/GCM mode.
+         * via the JSSE internal implementations. We also assume AES/128
+         * is always available since it is shipped with the SunJCE provider.
+         * However, AES/256 is unavailable when the default JCE policy
+         * jurisdiction files are installed because of key length restrictions.
          */
         boolean isAvailable() {
             if (allowed == false) {
                 return false;
             }
-
-            if ((this == B_AES_256) ||
-                    (this.cipherType == CipherType.AEAD_CIPHER)) {
+            if (this == B_AES_256) {
                 return isAvailable(this);
             }
 
@@ -541,50 +513,19 @@
         private static synchronized boolean isAvailable(BulkCipher cipher) {
             Boolean b = availableCache.get(cipher);
             if (b == null) {
-                int keySizeInBits = cipher.keySize * 8;
-                if (keySizeInBits > 128) {    // need the JCE unlimited
-                                               // strength jurisdiction policy
-                    try {
-                        if (Cipher.getMaxAllowedKeyLength(
-                                cipher.transformation) < keySizeInBits) {
-                            b = Boolean.FALSE;
-                        }
-                    } catch (Exception e) {
-                        b = Boolean.FALSE;
-                    }
+                try {
+                    SecretKey key = new SecretKeySpec
+                        (new byte[cipher.expandedKeySize], cipher.algorithm);
+                    IvParameterSpec iv =
+                        new IvParameterSpec(new byte[cipher.ivSize]);
+                    cipher.newCipher(ProtocolVersion.DEFAULT,
+                                            key, iv, secureRandom, true);
+                    b = Boolean.TRUE;
+                } catch (NoSuchAlgorithmException e) {
+                    b = Boolean.FALSE;
                 }
-
-                if (b == null) {
-                    b = Boolean.FALSE;          // may be reset to TRUE if
-                                                // the cipher is available
-                    CipherBox temporary = null;
-                    try {
-                        SecretKey key = new SecretKeySpec(
-                                            new byte[cipher.expandedKeySize],
-                                            cipher.algorithm);
-                        IvParameterSpec iv;
-                        if (cipher.cipherType == CipherType.AEAD_CIPHER) {
-                            iv = new IvParameterSpec(
-                                            new byte[cipher.fixedIvSize]);
-                        } else {
-                            iv = new IvParameterSpec(new byte[cipher.ivSize]);
-                        }
-                        temporary = cipher.newCipher(
-                                            ProtocolVersion.DEFAULT,
-                                            key, iv, secureRandom, true);
-                        b = temporary.isAvailable();
-                    } catch (NoSuchAlgorithmException e) {
-                        // not available
-                    } finally {
-                        if (temporary != null) {
-                            temporary.dispose();
-                        }
-                    }
-                }
-
                 availableCache.put(cipher, b);
             }
-
             return b.booleanValue();
         }
 
@@ -632,31 +573,27 @@
 
     // export strength ciphers
     final static BulkCipher B_NULL    =
-        new BulkCipher("NULL",          STREAM_CIPHER,    0,  0,  0, 0, true);
+                        new BulkCipher("NULL",         0,  0, 0, true);
     final static BulkCipher B_RC4_40  =
-        new BulkCipher(CIPHER_RC4,      STREAM_CIPHER,    5, 16,  0, 0, true);
+                        new BulkCipher(CIPHER_RC4,     5, 16, 0, true);
     final static BulkCipher B_RC2_40  =
-        new BulkCipher("RC2",           BLOCK_CIPHER,     5, 16,  8, 0, false);
+                        new BulkCipher("RC2",          5, 16, 8, false);
     final static BulkCipher B_DES_40  =
-        new BulkCipher(CIPHER_DES,      BLOCK_CIPHER,     5,  8,  8, 0, true);
+                        new BulkCipher(CIPHER_DES,     5,  8, 8, true);
 
     // domestic strength ciphers
     final static BulkCipher B_RC4_128 =
-        new BulkCipher(CIPHER_RC4,      STREAM_CIPHER,   16,  0,  0, true);
+                        new BulkCipher(CIPHER_RC4,     16,  0, true);
     final static BulkCipher B_DES     =
-        new BulkCipher(CIPHER_DES,      BLOCK_CIPHER,     8,  8,  0, true);
+                        new BulkCipher(CIPHER_DES,      8,  8, true);
     final static BulkCipher B_3DES    =
-        new BulkCipher(CIPHER_3DES,     BLOCK_CIPHER,    24,  8,  0, true);
+                        new BulkCipher(CIPHER_3DES,    24,  8, true);
     final static BulkCipher B_IDEA    =
-        new BulkCipher("IDEA",          BLOCK_CIPHER,    16,  8,  0, false);
+                        new BulkCipher("IDEA",         16,  8, false);
     final static BulkCipher B_AES_128 =
-        new BulkCipher(CIPHER_AES,      BLOCK_CIPHER,    16, 16,  0, true);
+                        new BulkCipher(CIPHER_AES,     16, 16, true);
     final static BulkCipher B_AES_256 =
-        new BulkCipher(CIPHER_AES,      BLOCK_CIPHER,    32, 16,  0, true);
-    final static BulkCipher B_AES_128_GCM =
-        new BulkCipher(CIPHER_AES_GCM,  AEAD_CIPHER,     16, 12,  4, true);
-    final static BulkCipher B_AES_256_GCM =
-        new BulkCipher(CIPHER_AES_GCM,  AEAD_CIPHER,     32, 12,  4, true);
+                        new BulkCipher(CIPHER_AES,     32, 16, true);
 
     // MACs
     final static MacAlg M_NULL = new MacAlg("NULL", 0);
@@ -956,12 +893,11 @@
          * Definition of the CipherSuites that are enabled by default.
          * They are listed in preference order, most preferred first, using
          * the following criteria:
-         * 1. Prefer Suite B compliant cipher suites, see RFC6460.
-         * 2. Prefer the stronger bulk cipher, in the order of AES_256(GCM),
-         *    AES_128(GCM), AES_256, AES_128, RC-4, 3DES-EDE.
-         * 3. Prefer the stronger MAC algorithm, in the order of SHA384,
+         * 1. Prefer the stronger buld cipher, in the order of AES_256,
+         *    AES_128, RC-4, 3DES-EDE.
+         * 2. Prefer the stronger MAC algorithm, in the order of SHA384,
          *    SHA256, SHA, MD5.
-         * 4. Prefer the better performance of key exchange and digital
+         * 3. Prefer the better performance of key exchange and digital
          *    signature algorithm, in the order of ECDHE-ECDSA, ECDHE-RSA,
          *    RSA, ECDH-ECDSA, ECDH-RSA, DHE-RSA, DHE-DSS.
          */
@@ -974,16 +910,6 @@
 
         //  ID           Key Exchange   Cipher     A  obs  suprt  PRF
         //  ======       ============   =========  =  ===  =====  ========
-
-
-        // Placeholder for cipher suites in GCM mode.
-        //
-        // For better compatibility and interoperability, we decrease the
-        // priority of cipher suites in GCM mode for a while as GCM
-        // technologies mature in the industry.  Eventually we'll move
-        // the GCM suites here.
-
-        // AES_256(CBC)
         add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
             0xc024, --p, K_ECDHE_ECDSA, B_AES_256, T, max, tls12, P_SHA384);
         add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
@@ -1014,7 +940,6 @@
         add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
             0x0038, --p, K_DHE_DSS,     B_AES_256, T);
 
-        // AES_128(CBC)
         add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
             0xc023, --p, K_ECDHE_ECDSA, B_AES_128, T, max, tls12, P_SHA256);
         add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
@@ -1045,7 +970,6 @@
         add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
             0x0032, --p, K_DHE_DSS,     B_AES_128, T);
 
-        // RC-4
         add("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
             0xC007, --p, K_ECDHE_ECDSA, B_RC4_128, N);
         add("TLS_ECDHE_RSA_WITH_RC4_128_SHA",
@@ -1057,51 +981,6 @@
         add("TLS_ECDH_RSA_WITH_RC4_128_SHA",
             0xC00C, --p, K_ECDH_RSA,    B_RC4_128, N);
 
-        // Cipher suites in GCM mode, see RFC 5288/5289.
-        //
-        // We may increase the priority of cipher suites in GCM mode when
-        // GCM technologies become mature in the industry.
-
-        // Suite B compliant cipher suites, see RFC 6460.
-        //
-        // Note that, at present this provider is not Suite B compliant. The
-        // preference order of the GCM cipher suites does not follow the spec
-        // of RFC 6460.
-        add("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
-            0xc02c, --p, K_ECDHE_ECDSA, B_AES_256_GCM, T, max, tls12, P_SHA384);
-        add("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
-            0xc02b, --p, K_ECDHE_ECDSA, B_AES_128_GCM, T, max, tls12, P_SHA256);
-
-        // AES_256(GCM)
-        add("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
-            0xc030, --p, K_ECDHE_RSA,   B_AES_256_GCM, T, max, tls12, P_SHA384);
-        add("TLS_RSA_WITH_AES_256_GCM_SHA384",
-            0x009d, --p, K_RSA,         B_AES_256_GCM, T, max, tls12, P_SHA384);
-        add("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
-            0xc02e, --p, K_ECDH_ECDSA,  B_AES_256_GCM, T, max, tls12, P_SHA384);
-        add("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",
-            0xc032, --p, K_ECDH_RSA,    B_AES_256_GCM, T, max, tls12, P_SHA384);
-        add("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
-            0x009f, --p, K_DHE_RSA,     B_AES_256_GCM, T, max, tls12, P_SHA384);
-        add("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",
-            0x00a3, --p, K_DHE_DSS,     B_AES_256_GCM, T, max, tls12, P_SHA384);
-
-        // AES_128(GCM)
-        add("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
-            0xc02f, --p, K_ECDHE_RSA,   B_AES_128_GCM, T, max, tls12, P_SHA256);
-        add("TLS_RSA_WITH_AES_128_GCM_SHA256",
-            0x009c, --p, K_RSA,         B_AES_128_GCM, T, max, tls12, P_SHA256);
-        add("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
-            0xc02d, --p, K_ECDH_ECDSA,  B_AES_128_GCM, T, max, tls12, P_SHA256);
-        add("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
-            0xc031, --p, K_ECDH_RSA,    B_AES_128_GCM, T, max, tls12, P_SHA256);
-        add("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
-            0x009e, --p, K_DHE_RSA,     B_AES_128_GCM, T, max, tls12, P_SHA256);
-        add("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
-            0x00a2, --p, K_DHE_DSS,     B_AES_128_GCM, T, max, tls12, P_SHA256);
-        // End of cipher suites in GCM mode.
-
-        // 3DES_EDE
         add("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
             0xC008, --p, K_ECDHE_ECDSA, B_3DES,    T);
         add("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
@@ -1145,22 +1024,17 @@
          */
         p = DEFAULT_SUITES_PRIORITY;
 
-        add("TLS_DH_anon_WITH_AES_256_GCM_SHA384",
-            0x00a7, --p, K_DH_ANON,     B_AES_256_GCM, N, max, tls12, P_SHA384);
-        add("TLS_DH_anon_WITH_AES_128_GCM_SHA256",
-            0x00a6, --p, K_DH_ANON,     B_AES_128_GCM, N, max, tls12, P_SHA256);
-
         add("TLS_DH_anon_WITH_AES_256_CBC_SHA256",
             0x006d, --p, K_DH_ANON,     B_AES_256, N, max, tls12, P_SHA256);
         add("TLS_ECDH_anon_WITH_AES_256_CBC_SHA",
-            0xC019, --p, K_ECDH_ANON,   B_AES_256, N);
+            0xC019, --p, K_ECDH_ANON,   B_AES_256, T);
         add("TLS_DH_anon_WITH_AES_256_CBC_SHA",
             0x003a, --p, K_DH_ANON,     B_AES_256, N);
 
         add("TLS_DH_anon_WITH_AES_128_CBC_SHA256",
             0x006c, --p, K_DH_ANON,     B_AES_128, N, max, tls12, P_SHA256);
         add("TLS_ECDH_anon_WITH_AES_128_CBC_SHA",
-            0xC018, --p, K_ECDH_ANON,   B_AES_128, N);
+            0xC018, --p, K_ECDH_ANON,   B_AES_128, T);
         add("TLS_DH_anon_WITH_AES_128_CBC_SHA",
             0x0034, --p, K_DH_ANON,     B_AES_128, N);
 
@@ -1170,7 +1044,7 @@
             0x0018, --p, K_DH_ANON,     B_RC4_128, N);
 
         add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA",
-            0xC017, --p, K_ECDH_ANON,   B_3DES,    N);
+            0xC017, --p, K_ECDH_ANON,   B_3DES,    T);
         add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
             0x001b, --p, K_DH_ANON,     B_3DES,    N);
 
@@ -1325,10 +1199,18 @@
         add("TLS_DH_RSA_WITH_AES_256_CBC_SHA256",          0x0069);
 
         // Unsupported cipher suites from RFC 5288
+        add("TLS_RSA_WITH_AES_128_GCM_SHA256",             0x009c);
+        add("TLS_RSA_WITH_AES_256_GCM_SHA384",             0x009d);
+        add("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",         0x009e);
+        add("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",         0x009f);
         add("TLS_DH_RSA_WITH_AES_128_GCM_SHA256",          0x00a0);
         add("TLS_DH_RSA_WITH_AES_256_GCM_SHA384",          0x00a1);
+        add("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",         0x00a2);
+        add("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",         0x00a3);
         add("TLS_DH_DSS_WITH_AES_128_GCM_SHA256",          0x00a4);
         add("TLS_DH_DSS_WITH_AES_256_GCM_SHA384",          0x00a5);
+        add("TLS_DH_anon_WITH_AES_128_GCM_SHA256",         0x00a6);
+        add("TLS_DH_anon_WITH_AES_256_GCM_SHA384",         0x00a7);
 
         // Unsupported cipher suites from RFC 5487
         add("TLS_PSK_WITH_AES_128_GCM_SHA256",             0x00a8);
@@ -1387,6 +1269,16 @@
         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 5289
+        add("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",     0xc02b);
+        add("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",     0xc02c);
+        add("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",      0xc02d);
+        add("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",      0xc02e);
+        add("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",       0xc02f);
+        add("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",       0xc030);
+        add("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",        0xc031);
+        add("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",        0xc032);
+
         // 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);
--- a/src/share/classes/sun/security/ssl/EngineInputRecord.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/EngineInputRecord.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2007, 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
@@ -178,6 +178,71 @@
     }
 
     /*
+     * Verifies and removes the MAC value.  Returns true if
+     * the MAC checks out OK.
+     *
+     * On entry:
+     *     position = beginning of app/MAC data
+     *     limit = end of MAC data.
+     *
+     * On return:
+     *     position = beginning of app data
+     *     limit = end of app data
+     */
+    boolean checkMAC(MAC signer, ByteBuffer bb) {
+        if (internalData) {
+            return checkMAC(signer);
+        }
+
+        int len = signer.MAClen();
+        if (len == 0) { // no mac
+            return true;
+        }
+
+        /*
+         * Grab the original limit
+         */
+        int lim = bb.limit();
+
+        /*
+         * Delineate the area to apply a MAC on.
+         */
+        int macData = lim - len;
+        bb.limit(macData);
+
+        byte[] mac = signer.compute(contentType(), bb);
+
+        if (len != mac.length) {
+            throw new RuntimeException("Internal MAC error");
+        }
+
+        /*
+         * Delineate the MAC values, position was already set
+         * by doing the compute above.
+         *
+         * We could zero the MAC area, but not much useful information
+         * there anyway.
+         */
+        bb.position(macData);
+        bb.limit(lim);
+
+        try {
+            for (int i = 0; i < len; i++) {
+                if (bb.get() != mac[i]) {  // No BB.equals(byte []); !
+                    return false;
+                }
+            }
+            return true;
+        } finally {
+            /*
+             * Position to the data.
+             */
+            bb.rewind();
+            bb.limit(macData);
+        }
+    }
+
+    /*
      * Pass the data down if it's internally cached, otherwise
      * do it here.
      *
@@ -186,85 +251,16 @@
      * If external data(app), return a new ByteBuffer with data to
      * process.
      */
-    ByteBuffer decrypt(Authenticator authenticator,
-            CipherBox box, ByteBuffer bb) throws BadPaddingException {
+    ByteBuffer decrypt(CipherBox box, ByteBuffer bb)
+            throws BadPaddingException {
 
         if (internalData) {
-            decrypt(authenticator, box);    // MAC is checked during decryption
+            decrypt(box);
             return tmpBB;
         }
 
-        BadPaddingException bpe = null;
-        if (!box.isNullCipher()) {
-            try {
-                // apply explicit nonce for AEAD/CBC cipher suites if needed
-                int nonceSize =
-                    box.applyExplicitNonce(authenticator, contentType(), bb);
-
-                // decrypt the content
-                if (box.isAEADMode()) {
-                    // DON'T encrypt the nonce_explicit for AEAD mode
-                    bb.position(bb.position() + nonceSize);
-                }   // The explicit IV for CBC mode can be decrypted.
-
-                box.decrypt(bb);
-                bb.position(nonceSize); // We don't actually remove the nonce.
-            } catch (BadPaddingException e) {
-                // RFC 2246 states that decryption_failed should be used
-                // for this purpose. However, that allows certain attacks,
-                // so we just send bad record MAC. We also need to make
-                // sure to always check the MAC to avoid a timing attack
-                // for the same issue. See paper by Vaudenay et al and the
-                // update in RFC 4346/5246.
-                //
-                // Failover to message authentication code checking.
-                bpe = new BadPaddingException("invalid padding");
-            }
-        }
-
-        // Requires message authentication code for null, stream and block
-        // cipher suites.
-        if (authenticator instanceof MAC) {
-            MAC signer = (MAC)authenticator;
-            int macLen = signer.MAClen();
-            if (macLen != 0) {
-                if (bb.remaining() < macLen) {
-                    // negative data length, something is wrong
-                    throw new BadPaddingException("bad record");
-                }
-
-                int position = bb.position();
-                int limit = bb.limit();
-                int macOffset = limit - macLen;
-
-                bb.limit(macOffset);
-                byte[] hash = signer.compute(contentType(), bb);
-                if (hash == null || macLen != hash.length) {
-                    // something is wrong with MAC implementation
-                    throw new RuntimeException("Internal MAC error");
-                }
-
-                bb.position(macOffset);
-                bb.limit(limit);
-
-                try {
-                    for (byte b : hash) {       // No BB.equals(byte []); !
-                        if (bb.get() != b) {
-                            throw new BadPaddingException("bad record MAC");
-                        }
-                    }
-                } finally {
-                    // reset to the data
-                    bb.position(position);
-                    bb.limit(macOffset);
-                }
-            }
-        }
-
-        // Is it a failover?
-        if (bpe != null) {
-            throw bpe;
-        }
+        box.decrypt(bb);
+        bb.rewind();
 
         return bb.slice();
     }
@@ -342,8 +338,8 @@
         if (debug != null && Debug.isOn("packet")) {
             try {
                 HexDumpEncoder hd = new HexDumpEncoder();
+                srcBB.limit(srcPos + len);
                 ByteBuffer bb = srcBB.duplicate();  // Use copy of BB
-                bb.limit(srcPos + len);
 
                 System.out.println("[Raw read (bb)]: length = " + len);
                 hd.encodeBuffer(bb, System.out);
--- a/src/share/classes/sun/security/ssl/EngineOutputRecord.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/EngineOutputRecord.java	Fri Mar 15 11:51:02 2013 -0300
@@ -29,6 +29,7 @@
 import java.io.*;
 import java.nio.*;
 
+
 /**
  * A OutputRecord class extension which uses external ByteBuffers
  * or the internal ByteArrayOutputStream for data manipulations.
@@ -100,6 +101,51 @@
         return finishedMsg;
     }
 
+
+    /**
+     * Calculate the MAC value, storing the result either in
+     * the internal buffer, or at the end of the destination
+     * ByteBuffer.
+     * <P>
+     * We assume that the higher levels have assured us enough
+     * room, otherwise we'll indirectly throw a
+     * BufferOverFlowException runtime exception.
+     *
+     * position should equal limit, and points to the next
+     * free spot.
+     */
+    private void addMAC(MAC signer, ByteBuffer bb)
+            throws IOException {
+
+        if (signer.MAClen() != 0) {
+            byte[] hash = signer.compute(contentType(), bb);
+
+            /*
+             * position was advanced to limit in compute above.
+             *
+             * Mark next area as writable (above layers should have
+             * established that we have plenty of room), then write
+             * out the hash.
+             */
+            bb.limit(bb.limit() + hash.length);
+            bb.put(hash);
+        }
+    }
+
+    /*
+     * Encrypt a ByteBuffer.
+     *
+     * We assume that the higher levels have assured us enough
+     * room for the encryption (plus padding), otherwise we'll
+     * indirectly throw a BufferOverFlowException runtime exception.
+     *
+     * position and limit will be the same, and points to the
+     * next free spot.
+     */
+    void encrypt(CipherBox box, ByteBuffer bb) {
+        box.encrypt(bb);
+    }
+
     /*
      * Override the actual write below.  We do things this way to be
      * consistent with InputRecord.  InputRecord may try to write out
@@ -114,8 +160,7 @@
          * Copy data out of buffer, it's ready to go.
          */
         ByteBuffer netBB = (ByteBuffer)
-            ByteBuffer.allocate(len).put(buf, off, len).flip();
-
+            ByteBuffer.allocate(len).put(buf, 0, len).flip();
         writer.putOutboundData(netBB);
     }
 
@@ -123,19 +168,17 @@
      * Main method for writing non-application data.
      * We MAC/encrypt, then send down for processing.
      */
-    void write(Authenticator authenticator, CipherBox writeCipher)
-            throws IOException {
-
+    void write(MAC writeMAC, CipherBox writeCipher) throws IOException {
         /*
          * Sanity check.
          */
         switch (contentType()) {
-            case ct_change_cipher_spec:
-            case ct_alert:
-            case ct_handshake:
-                break;
-            default:
-                throw new RuntimeException("unexpected byte buffers");
+        case ct_change_cipher_spec:
+        case ct_alert:
+        case ct_handshake:
+            break;
+        default:
+            throw new RuntimeException("unexpected byte buffers");
         }
 
         /*
@@ -150,10 +193,10 @@
          */
         if (!isEmpty()) {
             // compress();              // eventually
-            encrypt(authenticator, writeCipher);
-
-            // send down for processing
-            write((OutputStream)null, false, (ByteArrayOutputStream)null);
+            addMAC(writeMAC);
+            encrypt(writeCipher);
+            write((OutputStream)null, false,  // send down for processing
+                (ByteArrayOutputStream)null);
         }
         return;
     }
@@ -161,8 +204,8 @@
     /**
      * Main wrap/write driver.
      */
-    void write(EngineArgs ea, Authenticator authenticator,
-            CipherBox writeCipher) throws IOException {
+    void write(EngineArgs ea, MAC writeMAC, CipherBox writeCipher)
+            throws IOException {
         /*
          * sanity check to make sure someone didn't inadvertantly
          * send us an impossible combination we don't know how
@@ -174,7 +217,7 @@
          * Have we set the MAC's yet?  If not, we're not ready
          * to process application data yet.
          */
-        if (authenticator == MAC.NULL) {
+        if (writeMAC == MAC.NULL) {
             return;
         }
 
@@ -212,7 +255,7 @@
          */
         int length;
         if (engine.needToSplitPayload(writeCipher, protocolVersion)) {
-            write(ea, authenticator, writeCipher, 0x01);
+            write(ea, writeMAC, writeCipher, 0x01);
             ea.resetLim();      // reset application data buffer limit
             length = Math.min(ea.getAppRemaining(),
                         maxDataSizeMinusOneByteRecord);
@@ -222,14 +265,14 @@
 
         // Don't bother to really write empty records.
         if (length > 0) {
-            write(ea, authenticator, writeCipher, length);
+            write(ea, writeMAC, writeCipher, length);
         }
 
         return;
     }
 
-    void write(EngineArgs ea, Authenticator authenticator,
-            CipherBox writeCipher, int length) throws IOException {
+    void write(EngineArgs ea, MAC writeMAC, CipherBox writeCipher,
+            int length) throws IOException {
         /*
          * Copy out existing buffer values.
          */
@@ -243,76 +286,39 @@
          * Don't need to worry about SSLv2 rewrites, if we're here,
          * that's long since done.
          */
-        int dstData = dstPos + headerSize + writeCipher.getExplicitNonceSize();
+        int dstData = dstPos + headerSize;
         dstBB.position(dstData);
 
-        /*
-         * transfer application data into the network data buffer
-         */
         ea.gather(length);
-        dstBB.limit(dstBB.position());
-        dstBB.position(dstData);
 
         /*
          * "flip" but skip over header again, add MAC & encrypt
+         * addMAC will expand the limit to reflect the new
+         * data.
          */
-        if (authenticator instanceof MAC) {
-            MAC signer = (MAC)authenticator;
-            if (signer.MAClen() != 0) {
-                byte[] hash = signer.compute(contentType(), dstBB);
-
-                /*
-                 * position was advanced to limit in compute above.
-                 *
-                 * Mark next area as writable (above layers should have
-                 * established that we have plenty of room), then write
-                 * out the hash.
-                 */
-                dstBB.limit(dstBB.limit() + hash.length);
-                dstBB.put(hash);
-
-                // reset the position and limit
-                dstBB.limit(dstBB.position());
-                dstBB.position(dstData);
-            }
-        }
+        dstBB.limit(dstBB.position());
+        dstBB.position(dstData);
+        addMAC(writeMAC, dstBB);
 
-        if (!writeCipher.isNullCipher()) {
-            /*
-             * Requires explicit IV/nonce for CBC/AEAD cipher suites for TLS 1.1
-             * or later.
-             */
-            if (protocolVersion.v >= ProtocolVersion.TLS11.v &&
-                    (writeCipher.isCBCMode() || writeCipher.isAEADMode())) {
-                byte[] nonce = writeCipher.createExplicitNonce(
-                        authenticator, contentType(), dstBB.remaining());
-                dstBB.position(dstPos + headerSize);
-                dstBB.put(nonce);
-                if (!writeCipher.isAEADMode()) {
-                    // The explicit IV in TLS 1.1 and later can be encrypted.
-                    dstBB.position(dstPos + headerSize);
-                }   // Otherwise, DON'T encrypt the nonce_explicit for AEAD mode
-            }
+        /*
+         * Encrypt may pad, so again the limit may have changed.
+         */
+        dstBB.limit(dstBB.position());
+        dstBB.position(dstData);
+        encrypt(writeCipher, dstBB);
 
-            /*
-             * Encrypt may pad, so again the limit may have changed.
-             */
-            writeCipher.encrypt(dstBB, dstLim);
-
-            if ((debug != null) && (Debug.isOn("record") ||
-                    (Debug.isOn("handshake") &&
-                        (contentType() == ct_change_cipher_spec)))) {
+        if (debug != null
+                && (Debug.isOn("record") || Debug.isOn("handshake"))) {
+            if ((debug != null && Debug.isOn("record"))
+                    || contentType() == ct_change_cipher_spec)
                 System.out.println(Thread.currentThread().getName()
                     // v3.0/v3.1 ...
                     + ", WRITE: " + protocolVersion
                     + " " + InputRecord.contentName(contentType())
                     + ", length = " + length);
-            }
-        } else {
-            dstBB.position(dstBB.limit());
         }
 
-        int packetLength = dstBB.limit() - dstPos - headerSize;
+        int packetLength = dstBB.limit() - dstData;
 
         /*
          * Finish out the record header.
@@ -327,5 +333,7 @@
          * Position was already set by encrypt() above.
          */
         dstBB.limit(dstLim);
+
+        return;
     }
 }
--- a/src/share/classes/sun/security/ssl/EngineWriter.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/EngineWriter.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2007, 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
@@ -99,8 +99,7 @@
      * other writeRecord.
      */
     synchronized void writeRecord(EngineOutputRecord outputRecord,
-            Authenticator authenticator,
-            CipherBox writeCipher) throws IOException {
+            MAC writeMAC, CipherBox writeCipher) throws IOException {
 
         /*
          * Only output if we're still open.
@@ -109,7 +108,7 @@
             throw new IOException("writer side was already closed.");
         }
 
-        outputRecord.write(authenticator, writeCipher);
+        outputRecord.write(writeMAC, writeCipher);
 
         /*
          * Did our handshakers notify that we just sent the
@@ -152,8 +151,7 @@
      * Return any determined status.
      */
     synchronized HandshakeStatus writeRecord(
-            EngineOutputRecord outputRecord, EngineArgs ea,
-            Authenticator authenticator,
+            EngineOutputRecord outputRecord, EngineArgs ea, MAC writeMAC,
             CipherBox writeCipher) throws IOException {
 
         /*
@@ -183,7 +181,7 @@
             throw new IOException("The write side was already closed");
         }
 
-        outputRecord.write(ea, authenticator, writeCipher);
+        outputRecord.write(ea, writeMAC, writeCipher);
 
         if (debug != null && Debug.isOn("packet")) {
             dumpPacket(ea, false);
--- a/src/share/classes/sun/security/ssl/Handshaker.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/Handshaker.java	Fri Mar 15 11:51:02 2013 -0300
@@ -49,7 +49,6 @@
 import sun.security.ssl.CipherSuite.*;
 
 import static sun.security.ssl.CipherSuite.PRF.*;
-import static sun.security.ssl.CipherSuite.CipherType.*;
 
 /**
  * Handshaker ... processes handshake records from an SSL V3.0
@@ -715,47 +714,33 @@
     /**
      * Create a new read MAC and return it to caller.
      */
-    Authenticator newReadAuthenticator()
-            throws NoSuchAlgorithmException, InvalidKeyException {
-
-        Authenticator authenticator = null;
-        if (cipherSuite.cipher.cipherType == AEAD_CIPHER) {
-            authenticator = new Authenticator(protocolVersion);
+    MAC newReadMAC() throws NoSuchAlgorithmException, InvalidKeyException {
+        MacAlg macAlg = cipherSuite.macAlg;
+        MAC mac;
+        if (isClient) {
+            mac = macAlg.newMac(protocolVersion, svrMacSecret);
+            svrMacSecret = null;
         } else {
-            MacAlg macAlg = cipherSuite.macAlg;
-            if (isClient) {
-                authenticator = macAlg.newMac(protocolVersion, svrMacSecret);
-                svrMacSecret = null;
-            } else {
-                authenticator = macAlg.newMac(protocolVersion, clntMacSecret);
-                clntMacSecret = null;
-            }
+            mac = macAlg.newMac(protocolVersion, clntMacSecret);
+            clntMacSecret = null;
         }
-
-        return authenticator;
+        return mac;
     }
 
     /**
      * Create a new write MAC and return it to caller.
      */
-    Authenticator newWriteAuthenticator()
-            throws NoSuchAlgorithmException, InvalidKeyException {
-
-        Authenticator authenticator = null;
-        if (cipherSuite.cipher.cipherType == AEAD_CIPHER) {
-            authenticator = new Authenticator(protocolVersion);
+    MAC newWriteMAC() throws NoSuchAlgorithmException, InvalidKeyException {
+        MacAlg macAlg = cipherSuite.macAlg;
+        MAC mac;
+        if (isClient) {
+            mac = macAlg.newMac(protocolVersion, clntMacSecret);
+            clntMacSecret = null;
         } else {
-            MacAlg macAlg = cipherSuite.macAlg;
-            if (isClient) {
-                authenticator = macAlg.newMac(protocolVersion, clntMacSecret);
-                clntMacSecret = null;
-            } else {
-                authenticator = macAlg.newMac(protocolVersion, svrMacSecret);
-                svrMacSecret = null;
-            }
+            mac = macAlg.newMac(protocolVersion, svrMacSecret);
+            svrMacSecret = null;
         }
-
-        return authenticator;
+        return mac;
     }
 
     /*
@@ -1204,23 +1189,11 @@
         int prfHashLength = prf.getPRFHashLength();
         int prfBlockSize = prf.getPRFBlockSize();
 
-        // TLS v1.1 or later uses an explicit IV in CBC cipher suites to
-        // protect against the CBC attacks.  AEAD/GCM cipher suites in TLS
-        // v1.2 or later use a fixed IV as the implicit part of the partially
-        // implicit nonce technique described in RFC 5116.
-        int ivSize = cipher.ivSize;
-        if (cipher.cipherType == AEAD_CIPHER) {
-            ivSize = cipher.fixedIvSize;
-        } else if (protocolVersion.v >= ProtocolVersion.TLS11.v &&
-                cipher.cipherType == BLOCK_CIPHER) {
-            ivSize = 0;
-        }
-
         TlsKeyMaterialParameterSpec spec = new TlsKeyMaterialParameterSpec(
             masterKey, protocolVersion.major, protocolVersion.minor,
             clnt_random.random_bytes, svr_random.random_bytes,
             cipher.algorithm, cipher.keySize, expandedKeySize,
-            ivSize, hashSize,
+            cipher.ivSize, hashSize,
             prfHashAlg, prfHashLength, prfBlockSize);
 
         try {
@@ -1228,15 +1201,14 @@
             kg.init(spec);
             TlsKeyMaterialSpec keySpec = (TlsKeyMaterialSpec)kg.generateKey();
 
-            // Return null if cipher keys are not supposed to be generated.
             clntWriteKey = keySpec.getClientCipherKey();
             svrWriteKey = keySpec.getServerCipherKey();
 
             // Return null if IVs are not supposed to be generated.
+            // e.g. TLS 1.1+.
             clntWriteIV = keySpec.getClientIv();
             svrWriteIV = keySpec.getServerIv();
 
-            // Return null if MAC keys are not supposed to be generated.
             clntMacSecret = keySpec.getClientMacKey();
             svrMacSecret = keySpec.getServerMacKey();
         } catch (GeneralSecurityException e) {
@@ -1261,14 +1233,10 @@
                 printHex(dump, masterKey.getEncoded());
 
                 // Outputs:
-                if (clntMacSecret != null) {
-                    System.out.println("Client MAC write Secret:");
-                    printHex(dump, clntMacSecret.getEncoded());
-                    System.out.println("Server MAC write Secret:");
-                    printHex(dump, svrMacSecret.getEncoded());
-                } else {
-                    System.out.println("... no MAC keys used for this cipher");
-                }
+                System.out.println("Client MAC write Secret:");
+                printHex(dump, clntMacSecret.getEncoded());
+                System.out.println("Server MAC write Secret:");
+                printHex(dump, svrMacSecret.getEncoded());
 
                 if (clntWriteKey != null) {
                     System.out.println("Client write key:");
--- a/src/share/classes/sun/security/ssl/InputRecord.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/InputRecord.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,17 +77,6 @@
     /*
      * Construct the record to hold the maximum sized input record.
      * Data will be filled in separately.
-     *
-     * The structure of the byte buffer looks like:
-     *
-     *     |--------+---------+---------------------------------|
-     *     | header |   IV    | content, MAC/TAG, padding, etc. |
-     *     | headerPlusIVSize |
-     *
-     * header: the header of an SSL records
-     * IV:     the optional IV/nonce field, it is only required for block
-     *         (TLS 1.1 or later) and AEAD cipher suites.
-     *
      */
     InputRecord() {
         super(new byte[maxRecordSize]);
@@ -144,83 +133,44 @@
         return handshakeHash;
     }
 
-    void decrypt(Authenticator authenticator,
-            CipherBox box) throws BadPaddingException {
-
-        BadPaddingException bpe = null;
-        if (!box.isNullCipher()) {
-            try {
-                int cipheredLength = count - headerSize;
-
-                // apply explicit nonce for AEAD/CBC cipher suites if needed
-                int nonceSize = box.applyExplicitNonce(authenticator,
-                            contentType(), buf, headerSize, cipheredLength);
-                pos = headerSize + nonceSize;
-                lastHashed = pos;   // don't digest the explicit nonce
+    /*
+     * Verify and remove the MAC ... used for all records.
+     */
+    boolean checkMAC(MAC signer) {
+        int len = signer.MAClen();
+        if (len == 0) { // no mac
+            return true;
+        }
 
-                // decrypt the content
-                int offset = headerSize;
-                if (box.isAEADMode()) {
-                    // DON'T encrypt the nonce_explicit for AEAD mode
-                    offset += nonceSize;
-                }   // The explicit IV for CBC mode can be decrypted.
-
-                count = offset + box.decrypt(buf, offset, count - offset);
+        int offset = count - len;
 
-                // Note that we don't remove the nonce from the buffer.
-            } catch (BadPaddingException e) {
-                // RFC 2246 states that decryption_failed should be used
-                // for this purpose. However, that allows certain attacks,
-                // so we just send bad record MAC. We also need to make
-                // sure to always check the MAC to avoid a timing attack
-                // for the same issue. See paper by Vaudenay et al and the
-                // update in RFC 4346/5246.
-                //
-                // Failover to message authenticatoin code checking.
-                bpe = new BadPaddingException("invalid padding");
-            }
+        if (offset < headerSize) {
+            // data length would be negative, something is wrong
+            return false;
         }
 
-        // Requires message authentication code for null, stream and block
-        // cipher suites.
-        if (authenticator instanceof MAC) {
-            MAC signer = (MAC)authenticator;
-            int macLen = signer.MAClen();
-            if (macLen != 0) {
-                int macOffset = count - macLen;
-                int contentLen = macOffset - pos;
-                if (contentLen < 0) {
-                    // negative data length, something is wrong
-                    throw new BadPaddingException("bad record");
-                }
+        byte[] mac = signer.compute(contentType(), buf,
+            headerSize, offset - headerSize);
 
-                count -= macLen;  // Set the count before any MAC checking
-                                  // exception occurs, so that the following
-                                  // process can read the actual decrypted
-                                  // content (minus the MAC) in the fragment
-                                  // if necessary.
-                byte[] hash = signer.compute(contentType(),
-                                            buf, pos, contentLen);
-                if (hash == null || macLen != hash.length) {
-                    // something is wrong with MAC implementation
-                    throw new RuntimeException("Internal MAC error");
-                }
+        if (len != mac.length) {
+            throw new RuntimeException("Internal MAC error");
+        }
 
-                int offset = macOffset;
-                for (byte b : hash) {
-                    if (buf[offset++] != b) {
-                        throw new BadPaddingException("bad record MAC");
-                    }
-                }
+        for (int i = 0; i < len; i++) {
+            if (buf[offset + i] != mac[i]) {
+                return false;
             }
         }
+        count -= len;
+        return true;
+    }
 
-        // Is it a failover?
-        if (bpe != null) {
-            throw bpe;
-        }
+    void decrypt(CipherBox box) throws BadPaddingException {
+        int len = count - headerSize;
+        count = headerSize + box.decrypt(buf, headerSize, len);
     }
 
+
     /*
      * Well ... hello_request messages are _never_ hashed since we can't
      * know when they'd appear in the sequence.
--- a/src/share/classes/sun/security/ssl/JsseJce.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/JsseJce.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -155,11 +155,6 @@
      */
     final static String CIPHER_AES = "AES/CBC/NoPadding";
     /**
-     * JCE transformation string for AES in GCM mode
-     * without padding.
-     */
-    final static String CIPHER_AES_GCM = "AES/GCM/NoPadding";
-    /**
      * JCA identifier string for DSA, i.e. a DSA with SHA-1.
      */
     final static String SIGNATURE_DSA = "DSA";
--- a/src/share/classes/sun/security/ssl/MAC.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/MAC.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,15 +39,19 @@
 
 /**
  * This class computes the "Message Authentication Code" (MAC) for each
- * SSL stream and block cipher message.  This is essentially a shared-secret
- * signature, used to provide integrity protection for SSL messages.  The
- * MAC is actually one of several keyed hashes, as associated with the cipher
- * suite and protocol version. (SSL v3.0 uses one construct, TLS uses another.)
+ * SSL message.  This is essentially a shared-secret signature, used to
+ * provide integrity protection for SSL messages.  The MAC is actually
+ * one of several keyed hashes, as associated with the cipher suite and
+ * protocol version.  (SSL v3.0 uses one construct, TLS uses another.)
+ *
+ * <P>NOTE: MAC computation is the only place in the SSL protocol that the
+ * sequence number is used.  It's also reset to zero with each change of
+ * a cipher spec, so this is the only place this state is needed.
  *
  * @author David Brownell
  * @author Andreas Sterbenz
  */
-final class MAC extends Authenticator {
+final class MAC {
 
     final static MAC NULL = new MAC();
 
@@ -60,9 +64,26 @@
     // JCE Mac object
     private final Mac mac;
 
+    // byte array containing the additional information we MAC in each record
+    // (see below)
+    private final byte[] block;
+
+    // sequence number + record type + + record length
+    private static final int BLOCK_SIZE_SSL = 8 + 1 + 2;
+
+    // sequence number + record type + protocol version + record length
+    private static final int BLOCK_SIZE_TLS = 8 + 1 + 2 + 2;
+
+    // offset of record type in block
+    private static final int BLOCK_OFFSET_TYPE    = 8;
+
+    // offset of protocol version number in block (TLS only)
+    private static final int BLOCK_OFFSET_VERSION = 8 + 1;
+
     private MAC() {
         macSize = 0;
         mac = null;
+        block = null;
     }
 
     /**
@@ -70,8 +91,6 @@
      */
     MAC(MacAlg macAlg, ProtocolVersion protocolVersion, SecretKey key)
             throws NoSuchAlgorithmException, InvalidKeyException {
-        super(protocolVersion);
-
         this.macSize = macAlg.size;
 
         String algorithm;
@@ -91,6 +110,14 @@
 
         mac = JsseJce.getMac(algorithm);
         mac.init(key);
+
+        if (tls) {
+            block = new byte[BLOCK_SIZE_TLS];
+            block[BLOCK_OFFSET_VERSION]   = protocolVersion.major;
+            block[BLOCK_OFFSET_VERSION+1] = protocolVersion.minor;
+        } else {
+            block = new byte[BLOCK_SIZE_SSL];
+        }
     }
 
     /**
@@ -109,15 +136,7 @@
      * @param len the size of the compressed record
      */
     final byte[] compute(byte type, byte buf[], int offset, int len) {
-        if (macSize == 0) {
-            return nullMAC;
-        }
-
-        byte[] additional = acquireAuthenticationBytes(type, len);
-        mac.update(additional);
-        mac.update(buf, offset, len);
-
-        return mac.doFinal();
+        return compute(type, null, buf, offset, len);
     }
 
     /**
@@ -132,13 +151,78 @@
      *          demarcate the data to be MAC'd.
      */
     final byte[] compute(byte type, ByteBuffer bb) {
+        return compute(type, bb, null, 0, bb.remaining());
+    }
+
+    /**
+     * Check whether the sequence number is close to wrap
+     *
+     * Sequence numbers are of type uint64 and may not exceed 2^64-1.
+     * Sequence numbers do not wrap. When the sequence number is near
+     * to wrap, we need to close the connection immediately.
+     */
+    final boolean seqNumOverflow() {
+        /*
+         * Conservatively, we don't allow more records to be generated
+         * when there are only 2^8 sequence numbers left.
+         */
+        return (block != null && mac != null &&
+                block[0] == (byte)0xFF && block[1] == (byte)0xFF &&
+                block[2] == (byte)0xFF && block[3] == (byte)0xFF &&
+                block[4] == (byte)0xFF && block[5] == (byte)0xFF &&
+                block[6] == (byte)0xFF);
+    }
+
+    /*
+     * Check whether to renew the sequence number
+     *
+     * Sequence numbers are of type uint64 and may not exceed 2^64-1.
+     * Sequence numbers do not wrap.  If a TLS
+     * implementation would need to wrap a sequence number, it must
+     * renegotiate instead.
+     */
+    final boolean seqNumIsHuge() {
+        /*
+         * Conservatively, we should ask for renegotiation when there are
+         * only 2^48 sequence numbers left.
+         */
+        return (block != null && mac != null &&
+                block[0] == (byte)0xFF && block[1] == (byte)0xFF);
+    }
+
+    // increment the sequence number in the block array
+    // it is a 64-bit number stored in big-endian format
+    private void incrementSequenceNumber() {
+        int k = 7;
+        while ((k >= 0) && (++block[k] == 0)) {
+            k--;
+        }
+    }
+
+    /*
+     * Compute based on either buffer type, either bb.position/limit
+     * or buf/offset/len.
+     */
+    private byte[] compute(byte type, ByteBuffer bb, byte[] buf,
+            int offset, int len) {
+
         if (macSize == 0) {
             return nullMAC;
         }
 
-        byte[] additional = acquireAuthenticationBytes(type, bb.remaining());
-        mac.update(additional);
-        mac.update(bb);
+        block[BLOCK_OFFSET_TYPE] = type;
+        block[block.length - 2]  = (byte)(len >> 8);
+        block[block.length - 1]  = (byte)(len     );
+
+        mac.update(block);
+        incrementSequenceNumber();
+
+        // content
+        if (bb != null) {
+            mac.update(bb);
+        } else {
+            mac.update(buf, offset, len);
+        }
 
         return mac.doFinal();
     }
--- a/src/share/classes/sun/security/ssl/OutputRecord.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/OutputRecord.java	Fri Mar 15 11:51:02 2013 -0300
@@ -54,7 +54,6 @@
     private int                 lastHashed;
     private boolean             firstMessage;
     final private byte          contentType;
-    private int                 headerOffset;
 
     // current protocol version, sent as record version
     ProtocolVersion     protocolVersion;
@@ -71,23 +70,6 @@
      * Default constructor makes a record supporting the maximum
      * SSL record size.  It allocates the header bytes directly.
      *
-     * The structure of the byte buffer looks like:
-     *
-     *     |---------+--------+-------+---------------------------------|
-     *     | unused  | header |  IV   | content, MAC/TAG, padding, etc. |
-     *     |    headerPlusMaxIVSize   |
-     *
-     * unused: unused part of the buffer of size
-     *
-     *             headerPlusMaxIVSize - header size - IV size
-     *
-     *         When this object is created, we don't know the protocol
-     *         version number, IV length, etc., so reserve space in front
-     *         to avoid extra data movement (copies).
-     * header: the header of an SSL record
-     * IV:     the optional IV/nonce field, it is only required for block
-     *         (TLS 1.1 or later) and AEAD cipher suites.
-     *
      * @param type the content type for the record
      */
     OutputRecord(byte type, int size) {
@@ -95,10 +77,9 @@
         this.protocolVersion = ProtocolVersion.DEFAULT;
         this.helloVersion = ProtocolVersion.DEFAULT_HELLO;
         firstMessage = true;
-        count = headerPlusMaxIVSize;
+        count = headerSize;
         contentType = type;
         lastHashed = count;
-        headerOffset = headerPlusMaxIVSize - headerSize;
     }
 
     OutputRecord(byte type) {
@@ -138,9 +119,8 @@
     @Override
     public synchronized void reset() {
         super.reset();
-        count = headerPlusMaxIVSize;
+        count = headerSize;
         lastHashed = count;
-        headerOffset = headerPlusMaxIVSize - headerSize;
     }
 
     /*
@@ -193,84 +173,58 @@
      * of sending empty records over the network.
      */
     boolean isEmpty() {
-        return count == headerPlusMaxIVSize;
+        return count == headerSize;
     }
 
     /*
-     * Return true if the record is of an alert of the given description.
-     *
-     * Per SSL/TLS specifications, alert messages convey the severity of the
-     * message (warning or fatal) and a description of the alert. An alert
-     * is defined with a two bytes struct, {byte level, byte description},
-     * following after the header bytes.
+     * Return true if the record is of a given alert.
      */
     boolean isAlert(byte description) {
-        if ((count > (headerPlusMaxIVSize + 1)) && (contentType == ct_alert)) {
-            return buf[headerPlusMaxIVSize + 1] == description;
+        // An alert is defined with a two bytes struct,
+        // {byte level, byte description}, following after the header bytes.
+        if (count > (headerSize + 1) && contentType == ct_alert) {
+            return buf[headerSize + 1] == description;
         }
 
         return false;
     }
 
     /*
-     * Encrypt ... length may grow due to block cipher padding, or
-     * message authentication code or tag.
+     * Compute the MAC and append it to this record.  In case we
+     * are automatically flushing a handshake stream, make sure we
+     * have hashed the message first.
      */
-    void encrypt(Authenticator authenticator, CipherBox box)
-            throws IOException {
-
-        // In case we are automatically flushing a handshake stream, make
-        // sure we have hashed the message first.
+    void addMAC(MAC signer) throws IOException {
         //
         // when we support compression, hashing can't go here
         // since it'll need to be done on the uncompressed data,
         // and the MAC applies to the compressed data.
+        //
         if (contentType == ct_handshake) {
             doHashes();
         }
-
-        // Requires message authentication code for stream and block
-        // cipher suites.
-        if (authenticator instanceof MAC) {
-            MAC signer = (MAC)authenticator;
-            if (signer.MAClen() != 0) {
-                byte[] hash = signer.compute(contentType, buf,
-                    headerPlusMaxIVSize, count - headerPlusMaxIVSize);
-                write(hash);
-            }
-        }
-
-        if (!box.isNullCipher()) {
-            // Requires explicit IV/nonce for CBC/AEAD cipher suites for
-            // TLS 1.1 or later.
-            if ((protocolVersion.v >= ProtocolVersion.TLS11.v) &&
-                                    (box.isCBCMode() || box.isAEADMode())) {
-                byte[] nonce = box.createExplicitNonce(authenticator,
-                                    contentType, count - headerPlusMaxIVSize);
-                int offset = headerPlusMaxIVSize - nonce.length;
-                System.arraycopy(nonce, 0, buf, offset, nonce.length);
-                headerOffset = offset - headerSize;
-            } else {
-                headerOffset = headerPlusMaxIVSize - headerSize;
-            }
-
-            // encrypt the content
-            int offset = headerPlusMaxIVSize;
-            if (!box.isAEADMode()) {
-                // The explicit IV can be encrypted.
-                offset = headerOffset + headerSize;
-            }   // Otherwise, DON'T encrypt the nonce_explicit for AEAD mode
-
-            count = offset + box.encrypt(buf, offset, count - offset);
+        if (signer.MAClen() != 0) {
+            byte[] hash = signer.compute(contentType, buf,
+                    headerSize, count - headerSize);
+            write(hash);
         }
     }
 
     /*
+     * Encrypt ... length may grow due to block cipher padding
+     */
+    void encrypt(CipherBox box) {
+        int len = count - headerSize;
+        count = headerSize + box.encrypt(buf, headerSize, len);
+    }
+
+
+    /*
      * Tell how full the buffer is ... for filling it with application or
      * handshake data.
      */
     final int availableDataBytes() {
-        int dataSize = count - headerPlusMaxIVSize;
+        int dataSize = count - headerSize;
         return maxDataSize - dataSize;
     }
 
@@ -316,11 +270,11 @@
          * Don't emit content-free records.  (Even change cipher spec
          * messages have a byte of data!)
          */
-        if (count == headerPlusMaxIVSize) {
+        if (count == headerSize) {
             return;
         }
 
-        int length = count - headerOffset - headerSize;
+        int length = count - headerSize;
         // "should" really never write more than about 14 Kb...
         if (length < 0) {
             throw new SSLException("output record size too small: "
@@ -345,9 +299,7 @@
          */
          if (firstMessage && useV2Hello()) {
             byte[] v3Msg = new byte[length - 4];
-            System.arraycopy(buf, headerPlusMaxIVSize + 4,
-                                        v3Msg, 0, v3Msg.length);
-            headerOffset = 0;   // reset the header offset
+            System.arraycopy(buf, headerSize + 4, v3Msg, 0, v3Msg.length);
             V3toV2ClientHello(v3Msg);
             handshakeHash.reset();
             lastHashed = 2;
@@ -362,11 +314,11 @@
             /*
              * Fill out the header, write it and the message.
              */
-            buf[headerOffset + 0] = contentType;
-            buf[headerOffset + 1] = protocolVersion.major;
-            buf[headerOffset + 2] = protocolVersion.minor;
-            buf[headerOffset + 3] = (byte)(length >> 8);
-            buf[headerOffset + 4] = (byte)(length);
+            buf[0] = contentType;
+            buf[1] = protocolVersion.major;
+            buf[2] = protocolVersion.minor;
+            buf[3] = (byte)(length >> 8);
+            buf[4] = (byte)(length);
         }
         firstMessage = false;
 
@@ -386,8 +338,7 @@
              * when holdRecord is true, the implementation in this class
              * will be used.
              */
-            writeBuffer(heldRecordBuffer,
-                        buf, headerOffset, count - headerOffset, debugOffset);
+            writeBuffer(heldRecordBuffer, buf, 0, count, debugOffset);
         } else {
             // It's time to send, do we have buffered data?
             // May or may not have a heldRecordBuffer.
@@ -395,18 +346,15 @@
                 int heldLen = heldRecordBuffer.size();
 
                 // Ensure the capacity of this buffer.
-                int newCount = count + heldLen - headerOffset;
-                ensureCapacity(newCount);
+                ensureCapacity(count + heldLen);
 
                 // Slide everything in the buffer to the right.
-                System.arraycopy(buf, headerOffset,
-                                    buf, heldLen, count - headerOffset);
+                System.arraycopy(buf, 0, buf, heldLen, count);
 
                 // Prepend the held record to the buffer.
                 System.arraycopy(
                     heldRecordBuffer.toByteArray(), 0, buf, 0, heldLen);
-                count = newCount;
-                headerOffset = 0;
+                count += heldLen;
 
                 // Clear the held buffer.
                 heldRecordBuffer.reset();
@@ -414,8 +362,7 @@
                 // The held buffer has been dumped, set the debug dump offset.
                 debugOffset = heldLen;
             }
-            writeBuffer(s, buf, headerOffset,
-                        count - headerOffset, debugOffset);
+            writeBuffer(s, buf, 0, count, debugOffset);
         }
 
         reset();
@@ -435,11 +382,12 @@
         if (debug != null && Debug.isOn("packet")) {
             try {
                 HexDumpEncoder hd = new HexDumpEncoder();
+                ByteBuffer bb = ByteBuffer.wrap(
+                        buf, off + debugOffset, len - debugOffset);
 
                 System.out.println("[Raw write]: length = " +
-                                                    (len - debugOffset));
-                hd.encodeBuffer(new ByteArrayInputStream(buf,
-                    off + debugOffset, len - debugOffset), System.out);
+                    bb.remaining());
+                hd.encodeBuffer(bb, System.out);
             } catch (IOException e) { }
         }
     }
@@ -452,13 +400,8 @@
         return firstMessage
             && (helloVersion == ProtocolVersion.SSL20Hello)
             && (contentType == ct_handshake)
-            && (buf[headerOffset + 5] == HandshakeMessage.ht_client_hello)
-                                            //  5: recode header size
-            && (buf[headerPlusMaxIVSize + 4 + 2 + 32] == 0);
-                                            // V3 session ID is empty
-                                            //  4: handshake header size
-                                            //  2: client_version in ClientHello
-                                            // 32: random in ClientHello
+            && (buf[5] == HandshakeMessage.ht_client_hello)
+            && (buf[headerSize + 4+2+32] == 0); // V3 session ID is empty
     }
 
     /*
--- a/src/share/classes/sun/security/ssl/Record.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/Record.java	Fri Mar 15 11:51:02 2013 -0300
@@ -52,29 +52,20 @@
     static final int    trailerSize = 20;       // SHA1 hash size
     static final int    maxDataSize = 16384;    // 2^14 bytes of data
     static final int    maxPadding = 256;       // block cipher padding
-    static final int    maxIVLength = 256;      // IV length
-
-    /*
-     * The size of the header plus the max IV length
-     */
-    static final int    headerPlusMaxIVSize =
-                                      headerSize        // header
-                                    + maxIVLength;      // iv
+    static final int    maxIVLength = 256;      // block length
 
     /*
      * SSL has a maximum record size.  It's header, (compressed) data,
-     * padding, and a trailer for the message authentication information (MAC
-     * for block and stream ciphers, and message authentication tag for AEAD
-     * ciphers).
-     *
+     * padding, and a trailer for the MAC.
      * Some compression algorithms have rare cases where they expand the data.
      * As we don't support compression at this time, leave that out.
      */
     static final int    maxRecordSize =
-                                      headerPlusMaxIVSize   // header + iv
-                                    + maxDataSize           // data
-                                    + maxPadding            // padding
-                                    + trailerSize;          // MAC or AEAD tag
+                                      headerSize        // header
+                                    + maxIVLength       // iv
+                                    + maxDataSize       // data
+                                    + maxPadding        // padding
+                                    + trailerSize;      // MAC
 
     static final boolean enableCBCProtection =
             Debug.getBooleanProperty("jsse.enableCBCProtection", true);
@@ -86,7 +77,8 @@
     static final int    maxDataSizeMinusOneByteRecord =
                                   maxDataSize       // max data size
                                 - (                 // max one byte record size
-                                      headerPlusMaxIVSize   // header + iv
+                                      headerSize    // header
+                                    + maxIVLength   // iv
                                     + 1             // one byte data
                                     + maxPadding    // padding
                                     + trailerSize   // MAC
@@ -112,10 +104,11 @@
      * Allocate a smaller array.
      */
     static final int    maxAlertRecordSize =
-                                      headerPlusMaxIVSize   // header + iv
-                                    + 2                     // alert
-                                    + maxPadding            // padding
-                                    + trailerSize;          // MAC
+                                      headerSize        // header
+                                    + maxIVLength       // iv
+                                    + 2                 // alert
+                                    + maxPadding        // padding
+                                    + trailerSize;      // MAC
 
     /*
      * The overflow values of integers of 8, 16 and 24 bits.
--- a/src/share/classes/sun/security/ssl/SSLEngineImpl.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/SSLEngineImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -280,7 +280,7 @@
     /*
      * Crypto state that's reinitialized when the session changes.
      */
-    private Authenticator       readAuthenticator, writeAuthenticator;
+    private MAC                 readMAC, writeMAC;
     private CipherBox           readCipher, writeCipher;
     // NOTE: compression state would be saved here
 
@@ -377,9 +377,9 @@
          * Note:  compression support would go here too
          */
         readCipher = CipherBox.NULL;
-        readAuthenticator = MAC.NULL;
+        readMAC = MAC.NULL;
         writeCipher = CipherBox.NULL;
-        writeAuthenticator = MAC.NULL;
+        writeMAC = MAC.NULL;
 
         // default security parameters for secure renegotiation
         secureRenegotiation = false;
@@ -586,7 +586,7 @@
 
         try {
             readCipher = handshaker.newReadCipher();
-            readAuthenticator = handshaker.newReadAuthenticator();
+            readMAC = handshaker.newReadMAC();
         } catch (GeneralSecurityException e) {
             // "can't happen"
             throw new SSLException("Algorithm missing:  ", e);
@@ -622,7 +622,7 @@
 
         try {
             writeCipher = handshaker.newWriteCipher();
-            writeAuthenticator = handshaker.newWriteAuthenticator();
+            writeMAC = handshaker.newWriteMAC();
         } catch (GeneralSecurityException e) {
             // "can't happen"
             throw new SSLException("Algorithm missing:  ", e);
@@ -958,15 +958,34 @@
              * throw a fatal alert if the integrity check fails.
              */
             try {
-                decryptedBB = inputRecord.decrypt(
-                                    readAuthenticator, readCipher, readBB);
+                decryptedBB = inputRecord.decrypt(readCipher, readBB);
             } catch (BadPaddingException e) {
+                // RFC 2246 states that decryption_failed should be used
+                // for this purpose. However, that allows certain attacks,
+                // so we just send bad record MAC. We also need to make
+                // sure to always check the MAC to avoid a timing attack
+                // for the same issue. See paper by Vaudenay et al.
+                //
+                // rewind the BB if necessary.
+                readBB.rewind();
+
+                inputRecord.checkMAC(readMAC, readBB);
+
                 // use the same alert types as for MAC failure below
                 byte alertType = (inputRecord.contentType() ==
                     Record.ct_handshake) ?
                         Alerts.alert_handshake_failure :
                         Alerts.alert_bad_record_mac;
-                fatal(alertType, e.getMessage(), e);
+                fatal(alertType, "Invalid padding", e);
+            }
+
+            if (!inputRecord.checkMAC(readMAC, decryptedBB)) {
+                if (inputRecord.contentType() == Record.ct_handshake) {
+                    fatal(Alerts.alert_handshake_failure,
+                        "bad handshake record MAC");
+                } else {
+                    fatal(Alerts.alert_bad_record_mac, "bad record MAC");
+                }
             }
 
             // if (!inputRecord.decompress(c))
@@ -1118,7 +1137,7 @@
                 hsStatus = getHSStatus(hsStatus);
                 if (connectionState < cs_ERROR && !isInboundDone() &&
                         (hsStatus == HandshakeStatus.NOT_HANDSHAKING)) {
-                    if (checkSequenceNumber(readAuthenticator,
+                    if (checkSequenceNumber(readMAC,
                             inputRecord.contentType())) {
                         hsStatus = getHSStatus(null);
                     }
@@ -1271,7 +1290,7 @@
 
         // eventually compress as well.
         HandshakeStatus hsStatus =
-                writer.writeRecord(eor, ea, writeAuthenticator, writeCipher);
+                writer.writeRecord(eor, ea, writeMAC, writeCipher);
 
         /*
          * We only need to check the sequence number state for
@@ -1288,7 +1307,7 @@
         hsStatus = getHSStatus(hsStatus);
         if (connectionState < cs_ERROR && !isOutboundDone() &&
                 (hsStatus == HandshakeStatus.NOT_HANDSHAKING)) {
-            if (checkSequenceNumber(writeAuthenticator, eor.contentType())) {
+            if (checkSequenceNumber(writeMAC, eor.contentType())) {
                 hsStatus = getHSStatus(null);
             }
         }
@@ -1327,7 +1346,7 @@
      */
     void writeRecord(EngineOutputRecord eor) throws IOException {
         // eventually compress as well.
-        writer.writeRecord(eor, writeAuthenticator, writeCipher);
+        writer.writeRecord(eor, writeMAC, writeCipher);
 
         /*
          * Check the sequence number state
@@ -1341,7 +1360,7 @@
          * of the last record cannot be wrapped.
          */
         if ((connectionState < cs_ERROR) && !isOutboundDone()) {
-            checkSequenceNumber(writeAuthenticator, eor.contentType());
+            checkSequenceNumber(writeMAC, eor.contentType());
         }
     }
 
@@ -1359,14 +1378,14 @@
      *
      * Return true if the handshake status may be changed.
      */
-    private boolean checkSequenceNumber(Authenticator authenticator, byte type)
+    private boolean checkSequenceNumber(MAC mac, byte type)
             throws IOException {
 
         /*
          * Don't bother to check the sequence number for error or
          * closed connections, or NULL MAC
          */
-        if (connectionState >= cs_ERROR || authenticator == MAC.NULL) {
+        if (connectionState >= cs_ERROR || mac == MAC.NULL) {
             return false;
         }
 
@@ -1374,7 +1393,7 @@
          * Conservatively, close the connection immediately when the
          * sequence number is close to overflow
          */
-        if (authenticator.seqNumOverflow()) {
+        if (mac.seqNumOverflow()) {
             /*
              * TLS protocols do not define a error alert for sequence
              * number overflow. We use handshake_failure error alert
@@ -1397,7 +1416,7 @@
          * Don't bother to kickstart the renegotiation when the local is
          * asking for it.
          */
-        if ((type != Record.ct_handshake) && authenticator.seqNumIsHuge()) {
+        if ((type != Record.ct_handshake) && mac.seqNumIsHuge()) {
             if (debug != null && Debug.isOn("ssl")) {
                 System.out.println(Thread.currentThread().getName() +
                         ", request renegotiation " +
--- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -292,7 +292,7 @@
     /*
      * Crypto state that's reinitialized when the session changes.
      */
-    private Authenticator       readAuthenticator, writeAuthenticator;
+    private MAC                 readMAC, writeMAC;
     private CipherBox           readCipher, writeCipher;
     // NOTE: compression state would be saved here
 
@@ -586,9 +586,9 @@
          * Note:  compression support would go here too
          */
         readCipher = CipherBox.NULL;
-        readAuthenticator = MAC.NULL;
+        readMAC = MAC.NULL;
         writeCipher = CipherBox.NULL;
-        writeAuthenticator = MAC.NULL;
+        writeMAC = MAC.NULL;
 
         // initial security parameters for secure renegotiation
         secureRenegotiation = false;
@@ -829,7 +829,8 @@
             boolean holdRecord) throws IOException {
 
         // r.compress(c);
-        r.encrypt(writeAuthenticator, writeCipher);
+        r.addMAC(writeMAC);
+        r.encrypt(writeCipher);
 
         if (holdRecord) {
             // If we were requested to delay the record due to possibility
@@ -860,7 +861,7 @@
          * of the last record cannot be wrapped.
          */
         if (connectionState < cs_ERROR) {
-            checkSequenceNumber(writeAuthenticator, r.contentType());
+            checkSequenceNumber(writeMAC, r.contentType());
         }
 
         // turn off the flag of the first application record
@@ -985,14 +986,29 @@
              * throw a fatal alert if the integrity check fails.
              */
             try {
-                r.decrypt(readAuthenticator, readCipher);
+                r.decrypt(readCipher);
             } catch (BadPaddingException e) {
+                // RFC 2246 states that decryption_failed should be used
+                // for this purpose. However, that allows certain attacks,
+                // so we just send bad record MAC. We also need to make
+                // sure to always check the MAC to avoid a timing attack
+                // for the same issue. See paper by Vaudenay et al.
+                r.checkMAC(readMAC);
                 // use the same alert types as for MAC failure below
                 byte alertType = (r.contentType() == Record.ct_handshake)
                                         ? Alerts.alert_handshake_failure
                                         : Alerts.alert_bad_record_mac;
-                fatal(alertType, e.getMessage(), e);
+                fatal(alertType, "Invalid padding", e);
             }
+            if (!r.checkMAC(readMAC)) {
+                if (r.contentType() == Record.ct_handshake) {
+                    fatal(Alerts.alert_handshake_failure,
+                        "bad handshake record MAC");
+                } else {
+                    fatal(Alerts.alert_bad_record_mac, "bad record MAC");
+                }
+            }
+
 
             // if (!r.decompress(c))
             //     fatal(Alerts.alert_decompression_failure,
@@ -1143,7 +1159,7 @@
                * of the last record cannot be wrapped.
                */
               if (connectionState < cs_ERROR) {
-                  checkSequenceNumber(readAuthenticator, r.contentType());
+                  checkSequenceNumber(readMAC, r.contentType());
               }
 
               return;
@@ -1166,14 +1182,14 @@
      * implementation would need to wrap a sequence number, it must
      * renegotiate instead."
      */
-    private void checkSequenceNumber(Authenticator authenticator, byte type)
+    private void checkSequenceNumber(MAC mac, byte type)
             throws IOException {
 
         /*
          * Don't bother to check the sequence number for error or
          * closed connections, or NULL MAC.
          */
-        if (connectionState >= cs_ERROR || authenticator == MAC.NULL) {
+        if (connectionState >= cs_ERROR || mac == MAC.NULL) {
             return;
         }
 
@@ -1181,7 +1197,7 @@
          * Conservatively, close the connection immediately when the
          * sequence number is close to overflow
          */
-        if (authenticator.seqNumOverflow()) {
+        if (mac.seqNumOverflow()) {
             /*
              * TLS protocols do not define a error alert for sequence
              * number overflow. We use handshake_failure error alert
@@ -1203,7 +1219,7 @@
          * Don't bother to kickstart the renegotiation when the local is
          * asking for it.
          */
-        if ((type != Record.ct_handshake) && authenticator.seqNumIsHuge()) {
+        if ((type != Record.ct_handshake) && mac.seqNumIsHuge()) {
             if (debug != null && Debug.isOn("ssl")) {
                 System.out.println(Thread.currentThread().getName() +
                         ", request renegotiation " +
@@ -2065,7 +2081,7 @@
 
         try {
             readCipher = handshaker.newReadCipher();
-            readAuthenticator = handshaker.newReadAuthenticator();
+            readMAC = handshaker.newReadMAC();
         } catch (GeneralSecurityException e) {
             // "can't happen"
             throw new SSLException("Algorithm missing:  ", e);
@@ -2096,7 +2112,7 @@
 
         try {
             writeCipher = handshaker.newWriteCipher();
-            writeAuthenticator = handshaker.newWriteAuthenticator();
+            writeMAC = handshaker.newWriteMAC();
         } catch (GeneralSecurityException e) {
             // "can't happen"
             throw new SSLException("Algorithm missing:  ", e);
--- a/src/share/classes/sun/util/locale/LanguageTag.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/util/locale/LanguageTag.java	Fri Mar 15 11:51:02 2013 -0300
@@ -134,7 +134,7 @@
     }
 
     /*
-     * BNF in RFC5464
+     * BNF in RFC5646
      *
      * Language-Tag  = langtag             ; normal language tags
      *               / privateuse          ; private use tag
--- a/src/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/util/locale/provider/AuxLocaleProviderAdapter.java	Fri Mar 15 11:51:02 2013 -0300
@@ -43,6 +43,7 @@
 import java.util.spi.LocaleNameProvider;
 import java.util.spi.LocaleServiceProvider;
 import java.util.spi.TimeZoneNameProvider;
+import sun.util.spi.CalendarProvider;
 
 /**
  * An abstract parent class for the
@@ -140,6 +141,14 @@
         return getLocaleServiceProvider(CalendarNameProvider.class);
     }
 
+    /**
+     * Getter methods for sun.util.spi.* providers
+     */
+    @Override
+    public CalendarProvider getCalendarProvider() {
+        return getLocaleServiceProvider(CalendarProvider.class);
+    }
+
     @Override
     public LocaleResources getLocaleResources(Locale locale) {
         return null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/util/locale/provider/CalendarProviderImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,95 @@
+/*
+ * 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.util.locale.provider;
+
+import java.util.Calendar;
+import java.util.Calendar.Builder;
+import java.util.Locale;
+import java.util.Set;
+import java.util.TimeZone;
+import sun.util.spi.CalendarProvider;
+
+/**
+ * Concrete implementation of the  {@link sun.util.spi.CalendarProvider
+ * CalendarProvider} class for the JRE LocaleProviderAdapter.
+ *
+ * @author Naoto Sato
+ */
+public class CalendarProviderImpl extends CalendarProvider implements AvailableLanguageTags {
+    private final LocaleProviderAdapter.Type type;
+    private final Set<String> langtags;
+
+    public CalendarProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
+        this.type = type;
+        this.langtags = langtags;
+    }
+
+    /**
+     * Returns an array of all locales for which this locale service provider
+     * can provide localized objects or names.
+     *
+     * @return An array of all locales for which this locale service provider
+     * can provide localized objects or names.
+     */
+    @Override
+    public Locale[] getAvailableLocales() {
+        return LocaleProviderAdapter.toLocaleArray(langtags);
+    }
+
+    @Override
+    public boolean isSupportedLocale(Locale locale) {
+        // Support any locales.
+        return true;
+    }
+
+    /**
+     * Returns a new <code>Calendar</code> instance for the
+     * specified locale.
+     *
+     * @param zone the time zone
+     * @param locale the desired locale
+     * @exception NullPointerException if <code>locale</code> is null
+     * @exception IllegalArgumentException if <code>locale</code> isn't
+     *     one of the locales returned from
+     *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
+     *     getAvailableLocales()}.
+     * @return a <code>Calendar</code> instance.
+     * @see java.util.Calendar#getInstance(java.util.Locale)
+     */
+    @Override
+    public Calendar getInstance(TimeZone zone, Locale locale) {
+        return new Calendar.Builder()
+                     .setLocale(locale)
+                     .setTimeZone(zone)
+                     .setInstant(System.currentTimeMillis())
+                     .build();
+    }
+
+    @Override
+    public Set<String> getAvailableLanguageTags() {
+        return langtags;
+    }
+}
--- a/src/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java	Fri Mar 15 11:51:02 2013 -0300
@@ -34,10 +34,12 @@
 import java.text.spi.DateFormatSymbolsProvider;
 import java.text.spi.DecimalFormatSymbolsProvider;
 import java.text.spi.NumberFormatProvider;
+import java.util.Calendar;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Set;
 import java.util.StringTokenizer;
+import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.spi.CalendarDataProvider;
@@ -47,6 +49,7 @@
 import java.util.spi.LocaleServiceProvider;
 import java.util.spi.TimeZoneNameProvider;
 import sun.util.resources.LocaleData;
+import sun.util.spi.CalendarProvider;
 
 /**
  * LocaleProviderAdapter implementation for the legacy JRE locale data.
@@ -104,6 +107,8 @@
             return (P) getCalendarDataProvider();
         case "CalendarNameProvider":
             return (P) getCalendarNameProvider();
+        case "CalendarProvider":
+            return (P) getCalendarProvider();
         default:
             throw new InternalError("should not come down here");
         }
@@ -122,6 +127,8 @@
     private volatile CalendarDataProvider calendarDataProvider = null;
     private volatile CalendarNameProvider calendarNameProvider = null;
 
+    private volatile CalendarProvider calendarProvider = null;
+
     /*
      * Getter methods for java.text.spi.* providers
      */
@@ -283,6 +290,23 @@
         return calendarNameProvider;
     }
 
+    /**
+     * Getter methods for sun.util.spi.* providers
+     */
+    @Override
+    public CalendarProvider getCalendarProvider() {
+        if (calendarProvider == null) {
+            CalendarProvider provider = new CalendarProviderImpl(getAdapterType(),
+                                                    getLanguageTagSet("CalendarData"));
+            synchronized (this) {
+                if (calendarProvider == null) {
+                    calendarProvider = provider;
+                }
+            }
+        }
+        return calendarProvider;
+    }
+
     @Override
     public LocaleResources getLocaleResources(Locale locale) {
         LocaleResources lr = localeResourcesMap.get(locale);
--- a/src/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java	Fri Mar 15 11:51:02 2013 -0300
@@ -33,6 +33,7 @@
 import java.text.spi.DecimalFormatSymbolsProvider;
 import java.text.spi.NumberFormatProvider;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -46,6 +47,7 @@
 import java.util.spi.LocaleServiceProvider;
 import java.util.spi.TimeZoneNameProvider;
 import sun.util.cldr.CLDRLocaleProviderAdapter;
+import sun.util.spi.CalendarProvider;
 
 /**
  * The LocaleProviderAdapter abstract class.
@@ -89,10 +91,7 @@
      * LocaleProviderAdapter preference list. The default list is intended
      * to behave the same manner in JDK7.
      */
-    private static Type[] adapterPreference = {
-        Type.JRE,
-        Type.SPI,
-    };
+    private static final List<Type> adapterPreference;
 
     /**
      * JRE Locale Data Adapter instance
@@ -129,10 +128,11 @@
     static {
         String order = AccessController.doPrivileged(
                            new sun.security.action.GetPropertyAction("java.locale.providers"));
-        // Override adapterPreference with the properties one
+        List<Type> typeList = new ArrayList<>();
+
+        // Check user specified adapter preference
         if (order != null && order.length() != 0) {
             String[] types = order.split(",");
-            List<Type> typeList = new ArrayList<>();
             for (String type : types) {
                 try {
                     Type aType = Type.valueOf(type.trim().toUpperCase(Locale.ROOT));
@@ -153,19 +153,23 @@
                     LocaleServiceProviderPool.config(LocaleProviderAdapter.class, e.toString());
                 }
             }
+        }
 
-            if (!typeList.isEmpty()) {
-                if (!typeList.contains(Type.JRE)) {
-                    // Append FALLBACK as the last resort.
-                    fallbackLocaleProviderAdapter = new FallbackLocaleProviderAdapter();
-                    typeList.add(Type.FALLBACK);
-                }
-                adapterPreference = typeList.toArray(new Type[0]);
+        if (!typeList.isEmpty()) {
+            if (!typeList.contains(Type.JRE)) {
+                // Append FALLBACK as the last resort.
+                fallbackLocaleProviderAdapter = new FallbackLocaleProviderAdapter();
+                typeList.add(Type.FALLBACK);
             }
+        } else {
+            // Default preference list
+            typeList.add(Type.JRE);
+            typeList.add(Type.SPI);
         }
+
+        adapterPreference = Collections.unmodifiableList(typeList);
     }
 
-
     /**
      * Returns the singleton instance for each adapter type
      */
@@ -202,7 +206,7 @@
     /**
      * Returns the preference order of LocaleProviderAdapter.Type
      */
-    public static Type[] getAdapterPreference() {
+    public static List<Type> getAdapterPreference() {
         return adapterPreference;
     }
 
@@ -292,7 +296,10 @@
         }
         if (type == Type.JRE) {
             String oldname = locale.toString().replace('_', '-');
-            return langtags.contains(oldname);
+            return langtags.contains(oldname) ||
+                   "ja-JP-JP".equals(oldname) ||
+                   "th-TH-TH".equals(oldname) ||
+                   "no-NO-NY".equals(oldname);
         }
         return false;
     }
@@ -419,6 +426,14 @@
      */
     public abstract CalendarNameProvider getCalendarNameProvider();
 
+    /**
+     * Returns a CalendarProvider for this LocaleProviderAdapter, or null if no
+     * CalendarProvider is available.
+     *
+     * @return a CalendarProvider
+     */
+    public abstract CalendarProvider getCalendarProvider();
+
     public abstract LocaleResources getLocaleResources(Locale locale);
 
     public abstract Locale[] getAvailableLocales();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/util/spi/CalendarProvider.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,64 @@
+/*
+ * 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.util.spi;
+
+import java.util.Calendar;
+import java.util.Locale;
+import java.util.TimeZone;
+import java.util.spi.LocaleServiceProvider;
+
+/**
+ * An abstract class for service providers that
+ * provide instances of the
+ * {@link java.util.Calendar Calendar} class.
+ *
+ * @since        1.8
+ */
+public abstract class CalendarProvider extends LocaleServiceProvider {
+
+    /**
+     * Sole constructor.  (For invocation by subclass constructors, typically
+     * implicit.)
+     */
+    protected CalendarProvider() {
+    }
+
+    /**
+     * Returns a new <code>Calendar</code> instance for the
+     * specified locale.
+     *
+     * @param zone the time zone
+     * @param locale the desired locale
+     * @exception NullPointerException if <code>locale</code> is null
+     * @exception IllegalArgumentException if <code>locale</code> isn't
+     *     one of the locales returned from
+     *     {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
+     *     getAvailableLocales()}.
+     * @return a <code>Calendar</code> instance.
+     * @see java.util.Calendar#getInstance(java.util.Locale)
+     */
+    public abstract Calendar getInstance(TimeZone zone, Locale locale);
+}
--- a/src/share/demo/jvmti/hprof/hprof_init.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/demo/jvmti/hprof/hprof_init.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1899,11 +1899,17 @@
      */
     getSystemProperty("sun.boot.library.path", &boot_path);
     md_build_library_name(lname, FILENAME_MAX, boot_path, name);
+    if ( strlen(lname) == 0 ) {
+        HPROF_ERROR(JNI_TRUE, "Could not find library");
+    }
     jvmtiDeallocate(boot_path);
     handle = md_load_library(lname, err_buf, (int)sizeof(err_buf));
     if ( handle == NULL ) {
         /* This may be necessary on Windows. */
         md_build_library_name(lname, FILENAME_MAX, "", name);
+        if ( strlen(lname) == 0 ) {
+            HPROF_ERROR(JNI_TRUE, "Could not find library");
+        }
         handle = md_load_library(lname, err_buf, (int)sizeof(err_buf));
         if ( handle == NULL ) {
             HPROF_ERROR(JNI_TRUE, err_buf);
@@ -1968,6 +1974,9 @@
     getSystemProperty("sun.boot.library.path", &boot_path);
     /* Load in NPT library for character conversions */
     md_build_library_name(npt_lib, sizeof(npt_lib), boot_path, NPT_LIBNAME);
+    if ( strlen(npt_lib) == 0 ) {
+        HPROF_ERROR(JNI_TRUE, "Could not find npt library");
+    }
     jvmtiDeallocate(boot_path);
     NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL);
     if ( gdata->npt == NULL ) {
--- a/src/share/javavm/export/jni.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/javavm/export/jni.h	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -1951,6 +1951,7 @@
 #define JNI_VERSION_1_2 0x00010002
 #define JNI_VERSION_1_4 0x00010004
 #define JNI_VERSION_1_6 0x00010006
+#define JNI_VERSION_1_8 0x00010008
 
 #ifdef __cplusplus
 } /* extern "C" */
--- a/src/share/native/com/sun/java/util/jar/pack/constants.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/com/sun/java/util/jar/pack/constants.h	Fri Mar 15 11:51:02 2013 -0300
@@ -505,5 +505,9 @@
   bc_qldc    = _xldc_op+7,
   bc_qldc_w  = _xldc_op+8,
   _xldc_limit = _xldc_op+9,
+  _invoke_int_op = _xldc_limit,
+  _invokespecial_int = _invoke_int_op+0,
+  _invokestatic_int = _invoke_int_op+1,
+  _invoke_int_limit =  _invoke_int_op+2,
   _xxx_3_end
 };
--- a/src/share/native/com/sun/java/util/jar/pack/unpack.cpp	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/com/sun/java/util/jar/pack/unpack.cpp	Fri Mar 15 11:51:02 2013 -0300
@@ -2942,6 +2942,9 @@
   case bc_putfield:
     return &bc_fieldref;
 
+  case _invokespecial_int:
+  case _invokestatic_int:
+    return &bc_imethodref;
   case bc_invokevirtual:
   case bc_invokespecial:
   case bc_invokestatic:
@@ -4177,6 +4180,12 @@
         }
         origBC = bc;
         switch (bc) {
+        case _invokestatic_int:
+          origBC = bc_invokestatic;
+          break;
+        case _invokespecial_int:
+          origBC = bc_invokespecial;
+          break;
         case bc_ildc:
         case bc_cldc:
         case bc_fldc:
--- a/src/share/native/common/check_code.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/common/check_code.c	Fri Mar 15 11:51:02 2013 -0300
@@ -206,6 +206,8 @@
 
 #define LDC_METHOD_HANDLE_MAJOR_VERSION 51
 
+#define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION 51
+
 #define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION  52
 
 #define ALLOC_STACK_SIZE 16 /* big enough */
@@ -1146,11 +1148,14 @@
         int *saved_operand;
         int keys;
         int k, delta;
-        /* 4639449, 4647081: Padding bytes must be zero. */
-        unsigned char* bptr = (unsigned char*) (code + offset + 1);
-        for (; bptr < (unsigned char*)lpc; bptr++) {
-            if (*bptr != 0) {
-                CCerror(context, "Non zero padding bytes in switch");
+
+        if (context->major_version < NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION) {
+            /* 4639449, 4647081: Padding bytes must be zero. */
+            unsigned char* bptr = (unsigned char*) (code + offset + 1);
+            for (; bptr < (unsigned char*)lpc; bptr++) {
+                if (*bptr != 0) {
+                    CCerror(context, "Non zero padding bytes in switch");
+                }
             }
         }
         if (opcode == JVM_OPC_tableswitch) {
--- a/src/share/native/common/jni_util.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/common/jni_util.h	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -339,6 +339,10 @@
 
 void initializeEncoding();
 
+void* getProcessHandle();
+
+void buildJniFunctionName(const char *sym, const char *cname,
+                          char *jniEntryName);
 
 #ifdef __cplusplus
 } /* extern "C" */
--- a/src/share/native/java/io/ObjectOutputStream.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/java/io/ObjectOutputStream.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -23,10 +23,8 @@
  * questions.
  */
 
-#include "jni.h"
-#include "jvm.h"
 #include "jni_util.h"
-#include "jlong.h"
+#include "jdk_util.h"
 
 #include "java_lang_Float.h"
 #include "java_lang_Double.h"
@@ -88,7 +86,7 @@
     srcend = srcpos + nfloats;
     for ( ; srcpos < srcend; srcpos++) {
         fval = (float) floats[srcpos];
-        if (JVM_IsNaN(fval)) {          /* collapse NaNs */
+        if (ISNANF(fval)) {          /* collapse NaNs */
             ival = 0x7fc00000;
         } else {
             u.f = fval;
@@ -160,7 +158,7 @@
     srcend = srcpos + ndoubles;
     for ( ; srcpos < srcend; srcpos++) {
         dval = doubles[srcpos];
-        if (JVM_IsNaN((double) dval)) {         /* collapse NaNs */
+        if (ISNAND((double) dval)) {         /* collapse NaNs */
             lval = jint_to_jlong(0x7ff80000);
             lval = jlong_shl(lval, 32);
         } else {
--- a/src/share/native/java/io/io_util.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/java/io/io_util.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -47,10 +47,8 @@
     nread = IO_Read(fd, &ret, 1);
     if (nread == 0) { /* EOF */
         return -1;
-    } else if (nread == JVM_IO_ERR) { /* error */
+    } else if (nread == -1) { /* error */
         JNU_ThrowIOExceptionWithLastError(env, "Read error");
-    } else if (nread == JVM_IO_INTR) {
-        JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
     }
     return ret & 0xFF;
 }
@@ -111,10 +109,8 @@
         nread = IO_Read(fd, buf, len);
         if (nread > 0) {
             (*env)->SetByteArrayRegion(env, bytes, off, nread, (jbyte *)buf);
-        } else if (nread == JVM_IO_ERR) {
+        } else if (nread == -1) {
             JNU_ThrowIOExceptionWithLastError(env, "Read error");
-        } else if (nread == JVM_IO_INTR) {
-            JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
         } else { /* EOF */
             nread = -1;
         }
@@ -141,10 +137,8 @@
     } else {
         n = IO_Write(fd, &c, 1);
     }
-    if (n == JVM_IO_ERR) {
+    if (n == -1) {
         JNU_ThrowIOExceptionWithLastError(env, "Write error");
-    } else if (n == JVM_IO_INTR) {
-        JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
     }
 }
 
@@ -194,12 +188,9 @@
             } else {
                 n = IO_Write(fd, buf+off, len);
             }
-            if (n == JVM_IO_ERR) {
+            if (n == -1) {
                 JNU_ThrowIOExceptionWithLastError(env, "Write error");
                 break;
-            } else if (n == JVM_IO_INTR) {
-                JNU_ThrowByName(env, "java/io/InterruptedIOException", NULL);
-                break;
             }
             off += n;
             len -= n;
@@ -214,11 +205,11 @@
 throwFileNotFoundException(JNIEnv *env, jstring path)
 {
     char buf[256];
-    jint n;
+    size_t n;
     jobject x;
     jstring why = NULL;
 
-    n = JVM_GetLastErrorString(buf, sizeof(buf));
+    n = getLastErrorString(buf, sizeof(buf));
     if (n > 0) {
         why = JNU_NewStringPlatform(env, buf);
     }
--- a/src/share/native/java/io/io_util.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/java/io/io_util.h	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -54,7 +54,7 @@
                 jint len, jboolean append, jfieldID fid);
 void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags);
 void throwFileNotFoundException(JNIEnv *env, jstring path);
-
+size_t getLastErrorString(char *buf, size_t len);
 
 /*
  * Macros for managing platform strings.  The typical usage pattern is:
--- a/src/share/native/java/lang/ClassLoader.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/java/lang/ClassLoader.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -32,6 +32,7 @@
 #include "jvm.h"
 #include "java_lang_ClassLoader.h"
 #include "java_lang_ClassLoader_NativeLibrary.h"
+#include <string.h>
 
 /* defined in libverify.so/verify.dll (src file common/check_format.c) */
 extern jboolean VerifyClassname(char *utf_name, jboolean arrayAllowed);
@@ -286,6 +287,8 @@
 
 static jfieldID handleID;
 static jfieldID jniVersionID;
+static jfieldID loadedID;
+static void *procHandle;
 
 static jboolean initIDs(JNIEnv *env)
 {
@@ -300,6 +303,10 @@
         jniVersionID = (*env)->GetFieldID(env, this, "jniVersion", "I");
         if (jniVersionID == 0)
             return JNI_FALSE;
+        loadedID = (*env)->GetFieldID(env, this, "loaded", "Z");
+        if (loadedID == 0)
+             return JNI_FALSE;
+        procHandle = getProcessHandle();
     }
     return JNI_TRUE;
 }
@@ -308,13 +315,59 @@
 typedef void (JNICALL *JNI_OnUnload_t)(JavaVM *, void *);
 
 /*
+ * Support for finding JNI_On(Un)Load_<lib_name> if it exists.
+ * If cname == NULL then just find normal JNI_On(Un)Load entry point
+ */
+static void *findJniFunction(JNIEnv *env, void *handle,
+                                    const char *cname, jboolean isLoad) {
+    const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
+    const char *onUnloadSymbols[] = JNI_ONUNLOAD_SYMBOLS;
+    const char **syms;
+    int symsLen;
+    void *entryName = NULL;
+    char *jniFunctionName;
+    int i;
+    int len;
+
+    // Check for JNI_On(Un)Load<_libname> function
+    if (isLoad) {
+        syms = onLoadSymbols;
+        symsLen = sizeof(onLoadSymbols) / sizeof(char *);
+    } else {
+        syms = onUnloadSymbols;
+        symsLen = sizeof(onUnloadSymbols) / sizeof(char *);
+    }
+    for (i = 0; i < symsLen; i++) {
+        // cname + sym + '_' + '\0'
+        if ((len = (cname != NULL ? strlen(cname) : 0) + strlen(syms[i]) + 2) >
+            FILENAME_MAX) {
+            goto done;
+        }
+        jniFunctionName = malloc(len);
+        if (jniFunctionName == NULL) {
+            JNU_ThrowOutOfMemoryError(env, NULL);
+            goto done;
+        }
+        buildJniFunctionName(syms[i], cname, jniFunctionName);
+        entryName = JVM_FindLibraryEntry(handle, jniFunctionName);
+        free(jniFunctionName);
+        if(entryName) {
+            break;
+        }
+    }
+
+ done:
+    return entryName;
+}
+
+/*
  * Class:     java_lang_ClassLoader_NativeLibrary
  * Method:    load
- * Signature: (Ljava/lang/String;)J
+ * Signature: (Ljava/lang/String;Z)V
  */
 JNIEXPORT void JNICALL
 Java_java_lang_ClassLoader_00024NativeLibrary_load
-  (JNIEnv *env, jobject this, jstring name)
+  (JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
 {
     const char *cname;
     jint jniVersion;
@@ -327,18 +380,12 @@
     cname = JNU_GetStringPlatformChars(env, name, 0);
     if (cname == 0)
         return;
-    handle = JVM_LoadLibrary(cname);
+    handle = isBuiltin ? procHandle : JVM_LoadLibrary(cname);
     if (handle) {
-        const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
         JNI_OnLoad_t JNI_OnLoad;
-        unsigned int i;
-        for (i = 0; i < sizeof(onLoadSymbols) / sizeof(char *); i++) {
-            JNI_OnLoad = (JNI_OnLoad_t)
-                JVM_FindLibraryEntry(handle, onLoadSymbols[i]);
-            if (JNI_OnLoad) {
-                break;
-            }
-        }
+        JNI_OnLoad = (JNI_OnLoad_t)findJniFunction(env, handle,
+                                               isBuiltin ? cname : NULL,
+                                               JNI_TRUE);
         if (JNI_OnLoad) {
             JavaVM *jvm;
             (*env)->GetJavaVM(env, &jvm);
@@ -355,7 +402,8 @@
             goto done;
         }
 
-        if (!JVM_IsSupportedJNIVersion(jniVersion)) {
+        if (!JVM_IsSupportedJNIVersion(jniVersion) ||
+            (isBuiltin && jniVersion < JNI_VERSION_1_8)) {
             char msg[256];
             jio_snprintf(msg, sizeof(msg),
                          "unsupported JNI version 0x%08X required by %s",
@@ -375,6 +423,7 @@
         goto done;
     }
     (*env)->SetLongField(env, this, handleID, ptr_to_jlong(handle));
+    (*env)->SetBooleanField(env, this, loadedID, JNI_TRUE);
 
  done:
     JNU_ReleaseStringPlatformChars(env, name, cname);
@@ -383,41 +432,40 @@
 /*
  * Class:     java_lang_ClassLoader_NativeLibrary
  * Method:    unload
- * Signature: ()V
+ * Signature: (Z)V
  */
 JNIEXPORT void JNICALL
 Java_java_lang_ClassLoader_00024NativeLibrary_unload
-  (JNIEnv *env, jobject this)
+(JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
 {
     const char *onUnloadSymbols[] = JNI_ONUNLOAD_SYMBOLS;
     void *handle;
     JNI_OnUnload_t JNI_OnUnload;
-    unsigned int i;
+     const char *cname;
 
     if (!initIDs(env))
         return;
-
+    cname = JNU_GetStringPlatformChars(env, name, 0);
+    if (cname == NULL) {
+        return;
+    }
     handle = jlong_to_ptr((*env)->GetLongField(env, this, handleID));
-    for (i = 0; i < sizeof(onUnloadSymbols) / sizeof(char *); i++) {
-        JNI_OnUnload = (JNI_OnUnload_t )
-            JVM_FindLibraryEntry(handle, onUnloadSymbols[i]);
-        if (JNI_OnUnload) {
-            break;
-        }
-    }
-
+    JNI_OnUnload = (JNI_OnUnload_t )findJniFunction(env, handle,
+                                                isBuiltin ? cname : NULL,
+                                                JNI_FALSE);
     if (JNI_OnUnload) {
         JavaVM *jvm;
         (*env)->GetJavaVM(env, &jvm);
         (*JNI_OnUnload)(jvm, NULL);
     }
     JVM_UnloadLibrary(handle);
+    JNU_ReleaseStringPlatformChars(env, name, cname);
 }
 
 /*
  * Class:     java_lang_ClassLoader_NativeLibrary
  * Method:    find
- * Signature: (Ljava/lang/String;J)J
+ * Signature: (Ljava/lang/String;)J
  */
 JNIEXPORT jlong JNICALL
 Java_java_lang_ClassLoader_00024NativeLibrary_find
@@ -456,3 +504,63 @@
     return NULL;
 }
 
+/*
+ * Class:     java_lang_ClassLoader_NativeLibrary
+ * Method:    findBuiltinLib
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL
+Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib
+  (JNIEnv *env, jclass cls, jstring name)
+{
+    const char *cname;
+    char *libName;
+    int prefixLen = (int) strlen(JNI_LIB_PREFIX);
+    int suffixLen = (int) strlen(JNI_LIB_SUFFIX);
+    int len;
+    jstring lib;
+    void *ret;
+    const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
+
+    if (name == NULL) {
+        JNU_ThrowInternalError(env, "NULL filename for native library");
+        return NULL;
+    }
+    // Can't call initIDs because it will recurse into NativeLibrary via
+    // FindClass to check context so set prochandle here as well.
+    procHandle = getProcessHandle();
+    cname = JNU_GetStringPlatformChars(env, name, 0);
+    if (cname == NULL) {
+        JNU_ThrowOutOfMemoryError(env, NULL);
+        return NULL;
+    }
+    // Copy name Skipping PREFIX
+    len = strlen(cname);
+    if (len <= (prefixLen+suffixLen)) {
+        JNU_ReleaseStringPlatformChars(env, name, cname);
+        return NULL;
+    }
+    libName = malloc(len + 1); //+1 for null if prefix+suffix == 0
+    if (libName == NULL) {
+        JNU_ReleaseStringPlatformChars(env, name, cname);
+        JNU_ThrowOutOfMemoryError(env, NULL);
+        return NULL;
+    }
+    if (len > prefixLen) {
+        strcpy(libName, cname+prefixLen);
+    }
+    JNU_ReleaseStringPlatformChars(env, name, cname);
+
+    // Strip SUFFIX
+    libName[strlen(libName)-suffixLen] = '\0';
+
+    // Check for JNI_OnLoad_libname function
+    ret = findJniFunction(env, procHandle, libName, JNI_TRUE);
+    if (ret != NULL) {
+        lib = JNU_NewStringPlatform(env, libName);
+        free(libName);
+        return lib;
+    }
+    free(libName);
+    return NULL;
+}
--- a/src/share/native/java/util/zip/Inflater.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/share/native/java/util/zip/Inflater.c	Fri Mar 15 11:51:02 2013 -0300
@@ -27,6 +27,7 @@
  * Native method support for java.util.zip.Inflater
  */
 
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -60,12 +61,13 @@
 {
     z_stream *strm = calloc(1, sizeof(z_stream));
 
-    if (strm == 0) {
+    if (strm == NULL) {
         JNU_ThrowOutOfMemoryError(env, 0);
         return jlong_zero;
     } else {
-        char *msg;
-        switch (inflateInit2(strm, nowrap ? -MAX_WBITS : MAX_WBITS)) {
+        const char *msg;
+        int ret = inflateInit2(strm, nowrap ? -MAX_WBITS : MAX_WBITS);
+        switch (ret) {
           case Z_OK:
             return ptr_to_jlong(strm);
           case Z_MEM_ERROR:
@@ -73,7 +75,13 @@
             JNU_ThrowOutOfMemoryError(env, 0);
             return jlong_zero;
           default:
-            msg = strm->msg;
+            msg = ((strm->msg != NULL) ? strm->msg :
+                   (ret == Z_VERSION_ERROR) ?
+                   "zlib returned Z_VERSION_ERROR: "
+                   "compile time and runtime zlib implementations differ" :
+                   (ret == Z_STREAM_ERROR) ?
+                   "inflateInit2 returned Z_STREAM_ERROR" :
+                   "unknown error initializing zlib library");
             free(strm);
             JNU_ThrowInternalError(env, msg);
             return jlong_zero;
--- a/src/solaris/back/linker_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/back/linker_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -60,6 +60,7 @@
 
     char *path_sep = PATH_SEPARATOR;
     char *pathname = (char *)pname;
+    *buffer = '\0';
     while (strlen(pathname) > 0) {
         char *p = strchr(pathname, *path_sep);
         if (p == NULL) {
@@ -69,13 +70,17 @@
         if (p == pathname) {
             continue;
         }
-        (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (p - pathname),
+        (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (int)(p - pathname),
                        pathname, fname);
 
         if (access(buffer, F_OK) == 0) {
             break;
         }
-        pathname = p + 1;
+        if (*p == '\0') {
+            pathname = p;
+        } else {
+            pathname = p + 1;
+        }
         *buffer = '\0';
     }
 }
--- a/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java	Fri Mar 15 11:51:02 2013 -0300
@@ -26,9 +26,9 @@
 package sun.nio.ch;
 
 import java.io.IOException;
-import java.util.LinkedList;
-import java.util.HashSet;
-import java.util.Iterator;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Manipulates a native array of epoll_event structs on Linux:
@@ -52,37 +52,78 @@
  * this implementation we set data.fd to be the file descriptor that we
  * register. That way, we have the file descriptor available when we
  * process the events.
- *
- * All file descriptors registered with epoll have the POLLHUP and POLLERR
- * events enabled even when registered with an event set of 0. To ensure
- * that epoll_wait doesn't poll an idle file descriptor when the underlying
- * connection is closed or reset then its registration is deleted from
- * epoll (it will be re-added again if the event set is changed)
  */
 
 class EPollArrayWrapper {
     // EPOLL_EVENTS
-    static final int EPOLLIN      = 0x001;
+    private static final int EPOLLIN      = 0x001;
 
     // opcodes
-    static final int EPOLL_CTL_ADD      = 1;
-    static final int EPOLL_CTL_DEL      = 2;
-    static final int EPOLL_CTL_MOD      = 3;
+    private static final int EPOLL_CTL_ADD      = 1;
+    private static final int EPOLL_CTL_DEL      = 2;
+    private static final int EPOLL_CTL_MOD      = 3;
 
     // Miscellaneous constants
-    static final int SIZE_EPOLLEVENT  = sizeofEPollEvent();
-    static final int EVENT_OFFSET     = 0;
-    static final int DATA_OFFSET      = offsetofData();
-    static final int FD_OFFSET        = DATA_OFFSET;
-    static final int NUM_EPOLLEVENTS  = Math.min(IOUtil.fdLimit(), 8192);
+    private static final int SIZE_EPOLLEVENT  = sizeofEPollEvent();
+    private static final int EVENT_OFFSET     = 0;
+    private static final int DATA_OFFSET      = offsetofData();
+    private static final int FD_OFFSET        = DATA_OFFSET;
+    private static final int OPEN_MAX         = IOUtil.fdLimit();
+    private static final int NUM_EPOLLEVENTS  = Math.min(OPEN_MAX, 8192);
+
+    // Special value to indicate that an update should be ignored
+    private static final byte  KILLED = (byte)-1;
 
-    // Base address of the native pollArray
+    // Initial size of arrays for fd registration changes
+    private static final int INITIAL_PENDING_UPDATE_SIZE = 64;
+
+    // maximum size of updatesLow
+    private static final int MAX_UPDATE_ARRAY_SIZE = Math.min(OPEN_MAX, 64*1024);
+
+
+    // The fd of the epoll driver
+    private final int epfd;
+
+     // The epoll_event array for results from epoll_wait
+    private final AllocatedNativeObject pollArray;
+
+    // Base address of the epoll_event array
     private final long pollArrayAddress;
 
-    // Set of "idle" channels
-    private final HashSet<SelChImpl> idleSet;
+    // The fd of the interrupt line going out
+    private int outgoingInterruptFD;
+
+    // The fd of the interrupt line coming in
+    private int incomingInterruptFD;
+
+    // The index of the interrupt FD
+    private int interruptedIndex;
+
+    // Number of updated pollfd entries
+    int updated;
+
+    // object to synchronize fd registration changes
+    private final Object updateLock = new Object();
 
-    EPollArrayWrapper() {
+    // number of file descriptors with registration changes pending
+    private int updateCount;
+
+    // file descriptors with registration changes pending
+    private int[] updateDescriptors = new int[INITIAL_PENDING_UPDATE_SIZE];
+
+    // events for file descriptors with registration changes pending, indexed
+    // by file descriptor and stored as bytes for efficiency reasons. For
+    // file descriptors higher than MAX_UPDATE_ARRAY_SIZE (unlimited case at
+    // least) then the update is stored in a map.
+    private final byte[] eventsLow = new byte[MAX_UPDATE_ARRAY_SIZE];
+    private Map<Integer,Byte> eventsHigh;
+
+    // Used by release and updateRegistrations to track whether a file
+    // descriptor is registered with epoll.
+    private final BitSet registered = new BitSet();
+
+
+    EPollArrayWrapper() throws IOException {
         // creates the epoll file descriptor
         epfd = epollCreate();
 
@@ -91,50 +132,11 @@
         pollArray = new AllocatedNativeObject(allocationSize, true);
         pollArrayAddress = pollArray.address();
 
-        for (int i=0; i<NUM_EPOLLEVENTS; i++) {
-            putEventOps(i, 0);
-            putData(i, 0L);
-        }
-
-        // create idle set
-        idleSet = new HashSet<SelChImpl>();
+        // eventHigh needed when using file descriptors > 64k
+        if (OPEN_MAX > MAX_UPDATE_ARRAY_SIZE)
+            eventsHigh = new HashMap<>();
     }
 
-    // Used to update file description registrations
-    private static class Updator {
-        SelChImpl channel;
-        int opcode;
-        int events;
-        Updator(SelChImpl channel, int opcode, int events) {
-            this.channel = channel;
-            this.opcode = opcode;
-            this.events = events;
-        }
-        Updator(SelChImpl channel, int opcode) {
-            this(channel, opcode, 0);
-        }
-    }
-
-    private LinkedList<Updator> updateList = new LinkedList<Updator>();
-
-    // The epoll_event array for results from epoll_wait
-    private AllocatedNativeObject pollArray;
-
-    // The fd of the epoll driver
-    final int epfd;
-
-    // The fd of the interrupt line going out
-    int outgoingInterruptFD;
-
-    // The fd of the interrupt line coming in
-    int incomingInterruptFD;
-
-    // The index of the interrupt FD
-    int interruptedIndex;
-
-    // Number of updated pollfd entries
-    int updated;
-
     void initInterrupt(int fd0, int fd1) {
         outgoingInterruptFD = fd1;
         incomingInterruptFD = fd0;
@@ -146,11 +148,6 @@
         pollArray.putInt(offset, event);
     }
 
-    void putData(int i, long value) {
-        int offset = SIZE_EPOLLEVENT * i + DATA_OFFSET;
-        pollArray.putLong(offset, value);
-    }
-
     void putDescriptor(int i, int fd) {
         int offset = SIZE_EPOLLEVENT * i + FD_OFFSET;
         pollArray.putInt(offset, fd);
@@ -167,51 +164,83 @@
     }
 
     /**
-     * Update the events for a given channel.
+     * Sets the pending update events for the given file descriptor. This
+     * method has no effect if the update events is already set to KILLED,
+     * unless {@code force} is {@code true}.
      */
-    void setInterest(SelChImpl channel, int mask) {
-        synchronized (updateList) {
-            // if the previous pending operation is to add this file descriptor
-            // to epoll then update its event set
-            if (updateList.size() > 0) {
-                Updator last = updateList.getLast();
-                if (last.channel == channel && last.opcode == EPOLL_CTL_ADD) {
-                    last.events = mask;
-                    return;
-                }
+    private void setUpdateEvents(int fd, byte events, boolean force) {
+        if (fd < MAX_UPDATE_ARRAY_SIZE) {
+            if ((eventsLow[fd] != KILLED) || force) {
+                eventsLow[fd] = events;
+            }
+        } else {
+            Integer key = Integer.valueOf(fd);
+            if ((eventsHigh.get(key) != KILLED) || force) {
+                eventsHigh.put(key, Byte.valueOf(events));
             }
+        }
+    }
 
-            // update existing registration
-            updateList.add(new Updator(channel, EPOLL_CTL_MOD, mask));
+    /**
+     * Returns the pending update events for the given file descriptor.
+     */
+    private byte getUpdateEvents(int fd) {
+        if (fd < MAX_UPDATE_ARRAY_SIZE) {
+            return eventsLow[fd];
+        } else {
+            Byte result = eventsHigh.get(Integer.valueOf(fd));
+            // result should never be null
+            return result.byteValue();
         }
     }
 
     /**
-     * Add a channel's file descriptor to epoll
+     * Update the events for a given file descriptor
      */
-    void add(SelChImpl channel) {
-        synchronized (updateList) {
-            updateList.add(new Updator(channel, EPOLL_CTL_ADD));
+    void setInterest(int fd, int mask) {
+        synchronized (updateLock) {
+            // record the file descriptor and events
+            int oldCapacity = updateDescriptors.length;
+            if (updateCount == oldCapacity) {
+                int newCapacity = oldCapacity + INITIAL_PENDING_UPDATE_SIZE;
+                int[] newDescriptors = new int[newCapacity];
+                System.arraycopy(updateDescriptors, 0, newDescriptors, 0, oldCapacity);
+                updateDescriptors = newDescriptors;
+            }
+            updateDescriptors[updateCount++] = fd;
+
+            // events are stored as bytes for efficiency reasons
+            byte b = (byte)mask;
+            assert (b == mask) && (b != KILLED);
+            setUpdateEvents(fd, b, false);
         }
     }
 
     /**
-     * Remove a channel's file descriptor from epoll
+     * Add a file descriptor
      */
-    void release(SelChImpl channel) {
-        synchronized (updateList) {
-            // flush any pending updates
-            for (Iterator<Updator> it = updateList.iterator(); it.hasNext();) {
-                if (it.next().channel == channel) {
-                    it.remove();
-                }
+    void add(int fd) {
+        // force the initial update events to 0 as it may be KILLED by a
+        // previous registration.
+        synchronized (updateLock) {
+            assert !registered.get(fd);
+            setUpdateEvents(fd, (byte)0, true);
+        }
+    }
+
+    /**
+     * Remove a file descriptor
+     */
+    void remove(int fd) {
+        synchronized (updateLock) {
+            // kill pending and future update for this file descriptor
+            setUpdateEvents(fd, KILLED, false);
+
+            // remove from epoll
+            if (registered.get(fd)) {
+                epollCtl(epfd, EPOLL_CTL_DEL, fd, 0);
+                registered.clear(fd);
             }
-
-            // remove from the idle set (if present)
-            idleSet.remove(channel);
-
-            // remove from epoll (if registered)
-            epollCtl(epfd, EPOLL_CTL_DEL, channel.getFDVal(), 0);
         }
     }
 
@@ -239,36 +268,38 @@
     /**
      * Update the pending registrations.
      */
-    void updateRegistrations() {
-        synchronized (updateList) {
-            Updator u = null;
-            while ((u = updateList.poll()) != null) {
-                SelChImpl ch = u.channel;
-                if (!ch.isOpen())
-                    continue;
+    private void updateRegistrations() {
+        synchronized (updateLock) {
+            int j = 0;
+            while (j < updateCount) {
+                int fd = updateDescriptors[j];
+                short events = getUpdateEvents(fd);
+                boolean isRegistered = registered.get(fd);
+                int opcode = 0;
 
-                // if the events are 0 then file descriptor is put into "idle
-                // set" to prevent it being polled
-                if (u.events == 0) {
-                    boolean added = idleSet.add(u.channel);
-                    // if added to idle set then remove from epoll if registered
-                    if (added && (u.opcode == EPOLL_CTL_MOD))
-                        epollCtl(epfd, EPOLL_CTL_DEL, ch.getFDVal(), 0);
-                } else {
-                    // events are specified. If file descriptor was in idle set
-                    // it must be re-registered (by converting opcode to ADD)
-                    boolean idle = false;
-                    if (!idleSet.isEmpty())
-                        idle = idleSet.remove(u.channel);
-                    int opcode = (idle) ? EPOLL_CTL_ADD : u.opcode;
-                    epollCtl(epfd, opcode, ch.getFDVal(), u.events);
+                if (events != KILLED) {
+                    if (isRegistered) {
+                        opcode = (events != 0) ? EPOLL_CTL_MOD : EPOLL_CTL_DEL;
+                    } else {
+                        opcode = (events != 0) ? EPOLL_CTL_ADD : 0;
+                    }
+                    if (opcode != 0) {
+                        epollCtl(epfd, opcode, fd, events);
+                        if (opcode == EPOLL_CTL_ADD) {
+                            registered.set(fd);
+                        } else if (opcode == EPOLL_CTL_DEL) {
+                            registered.clear(fd);
+                        }
+                    }
                 }
+                j++;
             }
+            updateCount = 0;
         }
     }
 
     // interrupt support
-    boolean interrupted = false;
+    private boolean interrupted = false;
 
     public void interrupt() {
         interrupt(outgoingInterruptFD);
--- a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -53,26 +53,24 @@
     private volatile boolean closed = false;
 
     // Lock for interrupt triggering and clearing
-    private Object interruptLock = new Object();
+    private final Object interruptLock = new Object();
     private boolean interruptTriggered = false;
 
     /**
      * Package private constructor called by factory method in
      * the abstract superclass Selector.
      */
-    EPollSelectorImpl(SelectorProvider sp) {
+    EPollSelectorImpl(SelectorProvider sp) throws IOException {
         super(sp);
         long pipeFds = IOUtil.makePipe(false);
         fd0 = (int) (pipeFds >>> 32);
         fd1 = (int) pipeFds;
         pollWrapper = new EPollArrayWrapper();
         pollWrapper.initInterrupt(fd0, fd1);
-        fdToKey = new HashMap<Integer,SelectionKeyImpl>();
+        fdToKey = new HashMap<>();
     }
 
-    protected int doSelect(long timeout)
-        throws IOException
-    {
+    protected int doSelect(long timeout) throws IOException {
         if (closed)
             throw new ClosedSelectorException();
         processDeregisterQueue();
@@ -161,8 +159,9 @@
         if (closed)
             throw new ClosedSelectorException();
         SelChImpl ch = ski.channel;
-        fdToKey.put(Integer.valueOf(ch.getFDVal()), ski);
-        pollWrapper.add(ch);
+        int fd = Integer.valueOf(ch.getFDVal());
+        fdToKey.put(fd, ski);
+        pollWrapper.add(fd);
         keys.add(ski);
     }
 
@@ -171,7 +170,7 @@
         SelChImpl ch = ski.channel;
         int fd = ch.getFDVal();
         fdToKey.remove(Integer.valueOf(fd));
-        pollWrapper.release(ch);
+        pollWrapper.remove(fd);
         ski.setIndex(-1);
         keys.remove(ski);
         selectedKeys.remove(ski);
@@ -181,10 +180,11 @@
             ((SelChImpl)selch).kill();
     }
 
-    public void putEventOps(SelectionKeyImpl sk, int ops) {
+    public void putEventOps(SelectionKeyImpl ski, int ops) {
         if (closed)
             throw new ClosedSelectorException();
-        pollWrapper.setInterest(sk.channel, ops);
+        SelChImpl ch = ski.channel;
+        pollWrapper.setInterest(ch.getFDVal(), ops);
     }
 
     public Selector wakeup() {
@@ -200,5 +200,4 @@
     static {
         Util.load();
     }
-
 }
--- a/src/solaris/demo/jvmti/hprof/hprof_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/demo/jvmti/hprof/hprof_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -385,6 +385,7 @@
     // Loosely based on os_solaris.cpp
 
       char *pathname = (char *)pname;
+      *buffer = '\0';
       while (strlen(pathname) > 0) {
           char *p = strchr(pathname, ':');
           if (p == NULL) {
@@ -395,12 +396,16 @@
               continue;
           }
           (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX,
-                         (p - pathname), pathname, fname);
+                         (int)(p - pathname), pathname, fname);
 
           if (access(buffer, F_OK) == 0) {
-            break;
+              break;
           }
-          pathname = p + 1;
+          if (*p == '\0') {
+              pathname = p;
+          } else {
+              pathname = p + 1;
+          }
           *buffer = '\0';
       }
 }
--- a/src/solaris/native/common/jdk_util_md.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/native/common/jdk_util_md.h	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -23,4 +23,24 @@
  * questions.
  */
 
-// Currently, there are no unix specific functions defined.
+#ifndef JDK_UTIL_MD_H
+#define JDK_UTIL_MD_H
+
+// checking for nanness
+#ifdef __solaris__
+#include <ieeefp.h>
+#define ISNANF(f) isnanf(f)
+#define ISNAND(d) isnand(d)
+#elif defined(MACOSX)
+#include <math.h>
+#define ISNANF(f) isnan(f)
+#define ISNAND(d) isnan(d)
+#elif defined(__linux__) || defined(_ALLBSD_SOURCE)
+#include <math.h>
+#define ISNANF(f) isnanf(f)
+#define ISNAND(d) isnan(d)
+#else
+#error "missing platform-specific definition here"
+#endif
+
+#endif /* JDK_UTIL_MD_H */
--- a/src/solaris/native/common/jni_util_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/native/common/jni_util_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -25,6 +25,7 @@
 
 #include "jni.h"
 #include "jni_util.h"
+#include "dlfcn.h"
 
 jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
     return NULL;
@@ -33,3 +34,22 @@
 char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
     return NULL;
 }
+
+void* getProcessHandle() {
+    static void *procHandle = NULL;
+    if (procHandle != NULL) {
+        return procHandle;
+    }
+    procHandle = (void*)dlopen(NULL, RTLD_LAZY);
+    return procHandle;
+}
+
+void buildJniFunctionName(const char *sym, const char *cname,
+                          char *jniEntryName) {
+    strcpy(jniEntryName, sym);
+    if (cname != NULL) {
+        strcat(jniEntryName, "_");
+        strcat(jniEntryName, cname);
+    }
+}
+
--- a/src/solaris/native/java/io/FileDescriptor_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/native/java/io/FileDescriptor_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -23,9 +23,8 @@
  * questions.
  */
 
-#include "jni.h"
-#include "jni_util.h"
 #include "jvm.h"
+#include "io_util_md.h"
 
 #include "java_io_FileDescriptor.h"
 
@@ -51,8 +50,8 @@
 
 JNIEXPORT void JNICALL
 Java_java_io_FileDescriptor_sync(JNIEnv *env, jobject this) {
-    int fd = (*env)->GetIntField(env, this, IO_fd_fdID);
-    if (JVM_Sync(fd) == -1) {
+    FD fd = THIS_FD(this);
+    if (IO_Sync(fd) == -1) {
         JNU_ThrowByName(env, "java/io/SyncFailedException", "sync failed");
     }
 }
--- a/src/solaris/native/java/io/UnixFileSystem_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/native/java/io/UnixFileSystem_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -77,7 +77,7 @@
 
     WITH_PLATFORM_STRING(env, pathname, path) {
         char canonicalPath[JVM_MAXPATHLEN];
-        if (canonicalize(JVM_NativePath((char *)path),
+        if (canonicalize((char *)path,
                          canonicalPath, JVM_MAXPATHLEN) < 0) {
             JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
         } else {
@@ -241,19 +241,18 @@
     jboolean rv = JNI_FALSE;
 
     WITH_PLATFORM_STRING(env, pathname, path) {
-        int fd;
-        if (!strcmp (path, "/")) {
-            fd = JVM_EEXIST;    /* The root directory always exists */
-        } else {
-            fd = JVM_Open(path, JVM_O_RDWR | JVM_O_CREAT | JVM_O_EXCL, 0666);
-        }
-        if (fd < 0) {
-            if (fd != JVM_EEXIST) {
-                JNU_ThrowIOExceptionWithLastError(env, path);
+        FD fd;
+        /* The root directory always exists */
+        if (strcmp (path, "/")) {
+            fd = handleOpen(path, O_RDWR | O_CREAT | O_EXCL, 0666);
+            if (fd < 0) {
+                if (errno != EEXIST)
+                    JNU_ThrowIOExceptionWithLastError(env, path);
+            } else {
+                if (close(fd) == -1)
+                    JNU_ThrowIOExceptionWithLastError(env, path);
+                rv = JNI_TRUE;
             }
-        } else {
-            JVM_Close(fd);
-            rv = JNI_TRUE;
         }
     } END_PLATFORM_STRING(env, path);
     return rv;
--- a/src/solaris/native/java/io/io_util_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/native/java/io/io_util_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -29,6 +29,15 @@
 #include "io_util.h"
 #include "io_util_md.h"
 #include <string.h>
+#include <unistd.h>
+
+#ifdef __solaris__
+#include <sys/filio.h>
+#endif
+
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#include <sys/ioctl.h>
+#endif
 
 #ifdef MACOSX
 
@@ -62,6 +71,28 @@
 }
 #endif
 
+FD
+handleOpen(const char *path, int oflag, int mode) {
+    FD fd;
+    RESTARTABLE(open64(path, oflag, mode), fd);
+    if (fd != -1) {
+        struct stat64 buf64;
+        int result;
+        RESTARTABLE(fstat64(fd, &buf64), result);
+        if (result != -1) {
+            if (S_ISDIR(buf64.st_mode)) {
+                close(fd);
+                errno = EISDIR;
+                fd = -1;
+            }
+        } else {
+            close(fd);
+            fd = -1;
+        }
+    }
+    return fd;
+}
+
 void
 fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags)
 {
@@ -74,8 +105,8 @@
         while ((p > ps) && (*p == '/'))
             *p-- = '\0';
 #endif
-        fd = JVM_Open(ps, flags, 0666);
-        if (fd >= 0) {
+        fd = handleOpen(ps, flags, 0666);
+        if (fd != -1) {
             SET_FD(this, fd, fid);
         } else {
             throwFileNotFoundException(env, path);
@@ -83,7 +114,6 @@
     } END_PLATFORM_STRING(env, ps);
 }
 
-
 void
 fileClose(JNIEnv *env, jobject this, jfieldID fid)
 {
@@ -114,7 +144,89 @@
             dup2(devnull, fd);
             close(devnull);
         }
-    } else if (JVM_Close(fd) == -1) {
+    } else if (close(fd) == -1) {
         JNU_ThrowIOExceptionWithLastError(env, "close failed");
     }
 }
+
+ssize_t
+handleRead(FD fd, void *buf, jint len)
+{
+    ssize_t result;
+    RESTARTABLE(read(fd, buf, len), result);
+    return result;
+}
+
+ssize_t
+handleWrite(FD fd, const void *buf, jint len)
+{
+    ssize_t result;
+    RESTARTABLE(write(fd, buf, len), result);
+    return result;
+}
+
+jint
+handleAvailable(FD fd, jlong *pbytes)
+{
+    int mode;
+    struct stat64 buf64;
+    jlong size = -1, current = -1;
+
+    int result;
+    RESTARTABLE(fstat64(fd, &buf64), result);
+    if (result != -1) {
+        mode = buf64.st_mode;
+        if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
+            int n;
+            int result;
+            RESTARTABLE(ioctl(fd, FIONREAD, &n), result);
+            if (result >= 0) {
+                *pbytes = n;
+                return 1;
+            }
+        } else if (S_ISREG(mode)) {
+            size = buf64.st_size;
+        }
+    }
+
+    if ((current = lseek64(fd, 0, SEEK_CUR)) == -1) {
+        return 0;
+    }
+
+    if (size < current) {
+        if ((size = lseek64(fd, 0, SEEK_END)) == -1)
+            return 0;
+        else if (lseek64(fd, current, SEEK_SET) == -1)
+            return 0;
+    }
+
+    if (size >= current) {
+        *pbytes = size - current;
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+jint
+handleSetLength(FD fd, jlong length)
+{
+    int result;
+    RESTARTABLE(ftruncate64(fd, length), result);
+    return result;
+}
+
+size_t
+getLastErrorString(char *buf, size_t len)
+{
+    if (errno == 0 || len < 1) return 0;
+
+    const char *err = strerror(errno);
+    size_t n = strlen(err);
+    if (n >= len)
+        n = len - 1;
+
+    strncpy(buf, err, n);
+    buf[n] = '\0';
+    return n;
+}
--- a/src/solaris/native/java/io/io_util_md.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/solaris/native/java/io/io_util_md.h	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -23,7 +23,6 @@
  * questions.
  */
 
-#include "jni.h"
 #include "jni_util.h"
 
 /*
@@ -32,6 +31,18 @@
 #define FD jint
 
 /*
+ * Prototypes for functions in io_util_md.c called from io_util.c,
+ * FileDescriptor.c, FileInputStream.c, FileOutputStream.c,
+ * UnixFileSystem_md.c
+ */
+ssize_t handleWrite(FD fd, const void *buf, jint len);
+ssize_t handleRead(FD fd, void *buf, jint len);
+jint handleAvailable(FD fd, jlong *pbytes);
+jint handleSetLength(FD fd, jlong length);
+
+FD handleOpen(const char *path, int oflag, int mode);
+
+/*
  * Macros to set/get fd from the java.io.FileDescriptor.  These
  * macros rely on having an appropriately defined 'this' object
  * within the scope in which they're used.
@@ -53,15 +64,25 @@
 #define THIS_FD(obj) (*env)->GetIntField(env, obj, IO_fd_fdID)
 
 /*
- * Route the routines through VM
+ * Route the routines
  */
-#define IO_Append JVM_Write
-#define IO_Write JVM_Write
-#define IO_Sync JVM_Sync
-#define IO_Read JVM_Read
-#define IO_Lseek JVM_Lseek
-#define IO_Available JVM_Available
-#define IO_SetLength JVM_SetLength
+#define IO_Sync fsync
+#define IO_Read handleRead
+#define IO_Write handleWrite
+#define IO_Append handleWrite
+#define IO_Available handleAvailable
+#define IO_SetLength handleSetLength
+
+#ifdef _ALLBSD_SOURCE
+#define open64 open
+#define fstat64 fstat
+#define stat64 stat
+#define lseek64 lseek
+#define ftruncate64 ftruncate
+#define IO_Lseek lseek
+#else
+#define IO_Lseek lseek64
+#endif
 
 /*
  * On Solaris, the handle field is unused
@@ -69,6 +90,15 @@
 #define SET_HANDLE(fd) return (jlong)-1
 
 /*
+ * Retry the operation if it is interrupted
+ */
+#define RESTARTABLE(_cmd, _result) do { \
+    do { \
+        _result = _cmd; \
+    } while((_result == -1) && (errno == EINTR)); \
+} while(0)
+
+/*
  * IO helper function(s)
  */
 void fileClose(JNIEnv *env, jobject this, jfieldID fid);
--- a/src/windows/back/linker_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/back/linker_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -44,6 +44,7 @@
 
     char *path_sep = PATH_SEPARATOR;
     char *pathname = (char *)pname;
+    *buffer = '\0';
     while (strlen(pathname) > 0) {
         char *p = strchr(pathname, *path_sep);
         if (p == NULL) {
@@ -54,16 +55,20 @@
             continue;
         }
         if (*(p-1) == ':' || *(p-1) == '\\') {
-            (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname),
+            (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
                             pathname, fname);
         } else {
-            (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname),
+            (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
                             pathname, fname);
         }
         if (_access(buffer, 0) == 0) {
             break;
         }
-        pathname = p + 1;
+        if (*p == '\0') {
+            pathname = p;
+        } else {
+            pathname = p + 1;
+        }
         *buffer = '\0';
     }
 }
--- a/src/windows/classes/sun/nio/fs/WindowsConstants.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/classes/sun/nio/fs/WindowsConstants.java	Fri Mar 15 11:51:02 2013 -0300
@@ -181,6 +181,11 @@
     public static final int FILE_READ_ATTRIBUTES        = 0x0080;
     public static final int FILE_WRITE_ATTRIBUTES       = 0x0100;
 
+    public static final int FILE_GENERIC_READ           = 0x00120089;
+    public static final int FILE_GENERIC_WRITE          = 0x00120116;
+    public static final int FILE_GENERIC_EXECUTE        = 0x001200a0;
+    public static final int FILE_ALL_ACCESS             = 0x001f01ff;
+
     // operating system security
     public static final int TOKEN_DUPLICATE             = 0x0002;
     public static final int TOKEN_IMPERSONATE           = 0x0004;
--- a/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java	Fri Mar 15 11:51:02 2013 -0300
@@ -38,6 +38,7 @@
 import sun.security.util.SecurityConstants;
 
 import static sun.nio.fs.WindowsNativeDispatcher.*;
+import static sun.nio.fs.WindowsSecurity.*;
 import static sun.nio.fs.WindowsConstants.*;
 
 public class WindowsFileSystemProvider
@@ -289,67 +290,29 @@
     }
 
     /**
-     * Returns buffer with SID_AND_ATTRIBUTES structure representing the user
-     * associated with the current thread access token.
-     * FIXME - this should be cached.
+     * Checks the file security against desired access.
      */
-    private static NativeBuffer getUserInfo(WindowsPath file) throws IOException {
-        try {
-            long hToken = WindowsSecurity.processTokenWithQueryAccess;
-            int size = GetTokenInformation(hToken, TokenUser, 0L, 0);
-            assert size > 0;
-
-            NativeBuffer buffer = NativeBuffers.getNativeBuffer(size);
-            try {
-                int newsize = GetTokenInformation(hToken, TokenUser,
-                                                  buffer.address(), size);
-                if (newsize != size)
-                    throw new AssertionError();
-                return buffer;
-            } catch (WindowsException x) {
-                buffer.release();
-                throw x;
-            }
-        } catch (WindowsException x) {
-            throw new IOException(x.getMessage());
-        }
-    }
-
-    /**
-     * Reads the file ACL and return the effective access as ACCESS_MASK
-     */
-    private static int getEffectiveAccess(WindowsPath file) throws IOException {
-        // read security descriptor continaing ACL (symlinks are followed)
+    private static boolean hasDesiredAccess(WindowsPath file, int rights) throws IOException {
+        // read security descriptor containing ACL (symlinks are followed)
+        boolean hasRights = false;
         String target = WindowsLinkSupport.getFinalPath(file, true);
         NativeBuffer aclBuffer = WindowsAclFileAttributeView
-            .getFileSecurity(target, DACL_SECURITY_INFORMATION);
-
-        // retrieves DACL from security descriptor
-        long pAcl = GetSecurityDescriptorDacl(aclBuffer.address());
-
-        // Use GetEffectiveRightsFromAcl to get effective access to file
+            .getFileSecurity(target,
+                DACL_SECURITY_INFORMATION
+                | OWNER_SECURITY_INFORMATION
+                | GROUP_SECURITY_INFORMATION);
         try {
-            NativeBuffer userBuffer = getUserInfo(file);
-            try {
-                try {
-                    // SID_AND_ATTRIBUTES->pSid
-                    long pSid = unsafe.getAddress(userBuffer.address());
-                    long pTrustee = BuildTrusteeWithSid(pSid);
-                    try {
-                        return GetEffectiveRightsFromAcl(pAcl, pTrustee);
-                    } finally {
-                        LocalFree(pTrustee);
-                    }
-                } catch (WindowsException x) {
-                    throw new IOException("Unable to get effective rights from ACL: " +
-                        x.getMessage());
-                }
-            } finally {
-                userBuffer.release();
-            }
+            hasRights = checkAccessMask(aclBuffer.address(), rights,
+                FILE_GENERIC_READ,
+                FILE_GENERIC_WRITE,
+                FILE_GENERIC_EXECUTE,
+                FILE_ALL_ACCESS);
+        } catch (WindowsException exc) {
+            exc.rethrowAsIOException(file);
         } finally {
             aclBuffer.release();
         }
+        return hasRights;
     }
 
     /**
@@ -416,10 +379,10 @@
             mask |= FILE_EXECUTE;
         }
 
-        if ((getEffectiveAccess(file) & mask) == 0)
+        if (!hasDesiredAccess(file, mask))
             throw new AccessDeniedException(
                 file.getPathForExceptionMessage(), null,
-                "Effective permissions does not allow requested access");
+                "Permissions does not allow requested access");
 
         // for write access we neeed to check if the DOS readonly attribute
         // and if the volume is read-only
@@ -438,7 +401,6 @@
                 throw new AccessDeniedException(
                     file.getPathForExceptionMessage(), null, "Read-only file system");
             }
-            return;
         }
     }
 
--- a/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java	Fri Mar 15 11:51:02 2013 -0300
@@ -844,6 +844,23 @@
     static native void AdjustTokenPrivileges(long token, long luid, int attributes)
         throws WindowsException;
 
+
+    /**
+     * AccessCheck(
+     *   PSECURITY_DESCRIPTOR pSecurityDescriptor,
+     *   HANDLE ClientToken,
+     *   DWORD DesiredAccess,
+     *   PGENERIC_MAPPING GenericMapping,
+     *   PPRIVILEGE_SET PrivilegeSet,
+     *   LPDWORD PrivilegeSetLength,
+     *   LPDWORD GrantedAccess,
+     *   LPBOOL AccessStatus
+     * )
+     */
+    static native boolean AccessCheck(long token, long securityInfo, int accessMask,
+        int genericRead, int genericWrite, int genericExecute, int genericAll)
+        throws WindowsException;
+
     /**
      */
     static long LookupPrivilegeValue(String name) throws WindowsException {
@@ -858,28 +875,6 @@
         throws WindowsException;
 
     /**
-     * BuildTrusteeWithSid(
-     *   PTRUSTEE pTrustee,
-     *   PSID pSid
-     * )
-     *
-     * @return  pTrustee
-     */
-    static native long BuildTrusteeWithSid(long pSid);
-
-    /**
-     * GetEffectiveRightsFromAcl(
-     *   PACL pacl,
-     *   PTRUSTEE pTrustee,
-     *   PACCESS_MASK pAccessRights
-     * )
-     *
-     * @return  AccessRights
-     */
-    static native int GetEffectiveRightsFromAcl(long pAcl, long pTrustee)
-        throws WindowsException;
-
-    /**
      * CreateSymbolicLink(
      *   LPCWSTR lpSymlinkFileName,
      *   LPCWSTR lpTargetFileName,
--- a/src/windows/classes/sun/nio/fs/WindowsSecurity.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/classes/sun/nio/fs/WindowsSecurity.java	Fri Mar 15 11:51:02 2013 -0300
@@ -105,19 +105,46 @@
         return new Privilege() {
             @Override
             public void drop() {
-                try {
-                    if (stopImpersontating) {
-                        SetThreadToken(0L, 0L);
-                    } else {
-                        if (needToRevert) {
+                if (token != 0L) {
+                    try {
+                        if (stopImpersontating)
+                            SetThreadToken(0L, 0L);
+                        else if (needToRevert)
                             AdjustTokenPrivileges(token, pLuid, 0);
-                        }
+                    } catch (WindowsException x) {
+                        // should not happen
+                        throw new AssertionError(x);
+                    } finally {
+                        CloseHandle(token);
                     }
-                } catch (WindowsException x) {
-                    // should not happen
-                    throw new AssertionError(x);
                 }
             }
         };
     }
+
+    /**
+     * Check the access right against the securityInfo in the current thread.
+     */
+    static boolean checkAccessMask(long securityInfo, int accessMask,
+        int genericRead, int genericWrite, int genericExecute, int genericAll)
+        throws WindowsException
+    {
+        int privilegies = TOKEN_QUERY;
+        long hToken = OpenThreadToken(GetCurrentThread(), privilegies, false);
+        if (hToken == 0L && processTokenWithDuplicateAccess != 0L)
+            hToken = DuplicateTokenEx(processTokenWithDuplicateAccess,
+                privilegies);
+
+        boolean hasRight = false;
+        if (hToken != 0L) {
+            try {
+                hasRight = AccessCheck(hToken, securityInfo, accessMask,
+                    genericRead, genericWrite, genericExecute, genericAll);
+            } finally {
+                CloseHandle(hToken);
+            }
+        }
+        return hasRight;
+    }
+
 }
--- a/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java	Fri Mar 15 11:51:02 2013 -0300
@@ -35,17 +35,20 @@
 import java.text.spi.DateFormatSymbolsProvider;
 import java.text.spi.DecimalFormatSymbolsProvider;
 import java.text.spi.NumberFormatProvider;
+import java.util.Calendar;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle.Control;
 import java.util.Set;
+import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicReferenceArray;
 import java.util.spi.CalendarDataProvider;
 import java.util.spi.CalendarNameProvider;
+import sun.util.spi.CalendarProvider;
 
 /**
  * LocaleProviderdapter implementation for the Windows locale data.
@@ -98,9 +101,9 @@
         if (initialize()) {
             // Assuming the default locales do not include any extensions, so
             // no stripping is needed here.
-            Locale l = Locale.forLanguageTag(getDefaultLocale(CAT_FORMAT).replaceAll("_","-"));
+            Locale l = Locale.forLanguageTag(getDefaultLocale(CAT_FORMAT).replace('_', '-'));
             tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
-            l = Locale.forLanguageTag(getDefaultLocale(CAT_DISPLAY).replaceAll("_","-"));
+            l = Locale.forLanguageTag(getDefaultLocale(CAT_DISPLAY).replace('_', '-'));
             tmpSet.addAll(Control.getNoFallbackControl(Control.FORMAT_DEFAULT).getCandidateLocales("", l));
         }
         supportedLocaleSet = Collections.unmodifiableSet(tmpSet);
@@ -173,24 +176,12 @@
 
             @Override
             public Locale[] getAvailableLocales() {
-                if (isSupportedLocale(Locale.getDefault(Locale.Category.FORMAT))) {
-                    return supportedLocale;
-                }
-
-                return new Locale[0];
+                return getSupportedCalendarLocales();
             }
 
             @Override
             public boolean isSupportedLocale(Locale locale) {
-                // Only supports the locale with Gregorian calendar
-                if (supportedLocale.length != 0) {
-                    int calid = getCalendarID(locale.toLanguageTag());
-                    if (calid > 0 && calid < calIDToLDML.length) {
-                        return calIDToLDML[calid].startsWith("gregory");
-                    }
-                }
-
-                return false;
+                return isSupportedCalendarLocale(locale);
             }
 
             @Override
@@ -380,6 +371,29 @@
         };
     }
 
+    public static CalendarProvider getCalendarProvider() {
+        return new CalendarProvider() {
+            @Override
+            public Locale[] getAvailableLocales() {
+                return getSupportedCalendarLocales();
+            }
+
+            @Override
+            public boolean isSupportedLocale(Locale locale) {
+                return isSupportedCalendarLocale(locale);
+            }
+
+            @Override
+            public Calendar getInstance(TimeZone zone, Locale locale) {
+                return new Calendar.Builder()
+                             .setLocale(getCalendarLocale(locale))
+                             .setTimeZone(zone)
+                             .setInstant(System.currentTimeMillis())
+                             .build();
+            }
+        };
+    }
+
     private static String convertDateTimePattern(String winPattern) {
         String ret = winPattern.replaceAll("dddd", "EEEE");
         ret = ret.replaceAll("ddd", "EEE");
@@ -401,24 +415,21 @@
     }
 
     private static boolean isSupportedCalendarLocale(Locale locale) {
-        // special case for ja_JP_JP
-        if (JRELocaleConstants.JA_JP_JP.equals(locale)) {
-            return isJapaneseCalendar();
-        }
-
         Locale base = locale.stripExtensions();
         if (!supportedLocaleSet.contains(base)) {
             return false;
         }
 
-        String caltype = locale.getUnicodeLocaleType("ca");
-        if (caltype == null) {
-            return true;
+        String requestedCalType = locale.getUnicodeLocaleType("ca");
+        String nativeCalType =
+                calIDToLDML[getCalendarID(locale.toLanguageTag())]
+                .replaceFirst("_.*", ""); // remove locale part.
+
+        if (requestedCalType == null) {
+            return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
+        } else {
+            return requestedCalType.equals(nativeCalType);
         }
-
-        return caltype.equals(
-            calIDToLDML[getCalendarID(locale.toLanguageTag())]
-            .replaceFirst("_.*", ""));
     }
 
     private static Locale[] getSupportedNativeDigitLocales() {
--- a/src/windows/demo/jvmti/hprof/hprof_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/demo/jvmti/hprof/hprof_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -372,6 +372,7 @@
     // Loosley based on os_windows.cpp
 
     char *pathname = (char *)pname;
+    *buffer = '\0';
     while (strlen(pathname) > 0) {
         char *p = strchr(pathname, ';');
         if (p == NULL) {
@@ -382,16 +383,20 @@
             continue;
         }
         if (*(p-1) == ':' || *(p-1) == '\\') {
-            (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname),
+          (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
                             pathname, fname);
         } else {
-            (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname),
+          (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
                             pathname, fname);
         }
         if (_access(buffer, 0) == 0) {
             break;
         }
-        pathname = p + 1;
+        if (*p == '\0') {
+            pathname = p;
+        } else {
+            pathname = p + 1;
+        }
         *buffer = '\0';
     }
 }
--- a/src/windows/native/common/jdk_util_md.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/native/common/jdk_util_md.h	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -28,6 +28,11 @@
 #define JDK_UTIL_MD_H
 
 #include "jni.h"
+#include <float.h>
+
+// checking for nanness
+#define ISNANF(f) _isnan(f)
+#define ISNAND(d) _isnan(d)
 
 #ifdef __cplusplus
 extern "C" {
--- a/src/windows/native/common/jni_util_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/native/common/jni_util_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -137,3 +137,35 @@
     else
         return NULL;
 }
+
+void* getProcessHandle() {
+    return (void*)GetModuleHandle(NULL);
+}
+
+/*
+ * Windows symbols can be simple like JNI_OnLoad or __stdcall format
+ * like _JNI_OnLoad@8. We need to handle both.
+ */
+void buildJniFunctionName(const char *sym, const char *cname,
+                          char *jniEntryName) {
+    if (cname != NULL) {
+        char *p = strrchr(sym, '@');
+        if (p != NULL && p != sym) {
+            // sym == _JNI_OnLoad@8
+            strncpy(jniEntryName, sym, (p - sym));
+            jniEntryName[(p-sym)] = '\0';
+            // jniEntryName == _JNI_OnLoad
+            strcat(jniEntryName, "_");
+            strcat(jniEntryName, cname);
+            strcat(jniEntryName, p);
+            //jniEntryName == _JNI_OnLoad_cname@8
+        } else {
+            strcpy(jniEntryName, sym);
+            strcat(jniEntryName, "_");
+            strcat(jniEntryName, cname);
+        }
+    } else {
+        strcpy(jniEntryName, sym);
+    }
+    return;
+}
--- a/src/windows/native/java/io/io_util_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/native/java/io/io_util_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -208,7 +208,7 @@
     return pathbuf;
 }
 
-jlong
+FD
 winFileHandleOpen(JNIEnv *env, jstring path, int flags)
 {
     const DWORD access =
@@ -264,7 +264,7 @@
 void
 fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags)
 {
-    jlong h = winFileHandleOpen(env, path, flags);
+    FD h = winFileHandleOpen(env, path, flags);
     if (h >= 0) {
         SET_FD(this, h, fid);
     }
@@ -274,12 +274,12 @@
    old C style int fd as is used in HPI layer */
 
 static int
-handleNonSeekAvailable(jlong, long *);
+handleNonSeekAvailable(FD, long *);
 static int
-handleStdinAvailable(jlong, long *);
+handleStdinAvailable(FD, long *);
 
 int
-handleAvailable(jlong fd, jlong *pbytes) {
+handleAvailable(FD fd, jlong *pbytes) {
     HANDLE h = (HANDLE)fd;
     DWORD type = 0;
 
@@ -317,7 +317,7 @@
 }
 
 static int
-handleNonSeekAvailable(jlong fd, long *pbytes) {
+handleNonSeekAvailable(FD fd, long *pbytes) {
     /* This is used for available on non-seekable devices
      * (like both named and anonymous pipes, such as pipes
      *  connected to an exec'd process).
@@ -346,7 +346,7 @@
 }
 
 static int
-handleStdinAvailable(jlong fd, long *pbytes) {
+handleStdinAvailable(FD fd, long *pbytes) {
     HANDLE han;
     DWORD numEventsRead = 0;    /* Number of events read from buffer */
     DWORD numEvents = 0;        /* Number of events in buffer */
@@ -412,8 +412,8 @@
  * denied".
  */
 
-JNIEXPORT int
-handleSync(jlong fd) {
+int
+handleSync(FD fd) {
     /*
      * From the documentation:
      *
@@ -443,7 +443,7 @@
 
 
 int
-handleSetLength(jlong fd, jlong length) {
+handleSetLength(FD fd, jlong length) {
     HANDLE h = (HANDLE)fd;
     long high = (long)(length >> 32);
     DWORD ret;
@@ -459,7 +459,7 @@
 
 JNIEXPORT
 jint
-handleRead(jlong fd, void *buf, jint len)
+handleRead(FD fd, void *buf, jint len)
 {
     DWORD read = 0;
     BOOL result = 0;
@@ -482,7 +482,7 @@
     return (jint)read;
 }
 
-static jint writeInternal(jlong fd, const void *buf, jint len, jboolean append)
+static jint writeInternal(FD fd, const void *buf, jint len, jboolean append)
 {
     BOOL result = 0;
     DWORD written = 0;
@@ -510,13 +510,11 @@
     return (jint)written;
 }
 
-JNIEXPORT
-jint handleWrite(jlong fd, const void *buf, jint len) {
+jint handleWrite(FD fd, const void *buf, jint len) {
     return writeInternal(fd, buf, len, JNI_FALSE);
 }
 
-JNIEXPORT
-jint handleAppend(jlong fd, const void *buf, jint len) {
+jint handleAppend(FD fd, const void *buf, jint len) {
     return writeInternal(fd, buf, len, JNI_TRUE);
 }
 
@@ -545,7 +543,7 @@
 }
 
 jlong
-handleLseek(jlong fd, jlong offset, jint whence)
+handleLseek(FD fd, jlong offset, jint whence)
 {
     LARGE_INTEGER pos, distance;
     DWORD lowPos = 0;
@@ -569,3 +567,44 @@
     }
     return long_to_jlong(pos.QuadPart);
 }
+
+size_t
+getLastErrorString(char *buf, size_t len)
+{
+    DWORD errval;
+    if (len > 0) {
+        if ((errval = GetLastError()) != 0) {
+            // DOS error
+            size_t n = (size_t)FormatMessage(
+                FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+                NULL,
+                errval,
+                0,
+                buf,
+                (DWORD)len,
+                NULL);
+            if (n > 3) {
+                // Drop final '.', CR, LF
+                if (buf[n - 1] == '\n') n--;
+                if (buf[n - 1] == '\r') n--;
+                if (buf[n - 1] == '.') n--;
+                buf[n] = '\0';
+            }
+            return n;
+        }
+
+        if (errno != 0) {
+            // C runtime error that has no corresponding DOS error code
+            const char *err = strerror(errno);
+            size_t n = strlen(err);
+            if (n >= len)
+                n = len - 1;
+
+            strncpy(buf, err, n);
+            buf[n] = '\0';
+            return n;
+        }
+    }
+
+    return 0;
+}
--- a/src/windows/native/java/io/io_util_md.h	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/native/java/io/io_util_md.h	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -27,7 +27,12 @@
 #include "jni_util.h"
 
 /*
- * Prototypes for functions in io_util_md.c called from io_util,
+ * Macros to use the right data type for file descriptors
+ */
+#define FD jlong
+
+/*
+ * Prototypes for functions in io_util_md.c called from io_util.c,
  * FileDescriptor.c, FileInputStream.c, FileOutputStream.c
  */
 WCHAR* pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE);
@@ -35,26 +40,20 @@
 WCHAR* getPrefixed(const WCHAR* path, int pathlen);
 WCHAR* currentDir(int di);
 int currentDirLength(const WCHAR* path, int pathlen);
-void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags);
-int handleAvailable(jlong fd, jlong *pbytes);
-JNIEXPORT int handleSync(jlong fd);
-int handleSetLength(jlong fd, jlong length);
-JNIEXPORT jint handleRead(jlong fd, void *buf, jint len);
-JNIEXPORT jint handleWrite(jlong fd, const void *buf, jint len);
-JNIEXPORT jint handleAppend(jlong fd, const void *buf, jint len);
+int handleAvailable(FD fd, jlong *pbytes);
+int handleSync(FD fd);
+int handleSetLength(FD fd, jlong length);
+JNIEXPORT jint handleRead(FD fd, void *buf, jint len);
+jint handleWrite(FD fd, const void *buf, jint len);
+jint handleAppend(FD fd, const void *buf, jint len);
 jint handleClose(JNIEnv *env, jobject this, jfieldID fid);
-jlong handleLseek(jlong fd, jlong offset, jint whence);
+jlong handleLseek(FD fd, jlong offset, jint whence);
 
 /*
  * Returns an opaque handle to file named by "path".  If an error occurs,
  * returns -1 and an exception is pending.
  */
-jlong winFileHandleOpen(JNIEnv *env, jstring path, int flags);
-
-/*
- * Macros to use the right data type for file descriptors
- */
-#define FD jlong
+FD winFileHandleOpen(JNIEnv *env, jstring path, int flags);
 
 /*
  * Macros to set/get fd from the java.io.FileDescriptor.
--- a/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c	Fri Mar 15 11:51:02 2013 -0300
@@ -89,6 +89,7 @@
     rv = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &opt, sizeof(opt));
     if (rv == SOCKET_ERROR) {
         NET_ThrowNew(env, WSAGetLastError(), "Socket creation failed");
+        closesocket(fd);
         return -1;
     }
 
--- a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c	Fri Mar 15 11:51:02 2013 -0300
@@ -1021,6 +1021,33 @@
         throwWindowsException(env, GetLastError());
 }
 
+JNIEXPORT jboolean JNICALL
+Java_sun_nio_fs_WindowsNativeDispatcher_AccessCheck(JNIEnv* env,
+    jclass this, jlong token, jlong securityInfo, jint accessMask,
+    jint genericRead, jint genericWrite, jint genericExecute, jint genericAll)
+{
+    HANDLE hImpersonatedToken = (HANDLE)jlong_to_ptr(token);
+    PSECURITY_DESCRIPTOR security = (PSECURITY_DESCRIPTOR)jlong_to_ptr(securityInfo);
+    DWORD checkAccessRights = (DWORD)accessMask;
+    GENERIC_MAPPING mapping = {
+        genericRead,
+        genericWrite,
+        genericExecute,
+        genericAll};
+    PRIVILEGE_SET privileges = {0};
+    DWORD privilegesLength = sizeof(privileges);
+    DWORD grantedAccess = 0;
+    BOOL result = FALSE;
+
+    /* checkAccessRights is in-out parameter */
+    MapGenericMask(&checkAccessRights, &mapping);
+    if (AccessCheck(security, hImpersonatedToken, checkAccessRights,
+            &mapping, &privileges, &privilegesLength, &grantedAccess, &result) == 0)
+        throwWindowsException(env, GetLastError());
+
+    return (result == FALSE) ? JNI_FALSE : JNI_TRUE;
+}
+
 JNIEXPORT jlong JNICALL
 Java_sun_nio_fs_WindowsNativeDispatcher_LookupPrivilegeValue0(JNIEnv* env,
     jclass this, jlong name)
@@ -1037,35 +1064,6 @@
     return ptr_to_jlong(pLuid);
 }
 
-JNIEXPORT jlong JNICALL
-Java_sun_nio_fs_WindowsNativeDispatcher_BuildTrusteeWithSid(JNIEnv* env,
-    jclass this, jlong sid)
-{
-    PSID pSid = (HANDLE)jlong_to_ptr(sid);
-    PTRUSTEE_W pTrustee = LocalAlloc(0, sizeof(TRUSTEE_W));
-
-    if (pTrustee == NULL) {
-        JNU_ThrowInternalError(env, "Unable to allocate TRUSTEE_W structure");
-    } else {
-        BuildTrusteeWithSidW(pTrustee, pSid);
-    }
-    return ptr_to_jlong(pTrustee);
-}
-
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_WindowsNativeDispatcher_GetEffectiveRightsFromAcl(JNIEnv* env,
-    jclass this, jlong acl, jlong trustee)
-{
-    ACCESS_MASK access;
-    PACL pAcl = (PACL)jlong_to_ptr(acl);
-    PTRUSTEE pTrustee = (PTRUSTEE)jlong_to_ptr(trustee);
-
-    if (GetEffectiveRightsFromAcl(pAcl, pTrustee, &access) != ERROR_SUCCESS) {
-        throwWindowsException(env, GetLastError());
-    }
-    return (jint)access;
-}
-
 JNIEXPORT void JNICALL
 Java_sun_nio_fs_WindowsNativeDispatcher_CreateSymbolicLink0(JNIEnv* env,
     jclass this, jlong linkAddress, jlong targetAddress, jint flags)
--- a/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Sat Mar 02 11:06:58 2013 -0400
+++ b/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c	Fri Mar 15 11:51:02 2013 -0300
@@ -611,7 +611,12 @@
 
 int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) {
     if (pGetLocaleInfoEx) {
-        return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
+        if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
+            // defaults to "en"
+            return pGetLocaleInfoEx(L"en", type, data, buflen);
+        } else {
+            return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
+        }
     } else {
         // If we ever wanted to support WinXP, we will need extra module from
         // MS...
@@ -622,7 +627,12 @@
 
 int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val) {
     if (pGetCalendarInfoEx) {
-        return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
+        if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
+            // defaults to "en"
+            return pGetCalendarInfoEx(L"en", id, reserved, type, data, buflen, val);
+        } else {
+            return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
+        }
     } else {
         // If we ever wanted to support WinXP, we will need extra module from
         // MS...
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/LUtils.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/*
+ * support infrastructure to invoke a java class from the command line
+ */
+class LUtils {
+    static final sun.tools.jar.Main jarTool =
+            new sun.tools.jar.Main(System.out, System.err, "jar-tool");
+    static final com.sun.tools.javac.Main javac =
+            new com.sun.tools.javac.Main();
+    static final File cwd = new File(".").getAbsoluteFile();
+    static final String JAVAHOME = System.getProperty("java.home");
+    static final boolean isWindows =
+            System.getProperty("os.name", "unknown").startsWith("Windows");
+    //static final boolean isSDK = JAVAHOME.endsWith("jre");
+    static final File JAVA_BIN_FILE = new File(JAVAHOME, "bin");
+    static final File JAVA_CMD = new File(JAVA_BIN_FILE,
+            isWindows ? "java.exe" : "java");
+
+    protected LUtils() {
+    }
+
+    public static void compile(String... args) {
+        if (javac.compile(args) != 0) {
+            throw new RuntimeException("compilation fails");
+        }
+    }
+
+    static void createFile(File outFile, List<String> content) {
+        try {
+            Files.write(outFile.getAbsoluteFile().toPath(), content,
+                    Charset.defaultCharset());
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    static File getClassFile(File javaFile) {
+        return javaFile.getName().endsWith(".java")
+                ? new File(javaFile.getName().replace(".java", ".class"))
+                : null;
+    }
+
+    static String getSimpleName(File inFile) {
+        String fname = inFile.getName();
+        return fname.substring(0, fname.indexOf("."));
+    }
+
+    static TestResult doExec(String... cmds) {
+        return doExec(null, null, cmds);
+    }
+
+    /*
+     * A method which executes a java cmd and returns the results in a container
+     */
+    static TestResult doExec(Map<String, String> envToSet,
+            java.util.Set<String> envToRemove, String... cmds) {
+        String cmdStr = "";
+        for (String x : cmds) {
+            cmdStr = cmdStr.concat(x + " ");
+        }
+        ProcessBuilder pb = new ProcessBuilder(cmds);
+        Map<String, String> env = pb.environment();
+        if (envToRemove != null) {
+            for (String key : envToRemove) {
+                env.remove(key);
+            }
+        }
+        if (envToSet != null) {
+            env.putAll(envToSet);
+        }
+        BufferedReader rdr = null;
+        try {
+            List<String> outputList = new ArrayList<>();
+            pb.redirectErrorStream(true);
+            Process p = pb.start();
+            rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
+            String in = rdr.readLine();
+            while (in != null) {
+                outputList.add(in);
+                in = rdr.readLine();
+            }
+            p.waitFor();
+            p.destroy();
+
+            return new TestResult(cmdStr, p.exitValue(), outputList,
+                    env, new Throwable("current stack of the test"));
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            throw new RuntimeException(ex.getMessage());
+        }
+    }
+
+    static class TestResult {
+        String cmd;
+        int exitValue;
+        List<String> testOutput;
+        Map<String, String> env;
+        Throwable t;
+
+        public TestResult(String str, int rv, List<String> oList,
+                Map<String, String> env, Throwable t) {
+            cmd = str;
+            exitValue = rv;
+            testOutput = oList;
+            this.env = env;
+            this.t = t;
+        }
+
+        void assertZero(String message) {
+            if (exitValue != 0) {
+                System.err.println(this);
+                throw new RuntimeException(message);
+            }
+        }
+
+        @Override
+        public String toString() {
+            StringWriter sw = new StringWriter();
+            PrintWriter status = new PrintWriter(sw);
+            status.println("Cmd: " + cmd);
+            status.println("Return code: " + exitValue);
+            status.println("Environment variable:");
+            for (String x : env.keySet()) {
+                status.println("\t" + x + "=" + env.get(x));
+            }
+            status.println("Output:");
+            for (String x : testOutput) {
+                status.println("\t" + x);
+            }
+            status.println("Exception:");
+            status.println(t.getMessage());
+            t.printStackTrace(status);
+
+            return sw.getBuffer().toString();
+        }
+    }
+}
--- a/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java	Fri Mar 15 11:51:02 2013 -0300
@@ -26,20 +26,12 @@
  * @bug 8003881
  * @summary tests DoPrivileged action (implemented as lambda expressions) by
  * inserting them into the BootClassPath.
- * @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java
+ * @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java LUtils.java
  * @run main/othervm LambdaAccessControlDoPrivilegedTest
  */
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 public class LambdaAccessControlDoPrivilegedTest extends LUtils {
     public static void main(String... args) {
@@ -87,140 +79,3 @@
         jarFile.delete();
     }
 }
-
-/*
- * support infrastructure to invoke a java class from the command line
- */
-class LUtils {
-    static final sun.tools.jar.Main jarTool =
-            new sun.tools.jar.Main(System.out, System.err, "jar-tool");
-    static final com.sun.tools.javac.Main javac =
-            new com.sun.tools.javac.Main();
-    static final File cwd = new File(".").getAbsoluteFile();
-    static final String JAVAHOME = System.getProperty("java.home");
-    static final boolean isWindows =
-            System.getProperty("os.name", "unknown").startsWith("Windows");
-    //static final boolean isSDK = JAVAHOME.endsWith("jre");
-    static final File JAVA_BIN_FILE = new File(JAVAHOME, "bin");
-    static final File JAVA_CMD = new File(JAVA_BIN_FILE,
-            isWindows ? "java.exe" : "java");
-
-    protected LUtils() {
-    }
-
-    public static void compile(String... args) {
-        if (javac.compile(args) != 0) {
-            throw new RuntimeException("compilation fails");
-        }
-    }
-
-    static void createFile(File outFile, List<String> content) {
-        try {
-            Files.write(outFile.getAbsoluteFile().toPath(), content,
-                    Charset.defaultCharset());
-        } catch (IOException ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    static File getClassFile(File javaFile) {
-        return javaFile.getName().endsWith(".java")
-                ? new File(javaFile.getName().replace(".java", ".class"))
-                : null;
-    }
-
-    static String getSimpleName(File inFile) {
-        String fname = inFile.getName();
-        return fname.substring(0, fname.indexOf("."));
-    }
-
-    static TestResult doExec(String... cmds) {
-        return doExec(null, null, cmds);
-    }
-
-    /*
-     * A method which executes a java cmd and returns the results in a container
-     */
-    static TestResult doExec(Map<String, String> envToSet,
-            java.util.Set<String> envToRemove, String... cmds) {
-        String cmdStr = "";
-        for (String x : cmds) {
-            cmdStr = cmdStr.concat(x + " ");
-        }
-        ProcessBuilder pb = new ProcessBuilder(cmds);
-        Map<String, String> env = pb.environment();
-        if (envToRemove != null) {
-            for (String key : envToRemove) {
-                env.remove(key);
-            }
-        }
-        if (envToSet != null) {
-            env.putAll(envToSet);
-        }
-        BufferedReader rdr = null;
-        try {
-            List<String> outputList = new ArrayList<>();
-            pb.redirectErrorStream(true);
-            Process p = pb.start();
-            rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
-            String in = rdr.readLine();
-            while (in != null) {
-                outputList.add(in);
-                in = rdr.readLine();
-            }
-            p.waitFor();
-            p.destroy();
-
-            return new TestResult(cmdStr, p.exitValue(), outputList,
-                    env, new Throwable("current stack of the test"));
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            throw new RuntimeException(ex.getMessage());
-        }
-    }
-
-    static class TestResult {
-        String cmd;
-        int exitValue;
-        List<String> testOutput;
-        Map<String, String> env;
-        Throwable t;
-
-        public TestResult(String str, int rv, List<String> oList,
-                Map<String, String> env, Throwable t) {
-            cmd = str;
-            exitValue = rv;
-            testOutput = oList;
-            this.env = env;
-            this.t = t;
-        }
-
-        void assertZero(String message) {
-            if (exitValue != 0) {
-                System.err.println(this);
-                throw new RuntimeException(message);
-            }
-        }
-
-        @Override
-        public String toString() {
-            StringWriter sw = new StringWriter();
-            PrintWriter status = new PrintWriter(sw);
-            status.println("Cmd: " + cmd);
-            status.println("Return code: " + exitValue);
-            status.println("Environment variable:");
-            for (String x : env.keySet()) {
-                status.println("\t" + x + "=" + env.get(x));
-            }
-            status.println("Output:");
-            for (String x : testOutput) {
-                status.println("\t" + x);
-            }
-            status.println("Exception:");
-            status.println(t.getMessage());
-            t.printStackTrace(status);
-
-            return sw.getBuffer().toString();
-        }
-    }
-}
--- a/test/java/lang/invoke/lambda/LambdaAccessControlTest.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/java/lang/invoke/lambda/LambdaAccessControlTest.java	Fri Mar 15 11:51:02 2013 -0300
@@ -25,7 +25,7 @@
  * @test
  * @bug 8003881
  * @summary tests Lambda expression with a a security manager at top level
- * @compile -XDignore.symbol.file LambdaAccessControlTest.java
+ * @compile -XDignore.symbol.file LambdaAccessControlTest.java LUtils.java
  *
  * @run main/othervm LambdaAccessControlTest
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/reflect/OldenCompilingWithDefaults.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8009267
+ * @summary Verify uses of isAnnotationPresent compile under older source versions
+ * @compile -source 1.5 -target 1.5 OldenCompilingWithDefaults.java
+ * @compile -source 1.6 -target 1.6 OldenCompilingWithDefaults.java
+ * @compile -source 1.7 -target 1.7 OldenCompilingWithDefaults.java
+ * @compile                         OldenCompilingWithDefaults.java
+ */
+
+import java.lang.reflect.*;
+
+public class OldenCompilingWithDefaults {
+    public OldenCompilingWithDefaults(){}
+    static Object f;
+
+    public static void main(String... args) throws Exception {
+        Class<OldenCompilingWithDefaults> clazz = OldenCompilingWithDefaults.class;
+        Package pkg = clazz.getPackage();
+        Constructor<OldenCompilingWithDefaults> ctor = clazz.getConstructor();
+        Method m = clazz.getMethod("main", String[].class);
+        Field f = clazz.getField("f");
+
+        if(clazz.isAnnotationPresent(SuppressWarnings.class) ||
+           pkg.isAnnotationPresent(SuppressWarnings.class) ||
+           ctor.isAnnotationPresent(SuppressWarnings.class) ||
+           m.isAnnotationPresent(SuppressWarnings.class) ||
+           f.isAnnotationPresent(SuppressWarnings.class))
+            System.out.println("An annotation is present.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/net/Socket/HttpProxy.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6370908
+ * @summary Add support for HTTP_CONNECT proxy in Socket class
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import static java.lang.System.out;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.ServerSocket;
+import java.net.Socket;
+import sun.net.www.MessageHeader;
+
+public class HttpProxy {
+    final String proxyHost;
+    final int proxyPort;
+    static final int SO_TIMEOUT = 15000;
+
+    public static void main(String[] args) throws Exception {
+        String host;
+        int port;
+        if (args.length == 0) {
+            // Start internal proxy
+            ConnectProxyTunnelServer proxy = new ConnectProxyTunnelServer();
+            proxy.start();
+            host = "localhost";
+            port = proxy.getLocalPort();
+            out.println("Running with internal proxy: " + host + ":" + port);
+        } else if (args.length == 2) {
+            host = args[0];
+            port = Integer.valueOf(args[1]);
+            out.println("Running against specified proxy server: " + host + ":" + port);
+        } else {
+            System.err.println("Usage: java HttpProxy [<proxy host> <proxy port>]");
+            return;
+        }
+
+        HttpProxy p = new HttpProxy(host, port);
+        p.test();
+    }
+
+    public HttpProxy(String proxyHost, int proxyPort) {
+        this.proxyHost = proxyHost;
+        this.proxyPort = proxyPort;
+    }
+
+    void test() throws Exception {
+        InetSocketAddress proxyAddress = new InetSocketAddress(proxyHost, proxyPort);
+        Proxy httpProxy = new Proxy(Proxy.Type.HTTP, proxyAddress);
+
+        try (ServerSocket ss = new ServerSocket(0);
+             Socket sock = new Socket(httpProxy)) {
+            sock.setSoTimeout(SO_TIMEOUT);
+            sock.setTcpNoDelay(false);
+
+            InetSocketAddress externalAddress =
+                new InetSocketAddress(InetAddress.getLocalHost(), ss.getLocalPort());
+
+            out.println("Trying to connect to server socket on " + externalAddress);
+            sock.connect(externalAddress);
+            try (Socket externalSock = ss.accept()) {
+                // perform some simple checks
+                check(sock.isBound(), "Socket is not bound");
+                check(sock.isConnected(), "Socket is not connected");
+                check(!sock.isClosed(), "Socket should not be closed");
+                check(sock.getSoTimeout() == SO_TIMEOUT,
+                        "Socket should have a previously set timeout");
+                check(sock.getTcpNoDelay() ==  false, "NODELAY should be false");
+
+                simpleDataExchange(sock, externalSock);
+            }
+        }
+    }
+
+    static void check(boolean condition, String message) {
+        if (!condition) out.println(message);
+    }
+
+    static Exception unexpected(Exception e) {
+        out.println("Unexcepted Exception: " + e);
+        e.printStackTrace();
+        return e;
+    }
+
+    // performs a simple exchange of data between the two sockets
+    // and throws an exception if there is any problem.
+    void simpleDataExchange(Socket s1, Socket s2) throws Exception {
+        try (final InputStream i1 = s1.getInputStream();
+             final InputStream i2 = s2.getInputStream();
+             final OutputStream o1 = s1.getOutputStream();
+             final OutputStream o2 = s2.getOutputStream()) {
+            startSimpleWriter("simpleWriter1", o1, 100);
+            startSimpleWriter("simpleWriter2", o2, 200);
+            simpleRead(i2, 100);
+            simpleRead(i1, 200);
+        }
+    }
+
+    void startSimpleWriter(String threadName, final OutputStream os, final int start) {
+        (new Thread(new Runnable() {
+            public void run() {
+                try { simpleWrite(os, start); }
+                catch (Exception e) {unexpected(e); }
+            }}, threadName)).start();
+    }
+
+    void simpleWrite(OutputStream os, int start) throws Exception {
+        byte b[] = new byte[2];
+        for (int i=start; i<start+100; i++) {
+            b[0] = (byte) (i / 256);
+            b[1] = (byte) (i % 256);
+            os.write(b);
+        }
+    }
+
+    void simpleRead(InputStream is, int start) throws Exception {
+        byte b[] = new byte [2];
+        for (int i=start; i<start+100; i++) {
+            int x = is.read(b);
+            if (x == 1)
+                x += is.read(b,1,1);
+            if (x!=2)
+                throw new Exception("read error");
+            int r = bytes(b[0], b[1]);
+            if (r != i)
+                throw new Exception("read " + r + " expected " +i);
+        }
+    }
+
+    int bytes(byte b1, byte b2) {
+        int i1 = (int)b1 & 0xFF;
+        int i2 = (int)b2 & 0xFF;
+        return i1 * 256 + i2;
+    }
+
+    static class ConnectProxyTunnelServer extends Thread {
+
+        private final ServerSocket ss;
+
+        public ConnectProxyTunnelServer() throws IOException {
+            ss = new ServerSocket(0);
+        }
+
+        @Override
+        public void run() {
+            try (Socket clientSocket = ss.accept()) {
+                processRequest(clientSocket);
+            } catch (Exception e) {
+                out.println("Proxy Failed: " + e);
+                e.printStackTrace();
+            } finally {
+                try { ss.close(); } catch (IOException x) { unexpected(x); }
+            }
+        }
+
+        /**
+         * Returns the port on which the proxy is accepting connections.
+         */
+        public int getLocalPort() {
+            return ss.getLocalPort();
+        }
+
+        /*
+         * Processes the CONNECT request
+         */
+        private void processRequest(Socket clientSocket) throws Exception {
+            MessageHeader mheader = new MessageHeader(clientSocket.getInputStream());
+            String statusLine = mheader.getValue(0);
+
+            if (!statusLine.startsWith("CONNECT")) {
+                out.println("proxy server: processes only "
+                                  + "CONNECT method requests, recieved: "
+                                  + statusLine);
+                return;
+            }
+
+            // retrieve the host and port info from the status-line
+            InetSocketAddress serverAddr = getConnectInfo(statusLine);
+
+            //open socket to the server
+            try (Socket serverSocket = new Socket(serverAddr.getAddress(),
+                                                  serverAddr.getPort())) {
+                Forwarder clientFW = new Forwarder(clientSocket.getInputStream(),
+                                                   serverSocket.getOutputStream());
+                Thread clientForwarderThread = new Thread(clientFW, "ClientForwarder");
+                clientForwarderThread.start();
+                send200(clientSocket);
+                Forwarder serverFW = new Forwarder(serverSocket.getInputStream(),
+                                                   clientSocket.getOutputStream());
+                serverFW.run();
+                clientForwarderThread.join();
+            }
+        }
+
+        private void send200(Socket clientSocket) throws IOException {
+            OutputStream out = clientSocket.getOutputStream();
+            PrintWriter pout = new PrintWriter(out);
+
+            pout.println("HTTP/1.1 200 OK");
+            pout.println();
+            pout.flush();
+        }
+
+        /*
+         * This method retrieves the hostname and port of the tunnel destination
+         * from the request line.
+         * @param connectStr
+         *        of the form: <i>CONNECT server-name:server-port HTTP/1.x</i>
+         */
+        static InetSocketAddress getConnectInfo(String connectStr)
+            throws Exception
+        {
+            try {
+                int starti = connectStr.indexOf(' ');
+                int endi = connectStr.lastIndexOf(' ');
+                String connectInfo = connectStr.substring(starti+1, endi).trim();
+                // retrieve server name and port
+                endi = connectInfo.indexOf(':');
+                String name = connectInfo.substring(0, endi);
+                int port = Integer.parseInt(connectInfo.substring(endi+1));
+                return new InetSocketAddress(name, port);
+            } catch (Exception e) {
+                out.println("Proxy recieved a request: " + connectStr);
+                throw unexpected(e);
+            }
+        }
+    }
+
+    /* Reads from the given InputStream and writes to the given OutputStream */
+    static class Forwarder implements Runnable
+    {
+        private final InputStream in;
+        private final OutputStream os;
+
+        Forwarder(InputStream in, OutputStream os) {
+            this.in = in;
+            this.os = os;
+        }
+
+        @Override
+        public void run() {
+            try {
+                byte[] ba = new byte[1024];
+                int count;
+                while ((count = in.read(ba)) != -1) {
+                    os.write(ba, 0, count);
+                }
+            } catch (IOException e) {
+                unexpected(e);
+            }
+        }
+    }
+}
--- a/test/java/nio/channels/DatagramChannel/Connect.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/java/nio/channels/DatagramChannel/Connect.java	Fri Mar 15 11:51:02 2013 -0300
@@ -22,6 +22,7 @@
  */
 
 /* @test
+ * @bug 4313882 7183800
  * @summary Test DatagramChannel's send and receive methods
  * @author Mike McCloskey
  */
@@ -88,6 +89,9 @@
                 bb.put("hello".getBytes());
                 bb.flip();
                 InetAddress address = InetAddress.getLocalHost();
+                if (address.isLoopbackAddress()) {
+                    address = InetAddress.getLoopbackAddress();
+                }
                 InetSocketAddress isa = new InetSocketAddress(address, port);
                 dc.connect(isa);
                 dc.write(bb);
--- a/test/java/nio/channels/DatagramChannel/ConnectedSend.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/java/nio/channels/DatagramChannel/ConnectedSend.java	Fri Mar 15 11:51:02 2013 -0300
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4849277
+ * @bug 4849277 7183800
  * @summary Test DatagramChannel send while connected
  * @author Mike McCloskey
  */
@@ -46,14 +46,18 @@
 
         DatagramChannel sndChannel = DatagramChannel.open();
         sndChannel.socket().bind(null);
+        InetAddress address = InetAddress.getLocalHost();
+        if (address.isLoopbackAddress()) {
+            address = InetAddress.getLoopbackAddress();
+        }
         InetSocketAddress sender = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             sndChannel.socket().getLocalPort());
 
         DatagramChannel rcvChannel = DatagramChannel.open();
         rcvChannel.socket().bind(null);
         InetSocketAddress receiver = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             rcvChannel.socket().getLocalPort());
 
         rcvChannel.connect(sender);
@@ -80,14 +84,18 @@
     private static void test2() throws Exception {
         DatagramChannel sndChannel = DatagramChannel.open();
         sndChannel.socket().bind(null);
+        InetAddress address = InetAddress.getLocalHost();
+        if (address.isLoopbackAddress()) {
+            address = InetAddress.getLoopbackAddress();
+        }
         InetSocketAddress sender = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             sndChannel.socket().getLocalPort());
 
         DatagramChannel rcvChannel = DatagramChannel.open();
         rcvChannel.socket().bind(null);
         InetSocketAddress receiver = new InetSocketAddress(
-            InetAddress.getLocalHost(),
+            address,
             rcvChannel.socket().getLocalPort());
 
         rcvChannel.connect(sender);
--- a/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java	Fri Mar 15 11:51:02 2013 -0300
@@ -133,8 +133,11 @@
         dc.close();
 
         dc = DatagramChannel.open();
-
-        InetSocketAddress isa = new InetSocketAddress(InetAddress.getLocalHost(), port);
+        InetAddress address = InetAddress.getLocalHost();
+        if (address.isLoopbackAddress()) {
+            address = InetAddress.getLoopbackAddress();
+        }
+        InetSocketAddress isa = new InetSocketAddress(address, port);
 
         dc.connect(isa);
         return dc;
--- a/test/java/util/Collections/ReverseOrder.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/java/util/Collections/ReverseOrder.java	Fri Mar 15 11:51:02 2013 -0300
@@ -23,23 +23,56 @@
 
 /*
  * @test
- * @bug 4593209
+ * @bug 4593209 8001667
  * @summary Reverse comparator was subtly broken
  * @author Josh bloch
  */
 
 import java.util.*;
+import java.io.*;
 
 public class ReverseOrder {
+    static byte[] serialBytes(Object o) {
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(bos);
+            oos.writeObject(o);
+            oos.flush();
+            oos.close();
+            return bos.toByteArray();
+        } catch (Throwable t) {
+            throw new Error(t);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    static <T> T serialClone(T o) {
+        try {
+            ObjectInputStream ois = new ObjectInputStream
+                (new ByteArrayInputStream(serialBytes(o)));
+            T clone = (T) ois.readObject();
+            return clone;
+        } catch (Throwable t) {
+            throw new Error(t);
+        }
+    }
+
     public static void main(String[] args) throws Exception {
         Foo[] a = { new Foo(2), new Foo(3), new Foo(1) };
         List list = Arrays.asList(a);
-        Collections.sort(list, Collections.reverseOrder());
+        Comparator cmp = Collections.reverseOrder();
+        Collections.sort(list, cmp);
 
         Foo[] golden = { new Foo(3), new Foo(2), new Foo(1) };
         List goldenList = Arrays.asList(golden);
         if (!list.equals(goldenList))
             throw new Exception(list.toString());
+
+        Comparator clone = serialClone(cmp);
+        List list2 = Arrays.asList(a);
+        Collections.sort(list2, clone);
+        if (!list2.equals(goldenList))
+            throw new Exception(list.toString());
     }
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/ComparatorsTest.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8001667
+ * @run testng ComparatorsTest
+ */
+
+import java.util.Comparator;
+import java.util.Comparators;
+import java.util.AbstractMap;
+import java.util.Map;
+import org.testng.annotations.Test;
+
+import java.util.function.Function;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+import java.util.function.ToDoubleFunction;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertSame;
+
+/**
+ * Unit tests for helper methods in Comparators
+ */
+@Test(groups = "unit")
+public class ComparatorsTest {
+    private static class Thing {
+        public final int intField;
+        public final long longField;
+        public final double doubleField;
+        public final String stringField;
+
+        private Thing(int intField, long longField, double doubleField, String stringField) {
+            this.intField = intField;
+            this.longField = longField;
+            this.doubleField = doubleField;
+            this.stringField = stringField;
+        }
+
+        public int getIntField() {
+            return intField;
+        }
+
+        public long getLongField() {
+            return longField;
+        }
+
+        public double getDoubleField() {
+            return doubleField;
+        }
+
+        public String getStringField() {
+            return stringField;
+        }
+    }
+
+    private final int[] intValues = { -2, -2, -1, -1, 0, 0, 1, 1, 2, 2 };
+    private final long[] longValues = { -2, -2, -1, -1, 0, 0, 1, 1, 2, 2 };
+    private final double[] doubleValues = { -2, -2, -1, -1, 0, 0, 1, 1, 2, 2 };
+    private final String[] stringValues = { "a", "a", "b", "b", "c", "c", "d", "d", "e", "e" };
+    private final int[] comparisons = { 0, -1, 0, -1, 0, -1, 0, -1, 0 };
+
+    private<T> void assertComparisons(T[] things, Comparator<T> comp, int[] comparisons) {
+        for (int i=0; i<comparisons.length; i++) {
+            assertEquals(comparisons.length + 1, things.length);
+            assertEquals(comparisons[i], comp.compare(things[i], things[i+1]));
+            assertEquals(-comparisons[i], comp.compare(things[i+1], things[i]));
+        }
+    }
+
+    public void testIntComparator() {
+        Thing[] things = new Thing[intValues.length];
+        for (int i=0; i<intValues.length; i++)
+            things[i] = new Thing(intValues[i], 0L, 0.0, null);
+        Comparator<Thing> comp = Comparators.comparing(new ToIntFunction<ComparatorsTest.Thing>() {
+            @Override
+            public int applyAsInt(Thing thing) {
+                return thing.getIntField();
+            }
+        });
+
+        assertComparisons(things, comp, comparisons);
+    }
+
+    public void testLongComparator() {
+        Thing[] things = new Thing[longValues.length];
+        for (int i=0; i<longValues.length; i++)
+            things[i] = new Thing(0, longValues[i], 0.0, null);
+        Comparator<Thing> comp = Comparators.comparing(new ToLongFunction<ComparatorsTest.Thing>() {
+            @Override
+            public long applyAsLong(Thing thing) {
+                return thing.getLongField();
+            }
+        });
+
+        assertComparisons(things, comp, comparisons);
+    }
+
+    public void testDoubleComparator() {
+        Thing[] things = new Thing[doubleValues.length];
+        for (int i=0; i<doubleValues.length; i++)
+            things[i] = new Thing(0, 0L, doubleValues[i], null);
+        Comparator<Thing> comp = Comparators.comparing(new ToDoubleFunction<ComparatorsTest.Thing>() {
+            @Override
+            public double applyAsDouble(Thing thing) {
+                return thing.getDoubleField();
+            }
+        });
+
+        assertComparisons(things, comp, comparisons);
+    }
+
+    public void testComparing() {
+        Thing[] things = new Thing[doubleValues.length];
+        for (int i=0; i<doubleValues.length; i++)
+            things[i] = new Thing(0, 0L, 0.0, stringValues[i]);
+        Comparator<Thing> comp = Comparators.comparing(new Function<Thing, String>() {
+            @Override
+            public String apply(Thing thing) {
+                return thing.getStringField();
+            }
+        });
+
+        assertComparisons(things, comp, comparisons);
+    }
+
+    public void testNaturalOrderComparator() {
+        Comparator<String> comp = Comparators.naturalOrder();
+
+        assertComparisons(stringValues, comp, comparisons);
+    }
+
+    public void testReverseComparator() {
+        Comparator<String> cmpr = Comparators.reverseOrder();
+        Comparator<String> cmp = cmpr.reverseOrder();
+
+        assertEquals(cmp.reverseOrder(), cmpr);
+        assertEquals(0, cmp.compare("a", "a"));
+        assertEquals(0, cmpr.compare("a", "a"));
+        assertTrue(cmp.compare("a", "b") < 0);
+        assertTrue(cmpr.compare("a", "b") > 0);
+        assertTrue(cmp.compare("b", "a") > 0);
+        assertTrue(cmpr.compare("b", "a") < 0);
+    }
+
+    public void testReverseComparator2() {
+        Comparator<String> cmp = (s1, s2) -> s1.length() - s2.length();
+        Comparator<String> cmpr = cmp.reverseOrder();
+
+        assertEquals(cmpr.reverseOrder(), cmp);
+        assertEquals(0, cmp.compare("abc", "def"));
+        assertEquals(0, cmpr.compare("abc", "def"));
+        assertTrue(cmp.compare("abcd", "def") > 0);
+        assertTrue(cmpr.compare("abcd", "def") < 0);
+        assertTrue(cmp.compare("abc", "defg") < 0);
+        assertTrue(cmpr.compare("abc", "defg") > 0);
+    }
+
+    @Test(expectedExceptions=NullPointerException.class)
+    public void testReverseComparatorNPE() {
+        Comparator<String> cmp = Comparators.reverseOrder(null);
+    }
+
+    public void testComposeComparator() {
+        // Longer string in front
+        Comparator<String> first = (s1, s2) -> s2.length() - s1.length();
+        Comparator<String> second = Comparators.naturalOrder();
+        Comparator<String> composed = Comparators.compose(first, second);
+
+        assertTrue(composed.compare("abcdefg", "abcdef") < 0);
+        assertTrue(composed.compare("abcdef", "abcdefg") > 0);
+        assertTrue(composed.compare("abcdef", "abcdef") == 0);
+        assertTrue(composed.compare("abcdef", "ghijkl") < 0);
+        assertTrue(composed.compare("ghijkl", "abcdefg") > 0);
+    }
+
+    private <K, V> void assertPairComparison(K k1, V v1, K k2, V v2,
+                                        Comparator<Map.Entry<K, V>> ck,
+                                        Comparator<Map.Entry<K, V>> cv) {
+        final Map.Entry<K, V> p11 = new AbstractMap.SimpleImmutableEntry<>(k1, v1);
+        final Map.Entry<K, V> p12 = new AbstractMap.SimpleImmutableEntry<>(k1, v2);
+        final Map.Entry<K, V> p21 = new AbstractMap.SimpleImmutableEntry<>(k2, v1);
+        final Map.Entry<K, V> p22 = new AbstractMap.SimpleImmutableEntry<>(k2, v2);
+
+        assertTrue(ck.compare(p11, p11) == 0);
+        assertTrue(ck.compare(p12, p11) == 0);
+        assertTrue(ck.compare(p11, p12) == 0);
+        assertTrue(ck.compare(p12, p22) < 0);
+        assertTrue(ck.compare(p12, p21) < 0);
+        assertTrue(ck.compare(p21, p11) > 0);
+        assertTrue(ck.compare(p21, p12) > 0);
+
+        assertTrue(cv.compare(p11, p11) == 0);
+        assertTrue(cv.compare(p12, p11) > 0);
+        assertTrue(cv.compare(p11, p12) < 0);
+        assertTrue(cv.compare(p12, p22) == 0);
+        assertTrue(cv.compare(p12, p21) > 0);
+        assertTrue(cv.compare(p21, p11) == 0);
+        assertTrue(cv.compare(p21, p12) < 0);
+
+        Comparator<Map.Entry<K, V>> cmp = Comparators.compose(ck, cv);
+        assertTrue(cmp.compare(p11, p11) == 0);
+        assertTrue(cmp.compare(p12, p11) > 0);
+        assertTrue(cmp.compare(p11, p12) < 0);
+        assertTrue(cmp.compare(p12, p22) < 0);
+        assertTrue(cmp.compare(p12, p21) < 0);
+        assertTrue(cmp.compare(p21, p11) > 0);
+        assertTrue(cmp.compare(p21, p12) > 0);
+
+        cmp = Comparators.compose(cv, ck);
+        assertTrue(cmp.compare(p11, p11) == 0);
+        assertTrue(cmp.compare(p12, p11) > 0);
+        assertTrue(cmp.compare(p11, p12) < 0);
+        assertTrue(cmp.compare(p12, p22) < 0);
+        assertTrue(cmp.compare(p12, p21) > 0);
+        assertTrue(cmp.compare(p21, p11) > 0);
+        assertTrue(cmp.compare(p21, p12) < 0);
+    }
+
+    public void testKVComparatorable() {
+        assertPairComparison(1, "ABC", 2, "XYZ",
+                         Comparators.<Integer, String>naturalOrderKeys(),
+                         Comparators.<Integer, String>naturalOrderValues());
+    }
+
+    private static class People {
+        final String firstName;
+        final String lastName;
+        final int age;
+
+        People(String first, String last, int age) {
+            firstName = first;
+            lastName = last;
+            this.age = age;
+        }
+
+        String getFirstName() { return firstName; }
+        String getLastName() { return lastName; }
+        int getAge() { return age; }
+        long getAgeAsLong() { return (long) age; };
+        double getAgeAsDouble() { return (double) age; };
+    }
+
+    private final People people[] = {
+        new People("John", "Doe", 34),
+        new People("Mary", "Doe", 30),
+        new People("Maria", "Doe", 14),
+        new People("Jonah", "Doe", 10),
+        new People("John", "Cook", 54),
+        new People("Mary", "Cook", 50),
+    };
+
+    public void testKVComparators() {
+        // Comparator<People> cmp = Comparators.naturalOrder(); // Should fail to compiler as People is not comparable
+        // We can use simple comparator, but those have been tested above.
+        // Thus choose to do compose for some level of interation.
+        Comparator<People> cmp1 = Comparators.comparing((Function<People, String>) People::getFirstName);
+        Comparator<People> cmp2 = Comparators.comparing((Function<People, String>) People::getLastName);
+        Comparator<People> cmp = Comparators.compose(cmp1, cmp2);
+
+        assertPairComparison(people[0], people[0], people[1], people[1],
+                         Comparators.<People, People>byKey(cmp),
+                         Comparators.<People, People>byValue(cmp));
+
+    }
+
+    private <T> void assertComparison(Comparator<T> cmp, T less, T greater) {
+        assertTrue(cmp.compare(less, greater) < 0, "less");
+        assertTrue(cmp.compare(less, less) == 0, "equal");
+        assertTrue(cmp.compare(greater, less) > 0, "greater");
+    }
+
+    public void testComparatorDefaultMethods() {
+        Comparator<People> cmp = Comparators.comparing((Function<People, String>) People::getFirstName);
+        Comparator<People> cmp2 = Comparators.comparing((Function<People, String>) People::getLastName);
+        // reverseOrder
+        assertComparison(cmp.reverseOrder(), people[1], people[0]);
+        // thenComparing(Comparator)
+        assertComparison(cmp.thenComparing(cmp2), people[0], people[1]);
+        assertComparison(cmp.thenComparing(cmp2), people[4], people[0]);
+        // thenComparing(Function)
+        assertComparison(cmp.thenComparing(People::getLastName), people[0], people[1]);
+        assertComparison(cmp.thenComparing(People::getLastName), people[4], people[0]);
+        // thenComparing(ToIntFunction)
+        assertComparison(cmp.thenComparing(People::getAge), people[0], people[1]);
+        assertComparison(cmp.thenComparing(People::getAge), people[1], people[5]);
+        // thenComparing(ToLongFunction)
+        assertComparison(cmp.thenComparing(People::getAgeAsLong), people[0], people[1]);
+        assertComparison(cmp.thenComparing(People::getAgeAsLong), people[1], people[5]);
+        // thenComparing(ToDoubleFunction)
+        assertComparison(cmp.thenComparing(People::getAgeAsDouble), people[0], people[1]);
+        assertComparison(cmp.thenComparing(People::getAgeAsDouble), people[1], people[5]);
+    }
+
+    public void testGreaterOf() {
+        // lesser
+        assertSame(Comparators.greaterOf(Comparators.comparing(
+                                    (Function<People, String>) People::getFirstName))
+                              .apply(people[0], people[1]),
+                   people[1]);
+        // euqal
+        assertSame(Comparators.greaterOf(Comparators.comparing(
+                                    (Function<People, String>) People::getLastName))
+                              .apply(people[0], people[1]),
+                   people[0]);
+        // greater
+        assertSame(Comparators.greaterOf(Comparators.comparing(
+                                    (ToIntFunction<People>) People::getAge))
+                              .apply(people[0], people[1]),
+                   people[0]);
+    }
+
+    public void testLesserOf() {
+        // lesser
+        assertSame(Comparators.lesserOf(Comparators.comparing(
+                                    (Function<People, String>) People::getFirstName))
+                              .apply(people[0], people[1]),
+                   people[0]);
+        // euqal
+        assertSame(Comparators.lesserOf(Comparators.comparing(
+                                    (Function<People, String>) People::getLastName))
+                              .apply(people[0], people[1]),
+                   people[0]);
+        // greater
+        assertSame(Comparators.lesserOf(Comparators.comparing(
+                                    (ToIntFunction<People>) People::getAge))
+                              .apply(people[0], people[1]),
+                   people[1]);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Locale/Bug8004240.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8004240
+ * @summary Verify that getAdapterPreference returns an unmodifiable list.
+ * @compile -XDignore.symbol.file Bug8004240.java
+ * @run main Bug8004240
+ */
+
+import java.util.List;
+import sun.util.locale.provider.LocaleProviderAdapter;
+
+public class Bug8004240 {
+
+    public static void main(String[] args) {
+        List<LocaleProviderAdapter.Type> types = LocaleProviderAdapter.getAdapterPreference();
+
+        try {
+            types.set(0, null);
+        } catch (UnsupportedOperationException e) {
+            // success
+            return;
+        }
+
+        throw new RuntimeException("LocaleProviderAdapter.getAdapterPrefence() returned a modifiable list.");
+    }
+}
--- a/test/java/util/logging/LoggerResourceBundleRace.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/java/util/logging/LoggerResourceBundleRace.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -23,13 +23,14 @@
 
 /*
  * @test
- * @bug     7045594
+ * @bug     7045594 8002070
  * @summary ResourceBundle setting race in Logger.getLogger(name, rbName)
  * @author  Daniel D. Daugherty
  * @build RacingThreadsTest LoggerResourceBundleRace
- * @run main LoggerResourceBundleRace
+ * @run main/othervm LoggerResourceBundleRace
+ *
+ * (In samevm mode, the bundle classes don't end up in the classpath.)
  */
-
 import java.util.ListResourceBundle;
 import java.util.MissingResourceException;
 import java.util.concurrent.atomic.AtomicInteger;
--- a/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/javax/management/remote/mandatory/connection/RMIConnectionIdTest.java	Fri Mar 15 11:51:02 2013 -0300
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4901808
+ * @bug 4901808 7183800
  * @summary Check that RMI connection ids include client host name
  * @author Eamonn McManus
  * @run clean RMIConnectionIdTest
@@ -60,7 +60,7 @@
         }
         String clientAddr = rest.substring(0, spaceIndex);
         InetAddress clientInetAddr = InetAddress.getByName(clientAddr);
-        InetAddress localAddr = InetAddress.getLocalHost();
+        InetAddress localAddr = clientInetAddr.isLoopbackAddress() ? InetAddress.getLoopbackAddress() : InetAddress.getLocalHost();
         System.out.println("InetAddresses: local=" + localAddr + "; " +
                            "connectionId=" + clientInetAddr);
         if (!localAddr.equals(clientInetAddr)) {
--- a/test/sun/misc/Cleaner/ExitOnThrow.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/misc/Cleaner/ExitOnThrow.java	Fri Mar 15 11:51:02 2013 -0300
@@ -28,21 +28,17 @@
 
 public class ExitOnThrow {
 
-    private static volatile boolean ran = false;
-
     public static void main(String[] args) throws Exception {
         Cleaner.create(new Object(),
                        new Runnable() {
                                public void run() {
-                                   ran = true;
                                    throw new RuntimeException("Foo!");
                                }
                            });
-        while (!ran) {
+        while (true) {
             System.gc();
             Thread.sleep(100);
         }
-        System.exit(0);
     }
 
 }
--- a/test/sun/misc/Cleaner/exitOnThrow.sh	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/misc/Cleaner/exitOnThrow.sh	Fri Mar 15 11:51:02 2013 -0300
@@ -25,7 +25,7 @@
 
 #
 # @test
-# @bug 4954921
+# @bug 4954921 8009259
 # @summary Ensure that if a cleaner throws an exception then the VM exits
 #
 # @build ExitOnThrow
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/net/www/http/HttpClient/IsAvailable.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8009650
+ * @summary HttpClient available() check throws SocketException when connection
+ * has been closed
+ */
+
+import java.net.URL;
+import java.net.ServerSocket;
+import sun.net.www.http.HttpClient;
+import java.security.*;
+import java.lang.reflect.Method;
+
+public class IsAvailable {
+
+    public static void main(String[] args) throws Exception {
+        int readTimeout = 20;
+        ServerSocket ss = new ServerSocket(0);
+
+        URL url1 = new URL("http://localhost:" + ss.getLocalPort());
+        HttpClient c1 = HttpClient.New(url1);
+
+        Method available = HttpClient.class.
+                getDeclaredMethod("available", null);
+        available.setAccessible(true);
+
+        c1.setReadTimeout(readTimeout);
+        boolean a = (boolean) available.invoke(c1);
+        if (!a) {
+            throw new RuntimeException("connection should be available");
+        }
+        if (c1.getReadTimeout() != readTimeout) {
+            throw new RuntimeException("read timeout has been altered");
+        }
+
+        c1.closeServer();
+
+        a = (boolean) available.invoke(c1);
+        if (a) {
+            throw new RuntimeException("connection shouldn't be available");
+        }
+
+        ss.close();
+    }
+}
--- a/test/sun/security/ec/TestEC.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/ec/TestEC.java	Fri Mar 15 11:51:02 2013 -0300
@@ -21,11 +21,6 @@
  * questions.
  */
 
-//
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
-//
-
 /**
  * @test
  * @bug 6840752
@@ -35,7 +30,7 @@
  * @library ../pkcs11/sslecc
  * @library ../../../java/security/testlibrary
  * @compile -XDignore.symbol.file TestEC.java
- * @run main/othervm TestEC
+ * @run main TestEC
  */
 
 import java.security.NoSuchProviderException;
--- a/test/sun/security/krb5/auto/Context.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/krb5/auto/Context.java	Fri Mar 15 11:51:02 2013 -0300
@@ -297,6 +297,13 @@
     }
 
     /**
+     * Returns the cred inside, if there is one
+     */
+    public GSSCredential cred() {
+        return cred;
+    }
+
+    /**
      * Disposes the GSSContext within
      * @throws org.ietf.jgss.GSSException
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/krb5/auto/SpnegoLifeTime.java	Fri Mar 15 11:51:02 2013 -0300
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8000653
+ * @summary SPNEGO tests fail at context.getDelegCred().getRemainingInitLifetime(mechOid)
+ * @compile -XDignore.symbol.file SpnegoLifeTime.java
+ * @run main/othervm SpnegoLifeTime
+ */
+
+import org.ietf.jgss.Oid;
+import org.ietf.jgss.GSSCredential;
+import sun.security.jgss.GSSUtil;
+
+public class SpnegoLifeTime {
+
+    public static void main(String[] args) throws Exception {
+
+        Oid oid = GSSUtil.GSS_SPNEGO_MECH_OID;
+        new OneKDC(null).writeJAASConf();
+
+        Context c, s;
+        c = Context.fromJAAS("client");
+        s = Context.fromJAAS("server");
+
+        c.startAsClient(OneKDC.SERVER, oid);
+        c.x().requestCredDeleg(true);
+        s.startAsServer(oid);
+
+        Context.handshake(c, s);
+
+        GSSCredential cred = s.delegated().cred();
+        cred.getRemainingInitLifetime(oid);
+        cred.getUsage(oid);
+    }
+}
+
--- a/test/sun/security/pkcs11/fips/CipherTest.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/pkcs11/fips/CipherTest.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -147,25 +147,6 @@
             CS_16("TLS_DH_anon_WITH_AES_128_CBC_SHA256",     0x0303, 0xFFFF),
             CS_17("TLS_RSA_WITH_NULL_SHA256",                0x0303, 0xFFFF),
 
-            CS_20("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF),
-            CS_21("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF),
-            CS_22("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",   0x0303, 0xFFFF),
-            CS_23("TLS_RSA_WITH_AES_256_GCM_SHA384",         0x0303, 0xFFFF),
-            CS_24("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",  0x0303, 0xFFFF),
-            CS_25("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",    0x0303, 0xFFFF),
-            CS_26("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-            CS_27("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-
-            CS_28("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",   0x0303, 0xFFFF),
-            CS_29("TLS_RSA_WITH_AES_128_GCM_SHA256",         0x0303, 0xFFFF),
-            CS_30("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",  0x0303, 0xFFFF),
-            CS_31("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",    0x0303, 0xFFFF),
-            CS_32("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-            CS_33("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-
-            CS_34("TLS_DH_anon_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-            CS_35("TLS_DH_anon_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-
             // cipher suites obsoleted since TLS 1.2
             CS_50("SSL_RSA_WITH_DES_CBC_SHA",                0x0000, 0x0303),
             CS_51("SSL_DHE_RSA_WITH_DES_CBC_SHA",            0x0000, 0x0303),
--- a/test/sun/security/pkcs11/sslecc/CipherTest.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/pkcs11/sslecc/CipherTest.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -147,25 +147,6 @@
             CS_16("TLS_DH_anon_WITH_AES_128_CBC_SHA256",     0x0303, 0xFFFF),
             CS_17("TLS_RSA_WITH_NULL_SHA256",                0x0303, 0xFFFF),
 
-            CS_20("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF),
-            CS_21("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF),
-            CS_22("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",   0x0303, 0xFFFF),
-            CS_23("TLS_RSA_WITH_AES_256_GCM_SHA384",         0x0303, 0xFFFF),
-            CS_24("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",  0x0303, 0xFFFF),
-            CS_25("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",    0x0303, 0xFFFF),
-            CS_26("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-            CS_27("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-
-            CS_28("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",   0x0303, 0xFFFF),
-            CS_29("TLS_RSA_WITH_AES_128_GCM_SHA256",         0x0303, 0xFFFF),
-            CS_30("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",  0x0303, 0xFFFF),
-            CS_31("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",    0x0303, 0xFFFF),
-            CS_32("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-            CS_33("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-
-            CS_34("TLS_DH_anon_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-            CS_35("TLS_DH_anon_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-
             // cipher suites obsoleted since TLS 1.2
             CS_50("SSL_RSA_WITH_DES_CBC_SHA",                0x0000, 0x0303),
             CS_51("SSL_DHE_RSA_WITH_DES_CBC_SHA",            0x0000, 0x0303),
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java	Fri Mar 15 11:51:02 2013 -0300
@@ -21,16 +21,14 @@
  * questions.
  */
 
-//
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
-//
-
 /*
  * @test
  * @bug 7031830
  * @summary bad_record_mac failure on TLSv1.2 enabled connection with SSLEngine
  * @run main/othervm SSLEngineBadBufferArrayAccess
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
  */
 
 /**
--- a/test/sun/security/ssl/javax/net/ssl/TLSv12/ShortRSAKeyGCM.java	Sat Mar 02 11:06:58 2013 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,445 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-//
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
-//
-
-/*
- * @test
- * @bug 7030966
- * @summary Support AEAD CipherSuites
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_RSA_WITH_AES_128_GCM_SHA256
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_DH_anon_WITH_AES_128_GCM_SHA256
- */
-
-/*
- * Need additional key materials to run the following cases.
- *
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
- *
- * Need unlimited JCE Unlimited Strength Jurisdiction Policy to run the
- * following cases.
- *
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_RSA_WITH_AES_256_GCM_SHA384
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
- * @run main/othervm ShortRSAKeyGCM PKIX TLS_DH_anon_WITH_AES_256_GCM_SHA384
- */
-
-import java.net.*;
-import java.util.*;
-import java.io.*;
-import javax.net.ssl.*;
-import java.security.Security;
-import java.security.KeyStore;
-import java.security.KeyFactory;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
-import java.security.spec.*;
-import java.security.interfaces.*;
-import sun.misc.BASE64Decoder;
-
-
-public class ShortRSAKeyGCM {
-
-    /*
-     * =============================================================
-     * Set the various variables needed for the tests, then
-     * specify what tests to run on each side.
-     */
-
-    /*
-     * Should we run the client or server in a separate thread?
-     * Both sides can throw exceptions, but do you have a preference
-     * as to which side should be the main thread.
-     */
-    static boolean separateServerThread = true;
-
-    /*
-     * Where do we find the keystores?
-     */
-    // Certificates and key used in the test.
-    static String trustedCertStr =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICkjCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" +
-        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" +
-        "MTEwODE5MDE1MjE5WhcNMzIwNzI5MDE1MjE5WjA7MQswCQYDVQQGEwJVUzENMAsG\n" +
-        "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwgZ8wDQYJ\n" +
-        "KoZIhvcNAQEBBQADgY0AMIGJAoGBAM8orG08DtF98TMSscjGsidd1ZoN4jiDpi8U\n" +
-        "ICz+9dMm1qM1d7O2T+KH3/mxyox7Rc2ZVSCaUD0a3CkhPMnlAx8V4u0H+E9sqso6\n" +
-        "iDW3JpOyzMExvZiRgRG/3nvp55RMIUV4vEHOZ1QbhuqG4ebN0Vz2DkRft7+flthf\n" +
-        "vDld6f5JAgMBAAGjgaUwgaIwHQYDVR0OBBYEFLl81dnfp0wDrv0OJ1sxlWzH83Xh\n" +
-        "MGMGA1UdIwRcMFqAFLl81dnfp0wDrv0OJ1sxlWzH83XhoT+kPTA7MQswCQYDVQQG\n" +
-        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
-        "Y2WCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEE\n" +
-        "BQADgYEALlgaH1gWtoBZ84EW8Hu6YtGLQ/L9zIFmHonUPZwn3Pr//icR9Sqhc3/l\n" +
-        "pVTxOINuFHLRz4BBtEylzRIOPzK3tg8XwuLb1zd0db90x3KBCiAL6E6cklGEPwLe\n" +
-        "XYMHDn9eDsaq861Tzn6ZwzMgw04zotPMoZN0mVd/3Qca8UJFucE=\n" +
-        "-----END CERTIFICATE-----";
-
-    static String targetCertStr =
-        "-----BEGIN CERTIFICATE-----\n" +
-        "MIICNDCCAZ2gAwIBAgIBDDANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" +
-        "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" +
-        "MTExMTA3MTM1NTUyWhcNMzEwNzI1MTM1NTUyWjBPMQswCQYDVQQGEwJVUzENMAsG\n" +
-        "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UxEjAQBgNV\n" +
-        "BAMTCWxvY2FsaG9zdDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC3Pb49OSPfOD2G\n" +
-        "HSXFCFx1GJEZfqG9ZUf7xuIi/ra5dLjPGAaoY5QF2QOa8VnOriQCXDfyXHxsuRnE\n" +
-        "OomxL7EVAgMBAAGjeDB2MAsGA1UdDwQEAwID6DAdBgNVHQ4EFgQUXNCJK3/dtCIc\n" +
-        "xb+zlA/JINlvs/MwHwYDVR0jBBgwFoAUuXzV2d+nTAOu/Q4nWzGVbMfzdeEwJwYD\n" +
-        "VR0lBCAwHgYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDAzANBgkqhkiG9w0B\n" +
-        "AQQFAAOBgQB2qIDUxA2caMPpGtUACZAPRUtrGssCINIfItETXJZCx/cRuZ5sP4D9\n" +
-        "N1acoNDn0hCULe3lhXAeTC9NZ97680yJzregQMV5wATjo1FGsKY30Ma+sc/nfzQW\n" +
-        "+h/7RhYtoG0OTsiaDCvyhI6swkNJzSzrAccPY4+ZgU8HiDLzZTmM3Q==\n" +
-        "-----END CERTIFICATE-----";
-
-    // Private key in the format of PKCS#8, key size is 512 bits.
-    static String targetPrivateKey =
-        "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAtz2+PTkj3zg9hh0l\n" +
-        "xQhcdRiRGX6hvWVH+8biIv62uXS4zxgGqGOUBdkDmvFZzq4kAlw38lx8bLkZxDqJ\n" +
-        "sS+xFQIDAQABAkByx/5Oo2hQ/w2q4L8z+NTRlJ3vdl8iIDtC/4XPnfYfnGptnpG6\n" +
-        "ZThQRvbMZiai0xHQPQMszvAHjZVme1eDl3EBAiEA3aKJHynPVCEJhpfCLWuMwX5J\n" +
-        "1LntwJO7NTOyU5m8rPECIQDTpzn5X44r2rzWBDna/Sx7HW9IWCxNgUD2Eyi2nA7W\n" +
-        "ZQIgJerEorw4aCAuzQPxiGu57PB6GRamAihEAtoRTBQlH0ECIQDN08FgTtnesgCU\n" +
-        "DFYLLcw1CiHvc7fZw4neBDHCrC8NtQIgA8TOUkGnpCZlQ0KaI8KfKWI+vxFcgFnH\n" +
-        "3fnqsTgaUs4=";
-
-    static char passphrase[] = "passphrase".toCharArray();
-
-    /*
-     * Is the server ready to serve?
-     */
-    volatile static boolean serverReady = false;
-
-    /*
-     * Turn on SSL debugging?
-     */
-    static boolean debug = false;
-
-    /*
-     * Define the server side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
-     */
-    void doServerSide() throws Exception {
-        SSLContext context = generateSSLContext(null, targetCertStr,
-                                            targetPrivateKey);
-        SSLServerSocketFactory sslssf = context.getServerSocketFactory();
-        SSLServerSocket sslServerSocket =
-            (SSLServerSocket)sslssf.createServerSocket(serverPort);
-        serverPort = sslServerSocket.getLocalPort();
-
-        /*
-         * Signal Client, we're ready for his connect.
-         */
-        serverReady = true;
-
-        SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept();
-        sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites());
-        InputStream sslIS = sslSocket.getInputStream();
-        OutputStream sslOS = sslSocket.getOutputStream();
-
-        sslIS.read();
-        sslOS.write('A');
-        sslOS.flush();
-
-        sslSocket.close();
-    }
-
-    /*
-     * Define the client side of the test.
-     *
-     * If the server prematurely exits, serverReady will be set to true
-     * to avoid infinite hangs.
-     */
-    void doClientSide() throws Exception {
-
-        /*
-         * Wait for server to get started.
-         */
-        while (!serverReady) {
-            Thread.sleep(50);
-        }
-
-        SSLContext context = generateSSLContext(trustedCertStr, null, null);
-        SSLSocketFactory sslsf = context.getSocketFactory();
-
-        SSLSocket sslSocket =
-            (SSLSocket)sslsf.createSocket("localhost", serverPort);
-
-        // enable TLSv1.2 only
-        sslSocket.setEnabledProtocols(new String[] {"TLSv1.2"});
-
-        // enable a block cipher
-        sslSocket.setEnabledCipherSuites(new String[] {cipherSuite});
-
-        InputStream sslIS = sslSocket.getInputStream();
-        OutputStream sslOS = sslSocket.getOutputStream();
-
-        sslOS.write('B');
-        sslOS.flush();
-        sslIS.read();
-
-        sslSocket.close();
-    }
-
-    /*
-     * =============================================================
-     * The remainder is just support stuff
-     */
-    private static String tmAlgorithm;        // trust manager
-    private static String cipherSuite;        // cipher suite
-
-    private static void parseArguments(String[] args) {
-        tmAlgorithm = args[0];
-        cipherSuite = args[1];
-    }
-
-    private static SSLContext generateSSLContext(String trustedCertStr,
-            String keyCertStr, String keySpecStr) throws Exception {
-
-        // generate certificate from cert string
-        CertificateFactory cf = CertificateFactory.getInstance("X.509");
-
-        // create a key store
-        KeyStore ks = KeyStore.getInstance("JKS");
-        ks.load(null, null);
-
-        // import the trused cert
-        Certificate trusedCert = null;
-        ByteArrayInputStream is = null;
-        if (trustedCertStr != null) {
-            is = new ByteArrayInputStream(trustedCertStr.getBytes());
-            trusedCert = cf.generateCertificate(is);
-            is.close();
-
-            ks.setCertificateEntry("RSA Export Signer", trusedCert);
-        }
-
-        if (keyCertStr != null) {
-            // generate the private key.
-            PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec(
-                                new BASE64Decoder().decodeBuffer(keySpecStr));
-            KeyFactory kf = KeyFactory.getInstance("RSA");
-            RSAPrivateKey priKey =
-                    (RSAPrivateKey)kf.generatePrivate(priKeySpec);
-
-            // generate certificate chain
-            is = new ByteArrayInputStream(keyCertStr.getBytes());
-            Certificate keyCert = cf.generateCertificate(is);
-            is.close();
-
-            Certificate[] chain = null;
-            if (trusedCert != null) {
-                chain = new Certificate[2];
-                chain[0] = keyCert;
-                chain[1] = trusedCert;
-            } else {
-                chain = new Certificate[1];
-                chain[0] = keyCert;
-            }
-
-            // import the key entry.
-            ks.setKeyEntry("Whatever", priKey, passphrase, chain);
-        }
-
-        // create SSL context
-        TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmAlgorithm);
-        tmf.init(ks);
-
-        SSLContext ctx = SSLContext.getInstance("TLS");
-        if (keyCertStr != null && !keyCertStr.isEmpty()) {
-            KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509");
-            kmf.init(ks, passphrase);
-
-            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-            ks = null;
-        } else {
-            ctx.init(null, tmf.getTrustManagers(), null);
-        }
-
-        return ctx;
-    }
-
-
-    // use any free port by default
-    volatile int serverPort = 0;
-
-    volatile Exception serverException = null;
-    volatile Exception clientException = null;
-
-    public static void main(String[] args) throws Exception {
-        // reset the security property to make sure that the algorithms
-        // and keys used in this test are not disabled.
-        Security.setProperty("jdk.certpath.disabledAlgorithms", "MD2");
-
-        if (debug) {
-            System.setProperty("javax.net.debug", "all");
-        }
-
-        /*
-         * Get the customized arguments.
-         */
-        parseArguments(args);
-
-        /*
-         * Start the tests.
-         */
-        new ShortRSAKeyGCM();
-    }
-
-    Thread clientThread = null;
-    Thread serverThread = null;
-
-    /*
-     * Primary constructor, used to drive remainder of the test.
-     *
-     * Fork off the other side, then do your work.
-     */
-    ShortRSAKeyGCM() throws Exception {
-        try {
-            if (separateServerThread) {
-                startServer(true);
-                startClient(false);
-            } else {
-                startClient(true);
-                startServer(false);
-            }
-        } catch (Exception e) {
-            // swallow for now.  Show later
-        }
-
-        /*
-         * Wait for other side to close down.
-         */
-        if (separateServerThread) {
-            serverThread.join();
-        } else {
-            clientThread.join();
-        }
-
-        /*
-         * When we get here, the test is pretty much over.
-         * Which side threw the error?
-         */
-        Exception local;
-        Exception remote;
-        String whichRemote;
-
-        if (separateServerThread) {
-            remote = serverException;
-            local = clientException;
-            whichRemote = "server";
-        } else {
-            remote = clientException;
-            local = serverException;
-            whichRemote = "client";
-        }
-
-        /*
-         * If both failed, return the curthread's exception, but also
-         * print the remote side Exception
-         */
-        if ((local != null) && (remote != null)) {
-            System.out.println(whichRemote + " also threw:");
-            remote.printStackTrace();
-            System.out.println();
-            throw local;
-        }
-
-        if (remote != null) {
-            throw remote;
-        }
-
-        if (local != null) {
-            throw local;
-        }
-    }
-
-    void startServer(boolean newThread) throws Exception {
-        if (newThread) {
-            serverThread = new Thread() {
-                public void run() {
-                    try {
-                        doServerSide();
-                    } catch (Exception e) {
-                        /*
-                         * Our server thread just died.
-                         *
-                         * Release the client, if not active already...
-                         */
-                        System.err.println("Server died..." + e);
-                        serverReady = true;
-                        serverException = e;
-                    }
-                }
-            };
-            serverThread.start();
-        } else {
-            try {
-                doServerSide();
-            } catch (Exception e) {
-                serverException = e;
-            } finally {
-                serverReady = true;
-            }
-        }
-    }
-
-    void startClient(boolean newThread) throws Exception {
-        if (newThread) {
-            clientThread = new Thread() {
-                public void run() {
-                    try {
-                        doClientSide();
-                    } catch (Exception e) {
-                        /*
-                         * Our client thread just died.
-                         */
-                        System.err.println("Client died..." + e);
-                        clientException = e;
-                    }
-                }
-            };
-            clientThread.start();
-        } else {
-            try {
-                doClientSide();
-            } catch (Exception e) {
-                clientException = e;
-            }
-        }
-    }
-}
--- a/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java	Fri Mar 15 11:51:02 2013 -0300
@@ -21,15 +21,13 @@
  * questions.
  */
 
-//
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
-//
-
 /*
  * @test
  * @bug 7174244
  * @summary NPE in Krb5ProxyImpl.getServerKeys()
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
  * @run main/othervm CipherSuitesInOrder
  */
 
@@ -74,22 +72,6 @@
         "SSL_RSA_WITH_RC4_128_SHA",
         "TLS_ECDH_ECDSA_WITH_RC4_128_SHA",
         "TLS_ECDH_RSA_WITH_RC4_128_SHA",
-
-        "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
-        "TLS_RSA_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",
-        "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
-        "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
-
         "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
         "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
         "SSL_RSA_WITH_3DES_EDE_CBC_SHA",
@@ -101,9 +83,6 @@
 
         "TLS_EMPTY_RENEGOTIATION_INFO_SCSV",
 
-        "TLS_DH_anon_WITH_AES_256_GCM_SHA384",
-        "TLS_DH_anon_WITH_AES_128_GCM_SHA256",
-
         "TLS_DH_anon_WITH_AES_256_CBC_SHA256",
         "TLS_ECDH_anon_WITH_AES_256_CBC_SHA",
         "TLS_DH_anon_WITH_AES_256_CBC_SHA",
--- a/test/sun/security/ssl/sanity/interop/CipherTest.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/ssl/sanity/interop/CipherTest.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -148,25 +148,6 @@
             CS_16("TLS_DH_anon_WITH_AES_128_CBC_SHA256",     0x0303, 0xFFFF),
             CS_17("TLS_RSA_WITH_NULL_SHA256",                0x0303, 0xFFFF),
 
-            CS_20("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", 0x0303, 0xFFFF),
-            CS_21("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", 0x0303, 0xFFFF),
-            CS_22("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",   0x0303, 0xFFFF),
-            CS_23("TLS_RSA_WITH_AES_256_GCM_SHA384",         0x0303, 0xFFFF),
-            CS_24("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",  0x0303, 0xFFFF),
-            CS_25("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",    0x0303, 0xFFFF),
-            CS_26("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-            CS_27("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-
-            CS_28("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",   0x0303, 0xFFFF),
-            CS_29("TLS_RSA_WITH_AES_128_GCM_SHA256",         0x0303, 0xFFFF),
-            CS_30("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",  0x0303, 0xFFFF),
-            CS_31("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",    0x0303, 0xFFFF),
-            CS_32("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-            CS_33("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-
-            CS_34("TLS_DH_anon_WITH_AES_256_GCM_SHA384",     0x0303, 0xFFFF),
-            CS_35("TLS_DH_anon_WITH_AES_128_GCM_SHA256",     0x0303, 0xFFFF),
-
             // cipher suites obsoleted since TLS 1.2
             CS_50("SSL_RSA_WITH_DES_CBC_SHA",                0x0000, 0x0303),
             CS_51("SSL_DHE_RSA_WITH_DES_CBC_SHA",            0x0000, 0x0303),
--- a/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/sun/security/ssl/templates/SSLSocketSSLEngineTemplate.java	Fri Mar 15 11:51:02 2013 -0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,15 +21,14 @@
  * questions.
  */
 
-//
-// SunJSSE does not support dynamic system properties, no way to re-use
-// system properties in samevm/agentvm mode.
-//
-
 /*
  * @test
  * @bug 7105780
  * @summary Add SSLSocket client/SSLEngine server to templates directory.
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ *
  * @run main/othervm SSLSocketSSLEngineTemplate
  */
 
--- a/test/tools/pack200/AttributeTests.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/tools/pack200/AttributeTests.java	Fri Mar 15 11:51:02 2013 -0300
@@ -67,17 +67,7 @@
         File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT);
         Utils.jar("cvf", testjarFile.getName(), javaClassName);
 
-        // pack using native --repack
-        File nativejarFile = new File(cwd, "out-n" + Utils.JAR_FILE_EXT);
-        Utils.repack(testjarFile, nativejarFile, false,
-                     "--unknown-attribute=error");
-        Utils.doCompareVerify(testjarFile, nativejarFile);
-
-        // pack using java --repack
-        File javajarFile = new File(cwd, "out-j" + Utils.JAR_FILE_EXT);
-        Utils.repack(testjarFile, javajarFile, true,
-                     "--unknown-attribute=error");
-        Utils.doCompareBitWise(nativejarFile, javajarFile);
+        Utils.testWithRepack(testjarFile, "--unknown-attribute=error");
     }
     /*
      * this test checks to see if we get the expected strings for output
--- a/test/tools/pack200/InstructionTests.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/tools/pack200/InstructionTests.java	Fri Mar 15 11:51:02 2013 -0300
@@ -26,11 +26,10 @@
 import java.util.ArrayList;
 import java.util.List;
 import static java.nio.file.StandardOpenOption.*;
-import java.util.regex.Pattern;
 
 /*
  * @test
- * @bug 8003549
+ * @bug 8003549 8007297
  * @summary tests class files instruction formats introduced in JSR-335
  * @compile -XDignore.symbol.file Utils.java InstructionTests.java
  * @run main InstructionTests
@@ -48,52 +47,34 @@
         List<String> scratch = new ArrayList<>();
         final String fname = "A";
         String javaFileName = fname + Utils.JAVA_FILE_EXT;
-        scratch.add("interface IntIterator {");
+        scratch.add("interface I {");
         scratch.add("    default void forEach(){}");
         scratch.add("    static void next() {}");
         scratch.add("}");
-        scratch.add("class A implements IntIterator {");
-        scratch.add("public void forEach(Object o){");
-        scratch.add("IntIterator.super.forEach();");
-        scratch.add("IntIterator.next();");
-        scratch.add("}");
+        scratch.add("class A implements I {");
+        scratch.add("    public void forEach(Object o){");
+        scratch.add("        I.super.forEach();");
+        scratch.add("        I.next();");
+        scratch.add("    }");
         scratch.add("}");
         File cwd = new File(".");
         File javaFile = new File(cwd, javaFileName);
         Files.write(javaFile.toPath(), scratch, Charset.defaultCharset(),
                 CREATE, TRUNCATE_EXISTING);
 
-        // make sure we have -g so that we  compare LVT and LNT entries
+        // -g to compare LVT and LNT entries
         Utils.compiler("-g", javaFile.getName());
 
+        File propsFile = new File("pack.props");
+        scratch.clear();
+        scratch.add("com.sun.java.util.jar.pack.class.format.error=error");
+        scratch.add("pack.unknown.attribute=error");
+        Files.write(propsFile.toPath(), scratch, Charset.defaultCharset(),
+                CREATE, TRUNCATE_EXISTING);
         // jar the file up
         File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT);
         Utils.jar("cvf", testjarFile.getName(), ".");
 
-        // pack using --repack
-        File outjarFile = new File(cwd, "out" + Utils.JAR_FILE_EXT);
-        scratch.clear();
-        scratch.add(Utils.getPack200Cmd());
-        scratch.add("-J-ea");
-        scratch.add("-J-esa");
-        scratch.add("--repack");
-        scratch.add(outjarFile.getName());
-        scratch.add(testjarFile.getName());
-        List<String> output = Utils.runExec(scratch);
-        // TODO remove this when we get bc escapes working correctly
-        // this test anyhow would  fail  at that time
-        findString("WARNING: Passing.*" + fname + Utils.CLASS_FILE_EXT,
-                        output);
-
-        Utils.doCompareVerify(testjarFile, outjarFile);
-    }
-
-    static boolean findString(String str, List<String> list) {
-        Pattern p = Pattern.compile(str);
-        for (String x : list) {
-            if (p.matcher(x).matches())
-                return true;
-        }
-        throw new RuntimeException("Error: " + str + " not found in output");
+        Utils.testWithRepack(testjarFile, "--config-file=" + propsFile.getName());
     }
 }
--- a/test/tools/pack200/Utils.java	Sat Mar 02 11:06:58 2013 -0400
+++ b/test/tools/pack200/Utils.java	Fri Mar 15 11:51:02 2013 -0300
@@ -314,6 +314,20 @@
             throw new RuntimeException("jar command failed");
         }
     }
+
+    static void testWithRepack(File inFile, String... repackOpts) throws IOException {
+        File cwd = new File(".");
+        // pack using --repack in native mode
+        File nativejarFile = new File(cwd, "out-n" + Utils.JAR_FILE_EXT);
+        repack(inFile, nativejarFile, false, repackOpts);
+        doCompareVerify(inFile, nativejarFile);
+
+        // ensure bit compatibility between the unpacker variants
+        File javajarFile = new File(cwd, "out-j" + Utils.JAR_FILE_EXT);
+        repack(inFile, javajarFile, true, repackOpts);
+        doCompareBitWise(javajarFile, nativejarFile);
+    }
+
     static List<String> repack(File inFile, File outFile,
             boolean disableNative, String... extraOpts) {
         List<String> cmdList = new ArrayList<>();