changeset 7144:fc70416beef3

Merge
author valeriep
date Mon, 13 May 2013 16:52:33 -0700
parents 804da1e9bd04 86c1e8c799f5
children 59357ea7f131
files make/com/sun/script/Makefile make/sun/org/Makefile make/sun/org/mozilla/Makefile make/sun/org/mozilla/javascript/Makefile src/share/classes/com/sun/script/javascript/ExternalScriptable.java src/share/classes/com/sun/script/javascript/JSAdapter.java src/share/classes/com/sun/script/javascript/JavaAdapter.java src/share/classes/com/sun/script/javascript/META-INF/services/javax.script.ScriptEngineFactory src/share/classes/com/sun/script/javascript/RhinoClassShutter.java src/share/classes/com/sun/script/javascript/RhinoCompiledScript.java src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java src/share/classes/com/sun/script/javascript/RhinoTopLevel.java src/share/classes/com/sun/script/javascript/RhinoWrapFactory.java src/share/classes/com/sun/script/util/BindingsBase.java src/share/classes/com/sun/script/util/BindingsEntrySet.java src/share/classes/com/sun/script/util/BindingsImpl.java src/share/classes/com/sun/script/util/InterfaceImplementor.java src/share/classes/com/sun/script/util/ScriptEngineFactoryBase.java src/share/classes/java/beans/ReflectionUtils.java test/java/awt/Focus/OverrideRedirectWindowActivationTest/OverrideRedirectWindowActivationTest.java test/sun/security/provider/certpath/X509CertPath/ForwardBuildCompromised.java test/sun/security/provider/certpath/X509CertPath/ReverseBuildCompromised.java test/sun/security/provider/certpath/X509CertPath/ValidateCompromised.java
diffstat 234 files changed, 25320 insertions(+), 4317 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue May 07 14:13:53 2013 -0700
+++ b/.hgtags	Mon May 13 16:52:33 2013 -0700
@@ -209,3 +209,4 @@
 296676d534c52888c36e305a2bf7f345c4ca70f8 jdk8-b85
 7989cd0cc3a9149864589438ee2c949015d8aa9a jdk8-b86
 d5228e624826a10ccc5b05f30ad8d839b58fe48d jdk8-b87
+8dbb4b159e04de3c447c9242c70505e71f8624c7 jdk8-b88
--- a/make/com/sun/Makefile	Tue May 07 14:13:53 2013 -0700
+++ b/make/com/sun/Makefile	Mon May 13 16:52:33 2013 -0700
@@ -31,13 +31,6 @@
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
 
-ifndef OPENJDK
-  ORG_EXISTS := $(call DirExists,$(CLOSED_SRC)/share/classes/sun/org,,)
-  ifneq ("$(ORG_EXISTS)", "") 
-    SCRIPT_SUBDIR = script
-  endif
-endif
-
 # jarsigner is part of JRE
 SUBDIRS = java security net/ssl jarsigner
 
--- a/make/com/sun/script/Makefile	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-
-BUILDDIR = ../../..
-PACKAGE = com.sun.script
-PRODUCT = sun
-include $(BUILDDIR)/common/Defs.gmk
-
-AUTO_FILES_JAVA_DIRS = com/sun/script
-
-#
-# Files that need to be copied
-#
-SERVICEDIR = $(CLASSBINDIR)/META-INF/services
-                                                                                                
-FILES_copy = \
-	$(SERVICEDIR)/javax.script.ScriptEngineFactory
-
-include $(BUILDDIR)/common/Classes.gmk
-
-all: classes copy-files
-
-#
-# Copy the service provider configuration file into the resource
-# directory.
-#
-
-copy-files: $(FILES_copy)
-                                                                                                
-$(SERVICEDIR)/%: $(SHARE_SRC)/classes/com/sun/script/javascript/META-INF/services/%
-	$(install-file)
-                                                                                                
-.PHONY: copy-files
-
-
-clean::
-	$(RM) -r $(CLASSDESTDIR)/com/sun/script/javascript
-	$(RM) $(FILES_copy)
-
--- a/make/sun/Makefile	Tue May 07 14:13:53 2013 -0700
+++ b/make/sun/Makefile	Mon May 13 16:52:33 2013 -0700
@@ -31,12 +31,6 @@
 PRODUCT  = sun
 include $(BUILDDIR)/common/Defs.gmk
 
-# Rhino/Mozilla java sources
-ORG_EXISTS := $(call DirExists,$(CLOSED_SRC)/share/classes/sun/org,,)
-ifneq ("$(ORG_EXISTS)", "")
-  ORG_SUBDIR = org
-endif
-
 # Non windows subdirs
 ifneq ($(PLATFORM), windows)
   ifndef OPENJDK
@@ -83,7 +77,7 @@
                      $(LWAWT_PRE_SUBDIR) $(DISPLAY_LIBS) $(DGA_SUBDIR) $(LWAWT_SUBDIR) \
                      jawt font jpeg cmm $(DISPLAY_TOOLS)
 SUBDIRS_management = management
-SUBDIRS_misc       = $(ORG_SUBDIR) rmi tracing
+SUBDIRS_misc       = rmi tracing
 SUBDIRS_tools      = native2ascii serialver tools jconsole
 
 ifndef OPENJDK
--- a/make/sun/org/Makefile	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#
-# 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
-# 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.
-#
-
-#
-# Makefile for building Mozilla modules
-#
-
-BUILDDIR = ../..
-PRODUCT = org
-include $(BUILDDIR)/common/Defs.gmk
-
-SUBDIRS =  mozilla
-include $(BUILDDIR)/common/Subdirs.gmk
-
-all build clean clobber::
-	$(SUBDIRS-loop)
-
--- a/make/sun/org/mozilla/Makefile	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#
-# 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
-# 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.
-#
-
-#
-# Makefile for building Mozilla JavaScript modules
-#
-
-BUILDDIR = ../../..
-PRODUCT = org
-include $(BUILDDIR)/common/Defs.gmk
-
-SUBDIRS = javascript
-include $(BUILDDIR)/common/Subdirs.gmk
-
-all build clean clobber::
-	$(SUBDIRS-loop)
-
--- a/make/sun/org/mozilla/javascript/Makefile	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  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.
-#
-
-#
-# Makefile for building all of sun.org.mozilla.javascript.internal.*
-#
-
-BUILDDIR = ../../../..
-PACKAGE = sun.org.mozilla.javascript.internal
-PRODUCT = sun
-include $(BUILDDIR)/common/Defs.gmk
-
-AUTO_FILES_JAVA_DIRS = sun/org/mozilla/javascript/internal
-
-RESOURCEDIR = \
-	$(CLASSDESTDIR)/sun/org/mozilla/javascript/internal/resources
-	
-FILES_copy = \
-	$(RESOURCEDIR)/Messages.properties \
-	$(RESOURCEDIR)/Messages_fr.properties
-
-#
-# Rules
-#
-
-include $(BUILDDIR)/common/Classes.gmk
-
-all: classes copy-files
-
-#
-# Copy resource messages file for Rhino JavaScript interpreter
-#
-
-copy-files: $(FILES_copy)
-
-$(RESOURCEDIR)/%: $(CLOSED_SRC)/share/classes/sun/org/mozilla/javascript/internal/resources/%
-	$(install-file)
-
-.PHONY: copy-files
-
-clean clobber::
-	$(RM) -rf $(CLASSDESTDIR)/sun/org/mozilla/javascript
--- a/make/tools/src/build/tools/deps/refs.allowed	Tue May 07 14:13:53 2013 -0700
+++ b/make/tools/src/build/tools/deps/refs.allowed	Mon May 13 16:52:33 2013 -0700
@@ -30,7 +30,5 @@
 
 # Residual references to java.beans.
 # The RemoveMethods tool does not yet purge the constant pool.
-# Rhino is due to be replaced so not worth addressing this dependency now.
 #
-java.beans.PropertyChangeListener=java.util.logging.LogManager,sun.org.mozilla.javascript.internal.Context,compact1,compact2,compact3
-java.beans.PropertyChangeEvent=sun.org.mozilla.javascript.internal.Context,compact3
+java.beans.PropertyChangeListener=java.util.logging.LogManager,compact1,compact2,compact3
--- a/makefiles/CompileNativeLibraries.gmk	Tue May 07 14:13:53 2013 -0700
+++ b/makefiles/CompileNativeLibraries.gmk	Mon May 13 16:52:33 2013 -0700
@@ -63,7 +63,12 @@
 # Use this variable to set DEBUG_SYMBOLS true on windows for all libraries, but
 # not on other platforms.
 ifeq ($(OPENJDK_TARGET_OS), windows)
-    WINDOWS_ONLY := true
+    DEBUG_ALL_BINARIES := true
+endif
+
+# Build everything with debugging on OpenJDK
+ifdef OPENJDK
+    DEBUG_ALL_BINARIES := true
 endif
 
 #
@@ -91,7 +96,8 @@
 			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
 		CFLAGS_windows_debug:=-DLOGGING,\
 		ARFLAGS:=$(ARFLAGS),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 else
 
@@ -105,7 +111,8 @@
 		CFLAGS:=$(CFLAGS_JDKLIB) \
 			-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
 		LDFLAGS:=-nostdlib -r -arch x86_64,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBFDLIBM := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
 $(BUILD_LIBFDLIBM) : $(BUILD_LIBFDLIBM_MAC)
@@ -257,7 +264,7 @@
 			  -D "JDK_FTYPE=0x2L",\
 		REORDER:=$(LIBJAVA_REORDER), \
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjava,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJAVA)
 
@@ -308,7 +315,7 @@
 			  -D "JDK_INTERNAL_NAME=mlib_image" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBMLIB_IMAGE) : $(BUILD_LIBJAVA)
 
@@ -431,7 +438,8 @@
                          $(BUILD_LIBMLIB_LDLIBS) -ljava -ljvm \
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX_solaris:=-lc,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image_v))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image_v,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBMLIB_IMAGE_V): $(BUILD_LIBJAVA)
 
@@ -739,7 +747,7 @@
 			  -D "JDK_INTERNAL_NAME=awt" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBAWT) : $(BUILD_LIBJAVA)
 
@@ -895,7 +903,8 @@
 			  -D "JDK_FNAME=xawt.dll" \
 			  -D "JDK_INTERNAL_NAME=xawt" \
 			  -D "JDK_FTYPE=0x2L",\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_xawt))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_xawt,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBAWT_XAWT) : $(BUILD_LIBJAVA)
 
@@ -956,7 +965,7 @@
 			  -D "JDK_INTERNAL_NAME=zip" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libzip,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBZIP) : $(BUILD_LIBJAVA)
 
@@ -986,7 +995,7 @@
 			  -D "JDK_FNAME=unpack.dll" \
 			  -D "JDK_INTERNAL_NAME=unpack" \
 			  -D "JDK_FTYPE=0x2L",\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBUNPACK) : $(BUILD_LIBJAVA)
 
@@ -1100,7 +1109,7 @@
 			  -D "JDK_INTERNAL_NAME=dt_shmem" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdt_shmem,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
   BUILD_LIBRARIES += $(BUILD_LIBDT_SHMEM)
 
@@ -1134,7 +1143,7 @@
 			  -D "JDK_INTERNAL_NAME=jdwp" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjdwp,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJDWP) : $(BUILD_LIBJAVA)
 
@@ -1175,7 +1184,7 @@
 			  -D "JDK_INTERNAL_NAME=$(LIBJAAS_NAME)" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjaas,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJAAS) : $(BUILD_LIBJAVA)
 
@@ -1240,7 +1249,7 @@
 			  -D "JDK_INTERNAL_NAME=lcms" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/liblcms,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
     BUILD_LIBRARIES += $(BUILD_LIBLCMS)
 
@@ -1300,7 +1309,7 @@
 			  -D "JDK_FTYPE=0x2L",\
 		REORDER:=$(BUILD_LIBJPEG_REORDER),\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjpeg,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJPEG) : $(BUILD_LIBJAVA)
 
@@ -1377,7 +1386,7 @@
 			  -D "JDK_INTERNAL_NAME=fontmanager" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfontmanager,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBFONTMANAGER) : $(BUILD_LIBAWT)
 
@@ -1434,7 +1443,7 @@
 			  -D "JDK_INTERNAL_NAME=t2k" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libt2k,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
     # t2k is linked against fontmanager
     $(BUILD_LIBT2K) : $(BUILD_LIBFONTMANAGER)
@@ -1472,7 +1481,7 @@
 			  -D "JDK_INTERNAL_NAME=jawt" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJAWT) : $(BUILD_LIBAWT)
 
@@ -1521,7 +1530,8 @@
 		LDFLAGS_SUFFIX_solaris:=$(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX) -lXrender,\
 		LDFLAGS_SUFFIX_macosx:=-Xlinker -rpath -Xlinker @loader_path $(JAWT_LIBS) \
 				       -framework Cocoa $(LDFLAGS_JDKLIB_SUFFIX),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 ifndef BUILD_HEADLESS_ONLY
 $(BUILD_LIBJAWT) : $(BUILD_LIBAWT_XAWT)
@@ -1828,7 +1838,7 @@
 			  -D "JDK_INTERNAL_NAME=net" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnet,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBNET) : $(BUILD_LIBJAVA)
 
@@ -1965,7 +1975,7 @@
 			  -D "JDK_INTERNAL_NAME=nio" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnio,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBNIO)
 
@@ -2002,7 +2012,8 @@
 		LDFLAGS_SUFFIX_posix:=-lnio -lnet,\
 		LDFLAGS_SUFFIX_solaris:=-lsocket -ljava -ljvm -lc,\
 		LDFLAGS_SUFFIX_macosx:=-ljava -ljvm,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsctp))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsctp,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
     BUILD_LIBRARIES += $(BUILD_LIBSCTP)
 
@@ -2126,7 +2137,7 @@
 			  -D "JDK_INTERNAL_NAME=jli" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJLI)
 
@@ -2143,7 +2154,8 @@
 		OPTIMIZATION:=HIGH, \
 		CFLAGS:=$(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS),\
 		ARFLAGS:=$(ARFLAGS),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJLI_STATIC)
 
@@ -2161,7 +2173,8 @@
 		OPTIMIZATION:=HIGH, \
 		CFLAGS:=$(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS),\
 		LDFLAGS:=-nostdlib -r,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(JDK_OUTPUTDIR)/objs/libjli_static.a : $(BUILD_LIBJLI_STATIC)
 	$(call install-file)
@@ -2192,7 +2205,7 @@
 			  -D "JDK_INTERNAL_NAME=jfr" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjfr,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJFR)
 
@@ -2244,7 +2257,7 @@
 			  -D "JDK_INTERNAL_NAME=kcms" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkcms,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBKCMS) : $(BUILD_LIBJAVA)
 
@@ -2279,7 +2292,8 @@
 		LDFLAGS:=$(LDFLAGS_JDKLIB) \
 			 $(call SET_SHARED_LIBRARY_ORIGIN), \
 		LDFLAGS_SUFFIX:=-L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -ldga -lX11 $(LIBDL) -lc, \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunwjdga))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunwjdga,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBSUNWJDGA)
 
@@ -2369,7 +2383,8 @@
 		LDFLAGS_SUFFIX_linux:=-ljvm -lawt -lm $(LIBDL) -ljava,\
 		LDFLAGS_SUFFIX_solaris:=$(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc,\
 		LDFLAGS_SUFFIX_macosx:=-ljvm $(LIBCXX) -lawt $(LIBDL) -ljava,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBAWT_HEADLESS) : $(BUILD_LIBAWT)
 
@@ -2462,7 +2477,7 @@
 			  -D "JDK_INTERNAL_NAME=splashscreen" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsplashscreen,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(LIBSPLASHSCREEN)
 
@@ -2504,7 +2519,7 @@
 			  -D "JDK_INTERNAL_NAME=dcpr" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdcpr,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBDCPR) : $(BUILD_LIBJAVA)
 
@@ -2538,7 +2553,7 @@
 			  -D "JDK_INTERNAL_NAME=j2pcsc" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pcsc,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJ2PCSC)
 
@@ -2560,7 +2575,8 @@
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=$(LIBDL),\
 		LDFLAGS_SUFFIX_solaris:=-lc,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2gss))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2gss,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJ2GSS)
 endif
@@ -2599,7 +2615,7 @@
 			  -D "JDK_INTERNAL_NAME=$(BUILD_LIBKRB5_NAME)" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkrb5,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBKRB5)
 endif
@@ -2625,7 +2641,7 @@
 			  -D "JDK_INTERNAL_NAME=sunmscapi" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunmscapi,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBSUNMSCAPI)
 endif
@@ -2657,7 +2673,7 @@
 			  -D "JDK_INTERNAL_NAME=j2pkcs11" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pkcs11,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBJ2PKCS11)
 
@@ -2703,7 +2719,7 @@
 			  -D "JDK_INTERNAL_NAME=sunec" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunec,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBSUNEC)
 endif
@@ -2847,7 +2863,7 @@
 			  -D "JDK_INTERNAL_NAME=jsound" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsound,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJSOUND) : $(BUILD_LIBJAVA)
 
@@ -2882,7 +2898,8 @@
 		LDFLAGS:=$(LDFLAGS_JDKLIB)\
 			 $(call SET_SHARED_LIBRARY_ORIGIN),\
 		LDFLAGS_SUFFIX:=-lasound -ljava -ljvm,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJSOUNDALSA) : $(BUILD_LIBJAVA)
 
@@ -2915,7 +2932,7 @@
 			  -D "JDK_INTERNAL_NAME=jsoundds" \
 			  -D "JDK_FTYPE=0x2L",\
 		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundds,\
-		DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJSOUNDDS) : $(BUILD_LIBJAVA)
 
@@ -2940,7 +2957,8 @@
 		LDFLAGS:=$(LDFLAGS_JDKLIB),\
 		LDFLAGS_SUFFIX:=$(LIBDL),\
 		LDFLAGS_SUFFIX_solaris:=-lc,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBJ2UCRYPTO) : $(BUILD_LIBJAVA)
 
@@ -2970,7 +2988,8 @@
                                 -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
                                 -framework JavaNativeFoundation \
                                 $(LDFLAGS_JDKLIB_SUFFIX),\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(BUILD_LIBAPPLESCRIPTENGINE) : $(BUILD_LIBJAVA)
 
@@ -3009,7 +3028,8 @@
 	-framework OpenGL \
 	-framework IOSurface \
 	-framework QuartzCore, \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxapp))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxapp,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBOSXAPP)
 
@@ -3049,7 +3069,8 @@
     -framework Security \
     -framework SystemConfiguration \
     $(LDFLAGS_JDKLIB_SUFFIX), \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosx))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosx,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBOSX)
 
@@ -3182,7 +3203,8 @@
 				       -framework JavaRuntimeSupport \
 				       -framework OpenGL \
 				       -framework QuartzCore -ljava,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_lwawt))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_lwawt,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBAWT_LWAWT)
 
@@ -3222,7 +3244,8 @@
 				       -framework JavaNativeFoundation \
 				       -framework JavaRuntimeSupport \
 				       -ljava -ljvm,\
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxui))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxui,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 BUILD_LIBRARIES += $(BUILD_LIBOSXUI)
 
@@ -3262,7 +3285,8 @@
                                   -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
                                   -framework JavaNativeFoundation \
                                   -lffi, \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc32))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc32,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC64,\
 		LIBRARY:=JObjC,\
@@ -3286,7 +3310,8 @@
                                   -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
                                   -framework JavaNativeFoundation \
                                   -lffi, \
-		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc64))
+		OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc64,\
+		DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
 
 $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)JObjC$(SHARED_LIBRARY_SUFFIX): $(BUILD_LIBJOBJC32) $(BUILD_LIBJOBJC64)
 	$(LIPO) -create -output $@ $(BUILD_LIBJOBJC32) $(BUILD_LIBJOBJC64)
--- a/makefiles/CopyFiles.gmk	Tue May 07 14:13:53 2013 -0700
+++ b/makefiles/CopyFiles.gmk	Mon May 13 16:52:33 2013 -0700
@@ -458,24 +458,6 @@
 
 ifndef OPENJDK
 
-JS_RESOURCES_FILES := Messages.properties Messages_fr.properties
-JS_RESOURCES_SRC_DIR := $(JDK_TOPDIR)/src/closed/share/classes/sun/org/mozilla/javascript/internal/resources
-JS_RESOURCES_DST_DIR := $(JDK_OUTPUTDIR)/classes/sun/org/mozilla/javascript/internal/resources
-
-JS_RESOURCES_SRC := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_SRC_DIR)/$(F))
-JS_RESOURCES_DST := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_DST_DIR)/$(F))
-
-$(JS_RESOURCES_DST_DIR)/% : $(JS_RESOURCES_SRC_DIR)/%
-	$(call install-file)
-
-COPY_FILES += $(JS_RESOURCES_DST)
-
-endif
-
-##########################################################################################
-
-ifndef OPENJDK
-
 #
 # Solaris X11 Direct Graphics Access library
 #
--- a/makefiles/CopyIntoClasses.gmk	Tue May 07 14:13:53 2013 -0700
+++ b/makefiles/CopyIntoClasses.gmk	Mon May 13 16:52:33 2013 -0700
@@ -172,10 +172,6 @@
 else
     ALL_META-INF_DIRS:=$(ALL_META-INF_DIRS_share)
 endif
-# Filter out META-INF dirs that shouldn't be included
-ifdef OPENJDK
-  ALL_META-INF_DIRS:=$(filter-out %com/sun/script/javascript/META-INF,$(ALL_META-INF_DIRS))
-endif
 
 ifndef OPENJDK
     ALL_META-INF_DIRS += $(JDK_TOPDIR)/src/closed/share/classes/sun/java2d/cmm/kcms/META-INF
--- a/makefiles/GensrcX11Wrappers.gmk	Tue May 07 14:13:53 2013 -0700
+++ b/makefiles/GensrcX11Wrappers.gmk	Mon May 13 16:52:33 2013 -0700
@@ -86,10 +86,15 @@
 	$(MKDIR) -p $(@D)
 	$(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $*
 
+    # use -m32/-m64 only if the compiler supports it
+    ifeq ($(COMPILER_SUPPORTS_TARGET_BITS_FLAG),true)
+    MEMORY_MODEL_FLAG="-m$*"
+    endif
+
     # Compile the C code into an executable.
     $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c
 	$(MKDIR) -p $(@D)
-	(cd $(@D) && $(CC) -m$* -o $@ $< \
+	(cd $(@D) && $(CC) $(MEMORY_MODEL_FLAG) -o $@ $< \
               $(X_CFLAGS) \
               $(X_LIBS) \
               -I$(JDK_OUTPUTDIR)/include \
--- a/makefiles/Images.gmk	Tue May 07 14:13:53 2013 -0700
+++ b/makefiles/Images.gmk	Mon May 13 16:52:33 2013 -0700
@@ -352,16 +352,22 @@
         JDK_MAN_PAGES += jvisualvm.1
     endif
 
+    ifndef OPENJDK
+        MAN_SRC_BASEDIR:=$(JDK_TOPDIR)/src/closed
+    else
+        MAN_SRC_BASEDIR:=$(JDK_TOPDIR)/src
+    endif
+
     ifeq ($(OPENJDK_TARGET_OS), linux)
-        MAN_SRC_DIR:=$(JDK_TOPDIR)/src/linux/doc
+        MAN_SRC_DIR:=$(MAN_SRC_BASEDIR)/linux/doc
         MAN1_SUBDIR:=man
     endif
     ifeq ($(OPENJDK_TARGET_OS), solaris)
-        MAN_SRC_DIR:=$(JDK_TOPDIR)/src/solaris/doc
+        MAN_SRC_DIR:=$(MAN_SRC_BASEDIR)/solaris/doc
         MAN1_SUBDIR:=sun/man/man1
     endif
     ifeq ($(OPENJDK_TARGET_OS), macosx)
-        MAN_SRC_DIR:=$(JDK_TOPDIR)/src/bsd/doc
+        MAN_SRC_DIR:=$(MAN_SRC_BASEDIR)/bsd/doc
         MAN1_SUBDIR:=man
         JDK_MAN_PAGES := $(filter-out jcmd.1, $(JDK_MAN_PAGES))
         JDK_MAN_PAGES := $(filter-out jvisualvm.1, $(JDK_MAN_PAGES))
--- a/makefiles/profile-rtjar-includes.txt	Tue May 07 14:13:53 2013 -0700
+++ b/makefiles/profile-rtjar-includes.txt	Mon May 13 16:52:33 2013 -0700
@@ -57,6 +57,7 @@
     java/time \
     java/util \
     javax/net \
+    javax/script \
     javax/security \
     jdk \
     sun/invoke \
@@ -111,7 +112,6 @@
     com/sun/nio/sctp \
     com/sun/org/apache/xml/internal/security \
     com/sun/rowset \
-    com/sun/script \
     com/sun/security/auth \
     com/sun/security/jgss \
     com/sun/security/ntlm \
@@ -125,7 +125,6 @@
     javax/lang/model \
     javax/management \
     javax/naming \
-    javax/script \
     javax/security/auth/kerberos \
     javax/security/sasl \
     javax/smartcardio \
@@ -140,7 +139,6 @@
     sun/net/www/protocol/http/ntlm \
     sun/net/www/protocol/http/spnego \
     sun/nio/ch/sctp \
-    sun/org/mozilla \
     sun/security/acl \
     sun/security/jgss \
     sun/security/krb5 \
@@ -161,10 +159,6 @@
     javax/management/remote/rmi/_RMIServerImpl_Tie.class \
     javax/management/remote/rmi/_RMIServer_Stub.class
 
-PROFILE_3_INCLUDE_METAINF_SERVICES := \
-    META-INF/services/javax.script.ScriptEngineFactory 
-
-
 FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
     com/oracle \
     com/sun/accessibility/internal/resources \
--- a/src/macosx/classes/sun/awt/CGraphicsDevice.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/classes/sun/awt/CGraphicsDevice.java	Mon May 13 16:52:33 2013 -0700
@@ -35,10 +35,18 @@
 
 import sun.java2d.opengl.CGLGraphicsConfig;
 
-public final class CGraphicsDevice extends GraphicsDevice {
+public final class CGraphicsDevice extends GraphicsDevice
+        implements DisplayChangedListener {
 
-    // CoreGraphics display ID
-    private final int displayID;
+    /**
+     * CoreGraphics display ID. This identifier can become non-valid at any time
+     * therefore methods, which is using this id should be ready to it.
+     */
+    private volatile int displayID;
+    private volatile Insets screenInsets;
+    private volatile double xResolution;
+    private volatile double yResolution;
+    private volatile int scale;
 
     // Array of all GraphicsConfig instances for this device
     private final GraphicsConfiguration[] configs;
@@ -51,7 +59,7 @@
     // Save/restore DisplayMode for the Full Screen mode
     private DisplayMode originalMode;
 
-    public CGraphicsDevice(int displayID) {
+    public CGraphicsDevice(final int displayID) {
         this.displayID = displayID;
         configs = new GraphicsConfiguration[] {
             CGLGraphicsConfig.getConfig(this, 0)
@@ -89,7 +97,7 @@
      */
     @Override
     public String getIDstring() {
-        return "Display " + this.displayID;
+        return "Display " + displayID;
     }
 
     /**
@@ -104,15 +112,37 @@
     }
 
     public double getXResolution() {
-        return nativeGetXResolution(displayID);
+        return xResolution;
     }
 
     public double getYResolution() {
-        return nativeGetYResolution(displayID);
+        return yResolution;
     }
 
     public Insets getScreenInsets() {
-        return nativeGetScreenInsets(displayID);
+        return screenInsets;
+    }
+
+    public int getScaleFactor() {
+        return scale;
+    }
+
+    public void invalidate(final int defaultDisplayID) {
+        displayID = defaultDisplayID;
+    }
+
+    @Override
+    public void displayChanged() {
+        xResolution = nativeGetXResolution(displayID);
+        yResolution = nativeGetYResolution(displayID);
+        screenInsets = nativeGetScreenInsets(displayID);
+        scale = (int) nativeGetScaleFactor(displayID);
+        //TODO configs/fullscreenWindow/modes?
+    }
+
+    @Override
+    public void paletteChanged() {
+        // devices do not need to react to this event.
     }
 
     /**
@@ -219,10 +249,6 @@
         return nativeGetDisplayModes(displayID);
     }
 
-    public int getScaleFactor() {
-        return (int) nativeGetScaleFactor(displayID);
-    }
-
     private static native double nativeGetScaleFactor(int displayID);
 
     private static native void nativeSetDisplayMode(int displayID, int w, int h, int bpp, int refrate);
--- a/src/macosx/classes/sun/awt/CGraphicsEnvironment.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/classes/sun/awt/CGraphicsEnvironment.java	Mon May 13 16:52:33 2013 -0700
@@ -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
@@ -26,19 +26,20 @@
 package sun.awt;
 
 import java.awt.*;
-import java.awt.print.*;
 import java.util.*;
 
 import sun.java2d.*;
 
 /**
- * This is an implementation of a GraphicsEnvironment object for the default local GraphicsEnvironment used by the Java
- * Runtime Environment for Mac OS X GUI environments.
+ * This is an implementation of a GraphicsEnvironment object for the default
+ * local GraphicsEnvironment used by the Java Runtime Environment for Mac OS X
+ * GUI environments.
  *
  * @see GraphicsDevice
  * @see GraphicsConfiguration
  */
-public class CGraphicsEnvironment extends SunGraphicsEnvironment {
+public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
+
     // Global initialization of the Cocoa runtime.
     private static native void initCocoa();
 
@@ -53,7 +54,8 @@
     private static native int getMainDisplayID();
 
     /**
-     * Noop function that just acts as an entry point for someone to force a static initialization of this class.
+     * Noop function that just acts as an entry point for someone to force a
+     * static initialization of this class.
      */
     public static void init() { }
 
@@ -78,8 +80,9 @@
     }
 
     /**
-     * Register the instance with CGDisplayRegisterReconfigurationCallback()
-     * The registration uses a weak global reference -- if our instance is garbage collected, the reference will be dropped.
+     * Register the instance with CGDisplayRegisterReconfigurationCallback().
+     * The registration uses a weak global reference -- if our instance is
+     * garbage collected, the reference will be dropped.
      *
      * @return Return the registration context (a pointer).
      */
@@ -91,7 +94,7 @@
     private native void deregisterDisplayReconfiguration(long context);
 
     /** Available CoreGraphics displays. */
-    private final Map<Integer, CGraphicsDevice> devices = new HashMap<Integer, CGraphicsDevice>();
+    private final Map<Integer, CGraphicsDevice> devices = new HashMap<>(5);
 
     /** Reference to the display reconfiguration callback context. */
     private final long displayReconfigContext;
@@ -118,11 +121,18 @@
     /**
      * Called by the CoreGraphics Display Reconfiguration Callback.
      *
-     * @param displayId
-     *            CoreGraphics displayId
+     * @param displayId CoreGraphics displayId
+     * @param removed   true if displayId was removed, false otherwise.
      */
-    void _displayReconfiguration(long displayId) {
-        displayChanged();
+    void _displayReconfiguration(final int displayId, final boolean removed) {
+        synchronized (this) {
+            if (removed && devices.containsKey(displayId)) {
+                final CGraphicsDevice gd = devices.remove(displayId);
+                gd.invalidate(getMainDisplayID());
+                gd.displayChanged();
+            }
+        }
+        initDevices();
     }
 
     @Override
@@ -135,31 +145,30 @@
     }
 
     /**
-     * (Re)create all CGraphicsDevices
-     *
-     * @return
+     * (Re)create all CGraphicsDevices, reuses a devices if it is possible.
      */
-    private synchronized void initDevices() {
-        devices.clear();
+    private void initDevices() {
+        synchronized (this) {
+            final Map<Integer, CGraphicsDevice> old = new HashMap<>(devices);
+            devices.clear();
 
-        int mainID = getMainDisplayID();
+            int mainID = getMainDisplayID();
 
-        // initialization of the graphics device may change
-        // list of displays on hybrid systems via an activation
-        // of discrete video.
-        // So, we initialize the main display first, and then
-        // retrieve actual list of displays.
-        CGraphicsDevice mainDevice = new CGraphicsDevice(mainID);
+            // initialization of the graphics device may change
+            // list of displays on hybrid systems via an activation
+            // of discrete video.
+            // So, we initialize the main display first, and then
+            // retrieve actual list of displays.
+            if (!old.containsKey(mainID)) {
+                old.put(mainID, new CGraphicsDevice(mainID));
+            }
 
-        final int[] displayIDs = getDisplayIDs();
-
-        for (int displayID : displayIDs) {
-            if (displayID != mainID) {
-                devices.put(displayID, new CGraphicsDevice(displayID));
-            } else {
-                devices.put(mainID, mainDevice);
+            for (final int id : getDisplayIDs()) {
+                devices.put(id, old.containsKey(id) ? old.get(id)
+                                                    : new CGraphicsDevice(id));
             }
         }
+        displayChanged();
     }
 
     @Override
@@ -167,7 +176,7 @@
         final int mainDisplayID = getMainDisplayID();
         CGraphicsDevice d = devices.get(mainDisplayID);
         if (d == null) {
-            // we do not exepct that this may happen, the only responce
+            // we do not expect that this may happen, the only response
             // is to re-initialize the list of devices
             initDevices();
 
--- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Mon May 13 16:52:33 2013 -0700
@@ -87,18 +87,22 @@
 
     private final T target;
 
-    // Container peer. It may not be the peer of the target's direct
-    // parent, for example, in the case of hw/lw mixing. However,
-    // let's skip this scenario for the time being. We also assume
-    // the container peer is not null, which might also be false if
-    // addNotify() is called for a component outside of the hierarchy.
-    // The exception is LWWindowPeers: their parents are always null
-    private LWContainerPeer containerPeer;
+    /**
+     * Container peer. It may not be the peer of the target's direct parent, for
+     * example, in the case of hw/lw mixing. However, let's skip this scenario
+     * for the time being. We also assume the container peer is not null, which
+     * might also be false if addNotify() is called for a component outside of
+     * the hierarchy. The exception is LWWindowPeers: their containers are
+     * always null
+     */
+    private final LWContainerPeer containerPeer;
 
-    // Handy reference to the top-level window peer. Window peer is
-    // borrowed from the containerPeer in constructor, and should also
-    // be updated when the component is reparented to another container
-    private LWWindowPeer windowPeer;
+    /**
+     * Handy reference to the top-level window peer. Window peer is borrowed
+     * from the containerPeer in constructor, and should also be updated when
+     * the component is reparented to another container
+     */
+    private final LWWindowPeer windowPeer;
 
     private final AtomicBoolean disposed = new AtomicBoolean(false);
 
@@ -183,13 +187,13 @@
         this.target = target;
         this.platformComponent = platformComponent;
 
-        initializeContainerPeer();
         // Container peer is always null for LWWindowPeers, so
         // windowPeer is always null for them as well. On the other
         // hand, LWWindowPeer shouldn't use windowPeer at all
-        if (containerPeer != null) {
-            windowPeer = containerPeer.getWindowPeerOrSelf();
-        }
+        final Container container = SunToolkit.getNativeContainer(target);
+        containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
+        windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
+                                           : null;
         // don't bother about z-order here as updateZOrder()
         // will be called from addNotify() later anyway
         if (containerPeer != null) {
@@ -356,15 +360,6 @@
         return containerPeer;
     }
 
-    // Just a helper method
-    // Overridden in LWWindowPeer to skip containerPeer initialization
-    protected void initializeContainerPeer() {
-        Container parent = LWToolkit.getNativeContainer(target);
-        if (parent != null) {
-            containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(parent);
-        }
-    }
-
     public PlatformWindow getPlatformWindow() {
         LWWindowPeer windowPeer = getWindowPeer();
         return windowPeer.getPlatformWindow();
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Mon May 13 16:52:33 2013 -0700
@@ -41,7 +41,7 @@
 
 public class LWWindowPeer
     extends LWContainerPeer<Window, JComponent>
-    implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable
+    implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener
 {
     public static enum PeerType {
         SIMPLEWINDOW,
@@ -189,6 +189,7 @@
         if (getSurfaceData() == null) {
             replaceSurfaceData(false);
         }
+        activateDisplayListener();
     }
 
     // Just a helper method
@@ -201,15 +202,11 @@
         return this;
     }
 
-    @Override
-    protected void initializeContainerPeer() {
-        // No-op as LWWindowPeer doesn't have any containerPeer
-    }
-
     // ---- PEER METHODS ---- //
 
     @Override
     protected void disposeImpl() {
+        deactivateDisplayListener();
         SurfaceData oldData = getSurfaceData();
         synchronized (surfaceDataLock){
             surfaceData = null;
@@ -880,6 +877,18 @@
 
     // ---- UTILITY METHODS ---- //
 
+    private void activateDisplayListener() {
+        final GraphicsEnvironment ge =
+                GraphicsEnvironment.getLocalGraphicsEnvironment();
+        ((SunGraphicsEnvironment) ge).addDisplayChangedListener(this);
+    }
+
+    private void deactivateDisplayListener() {
+        final GraphicsEnvironment ge =
+                GraphicsEnvironment.getLocalGraphicsEnvironment();
+        ((SunGraphicsEnvironment) ge).removeDisplayChangedListener(this);
+    }
+
     private void postWindowStateChangedEvent(int newWindowState) {
         if (getTarget() instanceof Frame) {
             AWTAccessor.getFrameAccessor().setExtendedState(
@@ -941,7 +950,6 @@
             graphicsDevice = newGraphicsDevice;
         }
 
-        // TODO: DisplayChangedListener stuff
         final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
 
         if (!setGraphicsConfig(newGC)) return false;
@@ -954,6 +962,20 @@
         return true;
     }
 
+    @Override
+    public final void displayChanged() {
+        updateGraphicsDevice();
+        // Replace surface unconditionally, because internal state of the
+        // GraphicsDevice could be changed.
+        replaceSurfaceData();
+        repaintPeer();
+    }
+
+    @Override
+    public final void paletteChanged() {
+        // components do not need to react to this event.
+    }
+
     /*
      * May be called by delegate to provide SD to Java2D code.
      */
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon May 13 16:52:33 2013 -0700
@@ -32,6 +32,7 @@
 import java.beans.*;
 import java.lang.reflect.InvocationTargetException;
 import java.util.List;
+import java.util.Objects;
 
 import javax.swing.*;
 
@@ -916,9 +917,12 @@
 
         final Rectangle oldB = nativeBounds;
         nativeBounds = new Rectangle(x, y, width, height);
+        final GraphicsConfiguration oldGC = peer.getGraphicsConfiguration();
         peer.notifyReshape(x, y, width, height);
+        final GraphicsConfiguration newGC = peer.getGraphicsConfiguration();
+        // System-dependent appearance optimization.
         if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
-            || isFullScreenAnimationOn) {
+            || isFullScreenAnimationOn || !Objects.equals(newGC, oldGC)) {
             flushBuffers();
         }
     }
--- a/src/macosx/native/sun/awt/AWTEvent.h	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/native/sun/awt/AWTEvent.h	Mon May 13 16:52:33 2013 -0700
@@ -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
@@ -35,5 +35,6 @@
 jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags);
 jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods);
 NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods);
+unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers);
 
 #endif /* __AWTEVENT_H */
--- a/src/macosx/native/sun/awt/AWTEvent.m	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/native/sun/awt/AWTEvent.m	Mon May 13 16:52:33 2013 -0700
@@ -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
@@ -341,8 +341,7 @@
     {0, 0, 0}
 };
 
-static unichar
-NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
+unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
 {
     const struct _char *cur;
     // Mask off just the keyboard modifiers from the event modifier mask.
--- a/src/macosx/native/sun/awt/CGraphicsEnv.m	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/native/sun/awt/CGraphicsEnv.m	Mon May 13 16:52:33 2013 -0700
@@ -124,10 +124,11 @@
 
         jobject graphicsEnv = [wrapper jObjectWithEnv:env];
         if (graphicsEnv == NULL) return; // ref already GC'd
-
         static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
-        static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(J)V");
-        JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration);
+        static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(IZ)V");
+        JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
+                            (jint) display, 
+                            (jboolean) flags & kCGDisplayRemoveFlag);
     });
 }
 
--- a/src/macosx/native/sun/awt/CMenuItem.m	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/native/sun/awt/CMenuItem.m	Mon May 13 16:52:33 2013 -0700
@@ -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
@@ -71,12 +71,21 @@
 JNF_COCOA_ENTER(env);
 
     // If we are called as a result of user pressing a shorcut, do nothing,
-    // because AVTView has already sent corresponding key event to the Java 
+    // because AVTView has already sent corresponding key event to the Java
     // layer from performKeyEquivalent
     NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
     if ([currEvent type] == NSKeyDown) {
         NSString *menuKey = [sender keyEquivalent];
         NSString *eventKey = [currEvent charactersIgnoringModifiers];
+
+        // Apple uses characters from private Unicode range for some of the
+        // keys, so we need to do the same translation here that we do
+        // for the regular key down events
+        if ([eventKey length] == 1) {
+            unichar ch =  NsCharToJavaChar([eventKey characterAtIndex:0], 0);
+            eventKey = [NSString stringWithCharacters: &ch length: 1];
+        }
+
         if ([menuKey isEqualToString:eventKey]) {
             return;
         }
--- a/src/macosx/native/sun/awt/CTextPipe.m	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/native/sun/awt/CTextPipe.m	Mon May 13 16:52:33 2013 -0700
@@ -143,6 +143,8 @@
     CGContextRef cgRef = qsdo->cgRef;
     CGAffineTransform ctmText = CGContextGetTextMatrix(cgRef);
 
+    BOOL saved = false;
+
     /* Save and restore of graphics context is done before the iteration.  
        This seems to work using our test case (see bug ID 7158350) so we are restoring it at
        the end of the for loop.  If we find out that save/restore outside the loop
@@ -175,10 +177,19 @@
                 CFRelease(fallback);
 
                 if (cgFallback) {
+                    if (!saved) {
+                        CGContextSaveGState(cgRef);
+                        saved = true;
+                    }
                     CGContextSetFont(cgRef, cgFallback);
                     CFRelease(cgFallback);
                 }
             }
+        } else {
+            if (saved) {
+                CGContextRestoreGState(cgRef);
+                saved = false;
+            }
         }
 
         // if we have per-glyph transformations
--- a/src/macosx/native/sun/awt/awt.m	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/native/sun/awt/awt.m	Mon May 13 16:52:33 2013 -0700
@@ -316,7 +316,10 @@
     // its finishLaunching has initialized it.
     //  ApplicationDelegate is the support code for com.apple.eawt.
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]);
+        id<NSApplicationDelegate> delegate = [ApplicationDelegate sharedDelegate];
+        if (delegate != nil) {
+            OSXAPP_SetApplicationDelegate(delegate);
+        }        
     }];
 }
 
--- a/src/macosx/native/sun/java2d/opengl/CGLLayer.m	Tue May 07 14:13:53 2013 -0700
+++ b/src/macosx/native/sun/java2d/opengl/CGLLayer.m	Mon May 13 16:52:33 2013 -0700
@@ -216,7 +216,11 @@
 {
     JNF_COCOA_ENTER(env);
     CGLLayer *layer = jlong_to_ptr(layerPtr);
-    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+    // We always call all setXX methods asynchronously, exception is only in 
+    // this method where we need to change native texture size and layer's scale
+    // in one call on appkit, otherwise we'll get window's contents blinking, 
+    // during screen-2-screen moving.
+    [ThreadUtilities performOnMainThreadWaiting:[NSThread isMainThread] block:^(){
         layer.contentsScale = scale;
     }];
     JNF_COCOA_EXIT(env);
--- a/src/share/bin/java.c	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/bin/java.c	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2012, 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
@@ -149,12 +149,15 @@
 static void FreeKnownVMs();
 static jboolean IsWildCardEnabled();
 
-#define ARG_CHECK(n, f, a) if (n < 1) { \
-    JLI_ReportErrorMessage(f, a); \
-    printUsage = JNI_TRUE; \
-    *pret = 1; \
-    return JNI_TRUE; \
-}
+#define ARG_CHECK(AC_arg_count, AC_failure_message, AC_questionable_arg) \
+    do { \
+        if (AC_arg_count < 1) { \
+            JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \
+            printUsage = JNI_TRUE; \
+            *pret = 1; \
+            return JNI_TRUE; \
+        } \
+    } while (JNI_FALSE)
 
 /*
  * Running Java code in primordial thread caused many problems. We will
@@ -310,29 +313,37 @@
  * mainThread.isAlive() to work as expected.
  */
 #define LEAVE() \
-    if ((*vm)->DetachCurrentThread(vm) != 0) { \
-        JLI_ReportErrorMessage(JVM_ERROR2); \
-        ret = 1; \
-    } \
-    (*vm)->DestroyJavaVM(vm); \
-    return ret \
+    do { \
+        if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
+            JLI_ReportErrorMessage(JVM_ERROR2); \
+            ret = 1; \
+        } \
+        if (JNI_TRUE) { \
+            (*vm)->DestroyJavaVM(vm); \
+            return ret; \
+        } \
+    } while (JNI_FALSE)
 
-#define CHECK_EXCEPTION_NULL_LEAVE(e) \
-    if ((*env)->ExceptionOccurred(env)) { \
-        JLI_ReportExceptionDescription(env); \
-        LEAVE(); \
-    } \
-    if ((e) == NULL) { \
-        JLI_ReportErrorMessage(JNI_ERROR); \
-        LEAVE(); \
-    }
+#define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
+    do { \
+        if ((*env)->ExceptionOccurred(env)) { \
+            JLI_ReportExceptionDescription(env); \
+            LEAVE(); \
+        } \
+        if ((CENL_exception) == NULL) { \
+            JLI_ReportErrorMessage(JNI_ERROR); \
+            LEAVE(); \
+        } \
+    } while (JNI_FALSE)
 
-#define CHECK_EXCEPTION_LEAVE(rv) \
-    if ((*env)->ExceptionOccurred(env)) { \
-        JLI_ReportExceptionDescription(env); \
-        ret = (rv); \
-        LEAVE(); \
-    }
+#define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
+    do { \
+        if ((*env)->ExceptionOccurred(env)) { \
+            JLI_ReportExceptionDescription(env); \
+            ret = (CEL_return_value); \
+            LEAVE(); \
+        } \
+    } while (JNI_FALSE)
 
 int JNICALL
 JavaMain(void * _args)
@@ -434,7 +445,7 @@
      * consistent in the UI we need to track and report the application main class.
      */
     appClass = GetApplicationClass(env);
-    NULL_CHECK(appClass);
+    NULL_CHECK_RETURN_VALUE(appClass, -1);
     /*
      * PostJVMInit uses the class name as the application name for GUI purposes,
      * for example, on OSX this sets the application name in the menu bar for
--- a/src/share/bin/java.h	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/bin/java.h	Mon May 13 16:52:33 2013 -0700
@@ -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
@@ -242,14 +242,18 @@
     InvocationFunctions ifn;
 } JavaMainArgs;
 
-#define NULL_CHECK0(e) if ((e) == 0) { \
-    JLI_ReportErrorMessage(JNI_ERROR); \
-    return 0; \
-  }
+#define NULL_CHECK_RETURN_VALUE(NCRV_check_pointer, NCRV_return_value) \
+    do { \
+        if ((NCRV_check_pointer) == NULL) { \
+            JLI_ReportErrorMessage(JNI_ERROR); \
+            return NCRV_return_value; \
+        } \
+    } while (JNI_FALSE)
 
-#define NULL_CHECK(e) if ((e) == 0) { \
-    JLI_ReportErrorMessage(JNI_ERROR); \
-    return; \
-  }
+#define NULL_CHECK0(NC0_check_pointer) \
+    NULL_CHECK_RETURN_VALUE(NC0_check_pointer, 0)
+
+#define NULL_CHECK(NC_check_pointer) \
+    NULL_CHECK_RETURN_VALUE(NC_check_pointer, )
 
 #endif /* _JAVA_H_ */
--- a/src/share/bin/wildcard.c	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/bin/wildcard.c	Mon May 13 16:52:33 2013 -0700
@@ -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
@@ -136,8 +136,10 @@
 {
     WildcardIterator it = NEW_(WildcardIterator);
     HANDLE handle = FindFirstFile(wildcard, &find_data);
-    if (handle == INVALID_HANDLE_VALUE)
+    if (handle == INVALID_HANDLE_VALUE) {
+        JLI_MemFree(it);
         return NULL;
+    }
     it->handle = handle;
     it->firstFile = find_data.cFileName;
     return it;
--- a/src/share/classes/com/sun/jndi/dns/DnsContext.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/com/sun/jndi/dns/DnsContext.java	Mon May 13 16:52:33 2013 -0700
@@ -102,7 +102,7 @@
         this.domain = new DnsName(domain.endsWith(".")
                                   ? domain
                                   : domain + ".");
-        this.servers = servers;
+        this.servers = (servers == null) ? null : servers.clone();
         this.environment = (Hashtable<Object,Object>) environment.clone();
         envShared = false;
         parentIsDns = false;
@@ -129,11 +129,11 @@
      * no conflict.
      */
     private DnsContext(DnsContext ctx) {
-        environment = ctx.environment;
+        environment = ctx.environment;  // shared environment, copy-on-write
         envShared = ctx.envShared = true;
         parentIsDns = ctx.parentIsDns;
         domain = ctx.domain;
-        servers = ctx.servers;
+        servers = ctx.servers;          // shared servers, no write operation
         resolver = ctx.resolver;
         authoritative = ctx.authoritative;
         recursion = ctx.recursion;
--- a/src/share/classes/com/sun/jndi/ldap/BasicControl.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/com/sun/jndi/ldap/BasicControl.java	Mon May 13 16:52:33 2013 -0700
@@ -81,7 +81,7 @@
         this.id = id;
         this.criticality = criticality;
         if (value != null) {
-            this.value = value;
+            this.value = value.clone();
         }
     }
 
--- a/src/share/classes/com/sun/script/javascript/ExternalScriptable.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2005, 2006, 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 com.sun.script.javascript;
-import sun.org.mozilla.javascript.internal.*;
-import javax.script.*;
-import java.util.*;
-
-/**
- * ExternalScriptable is an implementation of Scriptable
- * backed by a JSR 223 ScriptContext instance.
- *
- * @author Mike Grogan
- * @author A. Sundararajan
- * @since 1.6
- */
-
-final class ExternalScriptable implements Scriptable {
-    /* Underlying ScriptContext that we use to store
-     * named variables of this scope.
-     */
-    private ScriptContext context;
-
-    /* JavaScript allows variables to be named as numbers (indexed
-     * properties). This way arrays, objects (scopes) are treated uniformly.
-     * Note that JSR 223 API supports only String named variables and
-     * so we can't store these in Bindings. Also, JavaScript allows name
-     * of the property name to be even empty String! Again, JSR 223 API
-     * does not support empty name. So, we use the following fallback map
-     * to store such variables of this scope. This map is not exposed to
-     * JSR 223 API. We can just script objects "as is" and need not convert.
-     */
-    private Map<Object, Object> indexedProps;
-
-    // my prototype
-    private Scriptable prototype;
-    // my parent scope, if any
-    private Scriptable parent;
-
-    ExternalScriptable(ScriptContext context) {
-        this(context, new HashMap<Object, Object>());
-    }
-
-    ExternalScriptable(ScriptContext context, Map<Object, Object> indexedProps) {
-        if (context == null) {
-            throw new NullPointerException("context is null");
-        }
-        this.context = context;
-        this.indexedProps = indexedProps;
-    }
-
-    ScriptContext getContext() {
-        return context;
-    }
-
-    private boolean isEmpty(String name) {
-        return name.equals("");
-    }
-
-    /**
-     * Return the name of the class.
-     */
-    public String getClassName() {
-        return "Global";
-    }
-
-    /**
-     * Returns the value of the named property or NOT_FOUND.
-     *
-     * If the property was created using defineProperty, the
-     * appropriate getter method is called.
-     *
-     * @param name the name of the property
-     * @param start the object in which the lookup began
-     * @return the value of the property (may be null), or NOT_FOUND
-     */
-    public synchronized Object get(String name, Scriptable start) {
-        if (isEmpty(name)) {
-            if (indexedProps.containsKey(name)) {
-                return indexedProps.get(name);
-            } else {
-                return NOT_FOUND;
-            }
-        } else {
-            synchronized (context) {
-                int scope = context.getAttributesScope(name);
-                if (scope != -1) {
-                    Object value = context.getAttribute(name, scope);
-                    return Context.javaToJS(value, this);
-                } else {
-                    return NOT_FOUND;
-                }
-            }
-        }
-    }
-
-    /**
-     * Returns the value of the indexed property or NOT_FOUND.
-     *
-     * @param index the numeric index for the property
-     * @param start the object in which the lookup began
-     * @return the value of the property (may be null), or NOT_FOUND
-     */
-    public synchronized Object get(int index, Scriptable start) {
-        Integer key = new Integer(index);
-        if (indexedProps.containsKey(index)) {
-            return indexedProps.get(key);
-        } else {
-            return NOT_FOUND;
-        }
-    }
-
-    /**
-     * Returns true if the named property is defined.
-     *
-     * @param name the name of the property
-     * @param start the object in which the lookup began
-     * @return true if and only if the property was found in the object
-     */
-    public synchronized boolean has(String name, Scriptable start) {
-        if (isEmpty(name)) {
-            return indexedProps.containsKey(name);
-        } else {
-            synchronized (context) {
-                return context.getAttributesScope(name) != -1;
-            }
-        }
-    }
-
-    /**
-     * Returns true if the property index is defined.
-     *
-     * @param index the numeric index for the property
-     * @param start the object in which the lookup began
-     * @return true if and only if the property was found in the object
-     */
-    public synchronized boolean has(int index, Scriptable start) {
-        Integer key = new Integer(index);
-        return indexedProps.containsKey(key);
-    }
-
-    /**
-     * Sets the value of the named property, creating it if need be.
-     *
-     * @param name the name of the property
-     * @param start the object whose property is being set
-     * @param value value to set the property to
-     */
-    public void put(String name, Scriptable start, Object value) {
-        if (start == this) {
-            synchronized (this) {
-                if (isEmpty(name)) {
-                    indexedProps.put(name, value);
-                } else {
-                    synchronized (context) {
-                        int scope = context.getAttributesScope(name);
-                        if (scope == -1) {
-                            scope = ScriptContext.ENGINE_SCOPE;
-                        }
-                        context.setAttribute(name, jsToJava(value), scope);
-                    }
-                }
-            }
-        } else {
-            start.put(name, start, value);
-        }
-    }
-
-    /**
-     * Sets the value of the indexed property, creating it if need be.
-     *
-     * @param index the numeric index for the property
-     * @param start the object whose property is being set
-     * @param value value to set the property to
-     */
-    public void put(int index, Scriptable start, Object value) {
-        if (start == this) {
-            synchronized (this) {
-                indexedProps.put(new Integer(index), value);
-            }
-        } else {
-            start.put(index, start, value);
-        }
-    }
-
-    /**
-     * Removes a named property from the object.
-     *
-     * If the property is not found, no action is taken.
-     *
-     * @param name the name of the property
-     */
-    public synchronized void delete(String name) {
-        if (isEmpty(name)) {
-            indexedProps.remove(name);
-        } else {
-            synchronized (context) {
-                int scope = context.getAttributesScope(name);
-                if (scope != -1) {
-                    context.removeAttribute(name, scope);
-                }
-            }
-        }
-    }
-
-    /**
-     * Removes the indexed property from the object.
-     *
-     * If the property is not found, no action is taken.
-     *
-     * @param index the numeric index for the property
-     */
-    public void delete(int index) {
-        indexedProps.remove(new Integer(index));
-    }
-
-    /**
-     * Get the prototype of the object.
-     * @return the prototype
-     */
-    public Scriptable getPrototype() {
-        return prototype;
-    }
-
-    /**
-     * Set the prototype of the object.
-     * @param prototype the prototype to set
-     */
-    public void setPrototype(Scriptable prototype) {
-        this.prototype = prototype;
-    }
-
-    /**
-     * Get the parent scope of the object.
-     * @return the parent scope
-     */
-    public Scriptable getParentScope() {
-        return parent;
-    }
-
-    /**
-     * Set the parent scope of the object.
-     * @param parent the parent scope to set
-     */
-    public void setParentScope(Scriptable parent) {
-        this.parent = parent;
-    }
-
-     /**
-     * Get an array of property ids.
-     *
-     * Not all property ids need be returned. Those properties
-     * whose ids are not returned are considered non-enumerable.
-     *
-     * @return an array of Objects. Each entry in the array is either
-     *         a java.lang.String or a java.lang.Number
-     */
-    public synchronized Object[] getIds() {
-        String[] keys = getAllKeys();
-        int size = keys.length + indexedProps.size();
-        Object[] res = new Object[size];
-        System.arraycopy(keys, 0, res, 0, keys.length);
-        int i = keys.length;
-        // now add all indexed properties
-        for (Object index : indexedProps.keySet()) {
-            res[i++] = index;
-        }
-        return res;
-    }
-
-    /**
-     * Get the default value of the object with a given hint.
-     * The hints are String.class for type String, Number.class for type
-     * Number, Scriptable.class for type Object, and Boolean.class for
-     * type Boolean. <p>
-     *
-     * A <code>hint</code> of null means "no hint".
-     *
-     * See ECMA 8.6.2.6.
-     *
-     * @param hint the type hint
-     * @return the default value
-     */
-    public Object getDefaultValue(Class typeHint) {
-        for (int i=0; i < 2; i++) {
-            boolean tryToString;
-            if (typeHint == ScriptRuntime.StringClass) {
-                tryToString = (i == 0);
-            } else {
-                tryToString = (i == 1);
-            }
-
-            String methodName;
-            Object[] args;
-            if (tryToString) {
-                methodName = "toString";
-                args = ScriptRuntime.emptyArgs;
-            } else {
-                methodName = "valueOf";
-                args = new Object[1];
-                String hint;
-                if (typeHint == null) {
-                    hint = "undefined";
-                } else if (typeHint == ScriptRuntime.StringClass) {
-                    hint = "string";
-                } else if (typeHint == ScriptRuntime.ScriptableClass) {
-                    hint = "object";
-                } else if (typeHint == ScriptRuntime.FunctionClass) {
-                    hint = "function";
-                } else if (typeHint == ScriptRuntime.BooleanClass
-                           || typeHint == Boolean.TYPE)
-                {
-                    hint = "boolean";
-                } else if (typeHint == ScriptRuntime.NumberClass ||
-                         typeHint == ScriptRuntime.ByteClass ||
-                         typeHint == Byte.TYPE ||
-                         typeHint == ScriptRuntime.ShortClass ||
-                         typeHint == Short.TYPE ||
-                         typeHint == ScriptRuntime.IntegerClass ||
-                         typeHint == Integer.TYPE ||
-                         typeHint == ScriptRuntime.FloatClass ||
-                         typeHint == Float.TYPE ||
-                         typeHint == ScriptRuntime.DoubleClass ||
-                         typeHint == Double.TYPE)
-                {
-                    hint = "number";
-                } else {
-                    throw Context.reportRuntimeError(
-                        "Invalid JavaScript value of type " +
-                        typeHint.toString());
-                }
-                args[0] = hint;
-            }
-            Object v = ScriptableObject.getProperty(this, methodName);
-            if (!(v instanceof Function))
-                continue;
-            Function fun = (Function) v;
-            Context cx = RhinoScriptEngine.enterContext();
-            try {
-                v = fun.call(cx, fun.getParentScope(), this, args);
-            } finally {
-                cx.exit();
-            }
-            if (v != null) {
-                if (!(v instanceof Scriptable)) {
-                    return v;
-                }
-                if (typeHint == ScriptRuntime.ScriptableClass
-                    || typeHint == ScriptRuntime.FunctionClass)
-                {
-                    return v;
-                }
-                if (tryToString && v instanceof Wrapper) {
-                    // Let a wrapped java.lang.String pass for a primitive
-                    // string.
-                    Object u = ((Wrapper)v).unwrap();
-                    if (u instanceof String)
-                        return u;
-                }
-            }
-        }
-        // fall through to error
-        String arg = (typeHint == null) ? "undefined" : typeHint.getName();
-        throw Context.reportRuntimeError(
-                  "Cannot find default value for object " + arg);
-    }
-
-    /**
-     * Implements the instanceof operator.
-     *
-     * @param instance The value that appeared on the LHS of the instanceof
-     *              operator
-     * @return true if "this" appears in value's prototype chain
-     *
-     */
-    public boolean hasInstance(Scriptable instance) {
-        // Default for JS objects (other than Function) is to do prototype
-        // chasing.
-        Scriptable proto = instance.getPrototype();
-        while (proto != null) {
-            if (proto.equals(this)) return true;
-            proto = proto.getPrototype();
-        }
-        return false;
-    }
-
-    private String[] getAllKeys() {
-        ArrayList<String> list = new ArrayList<String>();
-        synchronized (context) {
-            for (int scope : context.getScopes()) {
-                Bindings bindings = context.getBindings(scope);
-                if (bindings != null) {
-                    list.ensureCapacity(bindings.size());
-                    for (String key : bindings.keySet()) {
-                        list.add(key);
-                    }
-                }
-            }
-        }
-        String[] res = new String[list.size()];
-        list.toArray(res);
-        return res;
-    }
-
-   /**
-    * We convert script values to the nearest Java value.
-    * We unwrap wrapped Java objects so that access from
-    * Bindings.get() would return "workable" value for Java.
-    * But, at the same time, we need to make few special cases
-    * and hence the following function is used.
-    */
-    private Object jsToJava(Object jsObj) {
-        if (jsObj instanceof Wrapper) {
-            Wrapper njb = (Wrapper) jsObj;
-            /* importClass feature of ImporterTopLevel puts
-             * NativeJavaClass in global scope. If we unwrap
-             * it, importClass won't work.
-             */
-            if (njb instanceof NativeJavaClass) {
-                return njb;
-            }
-
-            /* script may use Java primitive wrapper type objects
-             * (such as java.lang.Integer, java.lang.Boolean etc)
-             * explicitly. If we unwrap, then these script objects
-             * will become script primitive types. For example,
-             *
-             *    var x = new java.lang.Double(3.0); print(typeof x);
-             *
-             * will print 'number'. We don't want that to happen.
-             */
-            Object obj = njb.unwrap();
-            if (obj instanceof Number || obj instanceof String ||
-                obj instanceof Boolean || obj instanceof Character) {
-                // special type wrapped -- we just leave it as is.
-                return njb;
-            } else {
-                // return unwrapped object for any other object.
-                return obj;
-            }
-        } else { // not-a-Java-wrapper
-            return jsObj;
-        }
-    }
-}
--- a/src/share/classes/com/sun/script/javascript/JSAdapter.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2005, 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 com.sun.script.javascript;
-
-import sun.org.mozilla.javascript.internal.*;
-import java.util.*;
-
-/**
- * JSAdapter is java.lang.reflect.Proxy equivalent for JavaScript. JSAdapter
- * calls specially named JavaScript methods on an adaptee object when property
- * access is attempted on it.
- *
- * Example:
- *
- *    var y = {
- *                __get__    : function (name) { ... }
- *                __has__    : function (name) { ... }
- *                __put__    : function (name, value) {...}
- *                __delete__ : function (name) { ... }
- *                __getIds__ : function () { ... }
- *            };
- *
- *    var x = new JSAdapter(y);
- *
- *    x.i;                        // calls y.__get__
- *    i in x;                     // calls y.__has__
- *    x.p = 10;                   // calls y.__put__
- *    delete x.p;                 // calls y.__delete__
- *    for (i in x) { print(i); }  // calls y.__getIds__
- *
- * If a special JavaScript method is not found in the adaptee, then JSAdapter
- * forwards the property access to the adaptee itself.
- *
- * JavaScript caller of adapter object is isolated from the fact that
- * the property access/mutation/deletion are really calls to
- * JavaScript methods on adaptee.  Use cases include 'smart'
- * properties, property access tracing/debugging, encaptulation with
- * easy client access - in short JavaScript becomes more "Self" like.
- *
- * Note that Rhino already supports special properties like __proto__
- * (to set, get prototype), __parent__ (to set, get parent scope). We
- * follow the same double underscore nameing convention here. Similarly
- * the name JSAdapter is derived from JavaAdapter -- which is a facility
- * to extend, implement Java classes/interfaces by JavaScript.
- *
- * @author A. Sundararajan
- * @since 1.6
- */
-public final class JSAdapter implements Scriptable, Function {
-    private JSAdapter(Scriptable obj) {
-        setAdaptee(obj);
-    }
-
-    // initializer to setup JSAdapter prototype in the given scope
-    public static void init(Context cx, Scriptable scope, boolean sealed)
-    throws RhinoException {
-        JSAdapter obj = new JSAdapter(cx.newObject(scope));
-        obj.setParentScope(scope);
-        obj.setPrototype(getFunctionPrototype(scope));
-        obj.isPrototype = true;
-        ScriptableObject.defineProperty(scope, "JSAdapter",  obj,
-                ScriptableObject.DONTENUM);
-    }
-
-    public String getClassName() {
-        return "JSAdapter";
-    }
-
-    public Object get(String name, Scriptable start) {
-        Function func = getAdapteeFunction(GET_PROP);
-        if (func != null) {
-            return call(func, new Object[] { name });
-        } else {
-            start = getAdaptee();
-            return start.get(name, start);
-        }
-    }
-
-    public Object get(int index, Scriptable start) {
-        Function func = getAdapteeFunction(GET_PROP);
-        if (func != null) {
-            return call(func, new Object[] { new Integer(index) });
-        } else {
-            start = getAdaptee();
-            return start.get(index, start);
-        }
-    }
-
-    public boolean has(String name, Scriptable start) {
-        Function func = getAdapteeFunction(HAS_PROP);
-        if (func != null) {
-            Object res = call(func, new Object[] { name });
-            return Context.toBoolean(res);
-        } else {
-            start = getAdaptee();
-            return start.has(name, start);
-        }
-    }
-
-    public boolean has(int index, Scriptable start) {
-        Function func = getAdapteeFunction(HAS_PROP);
-        if (func != null) {
-            Object res = call(func, new Object[] { new Integer(index) });
-            return Context.toBoolean(res);
-        } else {
-            start = getAdaptee();
-            return start.has(index, start);
-        }
-    }
-
-    public void put(String name, Scriptable start, Object value) {
-        if (start == this) {
-            Function func = getAdapteeFunction(PUT_PROP);
-            if (func != null) {
-                call(func, new Object[] { name, value });
-            } else {
-                start = getAdaptee();
-                start.put(name, start, value);
-            }
-        } else {
-            start.put(name, start, value);
-        }
-    }
-
-    public void put(int index, Scriptable start, Object value) {
-        if (start == this) {
-            Function func = getAdapteeFunction(PUT_PROP);
-            if( func != null) {
-                call(func, new Object[] { new Integer(index), value });
-            } else {
-                start = getAdaptee();
-                start.put(index, start, value);
-            }
-        } else {
-            start.put(index, start, value);
-        }
-    }
-
-    public void delete(String name) {
-        Function func = getAdapteeFunction(DEL_PROP);
-        if (func != null) {
-            call(func, new Object[] { name });
-        } else {
-            getAdaptee().delete(name);
-        }
-    }
-
-    public void delete(int index) {
-        Function func = getAdapteeFunction(DEL_PROP);
-        if (func != null) {
-            call(func, new Object[] { new Integer(index) });
-        } else {
-            getAdaptee().delete(index);
-        }
-    }
-
-    public Scriptable getPrototype() {
-        return prototype;
-    }
-
-    public void setPrototype(Scriptable prototype) {
-        this.prototype = prototype;
-    }
-
-    public Scriptable getParentScope() {
-        return parent;
-    }
-
-    public void setParentScope(Scriptable parent) {
-        this.parent = parent;
-    }
-
-    public Object[] getIds() {
-        Function func = getAdapteeFunction(GET_PROPIDS);
-        if (func != null) {
-            Object val = call(func, new Object[0]);
-            // in most cases, adaptee would return native JS array
-            if (val instanceof NativeArray) {
-                NativeArray array = (NativeArray) val;
-                Object[] res = new Object[(int)array.getLength()];
-                for (int index = 0; index < res.length; index++) {
-                    res[index] = mapToId(array.get(index, array));
-                }
-                return res;
-            } else if (val instanceof NativeJavaArray) {
-                // may be attempt wrapped Java array
-                Object tmp = ((NativeJavaArray)val).unwrap();
-                Object[] res;
-                if (tmp.getClass() == Object[].class) {
-                    Object[]  array = (Object[]) tmp;
-                    res = new Object[array.length];
-                    for (int index = 0; index < array.length; index++) {
-                        res[index] = mapToId(array[index]);
-                    }
-                } else {
-                    // just return an empty array
-                    res = Context.emptyArgs;
-                }
-                return res;
-            } else {
-                // some other return type, just return empty array
-                return Context.emptyArgs;
-            }
-        } else {
-            return getAdaptee().getIds();
-        }
-    }
-
-    public boolean hasInstance(Scriptable scriptable) {
-        if (scriptable instanceof JSAdapter) {
-            return true;
-        } else {
-            Scriptable proto = scriptable.getPrototype();
-            while (proto != null) {
-                if (proto.equals(this)) return true;
-                proto = proto.getPrototype();
-            }
-            return false;
-        }
-    }
-
-    public Object getDefaultValue(Class hint) {
-        return getAdaptee().getDefaultValue(hint);
-    }
-
-    public Object call(Context cx, Scriptable scope, Scriptable thisObj,
-            Object[] args)
-            throws RhinoException {
-        if (isPrototype) {
-            return construct(cx, scope, args);
-        } else {
-            Scriptable tmp = getAdaptee();
-            if (tmp instanceof Function) {
-                return ((Function)tmp).call(cx, scope, tmp, args);
-            } else {
-                throw Context.reportRuntimeError("TypeError: not a function");
-            }
-        }
-    }
-
-    public Scriptable construct(Context cx, Scriptable scope, Object[] args)
-    throws RhinoException {
-        if (isPrototype) {
-            Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
-            JSAdapter newObj;
-            if (args.length > 0) {
-                newObj = new JSAdapter(Context.toObject(args[0], topLevel));
-            } else {
-                throw Context.reportRuntimeError("JSAdapter requires adaptee");
-            }
-            return newObj;
-        } else {
-            Scriptable tmp = getAdaptee();
-            if (tmp instanceof Function) {
-                return ((Function)tmp).construct(cx, scope, args);
-            } else {
-                throw Context.reportRuntimeError("TypeError: not a constructor");
-            }
-        }
-    }
-
-    public Scriptable getAdaptee() {
-        return adaptee;
-    }
-
-    public void setAdaptee(Scriptable adaptee) {
-        if (adaptee == null) {
-            throw new NullPointerException("adaptee can not be null");
-        }
-        this.adaptee = adaptee;
-    }
-
-    //-- internals only below this point
-
-    // map a property id. Property id can only be an Integer or String
-    private Object mapToId(Object tmp) {
-        if (tmp instanceof Double) {
-            return new Integer(((Double)tmp).intValue());
-        } else {
-            return Context.toString(tmp);
-        }
-    }
-
-    private static Scriptable getFunctionPrototype(Scriptable scope) {
-        return ScriptableObject.getFunctionPrototype(scope);
-    }
-
-    private Function getAdapteeFunction(String name) {
-        Object o = ScriptableObject.getProperty(getAdaptee(), name);
-        return (o instanceof Function)? (Function)o : null;
-    }
-
-    private Object call(Function func, Object[] args) {
-        Context cx = Context.getCurrentContext();
-        Scriptable thisObj = getAdaptee();
-        Scriptable scope = func.getParentScope();
-        try {
-            return func.call(cx, scope, thisObj, args);
-        } catch (RhinoException re) {
-            throw Context.reportRuntimeError(re.getMessage());
-        }
-    }
-
-    private Scriptable prototype;
-    private Scriptable parent;
-    private Scriptable adaptee;
-    private boolean isPrototype;
-
-    // names of adaptee JavaScript functions
-    private static final String GET_PROP = "__get__";
-    private static final String HAS_PROP = "__has__";
-    private static final String PUT_PROP = "__put__";
-    private static final String DEL_PROP = "__delete__";
-    private static final String GET_PROPIDS = "__getIds__";
-}
--- a/src/share/classes/com/sun/script/javascript/JavaAdapter.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2005, 2006, 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 com.sun.script.javascript;
-
-import javax.script.Invocable;
-import sun.org.mozilla.javascript.internal.*;
-
-/**
- * This class implements Rhino-like JavaAdapter to help implement a Java
- * interface in JavaScript. We support this using Invocable.getInterface.
- * Using this JavaAdapter, script author could write:
- *
- *    var r = new java.lang.Runnable() {
- *                run: function() { script... }
- *            };
- *
- *    r.run();
- *    new java.lang.Thread(r).start();
- *
- * Note that Rhino's JavaAdapter support allows extending a Java class and/or
- * implementing one or more interfaces. This JavaAdapter implementation does
- * not support these.
- *
- * @author A. Sundararajan
- * @since 1.6
- */
-final class JavaAdapter extends ScriptableObject implements Function {
-    private JavaAdapter(Invocable engine) {
-        this.engine = engine;
-    }
-
-    static void init(Context cx, Scriptable scope, boolean sealed)
-    throws RhinoException {
-        RhinoTopLevel topLevel = (RhinoTopLevel) scope;
-        Invocable engine = topLevel.getScriptEngine();
-        JavaAdapter obj = new JavaAdapter(engine);
-        obj.setParentScope(scope);
-        obj.setPrototype(getFunctionPrototype(scope));
-        /*
-         * Note that we can't use defineProperty. A property of this
-         * name is already defined in Context.initStandardObjects. We
-         * simply overwrite the property value!
-         */
-        ScriptableObject.putProperty(topLevel, "JavaAdapter", obj);
-    }
-
-    public String getClassName() {
-        return "JavaAdapter";
-    }
-
-    public Object call(Context cx, Scriptable scope, Scriptable thisObj,
-            Object[] args) throws RhinoException {
-        return construct(cx, scope, args);
-    }
-
-    public Scriptable construct(Context cx, Scriptable scope, Object[] args)
-    throws RhinoException {
-        if (args.length == 2) {
-            Class<?> clazz = null;
-            Object obj1 = args[0];
-            if (obj1 instanceof Wrapper) {
-                Object o = ((Wrapper)obj1).unwrap();
-                if (o instanceof Class && ((Class)o).isInterface()) {
-                    clazz = (Class) o;
-                }
-            } else if (obj1 instanceof Class) {
-                if (((Class)obj1).isInterface()) {
-                    clazz = (Class) obj1;
-                }
-            }
-            if (clazz == null) {
-                throw Context.reportRuntimeError("JavaAdapter: first arg should be interface Class");
-            }
-
-            Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
-            return cx.toObject(engine.getInterface(args[1],  clazz), topLevel);
-        } else {
-            throw Context.reportRuntimeError("JavaAdapter requires two arguments");
-        }
-    }
-
-    private Invocable engine;
-}
--- a/src/share/classes/com/sun/script/javascript/META-INF/services/javax.script.ScriptEngineFactory	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-
-#script engines supported
-
-com.sun.script.javascript.RhinoScriptEngineFactory #javascript
-
--- a/src/share/classes/com/sun/script/javascript/RhinoClassShutter.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2005, 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 com.sun.script.javascript;
-
-import java.util.*;
-import sun.org.mozilla.javascript.internal.*;
-
-/**
- * This class prevents script access to certain sensitive classes.
- * Note that this class checks over and above SecurityManager. i.e., although
- * a SecurityManager would pass, class shutter may still prevent access.
- *
- * @author A. Sundararajan
- * @since 1.6
- */
-final class RhinoClassShutter implements ClassShutter {
-    private static Map<String, Boolean> protectedClasses;
-    private static RhinoClassShutter theInstance;
-
-    private RhinoClassShutter() {
-    }
-
-    static synchronized ClassShutter getInstance() {
-        if (theInstance == null) {
-            theInstance = new RhinoClassShutter();
-            protectedClasses = new HashMap<String, Boolean>();
-
-            // For now, we just have AccessController. Allowing scripts
-            // to this class will allow it to execute doPrivileged in
-            // bootstrap context. We can add more classes for other reasons.
-            protectedClasses.put("java.security.AccessController", Boolean.TRUE);
-        }
-        return theInstance;
-    }
-
-    public boolean visibleToScripts(String fullClassName) {
-        // first do the security check.
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            int i = fullClassName.lastIndexOf(".");
-            if (i != -1) {
-                try {
-                    sm.checkPackageAccess(fullClassName.substring(0, i));
-                } catch (SecurityException se) {
-                    return false;
-                }
-            }
-        }
-        // now, check is it a protected class.
-        return protectedClasses.get(fullClassName) == null;
-    }
-}
--- a/src/share/classes/com/sun/script/javascript/RhinoCompiledScript.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2005, 2006, 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 com.sun.script.javascript;
-import javax.script.*;
-import sun.org.mozilla.javascript.internal.*;
-
-/**
- * Represents compiled JavaScript code.
- *
- * @author Mike Grogan
- * @since 1.6
- */
-final class RhinoCompiledScript extends CompiledScript {
-
-    private RhinoScriptEngine engine;
-    private Script script;
-
-
-    RhinoCompiledScript(RhinoScriptEngine engine, Script script) {
-        this.engine = engine;
-        this.script = script;
-    }
-
-    public Object eval(ScriptContext context) throws ScriptException {
-
-        Object result = null;
-        Context cx = RhinoScriptEngine.enterContext();
-        try {
-
-            Scriptable scope = engine.getRuntimeScope(context);
-            Object ret = script.exec(cx, scope);
-            result = engine.unwrapReturnValue(ret);
-        } catch (RhinoException re) {
-            int line = (line = re.lineNumber()) == 0 ? -1 : line;
-            String msg;
-            if (re instanceof JavaScriptException) {
-                msg = String.valueOf(((JavaScriptException)re).getValue());
-            } else {
-                msg = re.toString();
-            }
-            ScriptException se = new ScriptException(msg, re.sourceName(), line);
-            se.initCause(re);
-            throw se;
-        } finally {
-            Context.exit();
-        }
-
-        return result;
-    }
-
-    public ScriptEngine getEngine() {
-        return engine;
-    }
-
-}
--- a/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,398 +0,0 @@
-/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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 com.sun.script.javascript;
-import com.sun.script.util.*;
-import javax.script.*;
-import sun.org.mozilla.javascript.internal.*;
-import java.lang.reflect.Method;
-import java.io.*;
-import java.util.*;
-
-
-/**
- * Implementation of <code>ScriptEngine</code> using the Mozilla Rhino
- * interpreter.
- *
- * @author Mike Grogan
- * @author A. Sundararajan
- * @since 1.6
- */
-public final class RhinoScriptEngine extends AbstractScriptEngine
-        implements  Invocable, Compilable {
-
-    private static final boolean DEBUG = false;
-
-    /* Scope where standard JavaScript objects and our
-     * extensions to it are stored. Note that these are not
-     * user defined engine level global variables. These are
-     * variables have to be there on all compliant ECMAScript
-     * scopes. We put these standard objects in this top level.
-     */
-    private RhinoTopLevel topLevel;
-
-    /* map used to store indexed properties in engine scope
-     * refer to comment on 'indexedProps' in ExternalScriptable.java.
-     */
-    private Map<Object, Object> indexedProps;
-
-    private ScriptEngineFactory factory;
-    private InterfaceImplementor implementor;
-
-    private static final int languageVersion = getLanguageVersion();
-    private static final int optimizationLevel = getOptimizationLevel();
-    static {
-        ContextFactory.initGlobal(new ContextFactory() {
-            protected Context makeContext() {
-                Context cx = super.makeContext();
-                cx.setLanguageVersion(languageVersion);
-                cx.setOptimizationLevel(optimizationLevel);
-                cx.setClassShutter(RhinoClassShutter.getInstance());
-                cx.setWrapFactory(RhinoWrapFactory.getInstance());
-                return cx;
-            }
-        });
-    }
-
-    private static final String RHINO_JS_VERSION = "rhino.js.version";
-    private static int getLanguageVersion() {
-        int version;
-        String tmp = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction(RHINO_JS_VERSION));
-        if (tmp != null) {
-            version = Integer.parseInt((String)tmp);
-        } else {
-            version = Context.VERSION_1_8;
-        }
-        return version;
-    }
-
-    private static final String RHINO_OPT_LEVEL = "rhino.opt.level";
-    private static int getOptimizationLevel() {
-        int optLevel = -1;
-        // disable optimizer under security manager, for now.
-        if (System.getSecurityManager() == null) {
-            optLevel = Integer.getInteger(RHINO_OPT_LEVEL, -1);
-        }
-        return optLevel;
-    }
-
-    /**
-     * Creates a new instance of RhinoScriptEngine
-     */
-    public RhinoScriptEngine() {
-
-        Context cx = enterContext();
-        try {
-            topLevel = new RhinoTopLevel(cx, this);
-        } finally {
-            cx.exit();
-        }
-
-        indexedProps = new HashMap<Object, Object>();
-
-        //construct object used to implement getInterface
-        implementor = new InterfaceImplementor(this) {
-                protected boolean isImplemented(Object thiz, Class<?> iface) {
-                    Context cx = enterContext();
-                    try {
-                        if (thiz != null && !(thiz instanceof Scriptable)) {
-                            thiz = cx.toObject(thiz, topLevel);
-                        }
-                        Scriptable engineScope = getRuntimeScope(context);
-                        Scriptable localScope = (thiz != null)? (Scriptable) thiz :
-                                                    engineScope;
-                        for (Method method : iface.getMethods()) {
-                            // ignore methods of java.lang.Object class
-                            if (method.getDeclaringClass() == Object.class) {
-                                continue;
-                            }
-                            Object obj = ScriptableObject.getProperty(localScope, method.getName());
-                            if (! (obj instanceof Function)) {
-                                return false;
-                            }
-                        }
-                        return true;
-                    } finally {
-                        cx.exit();
-                    }
-                }
-
-                protected Object convertResult(Method method, Object res)
-                                            throws ScriptException {
-                    Class desiredType = method.getReturnType();
-                    if (desiredType == Void.TYPE) {
-                        return null;
-                    } else {
-                        return Context.jsToJava(res, desiredType);
-                    }
-                }
-            };
-    }
-
-    public Object eval(Reader reader, ScriptContext ctxt)
-    throws ScriptException {
-        Object ret;
-
-        Context cx = enterContext();
-        try {
-            Scriptable scope = getRuntimeScope(ctxt);
-            String filename = (String) get(ScriptEngine.FILENAME);
-            filename = filename == null ? "<Unknown source>" : filename;
-
-            ret = cx.evaluateReader(scope, reader, filename , 1,  null);
-        } catch (RhinoException re) {
-            if (DEBUG) re.printStackTrace();
-            int line = (line = re.lineNumber()) == 0 ? -1 : line;
-            String msg;
-            if (re instanceof JavaScriptException) {
-                msg = String.valueOf(((JavaScriptException)re).getValue());
-            } else {
-                msg = re.toString();
-            }
-            ScriptException se = new ScriptException(msg, re.sourceName(), line);
-            se.initCause(re);
-            throw se;
-        } catch (IOException ee) {
-            throw new ScriptException(ee);
-        } finally {
-            cx.exit();
-        }
-
-        return unwrapReturnValue(ret);
-    }
-
-    public Object eval(String script, ScriptContext ctxt) throws ScriptException {
-        if (script == null) {
-            throw new NullPointerException("null script");
-        }
-        return eval(new StringReader(script) , ctxt);
-    }
-
-    public ScriptEngineFactory getFactory() {
-        if (factory != null) {
-            return factory;
-        } else {
-            return new RhinoScriptEngineFactory();
-        }
-    }
-
-    public Bindings createBindings() {
-        return new SimpleBindings();
-    }
-
-    //Invocable methods
-    public Object invokeFunction(String name, Object... args)
-    throws ScriptException, NoSuchMethodException {
-        return invoke(null, name, args);
-    }
-
-    public Object invokeMethod(Object thiz, String name, Object... args)
-    throws ScriptException, NoSuchMethodException {
-        if (thiz == null) {
-            throw new IllegalArgumentException("script object can not be null");
-        }
-        return invoke(thiz, name, args);
-    }
-
-    private Object invoke(Object thiz, String name, Object... args)
-    throws ScriptException, NoSuchMethodException {
-        Context cx = enterContext();
-        try {
-            if (name == null) {
-                throw new NullPointerException("method name is null");
-            }
-
-            if (thiz != null && !(thiz instanceof Scriptable)) {
-                thiz = cx.toObject(thiz, topLevel);
-            }
-
-            Scriptable engineScope = getRuntimeScope(context);
-            Scriptable localScope = (thiz != null)? (Scriptable) thiz :
-                                                    engineScope;
-            Object obj = ScriptableObject.getProperty(localScope, name);
-            if (! (obj instanceof Function)) {
-                throw new NoSuchMethodException("no such method: " + name);
-            }
-
-            Function func = (Function) obj;
-            Scriptable scope = func.getParentScope();
-            if (scope == null) {
-                scope = engineScope;
-            }
-            Object result = func.call(cx, scope, localScope,
-                                      wrapArguments(args));
-            return unwrapReturnValue(result);
-        } catch (RhinoException re) {
-            if (DEBUG) re.printStackTrace();
-            int line = (line = re.lineNumber()) == 0 ? -1 : line;
-            ScriptException se = new ScriptException(re.toString(), re.sourceName(), line);
-            se.initCause(re);
-            throw se;
-        } finally {
-            cx.exit();
-        }
-    }
-
-    public <T> T getInterface(Class<T> clasz) {
-        try {
-            return implementor.getInterface(null, clasz);
-        } catch (ScriptException e) {
-            return null;
-        }
-    }
-
-    public <T> T getInterface(Object thiz, Class<T> clasz) {
-        if (thiz == null) {
-            throw new IllegalArgumentException("script object can not be null");
-        }
-
-        try {
-            return implementor.getInterface(thiz, clasz);
-        } catch (ScriptException e) {
-            return null;
-        }
-    }
-
-    private static final String printSource =
-            "function print(str, newline) {                \n" +
-            "    if (typeof(str) == 'undefined') {         \n" +
-            "        str = 'undefined';                    \n" +
-            "    } else if (str == null) {                 \n" +
-            "        str = 'null';                         \n" +
-            "    }                                         \n" +
-            "    var out = context.getWriter();            \n" +
-            "    if (!(out instanceof java.io.PrintWriter))\n" +
-            "        out = new java.io.PrintWriter(out);   \n" +
-            "    out.print(String(str));                   \n" +
-            "    if (newline) out.print('\\n');            \n" +
-            "    out.flush();                              \n" +
-            "}\n" +
-            "function println(str) {                       \n" +
-            "    print(str, true);                         \n" +
-            "}";
-
-    Scriptable getRuntimeScope(ScriptContext ctxt) {
-        if (ctxt == null) {
-            throw new NullPointerException("null script context");
-        }
-
-        // we create a scope for the given ScriptContext
-        Scriptable newScope = new ExternalScriptable(ctxt, indexedProps);
-
-        // Set the prototype of newScope to be 'topLevel' so that
-        // JavaScript standard objects are visible from the scope.
-        newScope.setPrototype(topLevel);
-
-        // define "context" variable in the new scope
-        newScope.put("context", newScope, ctxt);
-
-        // define "print", "println" functions in the new scope
-        Context cx = enterContext();
-        try {
-            cx.evaluateString(newScope, printSource, "print", 1, null);
-        } finally {
-            cx.exit();
-        }
-        return newScope;
-    }
-
-
-    //Compilable methods
-    public CompiledScript compile(String script) throws ScriptException {
-        return compile(new StringReader(script));
-    }
-
-    public CompiledScript compile(java.io.Reader script) throws ScriptException {
-        CompiledScript ret = null;
-        Context cx = enterContext();
-
-        try {
-            String fileName = (String) get(ScriptEngine.FILENAME);
-            if (fileName == null) {
-                fileName = "<Unknown Source>";
-            }
-
-            Scriptable scope = getRuntimeScope(context);
-            Script scr = cx.compileReader(scope, script, fileName, 1, null);
-            ret = new RhinoCompiledScript(this, scr);
-        } catch (Exception e) {
-            if (DEBUG) e.printStackTrace();
-            throw new ScriptException(e);
-        } finally {
-            cx.exit();
-        }
-        return ret;
-    }
-
-
-    //package-private helpers
-
-    static Context enterContext() {
-        // call this always so that initializer of this class runs
-        // and initializes custom wrap factory and class shutter.
-        return Context.enter();
-    }
-
-    void setEngineFactory(ScriptEngineFactory fac) {
-        factory = fac;
-    }
-
-    Object[] wrapArguments(Object[] args) {
-        if (args == null) {
-            return Context.emptyArgs;
-        }
-        Object[] res = new Object[args.length];
-        for (int i = 0; i < res.length; i++) {
-            res[i] = Context.javaToJS(args[i], topLevel);
-        }
-        return res;
-    }
-
-    Object unwrapReturnValue(Object result) {
-        if (result instanceof Wrapper) {
-            result = ( (Wrapper) result).unwrap();
-        }
-
-        return result instanceof Undefined ? null : result;
-    }
-
-    /*
-    public static void main(String[] args) throws Exception {
-        if (args.length == 0) {
-            System.out.println("No file specified");
-            return;
-        }
-
-        InputStreamReader r = new InputStreamReader(new FileInputStream(args[0]));
-        ScriptEngine engine = new RhinoScriptEngine();
-
-        engine.put("x", "y");
-        engine.put(ScriptEngine.FILENAME, args[0]);
-        engine.eval(r);
-        System.out.println(engine.get("x"));
-    }
-    */
-}
--- a/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
- * 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
- * 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 com.sun.script.javascript;
-import javax.script.*;
-import java.util.*;
-import sun.org.mozilla.javascript.internal.*;
-import com.sun.script.util.*;
-
-/**
- * Factory to create RhinoScriptEngine
- *
- * @author Mike Grogan
- * @since 1.6
- */
-public class RhinoScriptEngineFactory extends ScriptEngineFactoryBase {
-
-    public RhinoScriptEngineFactory() {
-    }
-
-    public List<String> getExtensions() {
-        return extensions;
-    }
-
-    public List<String> getMimeTypes() {
-        return mimeTypes;
-    }
-
-    public List<String> getNames() {
-        return names;
-    }
-
-    public Object getParameter(String key) {
-        if (key.equals(ScriptEngine.NAME)) {
-            return "javascript";
-        } else if (key.equals(ScriptEngine.ENGINE)) {
-            return "Mozilla Rhino";
-        } else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
-            return "1.7 release 3 PRERELEASE";
-        } else if (key.equals(ScriptEngine.LANGUAGE)) {
-            return "ECMAScript";
-        } else if (key.equals(ScriptEngine.LANGUAGE_VERSION)) {
-            return "1.8";
-        } else if (key.equals("THREADING")) {
-            return "MULTITHREADED";
-        } else {
-            throw new IllegalArgumentException("Invalid key");
-        }
-    }
-
-    public ScriptEngine getScriptEngine() {
-        RhinoScriptEngine ret = new RhinoScriptEngine();
-        ret.setEngineFactory(this);
-        return ret;
-    }
-
-    public String getMethodCallSyntax(String obj, String method, String... args) {
-
-        String ret = obj + "." + method + "(";
-        int len = args.length;
-        if (len == 0) {
-            ret += ")";
-            return ret;
-        }
-
-        for (int i = 0; i < len; i++) {
-            ret += args[i];
-            if (i != len - 1) {
-                ret += ",";
-            } else {
-                ret += ")";
-            }
-        }
-        return ret;
-    }
-
-    public String getOutputStatement(String toDisplay) {
-        StringBuffer buf = new StringBuffer();
-        int len = toDisplay.length();
-        buf.append("print(\"");
-        for (int i = 0; i < len; i++) {
-            char ch = toDisplay.charAt(i);
-            switch (ch) {
-            case '"':
-                buf.append("\\\"");
-                break;
-            case '\\':
-                buf.append("\\\\");
-                break;
-            default:
-                buf.append(ch);
-                break;
-            }
-        }
-        buf.append("\")");
-        return buf.toString();
-    }
-
-    public String getProgram(String... statements) {
-        int len = statements.length;
-        String ret = "";
-        for (int i = 0; i < len; i++) {
-            ret += statements[i] + ";";
-        }
-
-        return ret;
-    }
-
-    /*
-    public static void main(String[] args) {
-        RhinoScriptEngineFactory fact = new RhinoScriptEngineFactory();
-        System.out.println(fact.getParameter(ScriptEngine.ENGINE_VERSION));
-    }
-    */
-
-    private static List<String> names;
-    private static List<String> mimeTypes;
-    private static List<String> extensions;
-
-    static {
-        names = new ArrayList<String>(6);
-        names.add("js");
-        names.add("rhino");
-        names.add("JavaScript");
-        names.add("javascript");
-        names.add("ECMAScript");
-        names.add("ecmascript");
-        names = Collections.unmodifiableList(names);
-
-        mimeTypes = new ArrayList<String>(4);
-        mimeTypes.add("application/javascript");
-        mimeTypes.add("application/ecmascript");
-        mimeTypes.add("text/javascript");
-        mimeTypes.add("text/ecmascript");
-        mimeTypes = Collections.unmodifiableList(mimeTypes);
-
-        extensions = new ArrayList<String>(1);
-        extensions.add("js");
-        extensions = Collections.unmodifiableList(extensions);
-    }
-}
--- a/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-/*
- * 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
- * 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 com.sun.script.javascript;
-
-import sun.org.mozilla.javascript.internal.*;
-import javax.script.*;
-
-/**
- * This class serves as top level scope for Rhino. This class adds
- * 3 top level functions (bindings, scope, sync) and two constructors
- * (JSAdapter, JavaAdapter).
- *
- * @author A. Sundararajan
- * @since 1.6
- */
-public final class RhinoTopLevel extends ImporterTopLevel {
-    RhinoTopLevel(Context cx, RhinoScriptEngine engine) {
-        super(cx);
-        this.engine = engine;
-
-
-        // initialize JSAdapter lazily. Reduces footprint & startup time.
-        new LazilyLoadedCtor(this, "JSAdapter",
-                "com.sun.script.javascript.JSAdapter",
-                false);
-
-        /*
-         * initialize JavaAdapter. We can't lazy initialize this because
-         * lazy initializer attempts to define a new property. But, JavaAdapter
-         * is an exisiting property that we overwrite.
-         */
-        JavaAdapter.init(cx, this, false);
-
-        // add top level functions
-        String names[] = { "bindings", "scope", "sync"  };
-        defineFunctionProperties(names, RhinoTopLevel.class,
-                ScriptableObject.DONTENUM);
-    }
-
-    /**
-     * The bindings function takes a JavaScript scope object
-     * of type ExternalScriptable and returns the underlying Bindings
-     * instance.
-     *
-     *    var page = scope(pageBindings);
-     *    with (page) {
-     *       // code that uses page scope
-     *    }
-     *    var b = bindings(page);
-     *    // operate on bindings here.
-     */
-    public static Object bindings(Context cx, Scriptable thisObj, Object[] args,
-            Function funObj) {
-        if (args.length == 1) {
-            Object arg = args[0];
-            if (arg instanceof Wrapper) {
-                arg = ((Wrapper)arg).unwrap();
-            }
-            if (arg instanceof ExternalScriptable) {
-                ScriptContext ctx = ((ExternalScriptable)arg).getContext();
-                Bindings bind = ctx.getBindings(ScriptContext.ENGINE_SCOPE);
-                return Context.javaToJS(bind,
-                           ScriptableObject.getTopLevelScope(thisObj));
-            }
-        }
-        return cx.getUndefinedValue();
-    }
-
-    /**
-     * The scope function creates a new JavaScript scope object
-     * with given Bindings object as backing store. This can be used
-     * to create a script scope based on arbitrary Bindings instance.
-     * For example, in webapp scenario, a 'page' level Bindings instance
-     * may be wrapped as a scope and code can be run in JavaScripe 'with'
-     * statement:
-     *
-     *    var page = scope(pageBindings);
-     *    with (page) {
-     *       // code that uses page scope
-     *    }
-     */
-    public static Object scope(Context cx, Scriptable thisObj, Object[] args,
-            Function funObj) {
-        if (args.length == 1) {
-            Object arg = args[0];
-            if (arg instanceof Wrapper) {
-                arg = ((Wrapper)arg).unwrap();
-            }
-            if (arg instanceof Bindings) {
-                ScriptContext ctx = new SimpleScriptContext();
-                ctx.setBindings((Bindings)arg, ScriptContext.ENGINE_SCOPE);
-                Scriptable res = new ExternalScriptable(ctx);
-                res.setPrototype(ScriptableObject.getObjectPrototype(thisObj));
-                res.setParentScope(ScriptableObject.getTopLevelScope(thisObj));
-                return res;
-            }
-        }
-        return cx.getUndefinedValue();
-    }
-
-    /**
-     * The sync function creates a synchronized function (in the sense
-     * of a Java synchronized method) from an existing function. The
-     * new function synchronizes on the <code>this</code> object of
-     * its invocation.
-     * js> var o = { f : sync(function(x) {
-     *       print("entry");
-     *       Packages.java.lang.Thread.sleep(x*1000);
-     *       print("exit");
-     *     })};
-     * js> thread(function() {o.f(5);});
-     * entry
-     * js> thread(function() {o.f(5);});
-     * js>
-     * exit
-     * entry
-     * exit
-     */
-    public static Object sync(Context cx, Scriptable thisObj, Object[] args,
-            Function funObj) {
-        if (args.length == 1 && args[0] instanceof Function) {
-            return new Synchronizer((Function)args[0]);
-        } else {
-            throw Context.reportRuntimeError("wrong argument(s) for sync");
-        }
-    }
-
-    RhinoScriptEngine getScriptEngine() {
-        return engine;
-    }
-
-    private RhinoScriptEngine engine;
-}
--- a/src/share/classes/com/sun/script/javascript/RhinoWrapFactory.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2005, 2006, 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 com.sun.script.javascript;
-
-import java.lang.reflect.*;
-import static sun.security.util.SecurityConstants.*;
-import sun.org.mozilla.javascript.internal.*;
-
-/**
- * This wrap factory is used for security reasons. JSR 223 script
- * engine interface and JavaScript engine classes are run as bootstrap
- * classes. For example, java.lang.Class.forName method (when called without
- * class loader) uses caller's class loader. This may be exploited by script
- * authors to access classes otherwise not accessible. For example,
- * classes in sun.* namespace are normally not accessible to untrusted
- * code and hence should not be accessible to JavaScript run from
- * untrusted code.
- *
- * @author A. Sundararajan
- * @since 1.6
- */
-final class RhinoWrapFactory extends WrapFactory {
-    private RhinoWrapFactory() {}
-    private static RhinoWrapFactory theInstance;
-
-    static synchronized WrapFactory getInstance() {
-        if (theInstance == null) {
-            theInstance = new RhinoWrapFactory();
-        }
-        return theInstance;
-    }
-
-    // We use instance of this class to wrap security sensitive
-    // Java object. Please refer below.
-    private static class RhinoJavaObject extends NativeJavaObject {
-        RhinoJavaObject(Scriptable scope, Object obj, Class type) {
-            // we pass 'null' to object. NativeJavaObject uses
-            // passed 'type' to reflect fields and methods when
-            // object is null.
-            super(scope, null, type);
-
-            // Now, we set actual object. 'javaObject' is protected
-            // field of NativeJavaObject.
-            javaObject = obj;
-        }
-    }
-
-    public Scriptable wrapAsJavaObject(Context cx, Scriptable scope,
-            Object javaObject, Class staticType) {
-        SecurityManager sm = System.getSecurityManager();
-        ClassShutter classShutter = RhinoClassShutter.getInstance();
-        if (javaObject instanceof ClassLoader) {
-            // Check with Security Manager whether we can expose a
-            // ClassLoader...
-            if (sm != null) {
-                sm.checkPermission(GET_CLASSLOADER_PERMISSION);
-            }
-            // if we fall through here, check permission succeeded.
-            return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
-        } else {
-            String name = null;
-            if (javaObject instanceof Class) {
-                name = ((Class)javaObject).getName();
-            } else if (javaObject instanceof Member) {
-                Member member = (Member) javaObject;
-                // Check member access. Don't allow reflective access to
-                // non-public members. Note that we can't call checkMemberAccess
-                // because that expects exact stack depth!
-                if (sm != null && !Modifier.isPublic(member.getModifiers())) {
-                    return null;
-                }
-                name = member.getDeclaringClass().getName();
-            }
-            // Now, make sure that no ClassShutter prevented Class or Member
-            // of it is accessed reflectively. Note that ClassShutter may
-            // prevent access to a class, even though SecurityManager permit.
-            if (name != null) {
-                if (!classShutter.visibleToScripts(name)) {
-                    return null;
-                } else {
-                    return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
-                }
-            }
-        }
-
-        // we have got some non-reflective object.
-        Class dynamicType = javaObject.getClass();
-        String name = dynamicType.getName();
-        if (!classShutter.visibleToScripts(name)) {
-            // Object of some sensitive class (such as sun.net.www.*
-            // objects returned from public method of java.net.URL class.
-            // We expose this object as though it is an object of some
-            // super class that is safe for access.
-
-            Class type = null;
-
-            // Whenever a Java Object is wrapped, we are passed with a
-            // staticType which is the type found from environment. For
-            // example, method return type known from signature. The dynamic
-            // type would be the actual Class of the actual returned object.
-            // If the staticType is an interface, we just use that type.
-            if (staticType != null && staticType.isInterface()) {
-                type = staticType;
-            } else {
-                // dynamicType is always a class type and never an interface.
-                // find an accessible super class of the dynamic type.
-                while (dynamicType != null) {
-                    dynamicType = dynamicType.getSuperclass();
-                    name = dynamicType.getName();
-                    if (classShutter.visibleToScripts(name)) {
-                         type = dynamicType; break;
-                    }
-                }
-                // atleast java.lang.Object has to be accessible. So, when
-                // we reach here, type variable should not be null.
-                assert type != null:
-                       "even java.lang.Object is not accessible?";
-            }
-            // create custom wrapper with the 'safe' type.
-            return new RhinoJavaObject(scope, javaObject, type);
-        } else {
-            return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
-        }
-    }
-}
--- a/src/share/classes/com/sun/script/util/BindingsBase.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2005, 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 com.sun.script.util;
-
-import javax.script.Bindings;
-import java.util.Map;
-import java.util.AbstractMap;
-
-/**
- * Abstract super class for Bindings implementations
- *
- * @author Mike Grogan
- * @since 1.6
- */
-public abstract class BindingsBase extends AbstractMap<String, Object>
-        implements Bindings {
-
-    //AbstractMap methods
-    public Object get(Object name) {
-        checkKey(name);
-        return getImpl((String)name);
-    }
-
-    public Object remove(Object key) {
-        checkKey(key);
-        return removeImpl((String)key);
-    }
-
-    public Object put(String key, Object value) {
-        checkKey(key);
-        return putImpl(key, value);
-    }
-
-    public void putAll(Map<? extends String, ? extends Object> toMerge) {
-        for (Map.Entry<? extends String, ? extends Object> entry : toMerge.entrySet()) {
-            String key = entry.getKey();
-            checkKey(key);
-            putImpl(entry.getKey(), entry.getValue());
-        }
-    }
-
-    //BindingsBase methods
-    public abstract Object putImpl(String name, Object value);
-    public abstract Object getImpl(String name);
-    public abstract Object removeImpl(String name);
-    public abstract String[] getNames();
-
-    protected void checkKey(Object key) {
-        if (key == null) {
-            throw new NullPointerException("key can not be null");
-        }
-        if (!(key instanceof String)) {
-            throw new ClassCastException("key should be String");
-        }
-        if (key.equals("")) {
-            throw new IllegalArgumentException("key can not be empty");
-        }
-    }
-}
--- a/src/share/classes/com/sun/script/util/BindingsEntrySet.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2005, 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 com.sun.script.util;
-import java.util.*;
-
-/**
- * Entry set implementation for Bindings implementations
- *
- * @author Mike Grogan
- * @since 1.6
- */
-public class BindingsEntrySet extends AbstractSet<Map.Entry<String, Object>> {
-
-    private BindingsBase base;
-    private String[] keys;
-
-    public BindingsEntrySet(BindingsBase base) {
-        this.base = base;
-        keys = base.getNames();
-    }
-
-    public int size() {
-        return keys.length;
-    }
-
-    public Iterator<Map.Entry<String, Object>> iterator() {
-        return new BindingsIterator();
-    }
-
-    public class BindingsEntry implements Map.Entry<String, Object> {
-        private String key;
-        public BindingsEntry(String key) {
-            this.key = key;
-        }
-
-        public Object setValue(Object value) {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getKey() {
-            return key;
-        }
-
-        public Object getValue() {
-            return base.get(key);
-        }
-
-    }
-
-    public class BindingsIterator implements Iterator<Map.Entry<String, Object>> {
-
-        private int current = 0;
-        private boolean stale = false;
-
-        public boolean hasNext() {
-            return (current < keys.length);
-        }
-
-        public BindingsEntry next() {
-            stale = false;
-            return new BindingsEntry(keys[current++]);
-        }
-
-        public void remove() {
-            if (stale || current == 0) {
-                throw new IllegalStateException();
-            }
-
-            stale = true;
-            base.remove(keys[current - 1]);
-        }
-
-    }
-
-}
--- a/src/share/classes/com/sun/script/util/BindingsImpl.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2005, 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 com.sun.script.util;
-import java.util.*;
-import javax.script.Bindings;
-
-/*
- * Abstract super class for Bindings implementations. Handles
- * global and local scopes.
- *
- * @author Mike Grogan
- * @since 1.6
- */
-public abstract class BindingsImpl extends BindingsBase {
-
-    //get method delegates to global if key is not defined in
-    //base class or local scope
-    protected Bindings global = null;
-
-    //get delegates to local scope
-    protected Bindings local = null;
-
-    public void setGlobal(Bindings n) {
-        global = n;
-    }
-
-    public void setLocal(Bindings n) {
-        local = n;
-    }
-
-    public  Set<Map.Entry<String, Object>> entrySet() {
-        return new BindingsEntrySet(this);
-    }
-
-    public Object get(Object key) {
-        checkKey(key);
-
-        Object ret  = null;
-        if ((local != null) && (null != (ret = local.get(key)))) {
-            return ret;
-        }
-
-        ret = getImpl((String)key);
-
-        if (ret != null) {
-            return ret;
-        } else if (global != null) {
-            return global.get(key);
-        } else {
-            return null;
-        }
-    }
-
-    public Object remove(Object key) {
-        checkKey(key);
-        Object ret = get(key);
-        if (ret != null) {
-            removeImpl((String)key);
-        }
-        return ret;
-    }
-}
--- a/src/share/classes/com/sun/script/util/InterfaceImplementor.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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 com.sun.script.util;
-
-import javax.script.*;
-import java.lang.reflect.*;
-import java.security.*;
-
-/*
- * java.lang.reflect.Proxy based interface implementor. This is meant
- * to be used to implement Invocable.getInterface.
- *
- * @author Mike Grogan
- * @since 1.6
- */
-public class InterfaceImplementor {
-
-    private Invocable engine;
-
-    /** Creates a new instance of Invocable */
-    public InterfaceImplementor(Invocable engine) {
-        this.engine = engine;
-    }
-
-    private final class InterfaceImplementorInvocationHandler
-                        implements InvocationHandler {
-        private Object thiz;
-        private AccessControlContext accCtxt;
-
-        public InterfaceImplementorInvocationHandler(Object thiz,
-            AccessControlContext accCtxt) {
-            this.thiz = thiz;
-            this.accCtxt = accCtxt;
-        }
-
-        public Object invoke(Object proxy , Method method, Object[] args)
-        throws java.lang.Throwable {
-            // give chance to convert input args
-            args = convertArguments(method, args);
-            Object result;
-            final Method m = method;
-            final Object[] a = args;
-            result = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
-                public Object run() throws Exception {
-                    if (thiz == null) {
-                        return engine.invokeFunction(m.getName(), a);
-                    } else {
-                        return engine.invokeMethod(thiz, m.getName(), a);
-                    }
-                }
-            }, accCtxt);
-            // give chance to convert the method result
-            return convertResult(method, result);
-        }
-    }
-
-    public <T> T getInterface(Object thiz, Class<T> iface)
-    throws ScriptException {
-        if (iface == null || !iface.isInterface()) {
-            throw new IllegalArgumentException("interface Class expected");
-        }
-        if (! isImplemented(thiz, iface)) {
-            return null;
-        }
-        AccessControlContext accCtxt = AccessController.getContext();
-        return iface.cast(Proxy.newProxyInstance(iface.getClassLoader(),
-            new Class[]{iface},
-            new InterfaceImplementorInvocationHandler(thiz, accCtxt)));
-    }
-
-    protected boolean isImplemented(Object thiz, Class<?> iface) {
-        return true;
-    }
-
-    // called to convert method result after invoke
-    protected Object convertResult(Method method, Object res)
-                                   throws ScriptException {
-        // default is identity conversion
-        return res;
-    }
-
-    // called to convert method arguments before invoke
-    protected Object[] convertArguments(Method method, Object[] args)
-                                      throws ScriptException {
-        // default is identity conversion
-        return args;
-    }
-}
--- a/src/share/classes/com/sun/script/util/ScriptEngineFactoryBase.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2005, 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 com.sun.script.util;
-import javax.script.*;
-
-/*
- * Abstract super class for factory implementations.
- *
- * @author Mike Grogan
- * @since 1.6
- */
-public abstract class ScriptEngineFactoryBase implements ScriptEngineFactory {
-
-    public String getName() {
-        return (String)getParameter(ScriptEngine.NAME);
-    }
-
-    public String getEngineName() {
-        return (String)getParameter(ScriptEngine.ENGINE);
-    }
-
-    public String getEngineVersion() {
-        return (String)getParameter(ScriptEngine.ENGINE_VERSION);
-    }
-
-    public String getLanguageName() {
-        return (String)getParameter(ScriptEngine.LANGUAGE);
-    }
-
-    public String getLanguageVersion() {
-        return (String)getParameter(ScriptEngine.LANGUAGE_VERSION);
-    }
-}
--- a/src/share/classes/java/awt/Component.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/awt/Component.java	Mon May 13 16:52:33 2013 -0700
@@ -1051,11 +1051,11 @@
         return parent;
     }
 
-    // This method is overriden in the Window class to return null,
+    // This method is overridden in the Window class to return null,
     //    because the parent field of the Window object contains
     //    the owner of the window, not its parent.
     Container getContainer() {
-        return getParent();
+        return getParent_NoClientCode();
     }
 
     /**
@@ -8194,10 +8194,10 @@
      * Fetches the native container somewhere higher up in the component
      * tree that contains this component.
      */
-    Container getNativeContainer() {
-        Container p = parent;
+    final Container getNativeContainer() {
+        Container p = getContainer();
         while (p != null && p.peer instanceof LightweightPeer) {
-            p = p.getParent_NoClientCode();
+            p = p.getContainer();
         }
         return p;
     }
--- a/src/share/classes/java/awt/Window.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/awt/Window.java	Mon May 13 16:52:33 2013 -0700
@@ -3914,7 +3914,7 @@
 
     // ************************** MIXING CODE *******************************
 
-    // A window has a parent, but it does NOT have a container
+    // A window has an owner, but it does NOT have a container
     @Override
     final Container getContainer() {
         return null;
--- a/src/share/classes/java/beans/MetaData.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/beans/MetaData.java	Mon May 13 16:52:33 2013 -0700
@@ -69,8 +69,9 @@
  * @author Philip Milne
  * @author Steve Langley
  */
+class MetaData {
 
-class NullPersistenceDelegate extends PersistenceDelegate {
+static final class NullPersistenceDelegate extends PersistenceDelegate {
     // Note this will be called by all classes when they reach the
     // top of their superclass chain.
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
@@ -87,7 +88,7 @@
  *
  * @author Sergey A. Malenkov
  */
-class EnumPersistenceDelegate extends PersistenceDelegate {
+static final class EnumPersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance == newInstance;
     }
@@ -98,7 +99,7 @@
     }
 }
 
-class PrimitivePersistenceDelegate extends PersistenceDelegate {
+static final class PrimitivePersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -109,7 +110,7 @@
     }
 }
 
-class ArrayPersistenceDelegate extends PersistenceDelegate {
+static final class ArrayPersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return (newInstance != null &&
                 oldInstance.getClass() == newInstance.getClass() && // Also ensures the subtype is correct.
@@ -150,7 +151,7 @@
     }
 }
 
-class ProxyPersistenceDelegate extends PersistenceDelegate {
+static final class ProxyPersistenceDelegate extends PersistenceDelegate {
     protected Expression instantiate(Object oldInstance, Encoder out) {
         Class<?> type = oldInstance.getClass();
         java.lang.reflect.Proxy p = (java.lang.reflect.Proxy)oldInstance;
@@ -185,7 +186,7 @@
 }
 
 // Strings
-class java_lang_String_PersistenceDelegate extends PersistenceDelegate {
+static final class java_lang_String_PersistenceDelegate extends PersistenceDelegate {
     protected Expression instantiate(Object oldInstance, Encoder out) { return null; }
 
     public void writeObject(Object oldInstance, Encoder out) {
@@ -194,7 +195,7 @@
 }
 
 // Classes
-class java_lang_Class_PersistenceDelegate extends PersistenceDelegate {
+static final class java_lang_Class_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -228,7 +229,7 @@
 }
 
 // Fields
-class java_lang_reflect_Field_PersistenceDelegate extends PersistenceDelegate {
+static final class java_lang_reflect_Field_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -243,7 +244,7 @@
 }
 
 // Methods
-class java_lang_reflect_Method_PersistenceDelegate extends PersistenceDelegate {
+static final class java_lang_reflect_Method_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -267,7 +268,7 @@
  *
  * @author Sergey A. Malenkov
  */
-class java_util_Date_PersistenceDelegate extends PersistenceDelegate {
+static class java_util_Date_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         if (!super.mutatesTo(oldInstance, newInstance)) {
             return false;
@@ -290,7 +291,7 @@
  *
  * @author Sergey A. Malenkov
  */
-final class java_sql_Timestamp_PersistenceDelegate extends java_util_Date_PersistenceDelegate {
+static final class java_sql_Timestamp_PersistenceDelegate extends java_util_Date_PersistenceDelegate {
     private static final Method getNanosMethod = getNanosMethod();
 
     private static Method getNanosMethod() {
@@ -354,7 +355,7 @@
  *
  * @author Sergey A. Malenkov
  */
-abstract class java_util_Collections extends PersistenceDelegate {
+private static abstract class java_util_Collections extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         if (!super.mutatesTo(oldInstance, newInstance)) {
             return false;
@@ -367,6 +368,10 @@
         return (oldC.size() == newC.size()) && oldC.containsAll(newC);
     }
 
+    protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
+        // do not initialize these custom collections in default way
+    }
+
     static final class EmptyList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
             return new Expression(oldInstance, Collections.class, "emptyList", null);
@@ -569,7 +574,7 @@
  *
  * @author Sergey A. Malenkov
  */
-class java_util_EnumMap_PersistenceDelegate extends PersistenceDelegate {
+static final class java_util_EnumMap_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return super.mutatesTo(oldInstance, newInstance) && (getType(oldInstance) == getType(newInstance));
     }
@@ -588,7 +593,7 @@
  *
  * @author Sergey A. Malenkov
  */
-class java_util_EnumSet_PersistenceDelegate extends PersistenceDelegate {
+static final class java_util_EnumSet_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return super.mutatesTo(oldInstance, newInstance) && (getType(oldInstance) == getType(newInstance));
     }
@@ -603,7 +608,7 @@
 }
 
 // Collection
-class java_util_Collection_PersistenceDelegate extends DefaultPersistenceDelegate {
+static class java_util_Collection_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         java.util.Collection<?> oldO = (java.util.Collection)oldInstance;
         java.util.Collection<?> newO = (java.util.Collection)newInstance;
@@ -618,7 +623,7 @@
 }
 
 // List
-class java_util_List_PersistenceDelegate extends DefaultPersistenceDelegate {
+static class java_util_List_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         java.util.List<?> oldO = (java.util.List<?>)oldInstance;
         java.util.List<?> newO = (java.util.List<?>)newInstance;
@@ -653,7 +658,7 @@
 
 
 // Map
-class java_util_Map_PersistenceDelegate extends DefaultPersistenceDelegate {
+static class java_util_Map_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         // System.out.println("Initializing: " + newInstance);
         java.util.Map<?,?> oldMap = (java.util.Map)oldInstance;
@@ -691,14 +696,14 @@
     }
 }
 
-class java_util_AbstractCollection_PersistenceDelegate extends java_util_Collection_PersistenceDelegate {}
-class java_util_AbstractList_PersistenceDelegate extends java_util_List_PersistenceDelegate {}
-class java_util_AbstractMap_PersistenceDelegate extends java_util_Map_PersistenceDelegate {}
-class java_util_Hashtable_PersistenceDelegate extends java_util_Map_PersistenceDelegate {}
+static final class java_util_AbstractCollection_PersistenceDelegate extends java_util_Collection_PersistenceDelegate {}
+static final class java_util_AbstractList_PersistenceDelegate extends java_util_List_PersistenceDelegate {}
+static final class java_util_AbstractMap_PersistenceDelegate extends java_util_Map_PersistenceDelegate {}
+static final class java_util_Hashtable_PersistenceDelegate extends java_util_Map_PersistenceDelegate {}
 
 
 // Beans
-class java_beans_beancontext_BeanContextSupport_PersistenceDelegate extends java_util_Collection_PersistenceDelegate {}
+static final class java_beans_beancontext_BeanContextSupport_PersistenceDelegate extends java_util_Collection_PersistenceDelegate {}
 
 // AWT
 
@@ -709,7 +714,7 @@
  *
  * @author Sergey A. Malenkov
  */
-final class java_awt_Insets_PersistenceDelegate extends PersistenceDelegate {
+static final class java_awt_Insets_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -733,7 +738,7 @@
  *
  * @author Sergey A. Malenkov
  */
-final class java_awt_Font_PersistenceDelegate extends PersistenceDelegate {
+static final class java_awt_Font_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -802,7 +807,7 @@
  *
  * @author Sergey A. Malenkov
  */
-final class java_awt_AWTKeyStroke_PersistenceDelegate extends PersistenceDelegate {
+static final class java_awt_AWTKeyStroke_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -843,7 +848,7 @@
     }
 }
 
-class StaticFieldsPersistenceDelegate extends PersistenceDelegate {
+static class StaticFieldsPersistenceDelegate extends PersistenceDelegate {
     protected void installFields(Encoder out, Class<?> cls) {
         Field fields[] = cls.getFields();
         for(int i = 0; i < fields.length; i++) {
@@ -870,13 +875,13 @@
 }
 
 // SystemColor
-class java_awt_SystemColor_PersistenceDelegate extends StaticFieldsPersistenceDelegate {}
+static final class java_awt_SystemColor_PersistenceDelegate extends StaticFieldsPersistenceDelegate {}
 
 // TextAttribute
-class java_awt_font_TextAttribute_PersistenceDelegate extends StaticFieldsPersistenceDelegate {}
+static final class java_awt_font_TextAttribute_PersistenceDelegate extends StaticFieldsPersistenceDelegate {}
 
 // MenuShortcut
-class java_awt_MenuShortcut_PersistenceDelegate extends PersistenceDelegate {
+static final class java_awt_MenuShortcut_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -889,7 +894,7 @@
 }
 
 // Component
-class java_awt_Component_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_Component_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         java.awt.Component c = (java.awt.Component)oldInstance;
@@ -936,7 +941,7 @@
 }
 
 // Container
-class java_awt_Container_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_Container_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         // Ignore the children of a JScrollPane.
@@ -971,7 +976,7 @@
 }
 
 // Choice
-class java_awt_Choice_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_Choice_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         java.awt.Choice m = (java.awt.Choice)oldInstance;
@@ -983,7 +988,7 @@
 }
 
 // Menu
-class java_awt_Menu_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_Menu_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         java.awt.Menu m = (java.awt.Menu)oldInstance;
@@ -995,7 +1000,7 @@
 }
 
 // MenuBar
-class java_awt_MenuBar_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_MenuBar_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         java.awt.MenuBar m = (java.awt.MenuBar)oldInstance;
@@ -1007,7 +1012,7 @@
 }
 
 // List
-class java_awt_List_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_List_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         java.awt.List m = (java.awt.List)oldInstance;
@@ -1022,7 +1027,7 @@
 // LayoutManagers
 
 // BorderLayout
-class java_awt_BorderLayout_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_BorderLayout_PersistenceDelegate extends DefaultPersistenceDelegate {
     private static final String[] CONSTRAINTS = {
             BorderLayout.NORTH,
             BorderLayout.SOUTH,
@@ -1053,41 +1058,44 @@
 }
 
 // CardLayout
-class java_awt_CardLayout_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_CardLayout_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance,
                               Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
-        Hashtable<?,?> tab = (Hashtable<?,?>)ReflectionUtils.getPrivateField(oldInstance,
-                                                                   java.awt.CardLayout.class,
-                                                                   "tab",
-                                                                   out.getExceptionListener());
-        if (tab != null) {
-            for(Enumeration<?> e = tab.keys(); e.hasMoreElements();) {
-                Object child = e.nextElement();
-                invokeStatement(oldInstance, "addLayoutComponent",
-                                new Object[]{child, (String)tab.get(child)}, out);
+        if (getVector(newInstance).isEmpty()) {
+            for (Object card : getVector(oldInstance)) {
+                Object[] args = {MetaData.getPrivateFieldValue(card, "java.awt.CardLayout$Card.name"),
+                                 MetaData.getPrivateFieldValue(card, "java.awt.CardLayout$Card.comp")};
+                invokeStatement(oldInstance, "addLayoutComponent", args, out);
             }
         }
     }
+    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
+        return super.mutatesTo(oldInstance, newInstance) && getVector(newInstance).isEmpty();
+    }
+    private static Vector<?> getVector(Object instance) {
+        return (Vector<?>) MetaData.getPrivateFieldValue(instance, "java.awt.CardLayout.vector");
+    }
 }
 
 // GridBagLayout
-class java_awt_GridBagLayout_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class java_awt_GridBagLayout_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance,
                               Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
-        Hashtable<?,?> comptable = (Hashtable<?,?>)ReflectionUtils.getPrivateField(oldInstance,
-                                                 java.awt.GridBagLayout.class,
-                                                 "comptable",
-                                                 out.getExceptionListener());
-        if (comptable != null) {
-            for(Enumeration<?> e = comptable.keys(); e.hasMoreElements();) {
-                Object child = e.nextElement();
-                invokeStatement(oldInstance, "addLayoutComponent",
-                                new Object[]{child, comptable.get(child)}, out);
+        if (getHashtable(newInstance).isEmpty()) {
+            for (Map.Entry<?,?> entry : getHashtable(oldInstance).entrySet()) {
+                Object[] args = {entry.getKey(), entry.getValue()};
+                invokeStatement(oldInstance, "addLayoutComponent", args, out);
             }
         }
     }
+    protected boolean mutatesTo(Object oldInstance, Object newInstance) {
+        return super.mutatesTo(oldInstance, newInstance) && getHashtable(newInstance).isEmpty();
+    }
+    private static Hashtable<?,?> getHashtable(Object instance) {
+        return (Hashtable<?,?>) MetaData.getPrivateFieldValue(instance, "java.awt.GridBagLayout.comptable");
+    }
 }
 
 // Swing
@@ -1095,7 +1103,7 @@
 // JFrame (If we do this for Window instead of JFrame, the setVisible call
 // will be issued before we have added all the children to the JFrame and
 // will appear blank).
-class javax_swing_JFrame_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_JFrame_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         java.awt.Window oldC = (java.awt.Window)oldInstance;
@@ -1115,7 +1123,7 @@
 // Models
 
 // DefaultListModel
-class javax_swing_DefaultListModel_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_DefaultListModel_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         // Note, the "size" property will be set here.
         super.initialize(type, oldInstance, newInstance, out);
@@ -1129,7 +1137,7 @@
 }
 
 // DefaultComboBoxModel
-class javax_swing_DefaultComboBoxModel_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_DefaultComboBoxModel_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         javax.swing.DefaultComboBoxModel<?> m = (javax.swing.DefaultComboBoxModel<?>)oldInstance;
@@ -1141,7 +1149,7 @@
 
 
 // DefaultMutableTreeNode
-class javax_swing_tree_DefaultMutableTreeNode_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_tree_DefaultMutableTreeNode_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object
                               newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
@@ -1157,7 +1165,7 @@
 }
 
 // ToolTipManager
-class javax_swing_ToolTipManager_PersistenceDelegate extends PersistenceDelegate {
+static final class javax_swing_ToolTipManager_PersistenceDelegate extends PersistenceDelegate {
     protected Expression instantiate(Object oldInstance, Encoder out) {
         return new Expression(oldInstance, javax.swing.ToolTipManager.class,
                               "sharedInstance", new Object[]{});
@@ -1165,7 +1173,7 @@
 }
 
 // JTabbedPane
-class javax_swing_JTabbedPane_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_JTabbedPane_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         javax.swing.JTabbedPane p = (javax.swing.JTabbedPane)oldInstance;
@@ -1180,7 +1188,7 @@
 }
 
 // Box
-class javax_swing_Box_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_Box_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return super.mutatesTo(oldInstance, newInstance) && getAxis(oldInstance).equals(getAxis(newInstance));
     }
@@ -1201,7 +1209,7 @@
 // Container will return all of the sub menu items that
 // need to be added to the menu item.
 // Not so for JMenu apparently.
-class javax_swing_JMenu_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_JMenu_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         javax.swing.JMenu m = (javax.swing.JMenu)oldInstance;
@@ -1219,7 +1227,7 @@
  *
  * @author Sergey A. Malenkov
  */
-final class javax_swing_border_MatteBorder_PersistenceDelegate extends PersistenceDelegate {
+static final class javax_swing_border_MatteBorder_PersistenceDelegate extends PersistenceDelegate {
     protected Expression instantiate(Object oldInstance, Encoder out) {
         MatteBorder border = (MatteBorder) oldInstance;
         Insets insets = border.getBorderInsets();
@@ -1239,7 +1247,7 @@
 }
 
 /* XXX - doens't seem to work. Debug later.
-class javax_swing_JMenu_PersistenceDelegate extends DefaultPersistenceDelegate {
+static final class javax_swing_JMenu_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
         javax.swing.JMenu m = (javax.swing.JMenu)oldInstance;
@@ -1261,7 +1269,7 @@
  *
  * @author Sergey A. Malenkov
  */
-final class sun_swing_PrintColorUIResource_PersistenceDelegate extends PersistenceDelegate {
+static final class sun_swing_PrintColorUIResource_PersistenceDelegate extends PersistenceDelegate {
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
         return oldInstance.equals(newInstance);
     }
@@ -1273,7 +1281,6 @@
     }
 }
 
-class MetaData {
     private static final Map<String,Field> fields = Collections.synchronizedMap(new WeakHashMap<String, Field>());
     private static Hashtable<String, PersistenceDelegate> internalPersistenceDelegates = new Hashtable<>();
 
@@ -1316,7 +1323,7 @@
         if (Enum.class.isAssignableFrom(type)) {
             return enumPersistenceDelegate;
         }
-        if (ReflectionUtils.isPrimitive(type)) {
+        if (null != XMLEncoder.primitiveTypeFor(type)) {
             return primitivePersistenceDelegate;
         }
         // The persistence delegate for arrays is non-trivial; instantiate it lazily.
@@ -1350,7 +1357,7 @@
             internalPersistenceDelegates.put(typeName, defaultPersistenceDelegate);
             try {
                 String name =  type.getName();
-                Class c = Class.forName("java.beans." + name.replace('.', '_')
+                Class c = Class.forName("java.beans.MetaData$" + name.replace('.', '_')
                                         + "_PersistenceDelegate");
                 pd = (PersistenceDelegate)c.newInstance();
                 internalPersistenceDelegates.put(typeName, pd);
--- a/src/share/classes/java/beans/ReflectionUtils.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2003, 2009, 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.beans;
-
-import java.lang.reflect.Field;
-
-/**
- * A utility class for reflectively finding methods, constuctors and fields
- * using reflection.
- */
-class ReflectionUtils {
-
-    @SuppressWarnings("rawtypes")
-    public static boolean isPrimitive(Class type) {
-        return primitiveTypeFor(type) != null;
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static Class primitiveTypeFor(Class wrapper) {
-        if (wrapper == Boolean.class) return Boolean.TYPE;
-        if (wrapper == Byte.class) return Byte.TYPE;
-        if (wrapper == Character.class) return Character.TYPE;
-        if (wrapper == Short.class) return Short.TYPE;
-        if (wrapper == Integer.class) return Integer.TYPE;
-        if (wrapper == Long.class) return Long.TYPE;
-        if (wrapper == Float.class) return Float.TYPE;
-        if (wrapper == Double.class) return Double.TYPE;
-        if (wrapper == Void.class) return Void.TYPE;
-        return null;
-    }
-
-    /**
-     * Returns the value of a private field.
-     *
-     * @param instance object instance
-     * @param cls class
-     * @param name name of the field
-     * @param el an exception listener to handle exceptions; or null
-     * @return value of the field; null if not found or an error is encountered
-     */
-    @SuppressWarnings("rawtypes")
-    public static Object getPrivateField(Object instance, Class cls,
-                                         String name, ExceptionListener el) {
-        try {
-            Field f = cls.getDeclaredField(name);
-            f.setAccessible(true);
-            return f.get(instance);
-        }
-        catch (Exception e) {
-            if (el != null) {
-                el.exceptionThrown(e);
-            }
-        }
-        return null;
-    }
-}
--- a/src/share/classes/java/beans/XMLEncoder.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/beans/XMLEncoder.java	Mon May 13 16:52:33 2013 -0700
@@ -604,7 +604,7 @@
                 return;
             }
 
-            Class<?> primitiveType = ReflectionUtils.primitiveTypeFor(value.getClass());
+            Class<?> primitiveType = primitiveTypeFor(value.getClass());
             if (primitiveType != null && target == value.getClass() &&
                 methodName.equals("new")) {
                 String primitiveTypeName = primitiveType.getName();
@@ -778,4 +778,18 @@
         indentation--;
         writeln("</" + tag + ">");
     }
+
+    @SuppressWarnings("rawtypes")
+    static Class primitiveTypeFor(Class wrapper) {
+        if (wrapper == Boolean.class) return Boolean.TYPE;
+        if (wrapper == Byte.class) return Byte.TYPE;
+        if (wrapper == Character.class) return Character.TYPE;
+        if (wrapper == Short.class) return Short.TYPE;
+        if (wrapper == Integer.class) return Integer.TYPE;
+        if (wrapper == Long.class) return Long.TYPE;
+        if (wrapper == Float.class) return Float.TYPE;
+        if (wrapper == Double.class) return Double.TYPE;
+        if (wrapper == Void.class) return Void.TYPE;
+        return null;
+    }
 }
--- a/src/share/classes/java/lang/invoke/MemberName.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/lang/invoke/MemberName.java	Mon May 13 16:52:33 2013 -0700
@@ -236,6 +236,8 @@
             assert(MethodHandleNatives.refKindIsMethod(refKind));
             if (clazz.isInterface())
                 assert(refKind == REF_invokeInterface ||
+                       refKind == REF_invokeStatic    ||
+                       refKind == REF_invokeSpecial   ||
                        refKind == REF_invokeVirtual && isObjectPublicMethod());
         } else {
             assert(false);
@@ -268,7 +270,7 @@
             assert(refKind == REF_invokeSpecial) : this;
             return true;
         }
-        assert(false) : this;
+        assert(false) : this+" != "+MethodHandleNatives.refKindName((byte)originalRefKind);
         return true;
     }
     private boolean staticIsConsistent() {
@@ -485,14 +487,19 @@
         if (this.type == null)
             this.type = new Object[] { m.getReturnType(), m.getParameterTypes() };
         if (wantSpecial) {
+            assert(!isAbstract()) : this;
             if (getReferenceKind() == REF_invokeVirtual)
                 changeReferenceKind(REF_invokeSpecial, REF_invokeVirtual);
+            else if (getReferenceKind() == REF_invokeInterface)
+                // invokeSpecial on a default method
+                changeReferenceKind(REF_invokeSpecial, REF_invokeInterface);
         }
     }
     public MemberName asSpecial() {
         switch (getReferenceKind()) {
         case REF_invokeSpecial:     return this;
         case REF_invokeVirtual:     return clone().changeReferenceKind(REF_invokeSpecial, REF_invokeVirtual);
+        case REF_invokeInterface:   return clone().changeReferenceKind(REF_invokeSpecial, REF_invokeInterface);
         case REF_newInvokeSpecial:  return clone().changeReferenceKind(REF_invokeSpecial, REF_newInvokeSpecial);
         }
         throw new IllegalArgumentException(this.toString());
--- a/src/share/classes/java/lang/reflect/Executable.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/lang/reflect/Executable.java	Mon May 13 16:52:33 2013 -0700
@@ -510,12 +510,12 @@
      */
     AnnotatedType getAnnotatedReturnType0(Type returnType) {
         return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
-                                                       sun.misc.SharedSecrets.getJavaLangAccess().
-                                                           getConstantPool(getDeclaringClass()),
-                                                       this,
-                                                       getDeclaringClass(),
-                                                       returnType,
-                                                       TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN_TYPE);
+                sun.misc.SharedSecrets.getJavaLangAccess().
+                        getConstantPool(getDeclaringClass()),
+                this,
+                getDeclaringClass(),
+                returnType,
+                TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN);
     }
 
     /**
@@ -535,12 +535,12 @@
      */
     public AnnotatedType getAnnotatedReceiverType() {
         return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
-                                                       sun.misc.SharedSecrets.getJavaLangAccess().
-                                                           getConstantPool(getDeclaringClass()),
-                                                       this,
-                                                       getDeclaringClass(),
-                                                       getDeclaringClass(),
-                                                       TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER_TYPE);
+                sun.misc.SharedSecrets.getJavaLangAccess().
+                        getConstantPool(getDeclaringClass()),
+                this,
+                getDeclaringClass(),
+                getDeclaringClass(),
+                TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
     }
 
     /**
@@ -556,7 +556,13 @@
      * @since 1.8
      */
     public AnnotatedType[] getAnnotatedParameterTypes() {
-        throw new UnsupportedOperationException("Not yet");
+        return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(),
+                sun.misc.SharedSecrets.getJavaLangAccess().
+                        getConstantPool(getDeclaringClass()),
+                this,
+                getDeclaringClass(),
+                getParameterTypes(),
+                TypeAnnotation.TypeAnnotationTarget.METHOD_FORMAL_PARAMETER);
     }
 
     /**
@@ -573,12 +579,12 @@
      */
     public AnnotatedType[] getAnnotatedExceptionTypes() {
         return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(),
-                                                        sun.misc.SharedSecrets.getJavaLangAccess().
-                                                            getConstantPool(getDeclaringClass()),
-                                                        this,
-                                                        getDeclaringClass(),
-                                                        getGenericExceptionTypes(),
-                                                        TypeAnnotation.TypeAnnotationTarget.THROWS);
+                sun.misc.SharedSecrets.getJavaLangAccess().
+                        getConstantPool(getDeclaringClass()),
+                this,
+                getDeclaringClass(),
+                getGenericExceptionTypes(),
+                TypeAnnotation.TypeAnnotationTarget.THROWS);
     }
 
 }
--- a/src/share/classes/java/lang/reflect/Field.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/lang/reflect/Field.java	Mon May 13 16:52:33 2013 -0700
@@ -1161,6 +1161,6 @@
                                                        this,
                                                        getDeclaringClass(),
                                                        getGenericType(),
-                                                       TypeAnnotation.TypeAnnotationTarget.FIELD_TYPE);
+                                                       TypeAnnotation.TypeAnnotationTarget.FIELD);
 }
 }
--- a/src/share/classes/java/lang/reflect/Modifier.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/lang/reflect/Modifier.java	Mon May 13 16:52:33 2013 -0700
@@ -350,8 +350,19 @@
       return (mod & MANDATED) != 0;
     }
 
+    // Note on the FOO_MODIFIERS fields and fooModifiers() methods:
+    // the sets of modifiers are not guaranteed to be constants
+    // across time and Java SE releases. Therefore, it would not be
+    // appropriate to expose an external interface to this information
+    // that would allow the values to be treated as Java-level
+    // constants since the values could be constant folded and updates
+    // to the sets of modifiers missed. Thus, the fooModifiers()
+    // methods return an unchanging values for a given release, but a
+    // value that can potentially change over time.
+
     /**
-     * See JLSv3 section 8.1.1.
+     * The Java source modifiers that can be applied to a class.
+     * @jls 8.1.1 Class Modifiers
      */
     private static final int CLASS_MODIFIERS =
         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
@@ -359,7 +370,8 @@
         Modifier.STRICT;
 
     /**
-     * See JLSv3 section 9.1.1.
+     * The Java source modifiers that can be applied to an interface.
+     * @jls 9.1.1 Interface Modifiers
      */
     private static final int INTERFACE_MODIFIERS =
         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
@@ -367,13 +379,15 @@
 
 
     /**
-     * See JLSv3 section 8.8.3.
+     * The Java source modifiers that can be applied to a constructor.
+     * @jls 8.8.3 Constructor Modifiers
      */
     private static final int CONSTRUCTOR_MODIFIERS =
         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE;
 
     /**
-     * See JLSv3 section 8.4.3.
+     * The Java source modifiers that can be applied to a method.
+     * @jls8.4.3  Method Modifiers
      */
     private static final int METHOD_MODIFIERS =
         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
@@ -381,7 +395,8 @@
         Modifier.SYNCHRONIZED   | Modifier.NATIVE       | Modifier.STRICT;
 
     /**
-     * See JLSv3 section 8.3.1.
+     * The Java source modifiers that can be applied to a field.
+     * @jls 8.3.1  Field Modifiers
      */
     private static final int FIELD_MODIFIERS =
         Modifier.PUBLIC         | Modifier.PROTECTED    | Modifier.PRIVATE |
@@ -389,6 +404,13 @@
         Modifier.VOLATILE;
 
     /**
+     * The Java source modifiers that can be applied to a method or constructor parameter.
+     * @jls 8.4.1 Formal Parameters
+     */
+    private static final int PARAMETER_MODIFIERS =
+        Modifier.FINAL;
+
+    /**
      *
      */
     static final int ACCESS_MODIFIERS =
@@ -411,7 +433,7 @@
      * Return an {@code int} value OR-ing together the source language
      * modifiers that can be applied to an interface.
      * @return an {@code int} value OR-ing together the source language
-     * modifiers that can be applied to an inteface.
+     * modifiers that can be applied to an interface.
      *
      * @jls 9.1.1 Interface Modifiers
      * @since 1.7
@@ -446,7 +468,6 @@
         return METHOD_MODIFIERS;
     }
 
-
     /**
      * Return an {@code int} value OR-ing together the source language
      * modifiers that can be applied to a field.
@@ -459,4 +480,17 @@
     public static int fieldModifiers() {
         return FIELD_MODIFIERS;
     }
+
+    /**
+     * Return an {@code int} value OR-ing together the source language
+     * modifiers that can be applied to a parameter.
+     * @return an {@code int} value OR-ing together the source language
+     * modifiers that can be applied to a parameter.
+     *
+     * @jls 8.4.1 Formal Parameters
+     * @since 1.8
+     */
+    public static int parameterModifiers() {
+        return PARAMETER_MODIFIERS;
+    }
 }
--- a/src/share/classes/java/lang/reflect/Parameter.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/lang/reflect/Parameter.java	Mon May 13 16:52:33 2013 -0700
@@ -200,6 +200,19 @@
         return tmp;
     }
 
+    /**
+     * Returns an AnnotatedType object that represents the use of a type to
+     * specify the type of the formal parameter represented by this Parameter.
+     *
+     * @return an {@code AnnotatedType} object representing the use of a type
+     *         to specify the type of the formal parameter represented by this
+     *         Parameter
+     */
+    public AnnotatedType getAnnotatedType() {
+        // no caching for now
+        return executable.getAnnotatedParameterTypes()[index];
+    }
+
     private transient volatile Class<?> parameterClassCache = null;
 
     /**
--- a/src/share/classes/java/util/regex/Pattern.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/util/regex/Pattern.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, 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
@@ -25,15 +25,19 @@
 
 package java.util.regex;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.text.CharacterIterator;
 import java.text.Normalizer;
 import java.util.Locale;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Arrays;
+import java.util.NoSuchElementException;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 
 
 /**
@@ -5742,4 +5746,83 @@
                     return Character.isMirrored(ch);}});
         }
     }
+
+    /**
+     * Creates a predicate which can be used to match a string.
+     *
+     * @return  The predicate which can be used for matching on a string
+     * @since   1.8
+     */
+    public Predicate<String> asPredicate() {
+        return s -> matcher(s).find();
+    }
+
+    /**
+     * Creates a stream from the given input sequence around matches of this
+     * pattern.
+     *
+     * <p> The stream returned by this method contains each substring of the
+     * input sequence that is terminated by another subsequence that matches
+     * this pattern or is terminated by the end of the input sequence.  The
+     * substrings in the stream are in the order in which they occur in the
+     * input.
+     *
+     * <p> If this pattern does not match any subsequence of the input then
+     * the resulting stream has just one element, namely the input sequence in
+     * string form.
+     *
+     * <p> If the input sequence is mutable, it must remain constant during the
+     * execution of the terminal stream operation.  Otherwise, the result of the
+     * terminal stream operation is undefined.
+     *
+     * @param   input
+     *          The character sequence to be split
+     *
+     * @return  The stream of strings computed by splitting the input
+     *          around matches of this pattern
+     * @see     #split(CharSequence)
+     * @since   1.8
+     */
+    public Stream<String> splitAsStream(final CharSequence input) {
+        class MatcherIterator implements Iterator<String> {
+            private final Matcher matcher;
+            // The start position of the next sub-sequence of input
+            // when current == input.length there are no more elements
+            private int current;
+            // null if the next element, if any, needs to obtained
+            private String nextElement;
+
+            MatcherIterator() {
+                this.matcher = matcher(input);
+            }
+
+            public String next() {
+                if (!hasNext())
+                    throw new NoSuchElementException();
+
+                String n = nextElement;
+                nextElement = null;
+                return n;
+            }
+
+            public boolean hasNext() {
+                if (nextElement != null)
+                    return true;
+
+                if (current == input.length())
+                    return false;
+
+                if (matcher.find()) {
+                    nextElement = input.subSequence(current, matcher.start()).toString();
+                    current = matcher.end();
+                } else {
+                    nextElement = input.subSequence(current, input.length()).toString();
+                    current = input.length();
+                }
+                return true;
+            }
+        }
+        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
+                new MatcherIterator(), Spliterator.ORDERED | Spliterator.NONNULL));
+    }
 }
--- a/src/share/classes/java/util/stream/MatchOps.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/util/stream/MatchOps.java	Mon May 13 16:52:33 2013 -0700
@@ -94,12 +94,7 @@
             }
         }
 
-        // @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
-        Supplier<BooleanTerminalSink<T>> s = new Supplier<BooleanTerminalSink<T>>() {
-            @Override
-            public BooleanTerminalSink<T> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.REFERENCE, matchKind, s);
+        return new MatchOp<>(StreamShape.REFERENCE, matchKind, MatchSink::new);
     }
 
     /**
@@ -128,12 +123,7 @@
             }
         }
 
-        // @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
-        Supplier<BooleanTerminalSink<Integer>> s = new Supplier<BooleanTerminalSink<Integer>>() {
-            @Override
-            public BooleanTerminalSink<Integer> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.INT_VALUE, matchKind, s);
+        return new MatchOp<>(StreamShape.INT_VALUE, matchKind, MatchSink::new);
     }
 
     /**
@@ -163,12 +153,7 @@
             }
         }
 
-        // @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
-        Supplier<BooleanTerminalSink<Long>> s = new Supplier<BooleanTerminalSink<Long>>() {
-            @Override
-            public BooleanTerminalSink<Long> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, s);
+        return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, MatchSink::new);
     }
 
     /**
@@ -198,12 +183,7 @@
             }
         }
 
-        // @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
-        Supplier<BooleanTerminalSink<Double>> s = new Supplier<BooleanTerminalSink<Double>>() {
-            @Override
-            public BooleanTerminalSink<Double> get() {return new MatchSink();}
-        };
-        return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, s);
+        return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new);
     }
 
     /**
--- a/src/share/classes/java/util/zip/GZIPInputStream.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/java/util/zip/GZIPInputStream.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, 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
@@ -27,6 +27,7 @@
 
 import java.io.SequenceInputStream;
 import java.io.ByteArrayInputStream;
+import java.io.FilterInputStream;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.EOFException;
@@ -212,7 +213,10 @@
         int n = inf.getRemaining();
         if (n > 0) {
             in = new SequenceInputStream(
-                        new ByteArrayInputStream(buf, len - n, n), in);
+                        new ByteArrayInputStream(buf, len - n, n),
+                        new FilterInputStream(in) {
+                            public void close() throws IOException {}
+                        });
         }
         // Uses left-to-right evaluation order
         if ((readUInt(in) != crc.getValue()) ||
--- a/src/share/classes/javax/swing/JDesktopPane.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/javax/swing/JDesktopPane.java	Mon May 13 16:52:33 2013 -0700
@@ -428,6 +428,15 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void remove(Component comp) {
+        super.remove(comp);
+        updateFramesCache();
+    }
+
+    /**
      * Selects the next <code>JInternalFrame</code> in this desktop pane.
      *
      * @param forward a boolean indicating which direction to select in;
--- a/src/share/classes/sun/java2d/pipe/AAShapePipe.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/java2d/pipe/AAShapePipe.java	Mon May 13 16:52:33 2013 -0700
@@ -127,7 +127,7 @@
 
     private static byte[] theTile;
 
-    public synchronized static byte[] getAlphaTile(int len) {
+    private synchronized static byte[] getAlphaTile(int len) {
         byte[] t = theTile;
         if (t == null || t.length < len) {
             t = new byte[len];
@@ -137,7 +137,7 @@
         return t;
     }
 
-    public synchronized static void dropAlphaTile(byte[] t) {
+    private synchronized static void dropAlphaTile(byte[] t) {
         theTile = t;
     }
 
--- a/src/share/classes/sun/net/httpserver/ServerImpl.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/net/httpserver/ServerImpl.java	Mon May 13 16:52:33 2013 -0700
@@ -321,15 +321,7 @@
         public void run() {
             while (!finished) {
                 try {
-                    ListIterator<HttpConnection> li =
-                        connsToRegister.listIterator();
-                    for (HttpConnection c : connsToRegister) {
-                        reRegister(c);
-                    }
-                    connsToRegister.clear();
-
                     List<Event> list = null;
-                    selector.select(1000);
                     synchronized (lolock) {
                         if (events.size() > 0) {
                             list = events;
@@ -343,8 +335,14 @@
                         }
                     }
 
+                    for (HttpConnection c : connsToRegister) {
+                        reRegister(c);
+                    }
+                    connsToRegister.clear();
+
+                    selector.select(1000);
+
                     /* process the selected list now  */
-
                     Set<SelectionKey> selected = selector.selectedKeys();
                     Iterator<SelectionKey> iter = selected.iterator();
                     while (iter.hasNext()) {
--- a/src/share/classes/sun/reflect/annotation/TypeAnnotation.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/reflect/annotation/TypeAnnotation.java	Mon May 13 16:52:33 2013 -0700
@@ -83,12 +83,13 @@
         CLASS_TYPE_PARAMETER,
         METHOD_TYPE_PARAMETER,
         CLASS_EXTENDS,
-        CLASS_IMPLEMENTS,
-        CLASS_PARAMETER_BOUND,
-        METHOD_PARAMETER_BOUND,
-        METHOD_RETURN_TYPE,
-        METHOD_RECEIVER_TYPE,
-        FIELD_TYPE,
+        CLASS_IMPLEMENTS, // Not in the spec
+        CLASS_TYPE_PARAMETER_BOUND,
+        METHOD_TYPE_PARAMETER_BOUND,
+        FIELD,
+        METHOD_RETURN,
+        METHOD_RECEIVER,
+        METHOD_FORMAL_PARAMETER,
         THROWS;
     }
     public static class TypeAnnotationTargetInfo {
--- a/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java	Mon May 13 16:52:33 2013 -0700
@@ -282,10 +282,10 @@
         AnnotatedElement boundsDecl;
         TypeAnnotationTarget target;
         if (decl instanceof Class) {
-            target = TypeAnnotationTarget.CLASS_PARAMETER_BOUND;
+            target = TypeAnnotationTarget.CLASS_TYPE_PARAMETER_BOUND;
             boundsDecl = (Class)decl;
         } else {
-            target = TypeAnnotationTarget.METHOD_PARAMETER_BOUND;
+            target = TypeAnnotationTarget.METHOD_TYPE_PARAMETER_BOUND;
             boundsDecl = (Executable)decl;
         }
         return TypeAnnotation.filter(TypeAnnotationParser.parseAllTypeAnnotations(boundsDecl), target);
@@ -371,14 +371,15 @@
     private static final byte LOCAL_VARIABLE = (byte)0x40;
     private static final byte RESOURCE_VARIABLE = (byte)0x41;
     private static final byte EXCEPTION_PARAMETER = (byte)0x42;
-    private static final byte CAST = (byte)0x43;
-    private static final byte INSTANCEOF = (byte)0x44;
-    private static final byte NEW = (byte)0x45;
-    private static final byte CONSTRUCTOR_REFERENCE_RECEIVER = (byte)0x46;
-    private static final byte METHOD_REFERENCE_RECEIVER = (byte)0x47;
-    private static final byte LAMBDA_FORMAL_PARAMETER = (byte)0x48;
-    private static final byte METHOD_REFERENCE = (byte)0x49;
-    private static final byte METHOD_REFERENCE_TYPE_ARGUMENT = (byte)0x50;
+    private static final byte INSTANCEOF = (byte)0x43;
+    private static final byte NEW = (byte)0x44;
+    private static final byte CONSTRUCTOR_REFERENCE = (byte)0x45;
+    private static final byte METHOD_REFERENCE = (byte)0x46;
+    private static final byte CAST = (byte)0x47;
+    private static final byte CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = (byte)0x48;
+    private static final byte METHOD_INVOCATION_TYPE_ARGUMENT = (byte)0x49;
+    private static final byte CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = (byte)0x4A;
+    private static final byte METHOD_REFERENCE_TYPE_ARGUMENT = (byte)0x4B;
 
     private static TypeAnnotation parseTypeAnnotation(ByteBuffer buf,
             ConstantPool cp,
@@ -417,19 +418,20 @@
                 return res;
             }} break;
         case CLASS_TYPE_PARAMETER_BOUND:
-            return parse2ByteTarget(TypeAnnotationTarget.CLASS_PARAMETER_BOUND, buf);
+            return parse2ByteTarget(TypeAnnotationTarget.CLASS_TYPE_PARAMETER_BOUND, buf);
         case METHOD_TYPE_PARAMETER_BOUND:
-            return parse2ByteTarget(TypeAnnotationTarget.METHOD_PARAMETER_BOUND, buf);
+            return parse2ByteTarget(TypeAnnotationTarget.METHOD_TYPE_PARAMETER_BOUND, buf);
         case FIELD:
-            return new TypeAnnotationTargetInfo(TypeAnnotationTarget.FIELD_TYPE);
+            return new TypeAnnotationTargetInfo(TypeAnnotationTarget.FIELD);
         case METHOD_RETURN:
-            return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RETURN_TYPE);
+            return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RETURN);
         case METHOD_RECEIVER:
-            return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RECEIVER_TYPE);
+            return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RECEIVER);
         case METHOD_FORMAL_PARAMETER: {
-            // Todo
             byte index = buf.get();
-            } break;
+            return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_FORMAL_PARAMETER,
+                    index);
+            } //unreachable break;
         case THROWS:
             return parseShortTarget(TypeAnnotationTarget.THROWS, buf);
 
@@ -445,30 +447,27 @@
                 short varLength = buf.getShort();
                 short index = buf.getShort();
             }
-            break;
+            return null;
         case EXCEPTION_PARAMETER: {
             byte index = buf.get();
-            } break;
+            }
+            return null;
+        case INSTANCEOF:
+        case NEW:
+        case CONSTRUCTOR_REFERENCE:
+        case METHOD_REFERENCE: {
+            short offset = buf.getShort();
+            }
+            return null;
         case CAST:
-        case INSTANCEOF:
-        case NEW: {
-            short offset = buf.getShort();
-            } break;
-        case CONSTRUCTOR_REFERENCE_RECEIVER:
-        case METHOD_REFERENCE_RECEIVER: {
-            short offset = buf.getShort();
-            byte index = buf.get();
-            } break;
-        case LAMBDA_FORMAL_PARAMETER: {
-            byte index = buf.get();
-            } break;
-        case METHOD_REFERENCE:
-            // This one isn't in the spec yet
-            break;
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+        case METHOD_INVOCATION_TYPE_ARGUMENT:
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
         case METHOD_REFERENCE_TYPE_ARGUMENT: {
             short offset = buf.getShort();
             byte index = buf.get();
-            } break;
+            }
+            return null;
 
         default:
             // will throw error below
--- a/src/share/classes/sun/reflect/generics/reflectiveObjects/GenericArrayTypeImpl.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/reflect/generics/reflectiveObjects/GenericArrayTypeImpl.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, 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,7 @@
 
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Type;
-
+import java.util.Objects;
 
 /**
  * Implementation of GenericArrayType interface for core reflection.
@@ -81,18 +81,13 @@
         if (o instanceof GenericArrayType) {
             GenericArrayType that = (GenericArrayType) o;
 
-            Type thatComponentType = that.getGenericComponentType();
-            return genericComponentType == null ?
-                thatComponentType == null :
-                genericComponentType.equals(thatComponentType);
+            return Objects.equals(genericComponentType, that.getGenericComponentType());
         } else
             return false;
     }
 
     @Override
     public int hashCode() {
-        return (genericComponentType == null) ?
-            0:
-            genericComponentType.hashCode();
+        return Objects.hashCode(genericComponentType);
     }
 }
--- a/src/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, 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
@@ -33,7 +33,7 @@
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.Arrays;
-
+import java.util.Objects;
 
 /** Implementing class for ParameterizedType interface. */
 
@@ -47,9 +47,7 @@
                                   Type ownerType) {
         this.actualTypeArguments = actualTypeArguments;
         this.rawType             = rawType;
-        if (ownerType != null) {
-            this.ownerType = ownerType;
-        } else { this.ownerType = rawType.getDeclaringClass();}
+        this.ownerType = (ownerType != null) ? ownerType : rawType.getDeclaringClass();
         validateConstructorArguments();
     }
 
@@ -62,7 +60,6 @@
         for (int i = 0; i < actualTypeArguments.length; i++) {
             // check actuals against formals' bounds
         }
-
     }
 
     /**
@@ -189,14 +186,9 @@
                 return ownerEquality && rawEquality && typeArgEquality;
             }
 
-
             return
-                (ownerType == null ?
-                 thatOwner == null :
-                 ownerType.equals(thatOwner)) &&
-                (rawType == null ?
-                 thatRawType == null :
-                 rawType.equals(thatRawType)) &&
+                Objects.equals(ownerType, thatOwner) &&
+                Objects.equals(rawType, thatRawType) &&
                 Arrays.equals(actualTypeArguments, // avoid clone
                               that.getActualTypeArguments());
         } else
@@ -207,8 +199,8 @@
     public int hashCode() {
         return
             Arrays.hashCode(actualTypeArguments) ^
-            (ownerType == null ? 0 : ownerType.hashCode() ) ^
-            (rawType == null   ? 0 : rawType.hashCode() );
+            Objects.hashCode(ownerType) ^
+            Objects.hashCode(rawType);
     }
 
     public String toString() {
@@ -239,10 +231,7 @@
             for(Type t: actualTypeArguments) {
                 if (!first)
                     sb.append(", ");
-                if (t instanceof Class)
-                    sb.append(((Class)t).getName());
-                else
-                    sb.append(t.toString());
+                sb.append(t.getTypeName());
                 first = false;
             }
             sb.append(">");
--- a/src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java	Mon May 13 16:52:33 2013 -0700
@@ -170,13 +170,8 @@
             GenericDeclaration thatDecl = that.getGenericDeclaration();
             String thatName = that.getName();
 
-            return
-                (genericDeclaration == null ?
-                 thatDecl == null :
-                 genericDeclaration.equals(thatDecl)) &&
-                (name == null ?
-                 thatName == null :
-                 name.equals(thatName));
+            return Objects.equals(genericDeclaration, thatDecl) &&
+                Objects.equals(name, thatName);
 
         } else
             return false;
--- a/src/share/classes/sun/reflect/generics/reflectiveObjects/WildcardTypeImpl.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/reflect/generics/reflectiveObjects/WildcardTypeImpl.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, 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
@@ -203,10 +203,7 @@
                 sb.append(" & ");
 
             first = false;
-            if (bound instanceof Class)
-                sb.append(((Class)bound).getName() );
-            else
-                sb.append(bound.toString());
+            sb.append(bound.getTypeName());
         }
         return sb.toString();
     }
--- a/src/share/classes/sun/security/krb5/internal/crypto/EType.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/security/krb5/internal/crypto/EType.java	Mon May 13 16:52:33 2013 -0700
@@ -55,11 +55,11 @@
     }
 
     public static void initStatic() {
-        boolean allowed = true;
+        boolean allowed = false;
         try {
             Config cfg = Config.getInstance();
             String temp = cfg.get("libdefaults", "allow_weak_crypto");
-            if (temp != null && temp.equals("false")) allowed = false;
+            if (temp != null && temp.equals("true")) allowed = true;
         } catch (Exception exc) {
             if (DEBUG) {
                 System.out.println ("Exception in getting allow_weak_crypto, " +
--- a/src/share/classes/sun/security/provider/certpath/CertPathHelper.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/security/provider/certpath/CertPathHelper.java	Mon May 13 16:52:33 2013 -0700
@@ -64,7 +64,7 @@
         instance.implSetPathToNames(sel, names);
     }
 
-    static void setDateAndTime(X509CRLSelector sel, Date date, long skew) {
+    public static void setDateAndTime(X509CRLSelector sel, Date date, long skew) {
         instance.implSetDateAndTime(sel, date, skew);
     }
 }
--- a/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java	Mon May 13 16:52:33 2013 -0700
@@ -50,7 +50,7 @@
  * @author Sean Mullan
  * @since 1.4.2
  */
-class DistributionPointFetcher {
+public class DistributionPointFetcher {
 
     private static final Debug debug = Debug.getInstance("certpath");
 
@@ -66,13 +66,14 @@
      * Return the X509CRLs matching this selector. The selector must be
      * an X509CRLSelector with certificateChecking set.
      */
-    static Collection<X509CRL> getCRLs(X509CRLSelector selector,
-                                       boolean signFlag, PublicKey prevKey,
-                                       String provider,
-                                       List<CertStore> certStores,
-                                       boolean[] reasonsMask,
-                                       Set<TrustAnchor> trustAnchors,
-                                       Date validity)
+    public static Collection<X509CRL> getCRLs(X509CRLSelector selector,
+                                              boolean signFlag,
+                                              PublicKey prevKey,
+                                              String provider,
+                                              List<CertStore> certStores,
+                                              boolean[] reasonsMask,
+                                              Set<TrustAnchor> trustAnchors,
+                                              Date validity)
         throws CertStoreException
     {
         X509Certificate cert = selector.getCertificateChecking();
--- a/src/share/classes/sun/security/provider/certpath/OCSP.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/security/provider/certpath/OCSP.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -85,10 +85,9 @@
      * value is negative, set the timeout length to the default.
      */
     private static int initializeTimeout() {
-        int tmp = java.security.AccessController.doPrivileged(
-                new GetIntegerAction("com.sun.security.ocsp.timeout",
-                                     DEFAULT_CONNECT_TIMEOUT));
-        if (tmp < 0) {
+        Integer tmp = java.security.AccessController.doPrivileged(
+                new GetIntegerAction("com.sun.security.ocsp.timeout"));
+        if (tmp == null || tmp < 0) {
             return DEFAULT_CONNECT_TIMEOUT;
         }
         // Convert to milliseconds, as the system property will be
--- a/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Mon May 13 16:52:33 2013 -0700
@@ -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
@@ -43,6 +43,7 @@
 import javax.security.auth.x500.X500Principal;
 
 import sun.misc.HexDumpEncoder;
+import sun.security.action.GetIntegerAction;
 import sun.security.x509.*;
 import sun.security.util.*;
 
@@ -144,9 +145,31 @@
     // Object identifier for the OCSPSigning key purpose
     private static final String KP_OCSP_SIGNING_OID = "1.3.6.1.5.5.7.3.9";
 
-    // Maximum clock skew in milliseconds (15 minutes) allowed when checking
-    // validity of OCSP responses
-    private static final long MAX_CLOCK_SKEW = 900000;
+    // Default maximum clock skew in milliseconds (15 minutes)
+    // allowed when checking validity of OCSP responses
+    private static final int DEFAULT_MAX_CLOCK_SKEW = 900000;
+
+    /**
+     * Integer value indicating the maximum allowable clock skew, in seconds,
+     * to be used for the OCSP check.
+     */
+    private static final int MAX_CLOCK_SKEW = initializeClockSkew();
+
+    /**
+     * Initialize the maximum allowable clock skew by getting the OCSP
+     * clock skew system property. If the property has not been set, or if its
+     * value is negative, set the skew to the default.
+     */
+    private static int initializeClockSkew() {
+        Integer tmp = java.security.AccessController.doPrivileged(
+                new GetIntegerAction("com.sun.security.ocsp.clockSkew"));
+        if (tmp == null || tmp < 0) {
+            return DEFAULT_MAX_CLOCK_SKEW;
+        }
+        // Convert to milliseconds, as the system property will be
+        // specified in seconds
+        return tmp * 1000;
+    }
 
     // an array of all of the CRLReasons (used in SingleResponse)
     private static CRLReason[] values = CRLReason.values();
--- a/src/share/classes/sun/security/provider/certpath/URICertStore.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/security/provider/certpath/URICertStore.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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,6 +51,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
+import sun.security.action.GetIntegerAction;
 import sun.security.x509.AccessDescription;
 import sun.security.x509.GeneralNameInterface;
 import sun.security.x509.URIName;
@@ -121,6 +122,33 @@
     private CertStore ldapCertStore;
     private String ldapPath;
 
+    // Default maximum connect timeout in milliseconds (15 seconds)
+    // allowed when downloading CRLs
+    private static final int DEFAULT_CRL_CONNECT_TIMEOUT = 15000;
+
+    /**
+     * Integer value indicating the connect timeout, in seconds, to be
+     * used for the CRL download. A timeout of zero is interpreted as
+     * an infinite timeout.
+     */
+    private static final int CRL_CONNECT_TIMEOUT = initializeTimeout();
+
+    /**
+     * Initialize the timeout length by getting the CRL timeout
+     * system property. If the property has not been set, or if its
+     * value is negative, set the timeout length to the default.
+     */
+    private static int initializeTimeout() {
+        Integer tmp = java.security.AccessController.doPrivileged(
+                new GetIntegerAction("com.sun.security.crl.timeout"));
+        if (tmp == null || tmp < 0) {
+            return DEFAULT_CRL_CONNECT_TIMEOUT;
+        }
+        // Convert to milliseconds, as the system property will be
+        // specified in seconds
+        return tmp * 1000;
+    }
+
     /**
      * Creates a URICertStore.
      *
@@ -364,6 +392,7 @@
                 connection.setIfModifiedSince(lastModified);
             }
             long oldLastModified = lastModified;
+            connection.setConnectTimeout(CRL_CONNECT_TIMEOUT);
             try (InputStream in = connection.getInputStream()) {
                 lastModified = connection.getLastModified();
                 if (oldLastModified != 0) {
--- a/src/share/classes/sun/security/ssl/SSLSessionImpl.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/share/classes/sun/security/ssl/SSLSessionImpl.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, 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
@@ -822,7 +822,7 @@
      * them are removed.
      */
     @Override
-    public void finalize() {
+    protected void finalize() throws Throwable {
         String[] names = getValueNames();
         for (int i = 0; i < names.length; i++) {
             removeValue(names[i]);
--- a/src/solaris/bin/jexec.c	Tue May 07 14:13:53 2013 -0700
+++ b/src/solaris/bin/jexec.c	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, 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
@@ -90,6 +90,8 @@
 static const char * BAD_EXEC_MSG     = "jexec failed";
 static const char * CRAZY_EXEC_MSG   = "missing args";
 static const char * MISSING_JAVA_MSG = "can't locate java";
+static const char * BAD_ARG_MSG      = "incorrect number of arguments";
+static const char * MEM_FAILED_MSG   = "memory allocation failed";
 #ifdef __linux__
 static const char * BAD_PATHNAME_MSG = "invalid path";
 static const char * BAD_FILE_MSG     = "invalid file";
@@ -156,6 +158,7 @@
     const char ** nargv = NULL;          /* new args array       */
     int           nargc = 0;             /* new args array count */
     int           argi  = 0;             /* index into old array */
+    size_t        alen  = 0;             /* length of new array */
 
     /* Make sure we have something to work with */
     if ((argc < 1) || (argv == NULL)) {
@@ -168,8 +171,14 @@
     if (getJavaPath(argv[argi++], java, RELATIVE_DEPTH) != 0) {
         errorExit(errno, MISSING_JAVA_MSG);
     }
-
-    nargv = (const char **) malloc((argc + 2) * (sizeof (const char *)));
+    alen = (argc + 2) * (sizeof (const char *));
+    if (alen <= 0 || alen > INT_MAX / sizeof(char *)) {
+        errorExit(errno, BAD_ARG_MSG);
+    }
+    nargv = (const char **) malloc(alen);
+    if (nargv == NULL) {
+        errorExit(errno, MEM_FAILED_MSG);
+    }
     nargv[nargc++] = java;
 
 #ifdef __linux__
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon May 13 16:52:33 2013 -0700
@@ -1887,7 +1887,9 @@
         switch (getWindowType())
         {
             case NORMAL:
-                typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_NORMAL;
+                typeAtom = (ownerPeer == null) ?
+                               protocol.XA_NET_WM_WINDOW_TYPE_NORMAL :
+                               protocol.XA_NET_WM_WINDOW_TYPE_DIALOG;
                 break;
             case UTILITY:
                 typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_UTILITY;
--- a/src/windows/classes/sun/awt/windows/WComponentPeer.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon May 13 16:52:33 2013 -0700
@@ -759,9 +759,7 @@
     WComponentPeer(Component target) {
         this.target = target;
         this.paintArea = new RepaintArea();
-        Container parent = WToolkit.getNativeContainer(target);
-        WComponentPeer parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
-        create(parentPeer);
+        create(getNativeParent());
         // fix for 5088782: check if window object is created successfully
         checkCreation();
 
@@ -771,6 +769,17 @@
     }
     abstract void create(WComponentPeer parent);
 
+    /**
+     * Gets the native parent of this peer. We use the term "parent" explicitly,
+     * because we override the method in top-level window peer implementations.
+     *
+     * @return the parent container/owner of this peer.
+     */
+    WComponentPeer getNativeParent() {
+        Container parent = SunToolkit.getNativeContainer((Component) target);
+        return (WComponentPeer) WToolkit.targetToPeer(parent);
+    }
+
     protected void checkCreation()
     {
         if ((hwnd == 0) || (pData == 0))
--- a/src/windows/classes/sun/awt/windows/WWindowPeer.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon May 13 16:52:33 2013 -0700
@@ -215,6 +215,12 @@
         createAwtWindow(parent);
     }
 
+    @Override
+    final WComponentPeer getNativeParent() {
+        final Container owner = ((Window) target).getOwner();
+        return (WComponentPeer) WToolkit.targetToPeer(owner);
+    }
+
     // should be overriden in WDialogPeer
     protected void realShow() {
         super.show();
--- a/src/windows/classes/sun/nio/fs/WindowsFileCopy.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/windows/classes/sun/nio/fs/WindowsFileCopy.java	Mon May 13 16:52:33 2013 -0700
@@ -224,7 +224,7 @@
                 String linkTarget = WindowsLinkSupport.readLink(source);
                 int flags = SYMBOLIC_LINK_FLAG_DIRECTORY;
                 CreateSymbolicLink(targetPath,
-                                   addPrefixIfNeeded(linkTarget),
+                                   WindowsPath.addPrefixIfNeeded(linkTarget),
                                    flags);
             }
         } catch (WindowsException x) {
@@ -414,7 +414,7 @@
             } else {
                 String linkTarget = WindowsLinkSupport.readLink(source);
                 CreateSymbolicLink(targetPath,
-                                   addPrefixIfNeeded(linkTarget),
+                                   WindowsPath.addPrefixIfNeeded(linkTarget),
                                    SYMBOLIC_LINK_FLAG_DIRECTORY);
             }
         } catch (WindowsException x) {
@@ -502,18 +502,4 @@
             priv.drop();
         }
     }
-
-    /**
-     * Add long path prefix to path if required
-     */
-    private static String addPrefixIfNeeded(String path) {
-        if (path.length() > 248) {
-            if (path.startsWith("\\\\")) {
-                path = "\\\\?\\UNC" + path.substring(1, path.length());
-            } else {
-                path = "\\\\?\\" + path;
-            }
-        }
-        return path;
-    }
 }
--- a/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java	Mon May 13 16:52:33 2013 -0700
@@ -231,7 +231,7 @@
             int end = (next == -1) ? path.length() : next;
             String search = sb.toString() + path.substring(curr, end);
             try {
-                FirstFile fileData = FindFirstFile(addLongPathPrefixIfNeeded(search));
+                FirstFile fileData = FindFirstFile(WindowsPath.addPrefixIfNeeded(search));
                 FindClose(fileData.handle());
 
                 // if a reparse point is encountered then we must return the
@@ -406,20 +406,6 @@
     }
 
     /**
-     * Add long path prefix to path if required.
-     */
-    private static String addLongPathPrefixIfNeeded(String path) {
-        if (path.length() > 248) {
-            if (path.startsWith("\\\\")) {
-                path = "\\\\?\\UNC" + path.substring(1, path.length());
-            } else {
-                path = "\\\\?\\" + path;
-            }
-        }
-        return path;
-    }
-
-    /**
      * Strip long path or symbolic link prefix from path
      */
     private static String stripPrefix(String path) {
--- a/src/windows/classes/sun/nio/fs/WindowsPath.java	Tue May 07 14:13:53 2013 -0700
+++ b/src/windows/classes/sun/nio/fs/WindowsPath.java	Mon May 13 16:52:33 2013 -0700
@@ -283,7 +283,7 @@
 
     // Add long path prefix to path if required
     static String addPrefixIfNeeded(String path) {
-        if (path.length() > 248) {
+        if (path.length() > MAX_PATH) {
             if (path.startsWith("\\\\")) {
                 path = "\\\\?\\UNC" + path.substring(1, path.length());
             } else {
--- a/test/Makefile	Tue May 07 14:13:53 2013 -0700
+++ b/test/Makefile	Mon May 13 16:52:33 2013 -0700
@@ -517,6 +517,7 @@
 	  javax/xml/soap \
 	  javax/xml/ws com/sun/internal/ws com/sun/org/glassfish \
 	  jdk/asm \
+	  jdk/lambda \
 	  com/sun/org/apache/xerces \
           com/sun/corba \
 	  com/sun/tracing \
--- a/test/java/awt/Focus/OverrideRedirectWindowActivationTest/OverrideRedirectWindowActivationTest.java	Tue May 07 14:13:53 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +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.
- *
- * 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       6385277
- * @summary   Tests that override redirect window gets activated on click.
- * @author    anton.tarasov@sun.com: area=awt.focus
- * @library   ../../regtesthelpers
- * @build     Util
- * @run       main OverrideRedirectWindowActivationTest
- */
-import java.awt.*;
-import java.awt.event.*;
-import java.util.concurrent.Callable;
-import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
-import test.java.awt.regtesthelpers.Util;
-
-public class OverrideRedirectWindowActivationTest {
-
-    private static Frame frame;
-    private static Window window;
-    private static Button fbutton;
-    private static Button wbutton;
-    private static Label label;
-    private static Robot robot;
-    private static SunToolkit toolkit;
-
-    public static void main(String[] args) throws Exception {
-
-        if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
-            System.out.println("No testing on Motif. Test passed.");
-            return;
-        }
-
-        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        robot = new Robot();
-        robot.setAutoDelay(50);
-
-        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
-
-            public void eventDispatched(AWTEvent e) {
-                System.out.println(e);
-            }
-        }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
-
-        createAndShowWindow();
-        toolkit.realSync();
-
-        createAndShowFrame();
-        toolkit.realSync();
-
-        // click on Frame
-        clickOn(getClickPoint(frame));
-
-        if (!frame.isFocused()) {
-            throw new RuntimeException("Error: a frame couldn't be focused by click.");
-        }
-
-        //click on Label in Window
-        clickOn(getClickPoint(label));
-
-        if (!window.isFocused()) {
-            throw new RuntimeException("Test failed: the window couldn't be activated by click!");
-        }
-
-        // bring focus back to the frame
-        clickOn(getClickPoint(fbutton));
-
-        if (!frame.isFocused()) {
-            throw new RuntimeException("Error: a frame couldn't be focused by click.");
-        }
-
-        // Test 2. Verifies that clicking on a component of unfocusable Window
-        //         won't activate it.
-
-        window.setFocusableWindowState(false);
-        toolkit.realSync();
-
-
-        clickOn(getClickPoint(label));
-
-        if (window.isFocused()) {
-            throw new RuntimeException("Test failed: unfocusable window got activated by click!");
-        }
-        System.out.println("Test passed.");
-
-    }
-
-    private static void createAndShowWindow() {
-
-        frame = new Frame("Test Frame");
-        window = new Window(frame);
-        wbutton = new Button("wbutton");
-        label = new Label("label");
-
-        window.setBounds(800, 200, 200, 100);
-        window.setLayout(new FlowLayout());
-        window.add(wbutton);
-        window.add(label);
-        window.setVisible(true);
-
-    }
-
-    private static void createAndShowFrame() {
-        fbutton = new Button("fbutton");
-
-        frame.setBounds(800, 0, 200, 100);
-        frame.setLayout(new FlowLayout());
-        frame.add(fbutton);
-        frame.setVisible(true);
-
-    }
-
-    static void clickOn(Point point) {
-
-        robot.mouseMove(point.x, point.y);
-
-        robot.mousePress(InputEvent.BUTTON1_MASK);
-        robot.mouseRelease(InputEvent.BUTTON1_MASK);
-
-        toolkit.realSync();
-    }
-
-    static Point getClickPoint(Component c) {
-        Point p = c.getLocationOnScreen();
-        Dimension d = c.getSize();
-        return new Point(p.x + (int) (d.getWidth() / 2), p.y + (int) (d.getHeight() / 2));
-    }
-
-    static Point getClickPoint(Frame frame) {
-        Point p = frame.getLocationOnScreen();
-        Dimension d = frame.getSize();
-        return new Point(p.x + (int) (d.getWidth() / 2), p.y + (frame.getInsets().top / 2));
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Focus/SimpleWindowActivationTest/SimpleWindowActivationTest.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2012, 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       6385277
+ * @summary   Tests that override redirect window gets activated on click.
+ * @author    anton.tarasov@sun.com: area=awt.focus
+ * @library   ../../regtesthelpers
+ * @build     Util
+ * @run       main SimpleWindowActivationTest
+ */
+import java.awt.*;
+import java.awt.event.*;
+import java.util.concurrent.Callable;
+import javax.swing.SwingUtilities;
+import sun.awt.SunToolkit;
+import test.java.awt.regtesthelpers.Util;
+
+public class SimpleWindowActivationTest {
+
+    private static Frame frame;
+    private static Window window;
+    private static Button fbutton;
+    private static Button wbutton;
+    private static Label label;
+    private static Robot robot;
+    private static SunToolkit toolkit;
+
+    public static void main(String[] args) throws Exception {
+
+        if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+            System.out.println("No testing on Motif. Test passed.");
+            return;
+        }
+
+        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+        robot.setAutoDelay(50);
+
+        Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+
+            public void eventDispatched(AWTEvent e) {
+                System.out.println(e);
+            }
+        }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
+
+        createAndShowWindow();
+        toolkit.realSync();
+
+        createAndShowFrame();
+        toolkit.realSync();
+
+        // click on Frame
+        clickOn(getClickPoint(frame));
+
+        if (!frame.isFocused()) {
+            throw new RuntimeException("Error: a frame couldn't be focused by click.");
+        }
+
+        //click on Label in Window
+        clickOn(getClickPoint(label));
+
+        if (!window.isFocused()) {
+            throw new RuntimeException("Test failed: the window couldn't be activated by click!");
+        }
+
+        // bring focus back to the frame
+        clickOn(getClickPoint(fbutton));
+
+        if (!frame.isFocused()) {
+            throw new RuntimeException("Error: a frame couldn't be focused by click.");
+        }
+
+        // Test 2. Verifies that clicking on a component of unfocusable Window
+        //         won't activate it.
+
+        window.setFocusableWindowState(false);
+        toolkit.realSync();
+
+
+        clickOn(getClickPoint(label));
+
+        if (window.isFocused()) {
+            throw new RuntimeException("Test failed: unfocusable window got activated by click!");
+        }
+        System.out.println("Test passed.");
+
+    }
+
+    private static void createAndShowWindow() {
+
+        frame = new Frame("Test Frame");
+        window = new Window(frame);
+        wbutton = new Button("wbutton");
+        label = new Label("label");
+
+        window.setBounds(800, 200, 300, 100);
+        window.setLayout(new FlowLayout());
+        window.add(wbutton);
+        window.add(label);
+        window.setVisible(true);
+
+    }
+
+    private static void createAndShowFrame() {
+        fbutton = new Button("fbutton");
+
+        frame.setBounds(800, 0, 300, 100);
+        frame.setLayout(new FlowLayout());
+        frame.add(fbutton);
+        frame.setVisible(true);
+
+    }
+
+    static void clickOn(Point point) {
+
+        robot.mouseMove(point.x, point.y);
+
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+        toolkit.realSync();
+    }
+
+    static Point getClickPoint(Component c) {
+        Point p = c.getLocationOnScreen();
+        Dimension d = c.getSize();
+        return new Point(p.x + (int) (d.getWidth() / 2), p.y + (int) (d.getHeight() / 2));
+    }
+
+    static Point getClickPoint(Frame frame) {
+        Point p = frame.getLocationOnScreen();
+        Dimension d = frame.getSize();
+        return new Point(p.x + (int) (d.getWidth() / 2), p.y + (frame.getInsets().top / 2));
+    }
+}
--- a/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/awt/Toolkit/BadDisplayTest/BadDisplayTest.sh	Mon May 13 16:52:33 2013 -0700
@@ -1,4 +1,4 @@
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 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
@@ -22,7 +22,8 @@
 ${TESTJAVA}/bin/javac -cp ${TESTSRC} -d . ${TESTSRC}/BadDisplayTest.java
 
 
-export DISPLAY=
+DISPLAY=
+export DISPLAY
 
 OS=`uname -s`
 case "$OS" in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/WMSpecificTests/Metacity/FullscreenDialogModality.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,144 @@
+/*
+ * 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 8012586
+ * @summary verify that modal dialog will appeared above fullscreen window under Metacity WM.
+ * @run main FullscreenDialogModality
+ * @run main/othervm FullscreenDialogModality
+ * @author vkravets
+ */
+
+import test.java.awt.regtesthelpers.Util;
+
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+
+public class FullscreenDialogModality extends Frame {
+
+    static Robot robot = null;
+
+    public void enterFS() {
+        GraphicsDevice gd = getGraphicsConfiguration().getDevice();
+        final boolean fs = gd.isFullScreenSupported();
+        System.out.println("FullscreenSupported: " + (fs ? "yes" : "no"));
+        gd.setFullScreenWindow(this);
+        try {
+            // Give the system time to set the FS window and display it
+            // properly
+            Thread.sleep(2000);
+        } catch (Exception e) {}
+    }
+
+    public void exitFS() {
+        GraphicsDevice gd = getGraphicsConfiguration().getDevice();
+        // reset window
+        gd.setFullScreenWindow(null);
+        try {
+            // Give the system time to set the FS window and display it
+            // properly
+            Thread.sleep(2000);
+        } catch (Exception e) {}
+    }
+
+    public void checkDialogModality() throws InvocationTargetException, InterruptedException {
+        // Dialog
+        final Dialog d = new Dialog(FullscreenDialogModality.this, "Modal dialog", Dialog.ModalityType.APPLICATION_MODAL);
+        d.setBounds(500, 500, 160, 160);
+        d.setModal(true);
+        d.setBackground(Color.red);
+        EventQueue.invokeLater(new Runnable()
+        {
+            public void run()
+            {
+                d.setVisible(true);
+            }
+        });
+        // Wait until the dialog is shown
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                // Empty
+            }
+        });
+
+        Util.waitForIdle(robot);
+        try {
+            //Check color
+            Point checkPoint = new Point(d.getX() + d.getWidth() / 2, d.getY() + d.getHeight() / 2);
+            Color actual = robot.getPixelColor(checkPoint.x, checkPoint.y);
+            System.out.println("Color = " + actual);
+            if (actual.getRGB() == Color.GREEN.getRGB()) {
+                throw new RuntimeException("Test FAILED: Modal dialog shown below fullscreen window");
+            } else if (actual.getRGB() == Color.RED.getRGB()) {
+                System.out.println("Test PASSED: Modal dialog shown above fullscreen window");
+            } else {
+                System.out.println("pixelColor " +
+                        Integer.toHexString(actual.getRGB()) +
+                        " at coordinates (" + checkPoint.x + ", " + checkPoint.y + ")");
+                throw new RuntimeException("Test FAILED: Unexpected behavior");
+            }
+
+            robot.delay(2000);
+            Util.waitForIdle(robot);
+        } finally {
+            d.dispose();
+        }
+    }
+
+    public static void main(String args[]) throws InvocationTargetException, InterruptedException {
+        if (Util.getWMID() != Util.METACITY_WM) {
+            System.out.println("This test is only useful on Metacity");
+            return;
+        }
+        robot = Util.createRobot();
+        Util.waitForIdle(robot);
+        final FullscreenDialogModality frame = new FullscreenDialogModality();
+        frame.setUndecorated(true);
+        frame.setBackground(Color.green);
+        frame.setSize(500, 500);
+        frame.setVisible(true);
+        try {
+            robot.delay(100);
+            Util.waitForIdle(robot);
+
+            EventQueue.invokeAndWait(new Runnable() {
+                public void run() {
+                    frame.enterFS();
+                }
+            });
+            robot.delay(200);
+            Util.waitForIdle(robot);
+
+            frame.checkDialogModality();
+
+            EventQueue.invokeAndWait(new Runnable() {
+                public void run() {
+                    frame.exitFS();
+                }
+            });
+        } finally {
+            frame.dispose();
+        }
+    }
+}
--- a/test/java/beans/XMLEncoder/AbstractTest.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/beans/XMLEncoder/AbstractTest.java	Mon May 13 16:52:33 2013 -0700
@@ -30,8 +30,10 @@
 
 import java.nio.charset.Charset;
 
+import java.lang.reflect.Field;
+
 abstract class AbstractTest<T> implements ExceptionListener {
-    private final BeanValidator validator = new BeanValidator();
+    final BeanValidator validator = new BeanValidator();
 
     public final void exceptionThrown(Exception exception) {
         throw new Error("unexpected exception", exception);
@@ -59,7 +61,7 @@
     }
 
     /**
-     * This method should be overriden
+     * This method should be overridden
      * if specified encoder should be initialized.
      *
      * @param encoder  the XML encoder to initialize
@@ -68,7 +70,7 @@
     }
 
     /**
-     * This method should be overriden
+     * This method should be overridden
      * if specified decoder should be initialized.
      *
      * @param decoder  the XML decoder to initialize
@@ -77,7 +79,7 @@
     }
 
     /**
-     * This method should be overriden
+     * This method should be overridden
      * for test-specific comparison.
      *
      * @param before  the object before encoding
@@ -134,6 +136,7 @@
     private byte[] writeObject(Object object) {
         ByteArrayOutputStream output = new ByteArrayOutputStream();
         XMLEncoder encoder = new XMLEncoder(output);
+        encoder.setExceptionListener(this);
         initialize(encoder);
         encoder.writeObject(object);
         encoder.close();
@@ -143,9 +146,24 @@
     private Object readObject(byte[] array) {
         ByteArrayInputStream input = new ByteArrayInputStream(array);
         XMLDecoder decoder = new XMLDecoder(input);
+        decoder.setExceptionListener(this);
         initialize(decoder);
         Object object = decoder.readObject();
         decoder.close();
         return object;
     }
+
+    static Field getField(String name) {
+        try {
+            int index = name.lastIndexOf('.');
+            String className = name.substring(0, index);
+            String fieldName = name.substring(1 + index);
+            Field field = Class.forName(className).getDeclaredField(fieldName);
+            field.setAccessible(true);
+            return field;
+        }
+        catch (Exception exception) {
+            throw new Error(exception);
+        }
+    }
 }
--- a/test/java/beans/XMLEncoder/BeanValidator.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/beans/XMLEncoder/BeanValidator.java	Mon May 13 16:52:33 2013 -0700
@@ -63,6 +63,15 @@
         }
         Class type = object1.getClass();
         if (!type.equals(object2.getClass())) {
+            // resolve different implementations of the Map.Entry interface
+            if ((object1 instanceof Map.Entry) && (object2 instanceof Map.Entry)) {
+                log("!!! special case", "Map.Entry");
+                Map.Entry entry1 = (Map.Entry) object1;
+                Map.Entry entry2 = (Map.Entry) object2;
+                validate(entry1.getKey(), entry2.getKey());
+                validate(entry1.getValue(), entry2.getValue());
+                return;
+            }
             throw new IllegalStateException("could not compare objects with different types");
         }
         // validate elements of arrays
@@ -82,10 +91,14 @@
             }
             return;
         }
+        // special case for collections: do not use equals
+        boolean ignore = Collection.class.isAssignableFrom(type)
+                || Map.Entry.class.isAssignableFrom(type)
+                || Map.class.isAssignableFrom(type);
         // validate objects using equals()
         // we assume that the method equals(Object) can be called,
         // if the class declares such method
-        if (isDefined(type, "equals", Object.class)) {
+        if (!ignore && isDefined(type, "equals", Object.class)) {
             if (object1.equals(object2)) {
                 return;
             }
@@ -205,27 +218,7 @@
     }
 
     private void validate(Map map1, Map map2, boolean sorted) {
-        if (map1.size() != map2.size()) {
-            throw new IllegalStateException("could not compare maps with different sizes");
-        }
-        if (sorted) {
-            Iterator first = map1.entrySet().iterator();
-            Iterator second = map2.entrySet().iterator();
-            int index = 0;
-            while (first.hasNext() && second.hasNext()) {
-                log("validate map entry", Integer.valueOf(index++));
-                validate(first.next(), second.next());
-            }
-            if (first.hasNext() || second.hasNext()) {
-                throw new IllegalStateException("one map contains more entries than another one");
-            }
-        } else {
-            // assume that equals() can be used for keys
-            for (Object key : map1.keySet()) {
-                log("validate map value for key", key);
-                validate(map1.get(key), map2.get(key));
-            }
-        }
+        validate(map1.entrySet(), map2.entrySet(), sorted);
     }
 
     private boolean isCyclic(Object object1, Object object2) {
--- a/test/java/beans/XMLEncoder/Test4631471.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/beans/XMLEncoder/Test4631471.java	Mon May 13 16:52:33 2013 -0700
@@ -28,7 +28,6 @@
  * @author Sergey Malenkov, Mark Davidson
  */
 
-import java.beans.XMLEncoder;
 import javax.swing.JTree;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
@@ -78,10 +77,6 @@
         // do not any validation
     }
 
-    protected final void initialize(XMLEncoder encoder) {
-        encoder.setExceptionListener(this);
-    }
-
     public static TreeNode getRoot() {
         DefaultMutableTreeNode node = new DefaultMutableTreeNode("root");
         DefaultMutableTreeNode first = new DefaultMutableTreeNode("first");
--- a/test/java/beans/XMLEncoder/Test4679556.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/beans/XMLEncoder/Test4679556.java	Mon May 13 16:52:33 2013 -0700
@@ -103,7 +103,6 @@
     }
 
     protected void initialize(XMLEncoder encoder) {
-        encoder.setExceptionListener(this);
         encoder.setPersistenceDelegate(C.class, new DefaultPersistenceDelegate() {
             protected Expression instantiate(Object oldInstance, Encoder out) {
                 C c = (C) oldInstance;
--- a/test/java/beans/XMLEncoder/java_awt_BorderLayout.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/beans/XMLEncoder/java_awt_BorderLayout.java	Mon May 13 16:52:33 2013 -0700
@@ -68,11 +68,9 @@
     @Override
     protected void validate(BorderLayout before, BorderLayout after) {
         super.validate(before, after);
-
-        BeanValidator validator = new BeanValidator();
         for (String constraint : CONSTRAINTS) {
-            validator.validate(before.getLayoutComponent(constraint),
-                               after.getLayoutComponent(constraint));
+            super.validator.validate(before.getLayoutComponent(constraint),
+                                     after.getLayoutComponent(constraint));
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/XMLEncoder/java_awt_CardLayout.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8007458
+ * @summary Tests CardLayout encoding
+ * @author Sergey Malenkov
+ */
+
+import java.awt.CardLayout;
+import java.lang.reflect.Field;
+import java.util.Vector;
+import javax.swing.JLabel;
+
+public final class java_awt_CardLayout extends AbstractTest<CardLayout> {
+    private static final Field VECTOR = getField("java.awt.CardLayout.vector");
+    private static final Field NAME = getField("java.awt.CardLayout$Card.name");
+    private static final Field COMP = getField("java.awt.CardLayout$Card.comp");
+
+    public static void main(String[] args) throws Exception {
+        new java_awt_CardLayout().test(true);
+    }
+
+    @Override
+    protected CardLayout getObject() {
+        CardLayout layout = new CardLayout();
+        layout.addLayoutComponent(new JLabel("a"), "a");
+        layout.addLayoutComponent(new JLabel("b"), "b");
+        layout.addLayoutComponent(new JLabel("c"), "c");
+        return layout;
+    }
+
+    @Override
+    protected CardLayout getAnotherObject() {
+        CardLayout layout = new CardLayout();
+        layout.addLayoutComponent(new JLabel("a"), "a");
+        layout.addLayoutComponent(new JLabel("b"), "b");
+        layout.addLayoutComponent(new JLabel("c"), "c");
+        layout.addLayoutComponent(new JLabel("d"), "d");
+        return layout;
+    }
+
+    @Override
+    protected void validate(CardLayout before, CardLayout after) {
+        super.validate(before, after);
+        try {
+            Vector a = (Vector) VECTOR.get(after);
+            Vector b = (Vector) VECTOR.get(before);
+            int size = a.size();
+            if (size != b.size()) {
+                throw new Error("different content");
+            }
+            for (int i = 0; i < size; i++) {
+                super.validator.validate(NAME.get(a.get(i)), NAME.get(b.get(i)));
+                super.validator.validate(COMP.get(a.get(i)), COMP.get(b.get(i)));
+            }
+        }
+        catch (Exception exception) {
+            throw new Error(exception);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/XMLEncoder/java_awt_GridBagLayout.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,101 @@
+/*
+ * 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 8007458
+ * @summary Tests GridBagLayout encoding
+ * @author Sergey Malenkov
+ */
+
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.lang.reflect.Field;
+import java.util.Hashtable;
+import java.util.Map;
+import javax.swing.JLabel;
+
+public final class java_awt_GridBagLayout extends AbstractTest<GridBagLayout> {
+    private static final Field HASHTABLE = getField("java.awt.GridBagLayout.comptable");
+
+    public static void main(String[] args) {
+        new java_awt_GridBagLayout().test(true);
+    }
+
+    @Override
+    protected GridBagLayout getObject() {
+        GridBagLayout layout = new GridBagLayout();
+        update(layout, "1", 1, 1);
+        update(layout, "2", 2, 2);
+        update(layout, "3", 3, 3);
+        return layout;
+    }
+
+    @Override
+    protected GridBagLayout getAnotherObject() {
+        GridBagLayout layout = new GridBagLayout();
+        update(layout, "11", 1, 1);
+        update(layout, "12", 1, 2);
+        update(layout, "21", 2, 1);
+        update(layout, "22", 2, 2);
+        return layout;
+    }
+
+    @Override
+    protected void validate(GridBagLayout before, GridBagLayout after) {
+        super.validate(before, after);
+        try {
+            Hashtable a = (Hashtable) HASHTABLE.get(after);
+            Hashtable b = (Hashtable) HASHTABLE.get(before);
+            super.validator.validate(a, b);
+
+//            for (int i = 0; i < size; i++) {
+//                validator.validate(NAME.get(a.get(i)), NAME.get(b.get(i)));
+//                validator.validate(COMP.get(a.get(i)), COMP.get(b.get(i)));
+//            }
+        }
+        catch (Exception exception) {
+            throw new Error(exception);
+        }
+
+
+
+//        for (String name : names) {
+//            validator.validate(getConstraints(before, name), getConstraints(after, name));
+//        }
+    }
+
+    private static void update(GridBagLayout layout, String id, int x, int y) {
+        GridBagConstraints gbc = new GridBagConstraints();
+        gbc.gridx = x;
+        gbc.gridy = y;
+        layout.addLayoutComponent(new JLabel(id), gbc);
+    }
+
+/*
+    private static GridBagConstraints getConstraints(GridBagLayout layout, String id) {
+        return (layout == null) ? null : ((MyGridBagLayout) layout).getConstraints(id);
+    }
+*/
+}
--- a/test/java/beans/XMLEncoder/javax_swing_DefaultCellEditor.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/beans/XMLEncoder/javax_swing_DefaultCellEditor.java	Mon May 13 16:52:33 2013 -0700
@@ -28,6 +28,7 @@
  * @author Sergey Malenkov
  */
 
+import java.beans.XMLEncoder;
 import javax.swing.DefaultCellEditor;
 import javax.swing.JTextField;
 import javax.swing.text.JTextComponent;
@@ -46,6 +47,11 @@
         // return new DefaultCellEditor(new JTextField("Second"));
     }
 
+    @Override
+    protected void initialize(XMLEncoder encoder) {
+        encoder.setExceptionListener(null); // TODO: ignore non-public listener because of 4808251
+    }
+
     protected void validate(DefaultCellEditor before, DefaultCellEditor after) {
         String text = ((JTextComponent) after.getComponent()).getText();
         if (!text.equals(((JTextComponent) before.getComponent()).getText()))
--- a/test/java/lang/Math/DivModTests.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/lang/Math/DivModTests.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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,7 +137,8 @@
             int tmp = x / y;     // Force ArithmeticException for divide by zero
             double ff = x - Math.floor((double)x / (double)y) * y;
             int fr = (int)ff;
-            if (fr != result) {
+            boolean t = (fr == ((Integer)result));
+            if (!result.equals(fr)) {
                 fail("FAIL: Math.floorMod(%d, %d) = %s differs from Math.floor(x, y): %d%n", x, y, result, fr);
             }
         } catch (ArithmeticException ae) {
@@ -240,8 +241,8 @@
             resultD = resultD.multiply(yD);
             resultD = xD.subtract(resultD);
             long fr = resultD.longValue();
-            if (fr != result) {
-                fail("FAIL: Long.floorMod(%d, %d) = %d is different than BigDecimal result: %d%n",x, y, result, fr);
+            if (!result.equals(fr)) {
+                fail("FAIL: Long.floorMod(%d, %d) = %d is different than BigDecimal result: %d%n", x, y, result, fr);
 
             }
         } catch (ArithmeticException ae) {
--- a/test/java/lang/annotation/TypeAnnotationReflection.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/lang/annotation/TypeAnnotationReflection.java	Mon May 13 16:52:33 2013 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8004698
+ * @bug 8004698 8007073
  * @summary Unit test for type annotations
  */
 
@@ -48,6 +48,8 @@
         testParameterizedType();
         testNestedParameterizedType();
         testWildcardType();
+        testParameterTypes();
+        testParameterType();
     }
 
     private static void check(boolean b) {
@@ -359,6 +361,154 @@
         t = w.getAnnotatedLowerBounds();
         check(t.length == 1);
     }
+
+    private static void testParameterTypes() throws Exception {
+        // NO PARAMS
+        Method m = Params.class.getDeclaredMethod("noParams", (Class<?>[])null);
+        AnnotatedType[] t = m.getAnnotatedParameterTypes();
+        check(t.length == 0);
+
+        // ONLY ANNOTATED PARAM TYPES
+        Class[] argsArr = {String.class, String.class, String.class};
+        m = Params.class.getDeclaredMethod("onlyAnnotated", (Class<?>[])argsArr);
+        t = m.getAnnotatedParameterTypes();
+        check(t.length == 3);
+
+        check(t[0].getAnnotations().length == 1);
+        check(t[0].getAnnotation(TypeAnno.class) != null);
+        check(t[0].getAnnotationsByType(TypeAnno.class)[0].value().equals("1"));
+
+        check(t[1].getAnnotations().length == 1);
+        check(t[1].getAnnotation(TypeAnno.class) != null);
+        check(t[1].getAnnotationsByType(TypeAnno.class)[0].value().equals("2"));
+
+        check(t[2].getAnnotations().length == 2);
+        check(t[2].getAnnotations()[0].annotationType().equals(TypeAnno.class));
+        check(t[2].getAnnotation(TypeAnno.class) != null);
+        check(t[2].getAnnotation(TypeAnno2.class) != null);
+        check(t[2].getAnnotationsByType(TypeAnno.class)[0].value().equals("3a"));
+        check(t[2].getAnnotationsByType(TypeAnno2.class)[0].value().equals("3b"));
+
+        // MIXED ANNOTATED PARAM TYPES
+        m = Params.class.getDeclaredMethod("mixed", (Class<?>[])argsArr);
+        t = m.getAnnotatedParameterTypes();
+        check(t.length == 3);
+
+        check(t[0].getAnnotations().length == 1);
+        check(t[0].getAnnotation(TypeAnno.class) != null);
+        check(t[0].getAnnotationsByType(TypeAnno.class)[0].value().equals("1"));
+
+        check(t[1].getAnnotations().length == 0);
+        check(t[1].getAnnotation(TypeAnno.class) == null);
+        check(t[1].getAnnotation(TypeAnno2.class) == null);
+
+        check(t[2].getAnnotations().length == 2);
+        check(t[2].getAnnotations()[0].annotationType().equals(TypeAnno.class));
+        check(t[2].getAnnotation(TypeAnno.class) != null);
+        check(t[2].getAnnotation(TypeAnno2.class) != null);
+        check(t[2].getAnnotationsByType(TypeAnno.class)[0].value().equals("3a"));
+        check(t[2].getAnnotationsByType(TypeAnno2.class)[0].value().equals("3b"));
+
+        // NO ANNOTATED PARAM TYPES
+        m = Params.class.getDeclaredMethod("unAnnotated", (Class<?>[])argsArr);
+        t = m.getAnnotatedParameterTypes();
+        check(t.length == 3);
+
+        check(t[0].getAnnotations().length == 0);
+        check(t[0].getAnnotation(TypeAnno.class) == null);
+        check(t[0].getAnnotation(TypeAnno2.class) == null);
+
+        check(t[1].getAnnotations().length == 0);
+        check(t[1].getAnnotation(TypeAnno.class) == null);
+        check(t[1].getAnnotation(TypeAnno2.class) == null);
+
+        check(t[2].getAnnotations().length == 0);
+        check(t[2].getAnnotation(TypeAnno.class) == null);
+        check(t[2].getAnnotation(TypeAnno2.class) == null);
+    }
+
+    private static void testParameterType() throws Exception {
+        // NO PARAMS
+        Method m = Params.class.getDeclaredMethod("noParams", (Class<?>[])null);
+        Parameter[] p = m.getParameters();
+        check(p.length == 0);
+
+        // ONLY ANNOTATED PARAM TYPES
+        Class[] argsArr = {String.class, String.class, String.class};
+        m = Params.class.getDeclaredMethod("onlyAnnotated", (Class<?>[])argsArr);
+        p = m.getParameters();
+        check(p.length == 3);
+        AnnotatedType t0 = p[0].getAnnotatedType();
+        AnnotatedType t1 = p[1].getAnnotatedType();
+        AnnotatedType t2 = p[2].getAnnotatedType();
+
+        check(t0.getAnnotations().length == 1);
+        check(t0.getAnnotation(TypeAnno.class) != null);
+        check(t0.getAnnotationsByType(TypeAnno.class)[0].value().equals("1"));
+
+        check(t1.getAnnotations().length == 1);
+        check(t1.getAnnotation(TypeAnno.class) != null);
+        check(t1.getAnnotationsByType(TypeAnno.class)[0].value().equals("2"));
+
+        check(t2.getAnnotations().length == 2);
+        check(t2.getAnnotations()[0].annotationType().equals(TypeAnno.class));
+        check(t2.getAnnotation(TypeAnno.class) != null);
+        check(t2.getAnnotation(TypeAnno2.class) != null);
+        check(t2.getAnnotationsByType(TypeAnno.class)[0].value().equals("3a"));
+        check(t2.getAnnotationsByType(TypeAnno2.class)[0].value().equals("3b"));
+
+        // MIXED ANNOTATED PARAM TYPES
+        m = Params.class.getDeclaredMethod("mixed", (Class<?>[])argsArr);
+        p = m.getParameters();
+        check(p.length == 3);
+
+        t0 = p[0].getAnnotatedType();
+        t1 = p[1].getAnnotatedType();
+        t2 = p[2].getAnnotatedType();
+
+        check(t0.getAnnotations().length == 1);
+        check(t0.getAnnotation(TypeAnno.class) != null);
+        check(t0.getAnnotationsByType(TypeAnno.class)[0].value().equals("1"));
+
+        check(t1.getAnnotations().length == 0);
+        check(t1.getAnnotation(TypeAnno.class) == null);
+        check(t1.getAnnotation(TypeAnno2.class) == null);
+
+        check(t2.getAnnotations().length == 2);
+        check(t2.getAnnotations()[0].annotationType().equals(TypeAnno.class));
+        check(t2.getAnnotation(TypeAnno.class) != null);
+        check(t2.getAnnotation(TypeAnno2.class) != null);
+        check(t2.getAnnotationsByType(TypeAnno.class)[0].value().equals("3a"));
+        check(t2.getAnnotationsByType(TypeAnno2.class)[0].value().equals("3b"));
+
+        // NO ANNOTATED PARAM TYPES
+        m = Params.class.getDeclaredMethod("unAnnotated", (Class<?>[])argsArr);
+        p = m.getParameters();
+        check(p.length == 3);
+
+        t0 = p[0].getAnnotatedType();
+        t1 = p[1].getAnnotatedType();
+        t2 = p[2].getAnnotatedType();
+
+        check(t0.getAnnotations().length == 0);
+        check(t0.getAnnotation(TypeAnno.class) == null);
+        check(t0.getAnnotation(TypeAnno2.class) == null);
+
+        check(t1.getAnnotations().length == 0);
+        check(t1.getAnnotation(TypeAnno.class) == null);
+        check(t1.getAnnotation(TypeAnno2.class) == null);
+
+        check(t2.getAnnotations().length == 0);
+        check(t2.getAnnotation(TypeAnno.class) == null);
+        check(t2.getAnnotation(TypeAnno2.class) == null);
+    }
+}
+
+class Params {
+    public void noParams() {}
+    public void onlyAnnotated(@TypeAnno("1") String s1, @TypeAnno("2") String s2, @TypeAnno("3a") @TypeAnno2("3b") String s3) {}
+    public void mixed(@TypeAnno("1") String s1, String s2, @TypeAnno("3a") @TypeAnno2("3b") String s3) {}
+    public void unAnnotated(String s1, String s2, String s3) {}
 }
 
 abstract class TestWildcardType {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/nio/file/Files/NameLimits.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,103 @@
+/*
+ * 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 8011128
+ * @summary Test file and directory name limits. This test is primarily
+ *   intended to test Files.createDirectory on resolved paths at or around
+ *   the short path limit of 248 on Windows.
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class NameLimits {
+
+    static final int MAX_PATH = 255;
+    static final int MIN_PATH = 8;     // arbitrarily chosen
+
+    static Path generatePath(int len) {
+        if (len < MIN_PATH)
+            throw new RuntimeException("Attempting to generate path less than MIN_PATH");
+        StringBuilder sb = new StringBuilder(len);
+        sb.append("name");
+        while (sb.length() < len) {
+            sb.append('X');
+        }
+        return Paths.get(sb.toString());
+    }
+
+    static boolean tryCreateFile(int len) throws IOException {
+        Path name = generatePath(len);
+        try {
+            Files.createFile(name);
+        } catch (IOException ioe) {
+            System.err.format("Unable to create file of length %d (full path %d), %s%n",
+                name.toString().length(), name.toAbsolutePath().toString().length(), ioe);
+            return false;
+        }
+        Files.delete(name);
+        return true;
+    }
+
+    static boolean tryCreateDirectory(int len) throws IOException {
+        Path name = generatePath(len);
+        try {
+            Files.createDirectory(name);
+        } catch (IOException ioe) {
+            System.err.format("Unable to create directory of length %d (full path %d), %s%n",
+                name.toString().length(), name.toAbsolutePath().toString().length(), ioe);
+            return false;
+        }
+        Files.delete(name);
+        return true;
+    }
+
+    public static void main(String[] args) throws Exception {
+        int len;
+
+        // find the maximum file name if MAX_PATH or less
+        len = MAX_PATH;
+        while (!tryCreateFile(len)) {
+            len--;
+        }
+        System.out.format("Testing createFile on paths %d .. %d%n", MIN_PATH, len);
+        while (len >= MIN_PATH) {
+            if (!tryCreateFile(len--))
+                throw new RuntimeException("Test failed");
+        }
+
+        // find the maximum directory name if MAX_PATH or less
+        len = MAX_PATH;
+        while (!tryCreateDirectory(len)) {
+            len--;
+        }
+        System.out.format("Testing createDirectory on paths %d .. %d%n", MIN_PATH, len);
+        while (len >= MIN_PATH) {
+            if (!tryCreateDirectory(len--))
+                throw new RuntimeException("Test failed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/concurrent/atomic/AtomicReferenceTest.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,58 @@
+/*
+ * 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.util.concurrent.atomic.AtomicReference;
+import java.util.function.UnaryOperator;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/*
+ * @test
+ * @summary Test Map default methods
+ * @run testng AtomicReferenceTest
+ * @author Jim Gish <jim.gish@oracle.com>
+ */
+public class AtomicReferenceTest {
+
+    /**
+     * Test of updateAndGet method, of class AtomicReference.
+     */
+    @Test
+    public void testUpdateAndGet() {
+        AtomicReference<Integer> instance = new AtomicReference<>(3);
+        assertEquals((int) instance.get(), 3);
+        assertEquals((int) instance.updateAndGet(x -> x + 2), 5);
+        assertEquals((int) instance.get(), 5);
+    }
+
+    /**
+     * Test of getAndUpdate method, of class AtomicReference.
+     */
+    @Test
+    public void testGetAndUpdate() {
+        AtomicReference<Integer> instance = new AtomicReference<>(3);
+        assertEquals((int) instance.get(), 3);
+        assertEquals((int) instance.getAndUpdate(x -> x + 3), 3);
+        assertEquals((int) instance.get(), 6);
+    }
+}
--- a/test/java/util/regex/RegExTest.java	Tue May 07 14:13:53 2013 -0700
+++ b/test/java/util/regex/RegExTest.java	Mon May 13 16:52:33 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, 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
@@ -33,7 +33,7 @@
  * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
  * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
  * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
- * 7067045 7014640 7189363 8007395 8013252 8013254
+ * 7067045 7014640 7189363 8007395 8013252 8013254 8012646
  */
 
 import java.util.regex.*;
@@ -41,6 +41,7 @@
 import java.io.*;
 import java.util.*;
 import java.nio.CharBuffer;
+import java.util.function.Predicate;
 
 /**
  * This is a test class created to check the operation of
@@ -145,6 +146,7 @@
         linebreakTest();
         branchTest();
         groupCurlyNotFoundSuppTest();
+        patternAsPredicate();
         if (failure) {
             throw new
                 RuntimeException("RegExTest failed, 1st failure: " +
@@ -3997,4 +3999,19 @@
         report("GroupCurly NotFoundSupp");
     }
 
+    // This test is for 8012646
+    private static void patternAsPredicate() throws Exception {
+        Predicate<String> p = Pattern.compile("[a-z]+").asPredicate();
+
+        if (p.test("")) {
+            failCount++;
+        }
+        if (!p.test("word")) {
+            failCount++;
+        }
+        if (p.test("1234")) {
+            failCount++;
+        }
+        report("Pattern.asPredicate");
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/TEST.properties	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,3 @@
+# This file identifies root(s) of the test-ng hierarchy.
+
+bootclasspath.dirs = .
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/CollectorOps.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import org.testng.Assert;
+
+import java.util.Spliterator;
+import java.util.function.IntFunction;
+
+/** Test helper class for java.util.stream test framework */
+public final class CollectorOps {
+    private CollectorOps() { }
+
+    public static <E_IN> StatefulTestOp<E_IN> collector() {
+        return new StatefulCollector<>(0, StreamShape.REFERENCE);
+    }
+
+    /* Utility classes for collecting output of intermediate pipeline stages */
+    public static class StatefulCollector<E_IN> implements StatefulTestOp<E_IN> {
+        private final int opFlags;
+        private final StreamShape inputShape;
+
+        public StatefulCollector(int opFlags, StreamShape inputShape) {
+            this.opFlags = opFlags;
+            this.inputShape = inputShape;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return inputShape;
+        }
+
+        @Override
+        public StreamShape outputShape() {
+            return inputShape;
+        }
+
+        @Override
+        public int opGetFlags() {
+            return opFlags;
+        }
+
+        @Override
+        public Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_IN> sink) {
+            return sink;
+        }
+
+        @Override
+        public <P_IN> Node<E_IN> opEvaluateParallel(PipelineHelper<E_IN> helper,
+                                                    Spliterator<P_IN> spliterator,
+                                                    IntFunction<E_IN[]> generator) {
+            return helper.evaluate(spliterator, false, generator);
+        }
+    }
+
+    public static class TestParallelSizedOp<T> extends StatefulCollector<T> {
+        public TestParallelSizedOp() {
+            this(StreamShape.REFERENCE);
+        }
+
+        protected TestParallelSizedOp(StreamShape shape) {
+            super(0, shape);
+        }
+
+        @Override
+        public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+                                                 Spliterator<P_IN> spliterator,
+                                                 IntFunction<T[]> generator) {
+            int flags = helper.getStreamAndOpFlags();
+
+            Assert.assertTrue(StreamOpFlag.SIZED.isKnown(flags));
+            return super.opEvaluateParallel(helper, spliterator, generator);
+        }
+
+        public static class OfInt extends TestParallelSizedOp<Integer> {
+            public OfInt() {
+                super(StreamShape.INT_VALUE);
+            }
+        }
+
+        public static class OfLong extends TestParallelSizedOp<Long> {
+            public OfLong() {
+                super(StreamShape.LONG_VALUE);
+            }
+        }
+
+        public static class OfDouble extends TestParallelSizedOp<Double> {
+            public OfDouble() {
+                super(StreamShape.DOUBLE_VALUE);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestDataProvider.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for double-valued streams */
+public class DoubleStreamTestDataProvider {
+    private static final double[] to0 = new double[0];
+    private static final double[] to1 = new double[1];
+    private static final double[] to10 = new double[10];
+    private static final double[] to100 = new double[100];
+    private static final double[] to1000 = new double[1000];
+    private static final double[] reversed = new double[100];
+    private static final double[] ones = new double[100];
+    private static final double[] twice = new double[200];
+    private static final double[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        double[][] arrays = {to0, to1, to10, to100, to1000};
+        for (double[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new double[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (double) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> list = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final double[] doubles = (double[]) data[1];
+
+                list.add(new Object[]{"array:" + name,
+                        TestData.Factory.ofArray("array:" + name, doubles)});
+
+                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+                for (double i : doubles) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+                list.add(streamDataDescr("Primitives.range(0,l): " + doubles.length,
+                                         () -> DoubleStream.range(0, doubles.length)));
+                list.add(streamDataDescr("Primitives.range(0,l,2): " + doubles.length,
+                                         () -> DoubleStream.range(0, doubles.length, 2)));
+                list.add(streamDataDescr("Primitives.range(0,l,3): " + doubles.length,
+                                         () -> DoubleStream.range(0, doubles.length, 3)));
+                list.add(streamDataDescr("Primitives.range(0,l,7): " + doubles.length,
+                                         () -> DoubleStream.range(0, doubles.length, 7)));
+            }
+            testData = list.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final double[] doubles = (double[]) data[1];
+
+                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+                for (double i : doubles) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(doubles)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(doubles, 0, doubles.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), doubles.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+                spliterators.add(splitDescr("Primitives.range(0,l):" + name,
+                                            () -> DoubleStream.range(0, doubles.length).spliterator()));
+                spliterators.add(splitDescr("Primitives.range(0,l,2):" + name,
+                                            () -> DoubleStream.range(0, doubles.length, 2).spliterator()));
+                spliterators.add(splitDescr("Primitives.range(0,l,3):" + name,
+                                            () -> DoubleStream.range(0, doubles.length, 3).spliterator()));
+                spliterators.add(splitDescr("Primitives.range(0,l,7):" + name,
+                                            () -> DoubleStream.range(0, doubles.length, 7).spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<DoubleStream> s) {
+        return new Object[] { description, TestData.Factory.ofDoubleSupplier(description, s) };
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfDouble> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, DoubleStreamTestData )
+    @DataProvider(name = "DoubleStreamTestData")
+    public static Object[][] makeDoubleStreamTestData() {
+        return testData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
+    @DataProvider(name = "DoubleSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/DoubleStreamTestScenario.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+package java.util.stream;
+
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.DoubleConsumer;
+import java.util.function.Function;
+
+/**
+ * Test scenarios for double streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum DoubleStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            DoubleStream s = m.apply(data.stream());
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (double t : m.apply(data.stream()).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (PrimitiveIterator.OfDouble seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextDouble());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (Spliterator.OfDouble spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(data.stream()).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(data.stream()).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(data.parallelStream()).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(data.parallelStream()).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (Spliterator.OfDouble spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(data.parallelStream()).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (double t : m.apply(data.parallelStream()).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            DoubleStream s = m.apply(data.parallelStream());
+            Spliterator.OfDouble sp = s.spliterator();
+            DoubleStream ss = StreamSupport.doubleParallelStream(() -> sp,
+                                                                 StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                                 | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED));
+            for (double t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            DoubleStream pipe2 = m.apply(pipe1);
+
+            for (double t : pipe2.toArray())
+                b.accept(t);
+        }
+    },;
+
+    private boolean isParallel;
+
+    DoubleStreamTestScenario(boolean isParallel) {
+        this.isParallel = isParallel;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.DOUBLE_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        _run(data, (DoubleConsumer) b, (Function<S_IN, DoubleStream>) m);
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void _run(TestData<T, S_IN> data, DoubleConsumer b, Function<S_IN, DoubleStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/FlagDeclaringOp.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+/**
+ * An operation that injects or clears flags but otherwise performs no operation on elements.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class FlagDeclaringOp<T> implements StatelessTestOp<T, T> {
+    private final int flags;
+    private final StreamShape shape;
+
+    public FlagDeclaringOp(int flags) {
+        this(flags, StreamShape.REFERENCE);
+    }
+
+    public FlagDeclaringOp(int flags, StreamShape shape) {
+        this.flags = flags;
+        this.shape = shape;
+    }
+
+    @Override
+    public StreamShape outputShape() {
+        return shape;
+    }
+
+    @Override
+    public StreamShape inputShape() {
+        return shape;
+    }
+
+    @Override
+    public int opGetFlags() {
+        return flags;
+    }
+
+    @Override
+    public Sink<T> opWrapSink(int flags, boolean parallel, Sink sink) {
+        return sink;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/IntStreamTestDataProvider.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for int-valued streams */
+public class IntStreamTestDataProvider {
+    private static final int[] to0 = new int[0];
+    private static final int[] to1 = new int[1];
+    private static final int[] to10 = new int[10];
+    private static final int[] to100 = new int[100];
+    private static final int[] to1000 = new int[1000];
+    private static final int[] reversed = new int[100];
+    private static final int[] ones = new int[100];
+    private static final int[] twice = new int[200];
+    private static final int[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        int[][] arrays = {to0, to1, to10, to100, to1000};
+        for (int[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new int[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> list = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final int[] ints = (int[]) data[1];
+
+                list.add(new Object[]{"array:" +
+                                      name, TestData.Factory.ofArray("array:" + name, ints)});
+
+                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+                for (int i : ints) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                         TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+                list.add(streamDataDescr("IntStream.intRange(0,l): " + ints.length,
+                                         () -> IntStream.range(0, ints.length)));
+                list.add(streamDataDescr("IntStream.intRange(0,l,2): " + ints.length,
+                                         () -> IntStream.range(0, ints.length, 2)));
+                list.add(streamDataDescr("IntStream.intRange(0,l,3): " + ints.length,
+                                         () -> IntStream.range(0, ints.length, 3)));
+                list.add(streamDataDescr("IntStream.intRange(0,l,7): " + ints.length,
+                                         () -> IntStream.range(0, ints.length, 7)));
+            }
+            testData = list.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final int[] ints = (int[]) data[1];
+
+                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+                for (int i : ints) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(ints)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(ints, 0, ints.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), ints.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+                spliterators.add(splitDescr("IntStream.intRange(0,l):" + name,
+                                            () -> IntStream.range(0, ints.length).spliterator()));
+                spliterators.add(splitDescr("IntStream.intRange(0,l,2):" + name,
+                                            () -> IntStream.range(0, ints.length, 2).spliterator()));
+                spliterators.add(splitDescr("IntStream.intRange(0,l,3):" + name,
+                                            () -> IntStream.range(0, ints.length, 3).spliterator()));
+                spliterators.add(splitDescr("IntStream.intRange(0,l,7):" + name,
+                                            () -> IntStream.range(0, ints.length, 7).spliterator()));
+
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<IntStream> s) {
+        return new Object[] { description, TestData.Factory.ofIntSupplier(description, s) };
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfInt> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, IntStreamTestData )
+    @DataProvider(name = "IntStreamTestData")
+    public static Object[][] makeIntStreamTestData() {
+        return testData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
+    @DataProvider(name = "IntSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/IntStreamTestScenario.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.IntConsumer;
+
+/**
+ * Test scenarios for int streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            IntStream s = m.apply(data.stream());
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (int t : m.apply(data.stream()).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (PrimitiveIterator.OfInt seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextInt());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (Spliterator.OfInt spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(data.stream()).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(data.stream()).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(data.parallelStream()).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(data.parallelStream()).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (Spliterator.OfInt spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(data.parallelStream()).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (int t : m.apply(data.parallelStream()).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            IntStream s = m.apply(data.parallelStream());
+            Spliterator.OfInt sp = s.spliterator();
+            IntStream ss = StreamSupport.intParallelStream(() -> sp,
+                                                           StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                           | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED));
+            for (int t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            IntStream pipe2 = m.apply(pipe1);
+
+            for (int t : pipe2.toArray())
+                b.accept(t);
+        }
+    },;
+
+    private boolean isParallel;
+
+    IntStreamTestScenario(boolean isParallel) {
+        this.isParallel = isParallel;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.INT_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        _run(data, (IntConsumer) b, (Function<S_IN, IntStream>) m);
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void _run(TestData<T, S_IN> data, IntConsumer b, Function<S_IN, IntStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/IntermediateTestOp.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+/**
+ * A base type for test operations
+ */
+interface IntermediateTestOp<E_IN, E_OUT> {
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+                                            IntermediateTestOp<?, T> op) {
+        if (op instanceof StatelessTestOp)
+            return StatelessTestOp.chain(upstream, (StatelessTestOp) op);
+
+        if (op instanceof StatefulTestOp)
+            return StatefulTestOp.chain(upstream, (StatefulTestOp) op);
+
+        throw new IllegalStateException("Unknown test op type: " + op.getClass().getName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/LambdaTestHelpers.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,471 @@
+/*
+ * Copyright (c) 1997, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.*;
+import java.util.function.BiConsumer;
+import java.util.function.BiPredicate;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.DoubleBinaryOperator;
+import java.util.function.DoubleConsumer;
+import java.util.function.DoublePredicate;
+import java.util.function.Function;
+import java.util.function.IntBinaryOperator;
+import java.util.function.IntConsumer;
+import java.util.function.IntFunction;
+import java.util.function.IntPredicate;
+import java.util.function.IntUnaryOperator;
+import java.util.function.LongBinaryOperator;
+import java.util.function.LongConsumer;
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToDoubleFunction;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
+ */
+public class LambdaTestHelpers {
+    public static final String LONG_STRING = "When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
+
+    @SuppressWarnings("rawtypes")
+    public static final Consumer bEmpty = x -> {  };
+    @SuppressWarnings("rawtypes")
+    public static final IntConsumer bIntEmpty = x -> {  };
+    @SuppressWarnings("rawtypes")
+    public static final BiConsumer bBiEmpty = (x,y) -> { };
+    @SuppressWarnings("rawtypes")
+    public static final Consumer bHashCode = x -> { Objects.hashCode(x); };
+    @SuppressWarnings("rawtypes")
+    public static final BiConsumer bBiHashCode = (x,y) -> { Objects.hash(x, y); };
+    public static final Function<Integer, Integer> mZero = x -> 0;
+    public static final Function<Integer, Integer> mId = x -> x;
+    public static final Function<Integer, Integer> mDoubler = x -> x * 2;
+    public static final Function<Integer, Stream<Integer>> mfId = e -> Collections.singletonList(e).stream();
+    public static final Function<Integer, Stream<Integer>> mfNull = e -> Collections.<Integer>emptyList().stream();
+    public static final Function<Integer, Stream<Integer>> mfLt = e -> {
+        List<Integer> l = new ArrayList<>();
+        for (int i=0; i<e; i++)
+            l.add(i);
+        return l.stream();
+    };
+    public static final ToIntFunction<Integer> imDoubler = x -> x * 2;
+    public static final ToLongFunction<Long> lmDoubler = x -> x * 2;
+    public static final ToDoubleFunction<Double> dmDoubler = x -> x * 2;
+    public static final Predicate<Integer> pFalse = x -> false;
+    public static final Predicate<Integer> pTrue = x -> true;
+    public static final Predicate<Integer> pEven = x -> 0 == x % 2;
+    public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
+    public static final IntPredicate ipFalse = x -> false;
+    public static final IntPredicate ipTrue = x -> true;
+    public static final IntPredicate ipEven = x -> 0 == x % 2;
+    public static final IntPredicate ipOdd = x -> 1 == x % 2;
+    public static final LongPredicate lpFalse = x -> false;
+    public static final LongPredicate lpTrue = x -> true;
+    public static final LongPredicate lpEven = x -> 0 == x % 2;
+    public static final LongPredicate lpOdd = x -> 1 == x % 2;
+    public static final DoublePredicate dpFalse = x -> false;
+    public static final DoublePredicate dpTrue = x -> true;
+    public static final DoublePredicate dpEven = x -> 0 == ((long) x) % 2;
+    public static final DoublePredicate dpOdd = x -> 1 == ((long) x) % 2;
+    public static final BinaryOperator<Integer> rPlus = (x, y) -> x+y;
+    public static final BinaryOperator<Integer> rMax = (x, y) -> Math.max(x, y);
+    public static final BinaryOperator<Integer> rMin = (x, y) -> Math.min(x,y);
+    public static final IntBinaryOperator irPlus = (x, y) -> x+y;
+    public static final IntBinaryOperator irMax = (x, y) -> Math.max(x, y);
+    public static final IntBinaryOperator irMin = (x, y) -> Math.min(x,y);
+    public static final IntUnaryOperator irDoubler = x -> x * 2;
+    public static final LongBinaryOperator lrPlus = (x, y) -> x+y;
+    public static final DoubleBinaryOperator drPlus = (x, y) -> x+y;
+    public static final Comparator<Integer> cInteger = (a, b) -> Integer.compare(a, b);
+    public static final BiPredicate<?, ?> bipFalse = (x, y) -> false;
+    public static final BiPredicate<?, ?> bipTrue = (x, y) -> true;
+    public static final BiPredicate<Integer, Integer> bipBothEven = (x, y) -> 0 == (x % 2 + y % 2);
+    public static final BiPredicate<Integer, Integer> bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
+    public static final BiPredicate<?, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
+
+    public static final IntFunction<Integer[]> integerArrayGenerator = s -> new Integer[s];
+
+    public static final IntFunction<Object[]> objectArrayGenerator = s -> new Object[s];
+
+    public static final Function<String, Stream<Character>> flattenChars = string -> {
+        List<Character> l = new ArrayList<>();
+        for (int i=0; i<string.length(); i++)
+            l.add(string.charAt(i));
+        return l.stream();
+    };
+
+    public static final Function<String, IntStream> flattenInt
+            = string -> IntStream.range(0, string.length()).map(string::charAt);
+
+    public static <T, R> Function<T, R> forPredicate(Predicate<? super T> predicate, R forTrue, R forFalse) {
+        Objects.requireNonNull(predicate);
+
+        return t -> predicate.test(t) ? forTrue : forFalse;
+    }
+
+    public static <T> Function<T, T> identity() {
+        return t -> t;
+    }
+
+    public static<V, T, R> Function<V, R> compose(Function<? super T, ? extends R> after, Function<? super V, ? extends T> before) {
+        Objects.requireNonNull(before);
+        return (V v) -> after.apply(before.apply(v));
+    }
+
+    public static List<Integer> empty() {
+        ArrayList<Integer> list = new ArrayList<>();
+        list.add(null);
+        return list;
+    }
+
+    public static List<Integer> countTo(int n) {
+        return range(1, n);
+    }
+
+    public static List<Integer> range(int l, int u) {
+        ArrayList<Integer> list = new ArrayList<>(u - l + 1);
+        for (int i=l; i<=u; i++) {
+            list.add(i);
+        }
+        return list;
+    }
+
+    public static List<Integer> repeat(int value, int n) {
+        ArrayList<Integer> list = new ArrayList<>(n);
+        for (int i=1; i<=n; i++) {
+            list.add(value);
+        }
+        return list;
+    }
+
+    public static List<Double> asDoubles(List<Integer> integers) {
+        ArrayList<Double> list = new ArrayList<>();
+        for (Integer i : integers) {
+            list.add((double) i);
+        }
+        return list;
+    }
+
+    public static List<Long> asLongs(List<Integer> integers) {
+        ArrayList<Long> list = new ArrayList<>();
+        for (Integer i : integers) {
+            list.add((long) i);
+        }
+        return list;
+    }
+
+    public static void assertCountSum(Stream<? super Integer> it, int count, int sum) {
+        assertCountSum(it.iterator(), count, sum);
+    }
+
+    public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
+        assertCountSum(it.iterator(), count, sum);
+    }
+
+    public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
+        int c = 0;
+        int s = 0;
+        while (it.hasNext()) {
+            int i = (Integer) it.next();
+            c++;
+            s += i;
+        }
+
+        assertEquals(c, count);
+        assertEquals(s, sum);
+    }
+
+    public static void assertConcat(Iterator<Character> it, String result) {
+        StringBuilder sb = new StringBuilder();
+        while (it.hasNext()) {
+            sb.append(it.next());
+        }
+
+        assertEquals(result, sb.toString());
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
+        i = toBoxedList(i).iterator();
+
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(last.compareTo(t) <= 0);
+            assertTrue(t.compareTo(last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
+        if (i instanceof PrimitiveIterator.OfInt
+                || i instanceof PrimitiveIterator.OfDouble
+                || i instanceof PrimitiveIterator.OfLong) {
+            i = toBoxedList(i).iterator();
+        }
+
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(comp.compare(last, t) <= 0);
+            assertTrue(comp.compare(t, last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
+        assertSorted(iter.iterator());
+    }
+
+    public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
+        assertSorted(iter.iterator(), comp);
+    }
+
+    public static <T> void assertUnique(Iterable<T> iter) {
+        assertUnique(iter.iterator());
+    }
+
+    public static<T> void assertUnique(Iterator<T> iter) {
+        if (!iter.hasNext()) {
+            return;
+        }
+
+        if (iter instanceof PrimitiveIterator.OfInt
+            || iter instanceof PrimitiveIterator.OfDouble
+            || iter instanceof PrimitiveIterator.OfLong) {
+            iter = toBoxedList(iter).iterator();
+        }
+
+        Set<T> uniq = new HashSet<>();
+        while(iter.hasNext()) {
+            T each = iter.next();
+            assertTrue(!uniq.contains(each));
+            uniq.add(each);
+        }
+    }
+
+    public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
+        if (actual instanceof Collection && expected instanceof Collection) {
+            assertEquals(actual, expected);
+        } else {
+            assertContents(actual.iterator(), expected.iterator());
+        }
+    }
+
+    public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
+        assertEquals(toBoxedList(actual), toBoxedList(expected));
+    }
+
+    @SafeVarargs
+    @SuppressWarnings("varargs")
+    public static<T> void assertContents(Iterator<T> actual, T... expected) {
+        assertContents(actual, Arrays.asList(expected).iterator());
+    }
+
+    /**
+     * The all consuming consumer (rampant capitalist) that can accepting a reference or any primitive value.
+     */
+    private static interface OmnivorousConsumer<T>
+            extends Consumer<T>, IntConsumer, LongConsumer, DoubleConsumer { }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> Consumer<T> toBoxingConsumer(Consumer<? super T> c) {
+        return (Consumer<T>) new OmnivorousConsumer() {
+            @Override
+            public void accept(Object t) {
+                c.accept((T) t);
+            }
+
+            @Override
+            public void accept(int t) {
+                accept((Object) t);
+            }
+
+            @Override
+            public void accept(long t) {
+                accept((Object) t);
+            }
+
+            @Override
+            public void accept(double t) {
+                accept((Object) t);
+            }
+        };
+    }
+
+    /**
+     * Convert an iterator to a list using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    private static<T> List<T> toBoxedList(Iterator<T> it) {
+        List<T> l = new ArrayList<>();
+        it.forEachRemaining(toBoxingConsumer(l::add));
+        return l;
+    }
+
+    /**
+     * Convert a spliterator to a list using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    public static<T> List<T> toBoxedList(Spliterator<T> sp) {
+        List<T> l = new ArrayList<>();
+        sp.forEachRemaining(toBoxingConsumer(l::add));
+        return l;
+    }
+
+    /**
+     * Convert an iterator to a multi-set, represented as a Map, using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    @SuppressWarnings("unchecked")
+    private static<T> Map<T, Integer> toBoxedMultiset(Iterator<T> it) {
+        Map<Object, Integer> result = new HashMap<>();
+
+        it.forEachRemaining(new OmnivorousConsumer<T>() {
+            @Override
+            public void accept(T t) {
+                add(t);
+            }
+
+            @Override
+            public void accept(int value) {
+                add(value);
+            }
+
+            @Override
+            public void accept(long value) {
+                add(value);
+            }
+
+            @Override
+            public void accept(double value) {
+                add(value);
+            }
+
+            void add(Object o) {
+                if (result.containsKey(o))
+                    result.put(o, result.get(o) + 1);
+                else
+                    result.put(o, 1);
+            }
+
+        });
+
+        return (Map<T, Integer>) result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void assertContentsEqual(Object a, Object b) {
+        if (a instanceof Iterable && b instanceof Iterable)
+            assertContents((Iterable) a, (Iterable) b);
+        else
+            assertEquals(a, b);
+    }
+
+    public static<T> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
+        assertContentsUnordered(actual.iterator(), expected.iterator());
+    }
+
+    public static<T> void assertContentsUnordered(Iterator<T> actual, Iterator<T> expected) {
+        assertEquals(toBoxedMultiset(actual), toBoxedMultiset(expected));
+    }
+
+    public static void launderAssertion(Runnable r, Supplier<String> additionalInfo) {
+        try {
+            r.run();
+        }
+        catch (AssertionError ae) {
+            AssertionError cloned = new AssertionError(ae.getMessage() + String.format("%n%s", additionalInfo.get()));
+            cloned.setStackTrace(ae.getStackTrace());
+            if (ae.getCause() != null)
+                cloned.initCause(ae.getCause());
+            throw cloned;
+        }
+    }
+
+    public static <T, S extends BaseStream<T, S>>
+    List<Function<S, S>> permuteStreamFunctions(List<Function<S, S>> opFunctions) {
+        List<List<Function<S, S>>> opFunctionPermutations = perm(opFunctions);
+
+        List<Function<S, S>> appliedFunctions = new ArrayList<>();
+        for (List<Function<S, S>> fs : opFunctionPermutations) {
+            Function<S, S> applied = s -> {
+                for (Function<S, S> f : fs) {
+                    s = f.apply(s);
+                }
+                return s;
+            };
+            appliedFunctions.add(applied);
+        }
+
+        return appliedFunctions;
+    }
+
+    private static <T> List<T> sub(List<T> l, int index) {
+        List<T> subL = new ArrayList<>(l);
+        subL.remove(index);
+        return subL;
+    }
+
+    public static <T> List<List<T>> perm(List<T> l) {
+        List<List<T>> result = new ArrayList<>();
+        for (int i = 0; i < l.size(); i++) {
+            for (List<T> perm : perm(sub(l, i))) {
+                perm.add(0, l.get(i));
+                result.add(perm);
+            }
+        }
+        result.add(new ArrayList<T>());
+
+        return result;
+    }
+
+    public static String flagsToString(int flags) {
+        StringJoiner sj = new StringJoiner(", ", "StreamOpFlag[", "]");
+        if (StreamOpFlag.DISTINCT.isKnown(flags)) sj.add("IS_DISTINCT");
+        if (StreamOpFlag.ORDERED.isKnown(flags)) sj.add("IS_ORDERED");
+        if (StreamOpFlag.SIZED.isKnown(flags)) sj.add("IS_SIZED");
+        if (StreamOpFlag.SORTED.isKnown(flags)) sj.add("IS_SORTED");
+        if (StreamOpFlag.SHORT_CIRCUIT.isKnown(flags)) sj.add("IS_SHORT_CIRCUIT");
+        return sj.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/LongStreamTestDataProvider.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for long-valued streams */
+public class LongStreamTestDataProvider {
+    private static final long[] to0 = new long[0];
+    private static final long[] to1 = new long[1];
+    private static final long[] to10 = new long[10];
+    private static final long[] to100 = new long[100];
+    private static final long[] to1000 = new long[1000];
+    private static final long[] reversed = new long[100];
+    private static final long[] ones = new long[100];
+    private static final long[] twice = new long[200];
+    private static final long[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        long[][] arrays = {to0, to1, to10, to100, to1000};
+        for (long[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new long[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (long) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> list = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final long[] longs = (long[]) data[1];
+
+                list.add(new Object[]{"array:" + name,
+                        TestData.Factory.ofArray("array:" + name, longs)});
+
+                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+                for (long i : longs) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+                list.add(streamDataDescr("LongStream.longRange(0,l): " + longs.length,
+                                         () -> LongStream.range(0, longs.length)));
+                list.add(streamDataDescr("LongStream.longRange(0,l,2): " + longs.length,
+                                         () -> LongStream.range(0, longs.length, 2)));
+                list.add(streamDataDescr("LongStream.longRange(0,l,3): " + longs.length,
+                                         () -> LongStream.range(0, longs.length, 3)));
+                list.add(streamDataDescr("LongStream.longRange(0,l,7): " + longs.length,
+                                         () -> LongStream.range(0, longs.length, 7)));
+            }
+            testData = list.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final long[] longs = (long[]) data[1];
+
+                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+                for (long i : longs) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(longs)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(longs, 0, longs.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), longs.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+                spliterators.add(splitDescr("LongStream.longRange(0,l):" + name,
+                                            () -> LongStream.range(0, longs.length).spliterator()));
+                spliterators.add(splitDescr("LongStream.longRange(0,l,2):" + name,
+                                            () -> LongStream.range(0, longs.length, 2).spliterator()));
+                spliterators.add(splitDescr("LongStream.longRange(0,l,3):" + name,
+                                            () -> LongStream.range(0, longs.length, 3).spliterator()));
+                spliterators.add(splitDescr("LongStream.longRange(0,l,7):" + name,
+                                            () -> LongStream.range(0, longs.length, 7).spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<LongStream> s) {
+        return new Object[] { description, TestData.Factory.ofLongSupplier(description, s) };
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfLong> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, LongStreamTestData )
+    @DataProvider(name = "LongStreamTestData")
+    public static Object[][] makeLongStreamTestData() {
+        return testData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
+    @DataProvider(name = "LongSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/LongStreamTestScenario.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+package java.util.stream;
+
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.LongConsumer;
+
+/**
+ * Test scenarios for long streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum LongStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            LongStream s = m.apply(data.stream());
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (long t : m.apply(data.stream()).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (PrimitiveIterator.OfLong seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextLong());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (Spliterator.OfLong spl = m.apply(data.stream()).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(data.stream()).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(data.stream()).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(data.parallelStream()).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(data.parallelStream()).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (Spliterator.OfLong spl = m.apply(data.parallelStream()).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(data.parallelStream()).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (long t : m.apply(data.parallelStream()).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            LongStream s = m.apply(data.parallelStream());
+            Spliterator.OfLong sp = s.spliterator();
+            LongStream ss = StreamSupport.longParallelStream(() -> sp,
+                                                             StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                             | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED));
+            for (long t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(data.parallelStream(),
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            LongStream pipe2 = m.apply(pipe1);
+
+            for (long t : pipe2.toArray())
+                b.accept(t);
+        }
+    },;
+
+    private boolean isParallel;
+
+    LongStreamTestScenario(boolean isParallel) {
+        this.isParallel = isParallel;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.LONG_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        _run(data, (LongConsumer) b, (Function<S_IN, LongStream>) m);
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void _run(TestData<T, S_IN> data, LongConsumer b, Function<S_IN, LongStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/stream/bootlib/java/util/stream/OpTestCase.java	Mon May 13 16:52:33 2013 -0700
@@ -0,0 +1,633 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Base class for streams test cases.  Provides 'exercise' methods for taking
+ * lambdas that construct and modify streams, and evaluates them in different
+ * ways and asserts that they produce equivalent results.
+ */
+@Test
+public abstract class OpTestCase extends Assert {
+
+    private final Map<StreamShape, Set<? extends BaseStreamTestScenario>> testScenarios;
+
+    protected OpTestCase() {
+        testScenarios = new EnumMap<>(StreamShape.class);
+        testScenarios.put(StreamShape.REFERENCE, Collections.unmodifiableSet(EnumSet.allOf(StreamTestScenario.class)));
+        testScenarios.put(StreamShape.INT_VALUE, Collections.unmodifiableSet(EnumSet.allOf(IntStreamTestScenario.class)));
+        testScenarios.put(StreamShape.LONG_VALUE, Collections.unmodifiableSet(EnumSet.allOf(LongStreamTestScenario.class)));
+        testScenarios.put(StreamShape.DOUBLE_VALUE, Collections.unmodifiableSet(EnumSet.allOf(DoubleStreamTestScenario.class)));
+    }
+
+    @SuppressWarnings("rawtypes")
+    public static int getStreamFlags(BaseStream s) {
+        return ((AbstractPipeline) s).getStreamFlags();
+    }
+
+    // Exercise stream operations
+
+    public interface BaseStreamTestScenario {
+        StreamShape getShape();
+
+        boolean isParallel();
+
+        abstract <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+        void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m);
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+        return withData(data).stream(m).exercise();
+    }
+
+    // Run multiple versions of exercise(), returning the result of the first, and asserting that others return the same result
+    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
+    @SafeVarargs
+    public final<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOpsMulti(TestData<T, S_IN> data,
+                                   Function<S_IN, S_OUT>... ms) {
+        Collection<U> result = null;
+        for (Function<S_IN, S_OUT> m : ms) {
+            if (result == null)
+                result = withData(data).stream(m).exercise();
+            else {
+                Collection<U> r2 = withData(data).stream(m).exercise();
+                assertEquals(result, r2);
+            }
+        }
+        return result;
+    }
+
+    // Run multiple versions of exercise() for an Integer stream, returning the result of the first, and asserting that others return the same result
+    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
+    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
+    public final
+    Collection<Integer> exerciseOpsInt(TestData.OfRef<Integer> data,
+                                       Function<Stream<Integer>, Stream<Integer>> mRef,
+                                       Function<IntStream, IntStream> mInt,
+                                       Function<LongStream, LongStream> mLong,
+                                       Function<DoubleStream, DoubleStream> mDouble) {
+        @SuppressWarnings({ "rawtypes", "unchecked" })
+        Function<Stream<Integer>, Stream<Integer>>[] ms = new Function[4];
+        ms[0] = mRef;
+        ms[1] = s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e);
+        ms[2] = s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e);
+        ms[3] = s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e);
+        return exerciseOpsMulti(data, ms);
+    }
+
+    public <T, U, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m) {
+        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).stream(m).exercise();
+    }
+
+    public <T, U, S_OUT extends BaseStream<U, S_OUT>, I extends Iterable<U>>
+    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m, I expected) {
+        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).stream(m).expectedResult(expected).exercise();
+    }
+
+    @SuppressWarnings("unchecked")
+    public <U, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(int[] data, Function<IntStream, S_OUT> m) {
+        return withData(TestData.Factory.ofArray("int array", data)).stream(m).exercise();
+    }
+
+    public Collection<Integer> exerciseOps(int[] data, Function<IntStream, IntStream> m, int[] expected) {
+        TestData.OfInt data1 = TestData.Factory.ofArray("int array", data);
+        return withData(data1).stream(m).expectedResult(expected).exercise();
+    }
+
+    public <T, S_IN extends BaseStream<T, S_IN>> DataStreamBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
+        Objects.requireNonNull(data);
+        return new DataStreamBuilder<>(data);
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class DataStreamBuilder<T, S_IN extends BaseStream<T, S_IN>> {
+        final TestData<T, S_IN> data;
+
+        private DataStreamBuilder(TestData<T, S_IN> data) {
+            this.data = Objects.requireNonNull(data);
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>>
+        ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> ops(IntermediateTestOp... ops) {
+            return new ExerciseDataStreamBuilder<>(data, (S_IN s) -> (S_OUT) chain(s, ops));
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+        stream(Function<S_IN, S_OUT> m) {
+            return new ExerciseDataStreamBuilder<>(data, m);
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+        stream(Function<S_IN, S_OUT> m, IntermediateTestOp<U, U> additionalOp) {
+            return new ExerciseDataStreamBuilder<>(data, s -> (S_OUT) chain(m.apply(s), additionalOp));
+        }
+
+        public <R> ExerciseDataTerminalBuilder<T, T, R, S_IN, S_IN>
+        terminal(Function<S_IN, R> terminalF) {
+            return new ExerciseDataTerminalBuilder<>(data, s -> s, terminalF);
+        }
+
+        public <U, R, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT>
+        terminal(Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
+            return new ExerciseDataTerminalBuilder<>(data, streamF, terminalF);
+        }
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class ExerciseDataStreamBuilder<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
+        final TestData<T, S_IN> data;
+        final Function<S_IN, S_OUT> m;
+        final StreamShape shape;
+
+        Set<BaseStreamTestScenario> testSet = new HashSet<>();
+
+        Collection<U> refResult;
+        boolean isOrdered;
+
+        Consumer<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
+
+        Consumer<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
+
+        BiConsumer<Iterable<U>, Iterable<U>> sequentialEqualityAsserter = LambdaTestHelpers::assertContentsEqual;
+        BiConsumer<Iterable<U>, Iterable<U>> parallelEqualityAsserter = LambdaTestHelpers::assertContentsEqual;
+
+        private ExerciseDataStreamBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+            this.data = data;
+
+            this.m = Objects.requireNonNull(m);
+
+            this.shape = ((AbstractPipeline<?, U, ?>) m.apply(data.stream())).getOutputShape();
+
+            // Have to initiate from the output shape of the last stream
+            // This means the stream mapper is required first rather than last
+            testSet.addAll(testScenarios.get(shape));
+        }
+
+        public BiConsumer<Iterable<U>, Iterable<U>> getEqualityAsserter(BaseStreamTestScenario t) {
+            return t.isParallel() ? parallelEqualityAsserter : sequentialEqualityAsserter;
+        }
+
+        //
+
+        public <I extends Iterable<U>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
+            List<U> l = new ArrayList<>();
+            expectedResult.forEach(l::add);
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(int[] expectedResult) {
+            List l = new ArrayList();
+            for (int anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(long[] expectedResult) {
+            List l = new ArrayList();
+            for (long anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(double[] expectedResult) {
+            List l = new ArrayList();
+            for (double anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> before(Consumer<TestData<T, S_IN>> before) {
+            this.before = Objects.requireNonNull(before);
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> after(Consumer<TestData<T, S_IN>> after) {
+            this.after = Objects.requireNonNull(after);
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(BaseStreamTestScenario... tests) {
+            return without(Arrays.asList(tests));
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(Collection<? extends BaseStreamTestScenario> tests) {
+            for (BaseStreamTestScenario ts : tests) {
+                if (ts.getShape() == shape) {
+                    testSet.remove(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalStateException("Test scenario set is empty");
+            }
+
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(BaseStreamTestScenario... tests) {
+            return with(Arrays.asList(tests));
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(Collection<? extends BaseStreamTestScenario> tests) {
+            testSet = new HashSet<>();
+
+            for (BaseStreamTestScenario ts : tests) {
+                if (ts.getShape() == shape) {
+                    testSet.add(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalS