Merge
authorlana
Mon, 07 Mar 2011 11:37:54 -0800
changeset 8636 baa2c3dffe9b
parent 8635 383a416a2bdf (current diff)
parent 8471 fd444c61e7ed (diff)
child 8637 be1b564b50aa
Merge
hotspot/make/windows/platform_amd64
hotspot/make/windows/platform_i486
hotspot/make/windows/platform_ia64
hotspot/src/share/tools/ProjectCreator/Macro.java
hotspot/src/share/tools/ProjectCreator/MacroDefinitions.java
jdk/src/share/classes/java/dyn/NoAccessException.java
jdk/src/share/classes/java/dyn/Switcher.java
jdk/test/java/lang/Thread/StopBeforeStart.java
--- a/.hgtags	Mon Mar 07 14:31:50 2011 +0000
+++ b/.hgtags	Mon Mar 07 11:37:54 2011 -0800
@@ -104,3 +104,6 @@
 f83cd8bd35c678f94e526990e03dc838d0ec2717 jdk7-b127
 7da3f5f30855dec6bf3a86529e87dee883b90c72 jdk7-b128
 6823ea7eb8eb6fab405d7edb7a5c2f690887a2fa jdk7-b129
+a36beda9b9de91231d92a2c529f21cc218fcf8d5 jdk7-b130
+d8af56da89bc0fc02a6b6ad78f51157a46d665ab jdk7-b131
+d61280d36755d1941fb487f554e8b7a6d0bca6a1 jdk7-b132
--- a/.hgtags-top-repo	Mon Mar 07 14:31:50 2011 +0000
+++ b/.hgtags-top-repo	Mon Mar 07 11:37:54 2011 -0800
@@ -104,3 +104,6 @@
 bd70f76b0309068f157ae759c36eac8f2c6d098e jdk7-b127
 57d702105b23fb90e40beaf00f8f8aeae5e249e7 jdk7-b128
 a6b015b59fbc2518762c17ccc35702f03ef7713a jdk7-b129
+cc58c11af15411042719e9c82707fdbef60a9e0f jdk7-b130
+5d86d951426aaf340b1ba84ae2d5ab5da65a71e2 jdk7-b131
+0f62a65fb666b337caa585015ab6ea2e60e709ca jdk7-b132
--- a/LICENSE	Mon Mar 07 14:31:50 2011 +0000
+++ b/LICENSE	Mon Mar 07 11:37:54 2011 -0800
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Sun Microsystems, Inc.  are subject to
-the following clarification and special exception to the GPL, but only where
-Sun has expressly included in the particular source file's header the words
-"Sun designates this particular file as subject to the "Classpath" exception
-as provided by Sun in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/Makefile	Mon Mar 07 14:31:50 2011 +0000
+++ b/Makefile	Mon Mar 07 11:37:54 2011 -0800
@@ -36,12 +36,6 @@
   JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
 endif
 
-# For start and finish echo lines
-TITLE_TEXT = Control $(PLATFORM) $(ARCH) $(RELEASE)
-DATE_STAMP = `$(DATE) '+%y-%m-%d %H:%M'`
-START_ECHO  = echo "$(TITLE_TEXT) $@ build started: $(DATE_STAMP)"
-FINISH_ECHO = echo "$(TITLE_TEXT) $@ build finished: $(DATE_STAMP)"
-
 default: all
 
 include $(JDK_MAKE_SHARED_DIR)/Defs-control.gmk
@@ -57,10 +51,6 @@
 include ./make/sponsors-rules.gmk
 include ./make/deploy-rules.gmk
 
-# What "all" means
-all::
-	@$(START_ECHO)
-
 all:: sanity
 
 ifeq ($(SKIP_FASTDEBUG_BUILD), false)
@@ -73,40 +63,44 @@
 
 all:: all_product_build 
 
-all:: 
-	@$(FINISH_ECHO)
+all_product_build::
 
 # Everything for a full product build
-all_product_build::
-	@$(START_ECHO)
+ifeq ($(SKIP_PRODUCT_BUILD), false)
 
-ifeq ($(SKIP_PRODUCT_BUILD), false)
-  
   all_product_build:: product_build
 
   ifeq ($(BUILD_INSTALL), true)
     all_product_build:: $(INSTALL)
     clobber:: install-clobber
   endif
-  
+
   ifeq ($(BUILD_SPONSORS), true)
     all_product_build:: $(SPONSORS)
     clobber:: sponsors-clobber
   endif
-  
+
   ifneq ($(SKIP_COMPARE_IMAGES), true)
     all_product_build:: compare-image
   endif
 
 endif
 
-all_product_build:: 
-	@$(FINISH_ECHO)
+define StartTimer
+	$(MKDIR) -p $(BUILDTIMESDIR)
+	$(RM) $(BUILDTIMESDIR)/build_time_*
+	$(call RecordStartTime,TOTAL)
+endef
+
+define StopTimer
+	$(if $(REPORT_BUILD_TIMES),$(call RecordEndTime,TOTAL) && $(call ReportBuildTimes,$1),)
+endef
 
 # Generic build of basic repo series
 generic_build_repo_series::
 	$(MKDIR) -p $(OUTPUTDIR)
 	$(MKDIR) -p $(OUTPUTDIR)/j2sdk-image
+	@$(call StartTimer)
 
 ifeq ($(BUILD_LANGTOOLS), true)
   generic_build_repo_series:: langtools
@@ -143,6 +137,9 @@
   clobber:: deploy-clobber
 endif
 
+generic_build_repo_series::
+	@$(call StopTimer,$(if $(DEBUG_NAME),$(DEBUG_NAME)_build,all_product_build))
+
 # The debug build, fastdebug or debug. Needs special handling.
 #  Note that debug builds do NOT do INSTALL steps, but must be done
 #  after the product build and before the INSTALL step of the product build.
@@ -167,28 +164,22 @@
 FRESH_DEBUG_BOOTDIR=$(ABS_BOOTDIR_OUTPUTDIR)/../$(PLATFORM)-$(ARCH)-$(DEBUG_NAME)/j2sdk-image
   
 create_fresh_product_bootdir: FRC
-	@$(START_ECHO)
 	$(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) \
 		GENERATE_DOCS=false \
 		BOOT_CYCLE_SETTINGS= \
 		build_product_image
-	@$(FINISH_ECHO)
 
 create_fresh_debug_bootdir: FRC
-	@$(START_ECHO)
 	$(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) \
 		GENERATE_DOCS=false \
 		BOOT_CYCLE_DEBUG_SETTINGS= \
 		build_debug_image
-	@$(FINISH_ECHO)
 
 create_fresh_fastdebug_bootdir: FRC
-	@$(START_ECHO)
 	$(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) \
 		GENERATE_DOCS=false \
 		BOOT_CYCLE_DEBUG_SETTINGS= \
 		build_fastdebug_image
-	@$(FINISH_ECHO)
 
 # Create boot image?
 ifeq ($(SKIP_BOOT_CYCLE),false)
@@ -197,6 +188,8 @@
   endif
 endif
 
+
+
 ifeq ($(DO_BOOT_CYCLE),true)
   
   # Create the bootdir to use in the build
@@ -221,27 +214,23 @@
 endif
 
 build_product_image:
-	@$(START_ECHO)
 	$(MAKE) \
 	        SKIP_FASTDEBUG_BUILD=true \
 	        SKIP_DEBUG_BUILD=true \
 	        $(BOOT_CYCLE_SETTINGS) \
 	        generic_build_repo_series
-	@$(FINISH_ECHO)
 
 #   NOTE: On windows, do not use $(ABS_OUTPUTDIR)-$(DEBUG_NAME).
 #         Due to the use of short paths in $(ABS_OUTPUTDIR), this may 
 #         not be the same location.
 
 generic_debug_build:
-	@$(START_ECHO)
 	$(MAKE) \
 		ALT_OUTPUTDIR=$(ABS_OUTPUTDIR)/../$(PLATFORM)-$(ARCH)-$(DEBUG_NAME) \
 	        DEBUG_NAME=$(DEBUG_NAME) \
 		GENERATE_DOCS=false \
 	        $(BOOT_CYCLE_DEBUG_SETTINGS) \
 		generic_build_repo_series
-	@$(FINISH_ECHO)
 
 build_debug_image:
 	$(MAKE) DEBUG_NAME=debug generic_debug_build
@@ -254,7 +243,8 @@
 debug_build:: build_debug_image
 fastdebug_build:: build_fastdebug_image
 
-clobber::
+clobber:: REPORT_BUILD_TIMES=
+clobber:: 
 	$(RM) -r $(OUTPUTDIR)/*
 	$(RM) -r $(OUTPUTDIR)/../$(PLATFORM)-$(ARCH)-debug/*
 	$(RM) -r $(OUTPUTDIR)/../$(PLATFORM)-$(ARCH)-fastdebug/*
--- a/corba/.hgtags	Mon Mar 07 14:31:50 2011 +0000
+++ b/corba/.hgtags	Mon Mar 07 11:37:54 2011 -0800
@@ -104,3 +104,6 @@
 64775e83f4df894355f45555f50c410de6727b4e jdk7-b127
 9baa8f94a11d6c5cab3f9f0e5a20106326d0932e jdk7-b128
 66fa0fcc779296c99746b09efce6109944f82f30 jdk7-b129
+563a8f8b5be3940e9346cffac4eff9ed02b3c69f jdk7-b130
+9d6dd2cdfcb92612dbd836ecded87770d52b49db jdk7-b131
+1b1e75e8f476e5c07f0d2b035993895e2603e1f0 jdk7-b132
--- a/corba/LICENSE	Mon Mar 07 14:31:50 2011 +0000
+++ b/corba/LICENSE	Mon Mar 07 11:37:54 2011 -0800
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Sun Microsystems, Inc.  are subject to
-the following clarification and special exception to the GPL, but only where
-Sun has expressly included in the particular source file's header the words
-"Sun designates this particular file as subject to the "Classpath" exception
-as provided by Sun in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/hotspot/.hgtags	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/.hgtags	Mon Mar 07 11:37:54 2011 -0800
@@ -148,3 +148,8 @@
 9a5762f448595794d449a8e17342abd81a3fadaf jdk7-b128
 ae4b185f2ed14af7bab610738c333840598cdcc4 jdk7-b129
 ae4b185f2ed14af7bab610738c333840598cdcc4 hs21-b01
+e9aa2ca89ad6c53420623d579765f9706ec523d7 jdk7-b130
+0aa3b49089112d5faa77902ad680c582ab53f651 jdk7-b131
+e9aa2ca89ad6c53420623d579765f9706ec523d7 hs21-b02
+0e531ab5ba04967a0e9aa6aef65e6eb3a0dcf632 jdk7-b132
+a8d643a4db47c7b58e0bcb49c77b5c3610de86a8 hs21-b03
--- a/hotspot/LICENSE	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/LICENSE	Mon Mar 07 11:37:54 2011 -0800
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Oracle and/or its affiliates, are subject to
-the following clarification and special exception to the GPL, but only where
-Oracle has expressly included in the particular source file's header the words
-"Oracle designates this particular file as subject to the "Classpath" exception
-as provided by Oracle in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -31,8 +31,7 @@
 /** Very minimal port for now to get frames working */
 
 public class StubRoutines {
-  private static AddressField      callStubReturnAddressField;
-  private static AddressField      callStubCompiledReturnAddressField;
+  private static AddressField callStubReturnAddressField;
 
   static {
     VM.registerVMInitializedObserver(new Observer() {
@@ -44,20 +43,7 @@
 
   private static synchronized void initialize(TypeDataBase db) {
     Type type = db.lookupType("StubRoutines");
-
     callStubReturnAddressField = type.getAddressField("_call_stub_return_address");
-    // Only some platforms have specific return from compiled to call_stub
-    try {
-      type = db.lookupType("StubRoutines::x86");
-      if (type != null) {
-        callStubCompiledReturnAddressField = type.getAddressField("_call_stub_compiled_return");
-      }
-    } catch (RuntimeException re) {
-      callStubCompiledReturnAddressField = null;
-    }
-    if (callStubCompiledReturnAddressField == null && VM.getVM().getCPU().equals("x86")) {
-      throw new InternalError("Missing definition for _call_stub_compiled_return");
-    }
   }
 
   public StubRoutines() {
@@ -65,20 +51,10 @@
 
   public boolean returnsToCallStub(Address returnPC) {
     Address addr = callStubReturnAddressField.getValue();
-    boolean result = false;
-    if (addr == null) {
-      result = (addr == returnPC);
-    } else {
-      result = addr.equals(returnPC);
-    }
-    if (result || callStubCompiledReturnAddressField == null ) return result;
-    // Could be a return to compiled code return point
-    addr = callStubCompiledReturnAddressField.getValue();
     if (addr == null) {
       return (addr == returnPC);
     } else {
       return (addr.equals(returnPC));
     }
-
   }
 }
--- a/hotspot/make/Makefile	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/Makefile	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
 #  ALT_OUTPUTDIR              Output directory to use for hotspot build
 #  ALT_EXPORT_PATH            Directory to export hotspot build to
 #  ALT_JDK_IMPORT_PATH        Current JDK build (only for create_jdk rules)
+#  ALT_JDK_TARGET_IMPORT_PATH Current JDK build when cross-compiling
 #  ALT_BUILD_WIN_SA           Building SA on Windows is disabled by default.
 #                             Set ALT_BUILD_WIN_SA=1 to enable building SA on
 #                             Windows.
--- a/hotspot/make/defs.make	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/defs.make	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -162,6 +162,13 @@
   JDK_IMPORT_PATH=$(ALT_JDK_IMPORT_PATH)
 endif
 
+# Other parts of JDK build may require an import JDK that can be executed
+# on the build host. For cross-compile builds we also need an import JDK
+# that matches the target arch, so for that we set ALT_JDK_TARGET_IMPORT_PATH
+ifneq ($(ALT_JDK_TARGET_IMPORT_PATH),)
+  JDK_IMPORT_PATH=$(ALT_JDK_TARGET_IMPORT_PATH)
+endif
+
 # Find JDK used for javac compiles
 BOOTDIR=$(SLASH_JAVA)/re/j2se/$(PREVIOUS_JDK_VERSION)/latest/binaries/$(PLATFORM)
 ifneq ($(ALT_BOOTDIR),)
--- a/hotspot/make/hotspot_version	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/hotspot_version	Mon Mar 07 11:37:54 2011 -0800
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=21
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=02
+HS_BUILD_NUMBER=03
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=7
--- a/hotspot/make/jprt.properties	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/jprt.properties	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -437,6 +437,7 @@
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_ParallelGC, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_ParNewGC, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_CMS, \
+    ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_G1, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_ParOldGC, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_default, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_SerialGC, \
--- a/hotspot/make/windows/create.bat	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/windows/create.bat	Mon Mar 07 11:37:54 2011 -0800
@@ -1,6 +1,6 @@
 @echo off
 REM
-REM Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+REM Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
 REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 REM
 REM This code is free software; you can redistribute it and/or modify it
@@ -50,9 +50,7 @@
 
 
 :testit
-cl 2>&1 | grep "IA-64" >NUL
-if %errorlevel% == 0 goto isia64
-cl 2>&1 | grep "AMD64" >NUL
+cl 2>&1 | grep "x64" >NUL
 if %errorlevel% == 0 goto amd64
 set ARCH=x86
 set BUILDARCH=i486
@@ -64,12 +62,6 @@
 set BUILDARCH=amd64
 set Platform_arch=x86
 set Platform_arch_model=x86_64
-goto done
-:isia64
-set ARCH=ia64
-set BUILDARCH=ia64
-set Platform_arch=ia64
-set Platform_arch_model=ia64
 :done
 
 setlocal
@@ -81,7 +73,7 @@
 REM Set HotSpotWorkSpace to the directy two steps above this script
 for %%i in ("%~dp0..") do ( set HotSpotWorkSpace=%%~dpi)
 set HotSpotBuildRoot=%HotSpotWorkSpace%build
-set HotSpotBuildSpace=%HotSpotBuildRoot%\vs
+set HotSpotBuildSpace=%HotSpotBuildRoot%\vs-%BUILDARCH%
 set HotSpotJDKDist=%1
 
 
@@ -89,9 +81,9 @@
 for /F %%i in ('sh %HotSpotWorkSpace%/make/windows/get_msc_ver.sh') do set %%i
 
 echo **************************************************************
-set ProjectFile=jvm.vcproj
+set ProjectFile=%HotSpotBuildSpace%\jvm.vcproj
 if "%MSC_VER%" == "1200" (
-set ProjectFile=jvm.dsp
+set ProjectFile=%HotSpotBuildSpace%\jvm.dsp
 echo Will generate VC6 project {unsupported}
 ) else (
 if "%MSC_VER%" == "1400" (
@@ -163,7 +155,7 @@
 )
 
 REM force regneration of ProjectFile
-if exist %HotSpotBuildSpace%\%ProjectFile% del %HotSpotBuildSpace%\%ProjectFile%
+if exist %ProjectFile% del %ProjectFile%
 
 for /D %%i in (compiler1, compiler2, tiered, core, kernel) do (
 echo -- %%i --
@@ -182,6 +174,7 @@
 echo BUILDARCH=%BUILDARCH%                 >>    %HotSpotBuildSpace%\%%i\local.make
 echo Platform_arch=%Platform_arch%         >>    %HotSpotBuildSpace%\%%i\local.make
 echo Platform_arch_model=%Platform_arch_model% >>    %HotSpotBuildSpace%\%%i\local.make
+echo MSC_VER=%MSC_VER% 			   >>    %HotSpotBuildSpace%\%%i\local.make
 
 for /D %%j in (debug, fastdebug, product) do (
 if NOT EXIST %HotSpotBuildSpace%\%%i\%%j mkdir %HotSpotBuildSpace%\%%i\%%j
@@ -196,7 +189,7 @@
 pushd %HotSpotBuildRoot%
 
 REM It doesn't matter which variant we use here, "compiler1" is as good as any of the others - we need the common variables
-nmake /nologo /F %HotSpotWorkSpace%/make/windows/projectfiles/common/Makefile LOCAL_MAKE=%HotSpotBuildSpace%\compiler1\local.make %HotSpotBuildRoot%/%ProjectFile%
+nmake /nologo /F %HotSpotWorkSpace%/make/windows/projectfiles/common/Makefile LOCAL_MAKE=%HotSpotBuildSpace%\compiler1\local.make %ProjectFile%
 
 popd
 
--- a/hotspot/make/windows/makefiles/compile.make	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/windows/makefiles/compile.make	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 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
@@ -141,9 +141,6 @@
 !endif
 !endif
 
-# Add what version of the compiler we think this is to the compile line
-CPP_FLAGS=$(CPP_FLAGS) /D "MSC_VER=$(MSC_VER)"
-
 # By default, we do not want to use the debug version of the msvcrt.dll file
 #   but if MFC_DEBUG is defined in the environment it will be used.
 MS_RUNTIME_OPTION = /MD
--- a/hotspot/make/windows/makefiles/projectcreator.make	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/windows/makefiles/projectcreator.make	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 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
@@ -36,8 +36,6 @@
         $(WorkSpace)\src\share\tools\ProjectCreator\DirectoryTree.java \
         $(WorkSpace)\src\share\tools\ProjectCreator\DirectoryTreeNode.java \
         $(WorkSpace)\src\share\tools\ProjectCreator\FileFormatException.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\Macro.java \
-        $(WorkSpace)\src\share\tools\ProjectCreator\MacroDefinitions.java \
         $(WorkSpace)\src\share\tools\ProjectCreator\ProjectCreator.java \
         $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatform.java \
         $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC6.java \
@@ -50,6 +48,10 @@
 
 # This is only used internally
 ProjectCreatorIncludesPRIVATE=\
+        -relativeInclude src\closed\share\vm \
+        -relativeInclude src\closed\os\windows\vm \
+        -relativeInclude src\closed\os_cpu\windows_$(Platform_arch)\vm \
+        -relativeInclude src\closed\cpu\$(Platform_arch)\vm \
         -relativeInclude src\share\vm \
         -relativeInclude src\share\vm\prims \
         -relativeInclude src\os\windows\vm \
@@ -84,7 +86,7 @@
         -buildBase $(HOTSPOTBUILDSPACE)\%f\%b \
         -startAt src \
         -compiler $(VcVersion) \
-        -projectFileName $(HOTSPOTBUILDROOT)\$(ProjectFile) \
+        -projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \
         -jdkTargetRoot $(HOTSPOTJDKDIST) \
         -define ALIGN_STACK_FRAMES \
         -define VM_LITTLE_ENDIAN \
@@ -106,13 +108,20 @@
 # Add in build-specific options
 !if "$(BUILDARCH)" == "i486"
 ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
+	-platformName Win32 \
         -define IA32 \
         -ignorePath x86_64 \
         -define TARGET_ARCH_MODEL_x86_32
 !else
+!if "$(BUILDARCH)" == "amd64"
 ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
+	-platformName x64 \
+        -define AMD64 \
+	-define _LP64 \
         -ignorePath x86_32 \
-        -define TARGET_ARCH_MODEL_x86_64
+        -define TARGET_ARCH_MODEL_x86_64 \
+	-define TARGET_OS_ARCH_MODEL_windows_x86_64
+!endif
 !endif
 
 ProjectCreatorIDEOptionsIgnoreCompiler1=\
--- a/hotspot/make/windows/makefiles/rules.make	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/windows/makefiles/rules.make	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -53,7 +53,7 @@
 !if "$(MSC_VER)" == "1200"
 
 VcVersion=VC6
-ProjectFile=vm.dsp
+ProjectFile=jvm.dsp
 
 !elseif "$(MSC_VER)" == "1400"
 
--- a/hotspot/make/windows/platform_amd64	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-// Platform file for win32 NT platform
-
-os_family = windows
-
-arch = x86
-
-arch_model = x86_64
-
-os_arch = windows_x86
-
-os_arch_model = windows_x86_64
-
-lib_arch = amd64
-
-compiler = visCPP
--- a/hotspot/make/windows/platform_i486	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-// Platform file for windows platform
-
-os_family = windows
-
-arch = x86
-
-arch_model = x86_32
-
-os_arch = windows_x86
-
-os_arch_model = windows_x86_32
-
-lib_arch = i386
-
-compiler = visCPP
--- a/hotspot/make/windows/platform_ia64	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-// Platform file for Itanium Windows platform $Revision: 1.0 $
-
-os_family = win32
-
-arch = ia64
-
-os_arch = win32_ia64
-
-compiler = visCPP
-
-gnu_dis_arch = ia64
-
--- a/hotspot/make/windows/projectfiles/common/Makefile	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/make/windows/projectfiles/common/Makefile	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 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
@@ -54,8 +54,6 @@
 JvmtiOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\jvmtifiles
 !include $(HOTSPOTWORKSPACE)/make/windows/makefiles/jvmti.make
 
-Platform=$(HOTSPOTWORKSPACE)/make/windows/platform_$(BUILDARCH)
-
 !if "$(Variant)" == "compiler2"
 # Pick up rules for building adlc
 !include $(HOTSPOTWORKSPACE)/make/windows/makefiles/adlc.make
@@ -105,17 +103,16 @@
 !endif
 
 ProjectCreatorIDEOptions =       $(ProjectCreatorIDEOptions) \
-      -platform            $(Platform) \
       -define              HOTSPOT_RELEASE_VERSION=\\\"$(HOTSPOT_RELEASE_VERSION)\\\" \
       -define              JRE_RELEASE_VERSION=\\\"$(JRE_RELEASE_VERSION)\\\" \
       -define              HOTSPOT_VM_DISTRO=\\\"$(HOTSPOT_VM_DISTRO)\\\"
 
-$(HOTSPOTBUILDROOT)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class
+$(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class
 	@$(RUN_JAVA) -Djava.class.path=$(HOTSPOTBUILDSPACE)/classes ProjectCreator WinGammaPlatform$(VcVersion) $(ProjectCreatorIDEOptions)
 
 clean:
 	@rm -rf $(HOTSPOTBUILDSPACE)/classes
-	@rm -r ../$(ProjectFile)
+	@rm -r $(HOTSPOTBUILDSPACE)/$(ProjectFile)
 
 $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class: $(ProjectCreatorSources)
 	@if exist $(HOTSPOTBUILDSPACE)\classes rmdir /s /q $(HOTSPOTBUILDSPACE)\classes
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -2407,14 +2407,23 @@
 #endif
 
 
-void MacroAssembler::load_sized_value(Address src, Register dst,
-                                      size_t size_in_bytes, bool is_signed) {
+void MacroAssembler::load_sized_value(Address src, Register dst, size_t size_in_bytes, bool is_signed) {
   switch (size_in_bytes) {
-  case  8: ldx(src, dst); break;
-  case  4: ld( src, dst); break;
-  case  2: is_signed ? ldsh(src, dst) : lduh(src, dst); break;
-  case  1: is_signed ? ldsb(src, dst) : ldub(src, dst); break;
-  default: ShouldNotReachHere();
+  case  8:  ld_long(src, dst); break;
+  case  4:  ld(     src, dst); break;
+  case  2:  is_signed ? ldsh(src, dst) : lduh(src, dst); break;
+  case  1:  is_signed ? ldsb(src, dst) : ldub(src, dst); break;
+  default:  ShouldNotReachHere();
+  }
+}
+
+void MacroAssembler::store_sized_value(Register src, Address dst, size_t size_in_bytes) {
+  switch (size_in_bytes) {
+  case  8:  st_long(src, dst); break;
+  case  4:  st(     src, dst); break;
+  case  2:  sth(    src, dst); break;
+  case  1:  stb(    src, dst); break;
+  default:  ShouldNotReachHere();
   }
 }
 
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -2330,8 +2330,9 @@
   void lcmp( Register Ra, Register Rb, Register Rresult);
 #endif
 
-  // Loading values by size and signed-ness
-  void load_sized_value(Address src, Register dst, size_t size_in_bytes, bool is_signed);
+  // Load and store values by size and signed-ness
+  void load_sized_value( Address src, Register dst, size_t size_in_bytes, bool is_signed);
+  void store_sized_value(Register src, Address dst, size_t size_in_bytes);
 
   void float_cmp( bool is_float, int unordered_result,
                   FloatRegister Fa, FloatRegister Fb,
--- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -596,16 +596,9 @@
         __ st_ptr(O1_scratch, Address(O0_argslot, 0));
       } else {
         Address prim_value_addr(O1_scratch, java_lang_boxing_object::value_offset_in_bytes(arg_type));
-        __ load_sized_value(prim_value_addr, O2_scratch, type2aelembytes(arg_type), is_signed_subword_type(arg_type));
-        if (arg_slots == 2) {
-          __ unimplemented("not yet tested");
-#ifndef _LP64
-          __ signx(O2_scratch, O3_scratch);  // Sign extend
-#endif
-          __ st_long(O2_scratch, Address(O0_argslot, 0));  // Uses O2/O3 on !_LP64
-        } else {
-          __ st_ptr( O2_scratch, Address(O0_argslot, 0));
-        }
+        const int arg_size = type2aelembytes(arg_type);
+        __ load_sized_value(prim_value_addr, O2_scratch, arg_size, is_signed_subword_type(arg_type));
+        __ store_sized_value(O2_scratch, Address(O0_argslot, 0), arg_size);  // long store uses O2/O3 on !_LP64
       }
 
       if (direct_to_method) {
@@ -784,11 +777,9 @@
       switch (ek) {
       case _adapter_opt_i2l:
         {
-          __ ldsw(arg_lsw, O2_scratch);      // Load LSW
-#ifndef _LP64
-          __ signx(O2_scratch, O3_scratch);  // Sign extend
-#endif
-          __ st_long(O2_scratch, arg_msw);   // Uses O2/O3 on !_LP64
+          __ ldsw(arg_lsw, O2_scratch);                           // Load LSW
+          NOT_LP64(__ srlx(O2_scratch, BitsPerInt, O3_scratch));  // Move high bits to lower bits for std
+          __ st_long(O2_scratch, arg_msw);                        // Uses O2/O3 on !_LP64
         }
         break;
       case _adapter_opt_unboxl:
--- a/hotspot/src/cpu/sparc/vm/sparc.ad	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad	Mon Mar 07 11:37:54 2011 -0800
@@ -8125,6 +8125,17 @@
 %}
 #endif
 
+instruct cmpLTMask0( iRegI dst, iRegI src, immI0 zero, flagsReg ccr ) %{
+  match(Set dst (CmpLTMask src zero));
+  effect(KILL ccr);
+  size(4);
+  format %{ "SRA    $src,#31,$dst\t# cmpLTMask0" %}
+  ins_encode %{
+    __ sra($src$$Register, 31, $dst$$Register);
+  %}
+  ins_pipe(ialu_reg_imm);
+%}
+
 instruct cmpLTMask_reg_reg( iRegI dst, iRegI p, iRegI q, flagsReg ccr ) %{
   match(Set dst (CmpLTMask p q));
   effect( KILL ccr );
@@ -8144,19 +8155,7 @@
 
   format %{ "SUBcc  $p,$q,$p\t! p' = p-q\n\t"
             "ADD    $p,$y,$tmp\t! g3=p-q+y\n\t"
-            "MOVl   $tmp,$p\t! p' < 0 ? p'+y : p'" %}
-  ins_encode( enc_cadd_cmpLTMask(p, q, y, tmp) );
-  ins_pipe( cadd_cmpltmask );
-%}
-
-instruct cadd_cmpLTMask2( iRegI p, iRegI q, iRegI y, iRegI tmp, flagsReg ccr ) %{
-  match(Set p (AddI (SubI p q) (AndI (CmpLTMask p q) y)));
-  effect( KILL ccr, TEMP tmp);
-  ins_cost(DEFAULT_COST*3);
-
-  format %{ "SUBcc  $p,$q,$p\t! p' = p-q\n\t"
-            "ADD    $p,$y,$tmp\t! g3=p-q+y\n\t"
-            "MOVl   $tmp,$p\t! p' < 0 ? p'+y : p'" %}
+            "MOVlt  $tmp,$p\t! p' < 0 ? p'+y : p'" %}
   ins_encode( enc_cadd_cmpLTMask(p, q, y, tmp) );
   ins_pipe( cadd_cmpltmask );
 %}
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -2349,6 +2349,17 @@
   a_byte(p);
 }
 
+void Assembler::por(XMMRegister dst, XMMRegister src) {
+  NOT_LP64(assert(VM_Version::supports_sse2(), ""));
+
+  emit_byte(0x66);
+  int  encode = prefix_and_encode(dst->encoding(), src->encoding());
+  emit_byte(0x0F);
+
+  emit_byte(0xEB);
+  emit_byte(0xC0 | encode);
+}
+
 void Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) {
   assert(isByte(mode), "invalid value");
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
@@ -6528,20 +6539,39 @@
   return off;
 }
 
-void MacroAssembler::load_sized_value(Register dst, Address src,
-                                      size_t size_in_bytes, bool is_signed) {
+void MacroAssembler::load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed, Register dst2) {
   switch (size_in_bytes) {
 #ifndef _LP64
-  // For case 8, caller is responsible for manually loading
-  // the second word into another register.
-  case  8: movl(dst, src); break;
+  case  8:
+    assert(dst2 != noreg, "second dest register required");
+    movl(dst,  src);
+    movl(dst2, src.plus_disp(BytesPerInt));
+    break;
 #else
-  case  8: movq(dst, src); break;
+  case  8:  movq(dst, src); break;
 #endif
-  case  4: movl(dst, src); break;
-  case  2: is_signed ? load_signed_short(dst, src) : load_unsigned_short(dst, src); break;
-  case  1: is_signed ? load_signed_byte( dst, src) : load_unsigned_byte( dst, src); break;
-  default: ShouldNotReachHere();
+  case  4:  movl(dst, src); break;
+  case  2:  is_signed ? load_signed_short(dst, src) : load_unsigned_short(dst, src); break;
+  case  1:  is_signed ? load_signed_byte( dst, src) : load_unsigned_byte( dst, src); break;
+  default:  ShouldNotReachHere();
+  }
+}
+
+void MacroAssembler::store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2) {
+  switch (size_in_bytes) {
+#ifndef _LP64
+  case  8:
+    assert(src2 != noreg, "second source register required");
+    movl(dst,                        src);
+    movl(dst.plus_disp(BytesPerInt), src2);
+    break;
+#else
+  case  8:  movq(dst, src); break;
+#endif
+  case  4:  movl(dst, src); break;
+  case  2:  movw(dst, src); break;
+  case  1:  movb(dst, src); break;
+  default:  ShouldNotReachHere();
   }
 }
 
@@ -8636,7 +8666,7 @@
 // Compare strings.
 void MacroAssembler::string_compare(Register str1, Register str2,
                                     Register cnt1, Register cnt2, Register result,
-                                    XMMRegister vec1, XMMRegister vec2) {
+                                    XMMRegister vec1) {
   Label LENGTH_DIFF_LABEL, POP_LABEL, DONE_LABEL, WHILE_HEAD_LABEL;
 
   // Compute the minimum of the string lengths and the
@@ -8683,62 +8713,85 @@
     bind(LSkip2);
   }
 
-  // Advance to next character
-  addptr(str1, 2);
-  addptr(str2, 2);
+  Address::ScaleFactor scale = Address::times_2;
+  int stride = 8;
+
+  // Advance to next element
+  addptr(str1, 16/stride);
+  addptr(str2, 16/stride);
 
   if (UseSSE42Intrinsics) {
-    // With SSE4.2, use double quad vector compare
-    Label COMPARE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL;
+    Label COMPARE_WIDE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL;
+    int pcmpmask = 0x19;
     // Setup to compare 16-byte vectors
-    movl(cnt1, cnt2);
-    andl(cnt2, 0xfffffff8); // cnt2 holds the vector count
-    andl(cnt1, 0x00000007); // cnt1 holds the tail count
-    testl(cnt2, cnt2);
+    movl(result, cnt2);
+    andl(cnt2, ~(stride - 1));   // cnt2 holds the vector count
     jccb(Assembler::zero, COMPARE_TAIL);
 
-    lea(str2, Address(str2, cnt2, Address::times_2));
-    lea(str1, Address(str1, cnt2, Address::times_2));
-    negptr(cnt2);
-
-    bind(COMPARE_VECTORS);
-    movdqu(vec1, Address(str1, cnt2, Address::times_2));
-    movdqu(vec2, Address(str2, cnt2, Address::times_2));
-    pxor(vec1, vec2);
-    ptest(vec1, vec1);
-    jccb(Assembler::notZero, VECTOR_NOT_EQUAL);
-    addptr(cnt2, 8);
-    jcc(Assembler::notZero, COMPARE_VECTORS);
-    jmpb(COMPARE_TAIL);
+    lea(str1, Address(str1, result, scale));
+    lea(str2, Address(str2, result, scale));
+    negptr(result);
+
+    // pcmpestri
+    //   inputs:
+    //     vec1- substring
+    //     rax - negative string length (elements count)
+    //     mem - scaned string
+    //     rdx - string length (elements count)
+    //     pcmpmask - cmp mode: 11000 (string compare with negated result)
+    //               + 00 (unsigned bytes) or  + 01 (unsigned shorts)
+    //   outputs:
+    //     rcx - first mismatched element index
+    assert(result == rax && cnt2 == rdx && cnt1 == rcx, "pcmpestri");
+
+    bind(COMPARE_WIDE_VECTORS);
+    movdqu(vec1, Address(str1, result, scale));
+    pcmpestri(vec1, Address(str2, result, scale), pcmpmask);
+    // After pcmpestri cnt1(rcx) contains mismatched element index
+
+    jccb(Assembler::below, VECTOR_NOT_EQUAL);  // CF==1
+    addptr(result, stride);
+    subptr(cnt2, stride);
+    jccb(Assembler::notZero, COMPARE_WIDE_VECTORS);
+
+    // compare wide vectors tail
+    testl(result, result);
+    jccb(Assembler::zero, LENGTH_DIFF_LABEL);
+
+    movl(cnt2, stride);
+    movl(result, stride);
+    negptr(result);
+    movdqu(vec1, Address(str1, result, scale));
+    pcmpestri(vec1, Address(str2, result, scale), pcmpmask);
+    jccb(Assembler::aboveEqual, LENGTH_DIFF_LABEL);
 
     // Mismatched characters in the vectors
     bind(VECTOR_NOT_EQUAL);
-    lea(str1, Address(str1, cnt2, Address::times_2));
-    lea(str2, Address(str2, cnt2, Address::times_2));
-    movl(cnt1, 8);
-
-    // Compare tail (< 8 chars), or rescan last vectors to
-    // find 1st mismatched characters
-    bind(COMPARE_TAIL);
-    testl(cnt1, cnt1);
-    jccb(Assembler::zero, LENGTH_DIFF_LABEL);
-    movl(cnt2, cnt1);
+    addptr(result, cnt1);
+    movptr(cnt2, result);
+    load_unsigned_short(result, Address(str1, cnt2, scale));
+    load_unsigned_short(cnt1, Address(str2, cnt2, scale));
+    subl(result, cnt1);
+    jmpb(POP_LABEL);
+
+    bind(COMPARE_TAIL); // limit is zero
+    movl(cnt2, result);
     // Fallthru to tail compare
   }
 
   // Shift str2 and str1 to the end of the arrays, negate min
-  lea(str1, Address(str1, cnt2, Address::times_2, 0));
-  lea(str2, Address(str2, cnt2, Address::times_2, 0));
+  lea(str1, Address(str1, cnt2, scale, 0));
+  lea(str2, Address(str2, cnt2, scale, 0));
   negptr(cnt2);
 
-    // Compare the rest of the characters
+  // Compare the rest of the elements
   bind(WHILE_HEAD_LABEL);
-  load_unsigned_short(result, Address(str1, cnt2, Address::times_2, 0));
-  load_unsigned_short(cnt1, Address(str2, cnt2, Address::times_2, 0));
+  load_unsigned_short(result, Address(str1, cnt2, scale, 0));
+  load_unsigned_short(cnt1, Address(str2, cnt2, scale, 0));
   subl(result, cnt1);
   jccb(Assembler::notZero, POP_LABEL);
   increment(cnt2);
-  jcc(Assembler::notZero, WHILE_HEAD_LABEL);
+  jccb(Assembler::notZero, WHILE_HEAD_LABEL);
 
   // Strings are equal up to min length.  Return the length difference.
   bind(LENGTH_DIFF_LABEL);
@@ -8747,7 +8800,7 @@
 
   // Discard the stored length difference
   bind(POP_LABEL);
-  addptr(rsp, wordSize);
+  pop(cnt1);
 
   // That's it
   bind(DONE_LABEL);
@@ -8795,6 +8848,7 @@
   if (UseSSE42Intrinsics) {
     // With SSE4.2, use double quad vector compare
     Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
+
     // Compare 16-byte vectors
     andl(result, 0x0000000e);  //   tail count (in bytes)
     andl(limit, 0xfffffff0);   // vector count (in bytes)
@@ -8808,11 +8862,23 @@
     movdqu(vec1, Address(ary1, limit, Address::times_1));
     movdqu(vec2, Address(ary2, limit, Address::times_1));
     pxor(vec1, vec2);
+
     ptest(vec1, vec1);
     jccb(Assembler::notZero, FALSE_LABEL);
     addptr(limit, 16);
     jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
 
+    testl(result, result);
+    jccb(Assembler::zero, TRUE_LABEL);
+
+    movdqu(vec1, Address(ary1, result, Address::times_1, -16));
+    movdqu(vec2, Address(ary2, result, Address::times_1, -16));
+    pxor(vec1, vec2);
+
+    ptest(vec1, vec1);
+    jccb(Assembler::notZero, FALSE_LABEL);
+    jmpb(TRUE_LABEL);
+
     bind(COMPARE_TAIL); // limit is zero
     movl(limit, result);
     // Fallthru to tail compare
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1277,6 +1277,9 @@
   void prefetcht2(Address src);
   void prefetchw(Address src);
 
+  // POR - Bitwise logical OR
+  void por(XMMRegister dst, XMMRegister src);
+
   // Shuffle Packed Doublewords
   void pshufd(XMMRegister dst, XMMRegister src, int mode);
   void pshufd(XMMRegister dst, Address src,     int mode);
@@ -1522,8 +1525,9 @@
   // Support for sign-extension (hi:lo = extend_sign(lo))
   void extend_sign(Register hi, Register lo);
 
-  // Loading values by size and signed-ness
-  void load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed);
+  // Load and store values by size and signed-ness
+  void load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed, Register dst2 = noreg);
+  void store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2 = noreg);
 
   // Support for inc/dec with optimal instruction selection depending on value
 
@@ -2293,7 +2297,7 @@
   // Compare strings.
   void string_compare(Register str1, Register str2,
                       Register cnt1, Register cnt2, Register result,
-                      XMMRegister vec1, XMMRegister vec2);
+                      XMMRegister vec1);
 
   // Compare char[] arrays.
   void char_arrays_equals(bool is_array_equ, Register ary1, Register ary2,
--- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -1899,8 +1899,6 @@
   Label do_double;
   Label done_conv;
 
-  address compiled_entry = __ pc();
-
   // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases
   if (UseSSE < 2) {
     __ lea(state, Address(rbp,  -(int)sizeof(BytecodeInterpreter)));
@@ -1934,15 +1932,7 @@
     __ jmp(done_conv);
   }
 
-#if 0
-  // emit a sentinel we can test for when converting an interpreter
-  // entry point to a compiled entry point.
-  __ a_long(Interpreter::return_sentinel);
-  __ a_long((int)compiled_entry);
-#endif
-
   // Return point to interpreter from compiled/native method
-
   InternalAddress return_from_native_method(__ pc());
 
   __ bind(done_conv);
--- a/hotspot/src/cpu/x86/vm/interpreter_x86.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/interpreter_x86.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -26,14 +26,6 @@
 #define CPU_X86_VM_INTERPRETER_X86_HPP
 
  public:
-
-  // Sentinel placed in the code for interpreter returns so
-  // that i2c adapters and osr code can recognize an interpreter
-  // return address and convert the return to a specialized
-  // block of code to handle compiedl return values and cleaning
-  // the fpu stack.
-  static const int return_sentinel;
-
   static Address::ScaleFactor stackElementScale() { return Address::times_4; }
 
   // Offset from rsp (which points to the last stack element)
--- a/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -51,9 +51,6 @@
 
 #define __ _masm->
 
-// Initialize the sentinel used to distinguish an interpreter return address.
-const int Interpreter::return_sentinel = 0xfeedbeed;
-
 //------------------------------------------------------------------------------------------------------------------------
 
 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -602,24 +602,18 @@
       // make room for the new argument:
       __ movl(rax_argslot, rcx_bmh_vmargslot);
       __ lea(rax_argslot, __ argument_address(rax_argslot));
-      insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask,
-                       rax_argslot, rbx_temp, rdx_temp);
+
+      insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, rax_argslot, rbx_temp, rdx_temp);
 
       // store bound argument into the new stack slot:
       __ load_heap_oop(rbx_temp, rcx_bmh_argument);
-      Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type));
       if (arg_type == T_OBJECT) {
         __ movptr(Address(rax_argslot, 0), rbx_temp);
       } else {
-        __ load_sized_value(rdx_temp, prim_value_addr,
-                            type2aelembytes(arg_type), is_signed_subword_type(arg_type));
-        __ movptr(Address(rax_argslot, 0), rdx_temp);
-#ifndef _LP64
-        if (arg_slots == 2) {
-          __ movl(rdx_temp, prim_value_addr.plus_disp(wordSize));
-          __ movl(Address(rax_argslot, Interpreter::stackElementSize), rdx_temp);
-        }
-#endif //_LP64
+        Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type));
+        const int arg_size = type2aelembytes(arg_type);
+        __ load_sized_value(rdx_temp, prim_value_addr, arg_size, is_signed_subword_type(arg_type), rbx_temp);
+        __ store_sized_value(Address(rax_argslot, 0), rdx_temp, arg_size, rbx_temp);
       }
 
       if (direct_to_method) {
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -660,25 +660,6 @@
                             int comp_args_on_stack,
                             const BasicType *sig_bt,
                             const VMRegPair *regs) {
-  // we're being called from the interpreter but need to find the
-  // compiled return entry point.  The return address on the stack
-  // should point at it and we just need to pull the old value out.
-  // load up the pointer to the compiled return entry point and
-  // rewrite our return pc. The code is arranged like so:
-  //
-  // .word Interpreter::return_sentinel
-  // .word address_of_compiled_return_point
-  // return_entry_point: blah_blah_blah
-  //
-  // So we can find the appropriate return point by loading up the word
-  // just prior to the current return address we have on the stack.
-  //
-  // We will only enter here from an interpreted frame and never from after
-  // passing thru a c2i. Azul allowed this but we do not. If we lose the
-  // race and use a c2i we will remain interpreted for the race loser(s).
-  // This removes all sorts of headaches on the x86 side and also eliminates
-  // the possibility of having c2i -> i2c -> c2i -> ... endless transitions.
-
 
   // Note: rsi contains the senderSP on entry. We must preserve it since
   // we may do a i2c -> c2i transition if we lose a race where compiled
@@ -687,40 +668,6 @@
   // Pick up the return address
   __ movptr(rax, Address(rsp, 0));
 
-  // If UseSSE >= 2 then no cleanup is needed on the return to the
-  // interpreter so skip fixing up the return entry point unless
-  // VerifyFPU is enabled.
-  if (UseSSE < 2 || VerifyFPU) {
-    Label skip, chk_int;
-    // If we were called from the call stub we need to do a little bit different
-    // cleanup than if the interpreter returned to the call stub.
-
-    ExternalAddress stub_return_address(StubRoutines::_call_stub_return_address);
-    __ cmpptr(rax, stub_return_address.addr());
-    __ jcc(Assembler::notEqual, chk_int);
-    assert(StubRoutines::x86::get_call_stub_compiled_return() != NULL, "must be set");
-    __ lea(rax, ExternalAddress(StubRoutines::x86::get_call_stub_compiled_return()));
-    __ jmp(skip);
-
-    // It must be the interpreter since we never get here via a c2i (unlike Azul)
-
-    __ bind(chk_int);
-#ifdef ASSERT
-    {
-      Label ok;
-      __ cmpl(Address(rax, -2*wordSize), Interpreter::return_sentinel);
-      __ jcc(Assembler::equal, ok);
-      __ int3();
-      __ bind(ok);
-    }
-#endif // ASSERT
-    __ movptr(rax, Address(rax, -wordSize));
-    __ bind(skip);
-  }
-
-  // rax, now contains the compiled return entry point which will do an
-  // cleanup needed for the return from compiled to interpreted.
-
   // Must preserve original SP for loading incoming arguments because
   // we need to align the outgoing SP for compiled code.
   __ movptr(rdi, rsp);
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -610,14 +610,6 @@
                             const BasicType *sig_bt,
                             const VMRegPair *regs) {
 
-  //
-  // We will only enter here from an interpreted frame and never from after
-  // passing thru a c2i. Azul allowed this but we do not. If we lose the
-  // race and use a c2i we will remain interpreted for the race loser(s).
-  // This removes all sorts of headaches on the x86 side and also eliminates
-  // the possibility of having c2i -> i2c -> c2i -> ... endless transitions.
-
-
   // Note: r13 contains the senderSP on entry. We must preserve it since
   // we may do a i2c -> c2i transition if we lose a race where compiled
   // code goes non-entrant while we get args ready.
@@ -627,6 +619,7 @@
   // save code can segv when fxsave instructions find improperly
   // aligned stack pointer.
 
+  // Pick up the return address
   __ movptr(rax, Address(rsp, 0));
 
   // Must preserve original SP for loading incoming arguments because
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -240,9 +240,30 @@
     BLOCK_COMMENT("call_stub_return_address:");
     return_address = __ pc();
 
-    Label common_return;
+#ifdef COMPILER2
+    {
+      Label L_skip;
+      if (UseSSE >= 2) {
+        __ verify_FPU(0, "call_stub_return");
+      } else {
+        for (int i = 1; i < 8; i++) {
+          __ ffree(i);
+        }
 
-    __ BIND(common_return);
+        // UseSSE <= 1 so double result should be left on TOS
+        __ movl(rsi, result_type);
+        __ cmpl(rsi, T_DOUBLE);
+        __ jcc(Assembler::equal, L_skip);
+        if (UseSSE == 0) {
+          // UseSSE == 0 so float result should be left on TOS
+          __ cmpl(rsi, T_FLOAT);
+          __ jcc(Assembler::equal, L_skip);
+        }
+        __ ffree(0);
+      }
+      __ BIND(L_skip);
+    }
+#endif // COMPILER2
 
     // store result depending on type
     // (everything that is not T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT)
@@ -305,37 +326,6 @@
     }
     __ jmp(exit);
 
-    // If we call compiled code directly from the call stub we will
-    // need to adjust the return back to the call stub to a specialized
-    // piece of code that can handle compiled results and cleaning the fpu
-    // stack. compiled code will be set to return here instead of the
-    // return above that handles interpreter returns.
-
-    BLOCK_COMMENT("call_stub_compiled_return:");
-    StubRoutines::x86::set_call_stub_compiled_return( __ pc());
-
-#ifdef COMPILER2
-    if (UseSSE >= 2) {
-      __ verify_FPU(0, "call_stub_compiled_return");
-    } else {
-      for (int i = 1; i < 8; i++) {
-        __ ffree(i);
-      }
-
-      // UseSSE <= 1 so double result should be left on TOS
-      __ movl(rsi, result_type);
-      __ cmpl(rsi, T_DOUBLE);
-      __ jcc(Assembler::equal, common_return);
-      if (UseSSE == 0) {
-        // UseSSE == 0 so float result should be left on TOS
-        __ cmpl(rsi, T_FLOAT);
-        __ jcc(Assembler::equal, common_return);
-      }
-      __ ffree(0);
-    }
-#endif /* COMPILER2 */
-    __ jmp(common_return);
-
     return start;
   }
 
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,5 @@
 // Implementation of the platform-specific part of StubRoutines - for
 // a description of how to extend it, see the stubRoutines.hpp file.
 
-address StubRoutines::x86::_verify_mxcsr_entry        = NULL;
-address StubRoutines::x86::_verify_fpu_cntrl_wrd_entry= NULL;
-address StubRoutines::x86::_call_stub_compiled_return = NULL;
+address StubRoutines::x86::_verify_mxcsr_entry         = NULL;
+address StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = NULL;
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -44,24 +44,14 @@
  friend class VMStructs;
 
  private:
-  // If we call compiled code directly from the call stub we will
-  // need to adjust the return back to the call stub to a specialized
-  // piece of code that can handle compiled results and cleaning the fpu
-  // stack. The variable holds that location.
-  static address _call_stub_compiled_return;
   static address _verify_mxcsr_entry;
   static address _verify_fpu_cntrl_wrd_entry;
-  static jint    _mxcsr_std;
 
  public:
   static address verify_mxcsr_entry()                        { return _verify_mxcsr_entry; }
   static address verify_fpu_cntrl_wrd_entry()                { return _verify_fpu_cntrl_wrd_entry; }
-
-  static address get_call_stub_compiled_return()             { return _call_stub_compiled_return; }
-  static void set_call_stub_compiled_return(address ret)     { _call_stub_compiled_return = ret; }
 };
 
-  static bool    returns_to_call_stub(address return_pc)     { return (return_pc == _call_stub_return_address) ||
-                                                                       return_pc == x86::get_call_stub_compiled_return(); }
+  static bool    returns_to_call_stub(address return_pc)     { return return_pc == _call_stub_return_address; }
 
 #endif // CPU_X86_VM_STUBROUTINES_X86_32_HPP
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -177,9 +177,7 @@
 
 address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step) {
   TosState incoming_state = state;
-
-  Label interpreter_entry;
-  address compiled_entry = __ pc();
+  address entry = __ pc();
 
 #ifdef COMPILER2
   // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases
@@ -197,14 +195,6 @@
     __ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled");
   }
 
-  __ jmp(interpreter_entry, relocInfo::none);
-  // emit a sentinel we can test for when converting an interpreter
-  // entry point to a compiled entry point.
-  __ a_long(Interpreter::return_sentinel);
-  __ a_long((int)compiled_entry);
-  address entry = __ pc();
-  __ bind(interpreter_entry);
-
   // In SSE mode, interpreter returns FP results in xmm0 but they need
   // to end up back on the FPU so it can operate on them.
   if (incoming_state == ftos && UseSSE >= 1) {
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -190,13 +190,7 @@
 }
 
 
-address TemplateInterpreterGenerator::generate_return_entry_for(TosState state,
-                                                                int step) {
-
-  // amd64 doesn't need to do anything special about compiled returns
-  // to the interpreter so the code that exists on x86 to place a sentinel
-  // here and the specialized cleanup code is not needed here.
-
+address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step) {
   address entry = __ pc();
 
   // Restore stack bottom in case i2c adjusted stack
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1710,39 +1710,6 @@
       __ pop(rdi);                               // get return address
       __ mov(rsp, rdx);                          // set sp to sender sp
 
-
-      Label skip;
-      Label chkint;
-
-      // The interpreter frame we have removed may be returning to
-      // either the callstub or the interpreter. Since we will
-      // now be returning from a compiled (OSR) nmethod we must
-      // adjust the return to the return were it can handler compiled
-      // results and clean the fpu stack. This is very similar to
-      // what a i2c adapter must do.
-
-      // Are we returning to the call stub?
-
-      __ cmp32(rdi, ExternalAddress(StubRoutines::_call_stub_return_address));
-      __ jcc(Assembler::notEqual, chkint);
-
-      // yes adjust to the specialized call stub  return.
-      assert(StubRoutines::x86::get_call_stub_compiled_return() != NULL, "must be set");
-      __ lea(rdi, ExternalAddress(StubRoutines::x86::get_call_stub_compiled_return()));
-      __ jmp(skip);
-
-      __ bind(chkint);
-
-      // Are we returning to the interpreter? Look for sentinel
-
-      __ cmpl(Address(rdi, -2*wordSize), Interpreter::return_sentinel);
-      __ jcc(Assembler::notEqual, skip);
-
-      // Adjust to compiled return back to interpreter
-
-      __ movptr(rdi, Address(rdi, -wordSize));
-      __ bind(skip);
-
       // Align stack pointer for compiled code (note that caller is
       // responsible for undoing this fixup by remembering the old SP
       // in an rbp,-relative location)
--- a/hotspot/src/cpu/x86/vm/x86_32.ad	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad	Mon Mar 07 11:37:54 2011 -0800
@@ -12629,16 +12629,16 @@
   ins_pipe( pipe_slow );
 %}
 
-instruct string_compare(eDIRegP str1, eCXRegI cnt1, eSIRegP str2, eBXRegI cnt2,
-                        eAXRegI result, regXD tmp1, regXD tmp2, eFlagsReg cr) %{
+instruct string_compare(eDIRegP str1, eCXRegI cnt1, eSIRegP str2, eDXRegI cnt2,
+                        eAXRegI result, regXD tmp1, eFlagsReg cr) %{
   match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
-  effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr);
-
-  format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result   // KILL $tmp1, $tmp2" %}
+  effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr);
+
+  format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result   // KILL $tmp1" %}
   ins_encode %{
     __ string_compare($str1$$Register, $str2$$Register,
                       $cnt1$$Register, $cnt2$$Register, $result$$Register,
-                      $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+                      $tmp1$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
--- a/hotspot/src/cpu/x86/vm/x86_64.ad	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad	Mon Mar 07 11:37:54 2011 -0800
@@ -11583,17 +11583,17 @@
   ins_pipe(pipe_slow);
 %}
 
-instruct string_compare(rdi_RegP str1, rcx_RegI cnt1, rsi_RegP str2, rbx_RegI cnt2,
-                        rax_RegI result, regD tmp1, regD tmp2, rFlagsReg cr)
+instruct string_compare(rdi_RegP str1, rcx_RegI cnt1, rsi_RegP str2, rdx_RegI cnt2,
+                        rax_RegI result, regD tmp1, rFlagsReg cr)
 %{
   match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
-  effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr);
-
-  format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result   // KILL $tmp1, $tmp2" %}
+  effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr);
+
+  format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result   // KILL $tmp1" %}
   ins_encode %{
     __ string_compare($str1$$Register, $str2$$Register,
                       $cnt1$$Register, $cnt2$$Register, $result$$Register,
-                      $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+                      $tmp1$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
--- a/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2008, 2009 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -30,7 +30,3 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
-
-#ifdef IA32
-address StubRoutines::x86::_call_stub_compiled_return = NULL;
-#endif // IA32
--- a/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -48,13 +48,4 @@
     method_handles_adapters_code_size = 0
   };
 
-#ifdef IA32
-  class x86 {
-    friend class VMStructs;
-
-   private:
-    static address _call_stub_compiled_return;
-  };
-#endif // IA32
-
 #endif // CPU_ZERO_VM_STUBROUTINES_ZERO_HPP
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1975,7 +1975,11 @@
       #ifndef RTLD_DL_SYMENT
       #define RTLD_DL_SYMENT 1
       #endif
-      Sym * info;
+#ifdef _LP64
+      Elf64_Sym * info;
+#else
+      Elf32_Sym * info;
+#endif
       if (dladdr1_func((void *)addr, &dlinfo, (void **)&info,
                        RTLD_DL_SYMENT)) {
         if ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr) {
@@ -6424,4 +6428,3 @@
    INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\
      os::Solaris::clear_interrupted);
 }
-
--- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -298,8 +298,8 @@
 static char* get_user_name_slow(int vmid) {
 
   // directory search
-  char* oldest_user = NULL;
-  time_t oldest_ctime = 0;
+  char* latest_user = NULL;
+  time_t latest_ctime = 0;
 
   const char* tmpdirname = os::get_temp_directory();
 
@@ -375,18 +375,29 @@
           continue;
         }
 
-        // compare and save filename with latest creation time
-        if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) {
-
-          if (statbuf.st_ctime > oldest_ctime) {
-            char* user = strchr(dentry->d_name, '_') + 1;
+        // If we found a matching file with a newer creation time, then
+        // save the user name. The newer creation time indicates that
+        // we found a newer incarnation of the process associated with
+        // vmid. Due to the way that Windows recycles pids and the fact
+        // that we can't delete the file from the file system namespace
+        // until last close, it is possible for there to be more than
+        // one hsperfdata file with a name matching vmid (diff users).
+        //
+        // We no longer ignore hsperfdata files where (st_size == 0).
+        // In this function, all we're trying to do is determine the
+        // name of the user that owns the process associated with vmid
+        // so the size doesn't matter. Very rarely, we have observed
+        // hsperfdata files where (st_size == 0) and the st_size field
+        // later becomes the expected value.
+        //
+        if (statbuf.st_ctime > latest_ctime) {
+          char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
-            oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1);
+          if (latest_user != NULL) FREE_C_HEAP_ARRAY(char, latest_user);
+          latest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1);
 
-            strcpy(oldest_user, user);
-            oldest_ctime = statbuf.st_ctime;
-          }
+          strcpy(latest_user, user);
+          latest_ctime = statbuf.st_ctime;
         }
 
         FREE_C_HEAP_ARRAY(char, filename);
@@ -399,7 +410,7 @@
   os::closedir(tmpdirp);
   FREE_C_HEAP_ARRAY(char, tdbuf);
 
-  return(oldest_user);
+  return(latest_user);
 }
 
 // return the name of the user that owns the process identified by vmid.
@@ -1339,6 +1350,38 @@
     CloseHandle(fh);
     fh = NULL;
     return NULL;
+  } else {
+    // We created the file mapping, but rarely the size of the
+    // backing store file is reported as zero (0) which can cause
+    // failures when trying to use the hsperfdata file.
+    struct stat statbuf;
+    int ret_code = ::stat(filename, &statbuf);
+    if (ret_code == OS_ERR) {
+      if (PrintMiscellaneous && Verbose) {
+        warning("Could not get status information from file %s: %s\n",
+            filename, strerror(errno));
+      }
+      CloseHandle(fmh);
+      CloseHandle(fh);
+      fh = NULL;
+      fmh = NULL;
+      return NULL;
+    }
+
+    // We could always call FlushFileBuffers() but the Microsoft
+    // docs indicate that it is considered expensive so we only
+    // call it when we observe the size as zero (0).
+    if (statbuf.st_size == 0 && FlushFileBuffers(fh) != TRUE) {
+      DWORD lasterror = GetLastError();
+      if (PrintMiscellaneous && Verbose) {
+        warning("could not flush file %s: %d\n", filename, lasterror);
+      }
+      CloseHandle(fmh);
+      CloseHandle(fh);
+      fh = NULL;
+      fmh = NULL;
+      return NULL;
+    }
   }
 
   // the file has been successfully created and the file mapping
--- a/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2007, 2008 Red Hat, Inc.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -300,4 +300,18 @@
                               (intptr_t) compare_value);
 }
 
+inline jlong Atomic::load(volatile jlong* src) {
+  volatile jlong dest;
+  os::atomic_copy64(src, &dest);
+  return dest;
+}
+
+inline void Atomic::store(jlong store_value, jlong* dest) {
+  os::atomic_copy64((volatile jlong*)&store_value, (volatile jlong*)dest);
+}
+
+inline void Atomic::store(jlong store_value, volatile jlong* dest) {
+  os::atomic_copy64((volatile jlong*)&store_value, dest);
+}
+
 #endif // OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP
--- a/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -67,7 +67,6 @@
 inline void Atomic_move_long(volatile jlong* src, volatile jlong* dst) {
 #ifdef COMPILER2
   // Compiler2 does not support v8, it is used only for v9.
-  assert (VM_Version::v9_instructions_work(), "only supported on v9");
   _Atomic_move_long_v9(src, dst);
 #else
   // The branch is cheaper then emulated LDD.
--- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -189,14 +189,22 @@
               tty->print_cr("cpu_info.implementation: %s", implementation);
             }
 #endif
-            if (strncmp(implementation, "SPARC64", 7) == 0) {
+            // Convert to UPPER case before compare.
+            char* impl = strdup(implementation);
+
+            for (int i = 0; impl[i] != 0; i++)
+              impl[i] = (char)toupper((uint)impl[i]);
+            if (strstr(impl, "SPARC64") != NULL) {
               features |= sparc64_family_m;
-            } else if (strncmp(implementation, "UltraSPARC-T", 12) == 0) {
+            } else if (strstr(impl, "SPARC-T") != NULL) {
               features |= T_family_m;
-              if (strncmp(implementation, "UltraSPARC-T1", 13) == 0) {
+              if (strstr(impl, "SPARC-T1") != NULL) {
                 features |= T1_model_m;
               }
+            } else {
+              assert(strstr(impl, "SPARC") != NULL, "should be sparc");
             }
+            free((void*)impl);
             break;
           }
         } // for(
--- a/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -71,7 +71,7 @@
     PVOID HandlerData;
 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
 
-#if MSC_VER < 1500
+#if _MSC_VER < 1500
 
 /* Not needed for VS2008 compiler, comes from winnt.h. */
 typedef EXCEPTION_DISPOSITION (*PEXCEPTION_ROUTINE) (
--- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,12 +51,14 @@
         if (vars == null) vars = new Hashtable();
 
         String flavourBuild =  flavour + "_" + build;
+        String platformName = getFieldString(null, "PlatformName");
         System.out.println();
         System.out.println(flavourBuild);
 
-        put("Name", getCI().makeCfgName(flavourBuild));
+        put("Name", getCI().makeCfgName(flavourBuild, platformName));
         put("Flavour", flavour);
         put("Build", build);
+        put("PlatformName", platformName);
 
         // ones mentioned above were needed to expand format
         String buildBase = expandFormat(getFieldString(null, "BuildBase"));
@@ -93,7 +95,7 @@
     protected void initDefaultLinkerFlags() {
         Vector linkerFlags = new Vector();
 
-        linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll")));
+        linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"), get("PlatformName")));
 
         put("LinkerFlags", linkerFlags);
     }
@@ -115,18 +117,15 @@
     }
 
 
-    Vector getPreferredPaths(MacroDefinitions macros) {
+    Vector getPreferredPaths() {
         Vector preferredPaths = new Vector();
+
         // In the case of multiple files with the same name in
-        // different subdirectories, prefer the versions specified in
-        // the platform file as the "os_family" and "arch" macros.
-        for (Iterator iter = macros.getMacros(); iter.hasNext(); ) {
-            Macro macro = (Macro) iter.next();
-            if (macro.name.equals("os_family") ||
-                macro.name.equals("arch")) {
-                preferredPaths.add(macro.contents);
-            }
-        }
+        // different subdirectories, prefer these versions
+        preferredPaths.add("windows");
+        preferredPaths.add("x86");
+        preferredPaths.add("closed");
+
         // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
         preferredPaths.add("opto");
 
@@ -137,18 +136,7 @@
     void handleDB() {
         WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject");
 
-        File incls = new File(get("OutputDir")+Util.sep+"incls");
-
-        incls.mkdirs();
-
-        MacroDefinitions macros = new MacroDefinitions();
-        try {
-            macros.readFrom(getFieldString(null, "Platform"), false);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
-        putSpecificField("AllFilesHash", computeAllFiles(platform, macros));
+        putSpecificField("AllFilesHash", computeAllFiles(platform));
     }
 
 
@@ -190,10 +178,10 @@
         ht.put(expandFormat(key), expandFormat(value));
     }
 
-    Hashtable computeAllFiles(WinGammaPlatform platform, MacroDefinitions macros) {
+    Hashtable computeAllFiles(WinGammaPlatform platform) {
         Hashtable rv = new Hashtable();
         DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt"));
-        Vector preferredPaths = getPreferredPaths(macros);
+        Vector preferredPaths = getPreferredPaths();
 
         // Hold errors until end
         Vector filesNotFound = new Vector();
@@ -228,8 +216,7 @@
             System.err.println("Error: some files were not found or " +
                                "appeared in multiple subdirectories of " +
                                "directory " + get("SourceBase") + " and could not " +
-                               "be resolved with the os_family and arch " +
-                               "macros in the platform file.");
+                               "be resolved with os_family and arch.");
             if (filesNotFound.size() != 0) {
                 System.err.println("Files not found:");
                 for (Iterator iter = filesNotFound.iterator();
@@ -254,10 +241,14 @@
         Vector sysDefines = new Vector();
         sysDefines.add("WIN32");
         sysDefines.add("_WINDOWS");
-        sysDefines.add("HOTSPOT_BUILD_USER="+System.getProperty("user.name"));
+        sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\"");
         sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\"");
         sysDefines.add("_JNI_IMPLEMENTATION_");
-        sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\"");
+        if (vars.get("PlatformName").equals("Win32")) {
+            sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\"");
+        } else {
+            sysDefines.add("HOTSPOT_LIB_ARCH=\\\"amd64\\\"");
+        }
 
         sysDefines.addAll(defines);
 
@@ -710,7 +701,7 @@
 }
 abstract class CompilerInterface {
     abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir);
-    abstract Vector getBaseLinkerFlags(String outDir, String outDll);
+    abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName);
     abstract Vector getDebugCompilerFlags(String opt);
     abstract Vector getDebugLinkerFlags();
     abstract void   getAdditionalNonKernelLinkerFlags(Vector rv);
@@ -718,7 +709,7 @@
     abstract Vector getProductLinkerFlags();
     abstract String getOptFlag();
     abstract String getNoOptFlag();
-    abstract String makeCfgName(String flavourBuild);
+    abstract String makeCfgName(String flavourBuild, String platformName);
 
     void addAttr(Vector receiver, String attr, String value) {
         receiver.add(attr); receiver.add(value);
--- a/hotspot/src/share/tools/ProjectCreator/DirectoryTree.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/DirectoryTree.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -55,6 +55,9 @@
         private Vector nodes = new Vector();
 
         public FileIterator(Node rootNode) {
+            if(rootNode == null) {
+                return;
+            }
             nodes.add(rootNode);
             prune();
         }
@@ -112,10 +115,7 @@
         throws IllegalArgumentException {
         File root = new File(Util.normalize(baseDirectory));
         if (!root.isDirectory()) {
-            throw new IllegalArgumentException("baseDirectory \"" +
-                                               baseDirectory +
-                                               "\" does not exist or " +
-                                               "is not a directory");
+            return;
         }
         try {
             root = root.getCanonicalFile();
--- a/hotspot/src/share/tools/ProjectCreator/FileFormatException.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/FileFormatException.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -22,7 +22,9 @@
  *
  */
 
+@SuppressWarnings("serial")
 public class FileFormatException extends Exception {
+
     public FileFormatException() {
         super();
     }
--- a/hotspot/src/share/tools/ProjectCreator/Macro.java	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- *
- */
-
-public class Macro {
-    public String name;
-    public String contents;
-}
--- a/hotspot/src/share/tools/ProjectCreator/MacroDefinitions.java	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- *
- */
-
-import java.io.*;
-import java.util.*;
-
-public class MacroDefinitions {
-    private Vector macros;
-
-    public MacroDefinitions() {
-        macros = new Vector();
-    }
-
-    public void addMacro(String name, String contents) {
-        Macro macro = new Macro();
-        macro.name = name;
-        macro.contents = contents;
-        macros.add(macro);
-    }
-
-    private boolean lineIsEmpty(String s) {
-        for (int i = 0; i < s.length(); i++) {
-            if (!Character.isWhitespace(s.charAt(i))) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public void readFrom(String fileName, boolean missingOk)
-        throws FileNotFoundException, FileFormatException, IOException {
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new FileReader(fileName));
-        } catch (FileNotFoundException e) {
-            if (missingOk) {
-                return;
-            } else {
-                throw(e);
-            }
-        }
-        String line;
-        do {
-            line = reader.readLine();
-            if (line != null) {
-                // This had to be rewritten (compare to Database.java)
-                // because the Solaris platform file has been
-                // repurposed and now contains "macros" with spaces in
-                // them.
-
-                if ((!line.startsWith("//")) &&
-                    (!lineIsEmpty(line))) {
-                    int nameBegin = -1;
-                    int nameEnd = -1;
-                    boolean gotEquals = false;
-                    int contentsBegin = -1;
-                    int contentsEnd = -1;
-
-                    int i = 0;
-                    // Scan forward for beginning of name
-                    while (i < line.length()) {
-                        if (!Character.isWhitespace(line.charAt(i))) {
-                            break;
-                        }
-                        i++;
-                    }
-                    nameBegin = i;
-
-                    // Scan forward for end of name
-                    while (i < line.length()) {
-                        if (Character.isWhitespace(line.charAt(i))) {
-                            break;
-                        }
-                        i++;
-                    }
-                    nameEnd = i;
-
-                    // Scan forward for equals sign
-                    while (i < line.length()) {
-                        if (line.charAt(i) == '=') {
-                            gotEquals = true;
-                            break;
-                        }
-                        i++;
-                    }
-
-                    // Scan forward for start of contents
-                    i++;
-                    while (i < line.length()) {
-                        if (!Character.isWhitespace(line.charAt(i))) {
-                            break;
-                        }
-                        i++;
-                    }
-                    contentsBegin = i;
-
-                    // Scan *backward* for end of contents
-                    i = line.length() - 1;
-                    while (i >= 0) {
-                        if (!Character.isWhitespace(line.charAt(i))) {
-                            break;
-                        }
-                    }
-                    contentsEnd = i+1;
-
-                    // Now do consistency check
-                    if (!((nameBegin < nameEnd) &&
-                          (nameEnd < contentsBegin) &&
-                          (contentsBegin < contentsEnd) &&
-                          (gotEquals == true))) {
-                        throw new FileFormatException(
-                            "Expected \"macroname = value\", " +
-                            "but found: " + line
-                        );
-                    }
-
-                    String name = line.substring(nameBegin, nameEnd);
-                    String contents = line.substring(contentsBegin,
-                                                     contentsEnd);
-                    addMacro(name, contents);
-                }
-            }
-        } while (line != null);
-        reader.close();
-    }
-
-    /** This returns an Iterator of Macros. You should not mutate the
-        returned Macro objects or use the Iterator to remove
-        macros. */
-    public Iterator getMacros() {
-        return macros.iterator();
-    }
-}
--- a/hotspot/src/share/tools/ProjectCreator/Util.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/Util.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
         return sb.toString();
     }
 
-     static String join(String padder, String v[]) {
+    static String join(String padder, String v[]) {
         StringBuffer sb = new StringBuffer();
 
         for (int i=0; i<v.length; i++) {
@@ -80,9 +80,16 @@
 
 
     static String normalize(String file) {
-        return file.replace('\\', '/');
+        file = file.replace('\\', '/');
+        if (file.length() > 2) {
+            if (file.charAt(1) == ':' && file.charAt(2) == '/') {
+                // convert drive letter to uppercase
+                String drive = file.substring(0, 1).toUpperCase();
+                return drive + file.substring(1);
+            }
+        }
+        return file;
     }
 
     static String sep = File.separator;
-    static String os = "Win32"; //System.getProperty("os.name");
 }
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -235,13 +235,6 @@
             (locationsInTree.size() == 0)) {
             filesNotFound.add(fileName);
         } else if (locationsInTree.size() > 1) {
-            // We shouldn't have duplicate file names in our workspace.
-            System.err.println();
-            System.err.println("There are multiple files named as: " + fileName);
-            System.exit(-1);
-            // The following code could be safely removed if we don't need duplicate
-            // file names.
-
             // Iterate through them, trying to find one with a
             // preferred path
         search:
@@ -336,7 +329,7 @@
 
         String projectName = getProjectName(projectFileName, ext);
 
-        writeProjectFile(projectFileName, projectName, createAllConfigs());
+        writeProjectFile(projectFileName, projectName, createAllConfigs(BuildConfig.getFieldString(null, "PlatformName")));
     }
 
     protected void writePrologue(String[] args) {
@@ -376,7 +369,13 @@
                               HsArgHandler.STRING
                               ),
 
-                new HsArgRule("-projectFileName",
+              new HsArgRule("-platformName",
+                              "PlatformName",
+                              null,
+                              HsArgHandler.STRING
+                              ),
+
+              new HsArgRule("-projectFileName",
                               "ProjectFileName",
                               null,
                               HsArgHandler.STRING
@@ -394,12 +393,6 @@
                               HsArgHandler.STRING
                               ),
 
-                new HsArgRule("-platform",
-                              "Platform",
-                              null,
-                              HsArgHandler.STRING
-                              ),
-
                 new HsArgRule("-absoluteInclude",
                               "AbsoluteInclude",
                               null,
@@ -590,28 +583,27 @@
         BuildConfig.putField(null, "PlatformObject", this);
     }
 
-    Vector createAllConfigs() {
+    Vector createAllConfigs(String platform) {
         Vector allConfigs = new Vector();
 
         allConfigs.add(new C1DebugConfig());
 
-        boolean b = true;
-        if (b) {
-            allConfigs.add(new C1FastDebugConfig());
-            allConfigs.add(new C1ProductConfig());
+        allConfigs.add(new C1FastDebugConfig());
+        allConfigs.add(new C1ProductConfig());
 
-            allConfigs.add(new C2DebugConfig());
-            allConfigs.add(new C2FastDebugConfig());
-            allConfigs.add(new C2ProductConfig());
+        allConfigs.add(new C2DebugConfig());
+        allConfigs.add(new C2FastDebugConfig());
+        allConfigs.add(new C2ProductConfig());
 
-            allConfigs.add(new TieredDebugConfig());
-            allConfigs.add(new TieredFastDebugConfig());
-            allConfigs.add(new TieredProductConfig());
+        allConfigs.add(new TieredDebugConfig());
+        allConfigs.add(new TieredFastDebugConfig());
+        allConfigs.add(new TieredProductConfig());
 
-            allConfigs.add(new CoreDebugConfig());
-            allConfigs.add(new CoreFastDebugConfig());
-            allConfigs.add(new CoreProductConfig());
+        allConfigs.add(new CoreDebugConfig());
+        allConfigs.add(new CoreFastDebugConfig());
+        allConfigs.add(new CoreProductConfig());
 
+        if (platform.equals("Win32")) {
             allConfigs.add(new KernelDebugConfig());
             allConfigs.add(new KernelFastDebugConfig());
             allConfigs.add(new KernelProductConfig());
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -223,7 +223,7 @@
         return rv;
     }
 
-    Vector getBaseLinkerFlags(String outDir, String outDll) {
+    Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
         Vector rv = new Vector();
 
         rv.add("PROP Ignore_Export_Lib 0");
@@ -231,8 +231,12 @@
         rv.add("ADD CPP /MD");
         rv.add("ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib " +
                "           advapi32.lib shell32.lib ole32.lib oleaut32.lib winmm.lib");
+        String machine = "/machine:I386";
+        if (platformName.equals("x64")) {
+                machine = "/machine:X64";
+        }
         rv.add("ADD LINK32      /out:\""+outDll+"\" "+
-               "                /nologo /subsystem:windows /machine:I386" +
+               "                /nologo /subsystem:windows /machine:" + machine +
                "                /nologo /base:\"0x8000000\" /subsystem:windows /dll" +
                "                /export:JNI_GetDefaultJavaVMInitArgs /export:JNI_CreateJavaVM /export:JNI_GetCreatedJavaVMs "+
                "                /export:jio_snprintf /export:jio_printf /export:jio_fprintf /export:jio_vfprintf "+
@@ -287,7 +291,7 @@
         return "d";
     }
 
-    String makeCfgName(String flavourBuild) {
-        return "vm - "+ Util.os + " " + flavourBuild;
+    String makeCfgName(String flavourBuild, String platform) {
+        return "vm - "+ platform + " " + flavourBuild;
     }
 }
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
     public void writeProjectFile(String projectFileName, String projectName,
                                  Vector allConfigs) throws IOException {
         System.out.println();
-        System.out.println("    Writing .vcproj file...");
+        System.out.println("    Writing .vcproj file: "+projectFileName);
         // If we got this far without an error, we're safe to actually
         // write the .vcproj file
         printWriter = new PrintWriter(new FileWriter(projectFileName));
@@ -54,9 +54,8 @@
                 "SccLocalPath", ""
             }
             );
-
         startTag("Platforms", null);
-        tag("Platform", new String[] {"Name", Util.os});
+        tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")});
         endTag("Platforms");
 
         startTag("Configurations", null);
@@ -81,12 +80,47 @@
 
 
     abstract class NameFilter {
-        protected String fname;
+                protected String fname;
 
         abstract boolean match(FileInfo fi);
 
         String  filterString() { return ""; }
         String name() { return this.fname;}
+
+        @Override
+        // eclipse auto-generated
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + getOuterType().hashCode();
+            result = prime * result + ((fname == null) ? 0 : fname.hashCode());
+            return result;
+        }
+
+        @Override
+        // eclipse auto-generated
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            NameFilter other = (NameFilter) obj;
+            if (!getOuterType().equals(other.getOuterType()))
+                return false;
+            if (fname == null) {
+                if (other.fname != null)
+                    return false;
+            } else if (!fname.equals(other.fname))
+                return false;
+            return true;
+        }
+
+        // eclipse auto-generated
+        private WinGammaPlatformVC7 getOuterType() {
+            return WinGammaPlatformVC7.this;
+        }
     }
 
     class DirectoryFilter extends NameFilter {
@@ -109,9 +143,50 @@
 
 
         boolean match(FileInfo fi) {
-           int lastSlashIndex = fi.full.lastIndexOf('/');
-           String fullDir = fi.full.substring(0, lastSlashIndex);
-           return fullDir.endsWith(dir);
+            int lastSlashIndex = fi.full.lastIndexOf('/');
+            String fullDir = fi.full.substring(0, lastSlashIndex);
+            return fullDir.endsWith(dir);
+        }
+
+        @Override
+        // eclipse auto-generated
+        public int hashCode() {
+            final int prime = 31;
+            int result = super.hashCode();
+            result = prime * result + getOuterType().hashCode();
+            result = prime * result + baseLen;
+            result = prime * result + ((dir == null) ? 0 : dir.hashCode());
+            result = prime * result + dirLen;
+            return result;
+        }
+
+        @Override
+        // eclipse auto-generated
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (!super.equals(obj))
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            DirectoryFilter other = (DirectoryFilter) obj;
+            if (!getOuterType().equals(other.getOuterType()))
+                return false;
+            if (baseLen != other.baseLen)
+                return false;
+            if (dir == null) {
+                if (other.dir != null)
+                    return false;
+            } else if (!dir.equals(other.dir))
+                return false;
+            if (dirLen != other.dirLen)
+                return false;
+            return true;
+        }
+
+        // eclipse auto-generated
+        private WinGammaPlatformVC7 getOuterType() {
+            return WinGammaPlatformVC7.this;
         }
     }
 
@@ -232,32 +307,39 @@
         DirectoryFilter container = null;
         for(FileInfo fileInfo : files) {
 
-           if (!fileInfo.full.startsWith(sbase)) {
-              continue;
-           }
+            if (!fileInfo.full.startsWith(sbase)) {
+                continue;
+            }
+
+            int lastSlash = fileInfo.full.lastIndexOf('/');
+            String dir = fileInfo.full.substring(sbase.length(), lastSlash);
+            if(dir.equals("share/vm")) {
+                // skip files directly in share/vm - should only be precompiled.hpp which is handled below
+                continue;
+            }
+            if (!dir.equals(currentDir)) {
+                currentDir = dir;
+                if (container != null && !rv.contains(container)) {
+                    rv.add(container);
+                }
 
-           int lastSlash = fileInfo.full.lastIndexOf('/');
-           String dir = fileInfo.full.substring(sbase.length(), lastSlash);
-           if(dir.equals("share/vm")) {
-              // skip files directly in share/vm - should only be precompiled.hpp which is handled below
-              continue;
-           }
-           if (!dir.equals(currentDir)) {
-              currentDir = dir;
-              if (container != null) {
-                 rv.add(container);
-              }
-
-              // remove "share/vm/" from names
-              String name = dir;
-              if (dir.startsWith("share/vm/")) {
-                 name = dir.substring("share/vm/".length(), dir.length());
-              }
-              container = new DirectoryFilter(name, dir, sbase);
-           }
+                // remove "share/vm/" from names
+                String name = dir;
+                if (dir.startsWith("share/vm/")) {
+                    name = dir.substring("share/vm/".length(), dir.length());
+                }
+                DirectoryFilter newfilter = new DirectoryFilter(name, dir, sbase);
+                int i = rv.indexOf(newfilter);
+                if(i == -1) {
+                    container = newfilter;
+                } else {
+                    // if the filter already exists, reuse it
+                    container = (DirectoryFilter) rv.get(i);
+                }
+            }
         }
-        if (container != null) {
-           rv.add(container);
+        if (container != null && !rv.contains(container)) {
+            rv.add(container);
         }
 
         ContainerFilter generated = new ContainerFilter("Generated");
@@ -583,7 +665,7 @@
         return rv;
     }
 
-    Vector getBaseLinkerFlags(String outDir, String outDll) {
+    Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
         Vector rv = new Vector();
 
         addAttr(rv, "Name", "VCLinkerTool");
@@ -610,8 +692,13 @@
         addAttr(rv, "SubSystem", "2");
         addAttr(rv, "BaseAddress", "0x8000000");
         addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib");
-        // Set /MACHINE option. 1 is machineX86
-        addAttr(rv, "TargetMachine", "1");
+        if(platformName.equals("Win32")) {
+            // Set /MACHINE option. 1 is X86
+            addAttr(rv, "TargetMachine", "1");
+        } else {
+            // Set /MACHINE option. 17 is X64
+            addAttr(rv, "TargetMachine", "17");
+        }
 
         return rv;
     }
@@ -656,12 +743,6 @@
         addAttr(rv, "Optimization", "2");
         // Set /Oy- option
         addAttr(rv, "OmitFramePointers", "FALSE");
-    }
-
-    Vector getProductCompilerFlags() {
-        Vector rv = new Vector();
-
-        getProductCompilerFlags_common(rv);
         // Set /Ob option.  1 is expandOnlyInline
         addAttr(rv, "InlineFunctionExpansion", "1");
         // Set /GF option.
@@ -670,6 +751,12 @@
         addAttr(rv, "RuntimeLibrary", "2");
         // Set /Gy option
         addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
+    }
+
+    Vector getProductCompilerFlags() {
+        Vector rv = new Vector();
+
+        getProductCompilerFlags_common(rv);
 
         return rv;
     }
@@ -693,7 +780,7 @@
         return "0";
     }
 
-    String makeCfgName(String flavourBuild) {
-        return  flavourBuild + "|" + Util.os;
+    String makeCfgName(String flavourBuild, String platform) {
+        return  flavourBuild + "|" + platform;
     }
 }
--- a/hotspot/src/share/vm/adlc/adlc.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/adlc/adlc.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -42,11 +42,6 @@
 using namespace std;
 #endif
 
-// make sure the MSC_VER and _MSC_VER settings make sense
-#if _MSC_VER != MSC_VER && (_MSC_VER != 1400 || MSC_VER != 1399)
-#error "Something is wrong with the detection of MSC_VER in the makefiles"
-#endif
-
 #if _MSC_VER >= 1400
 #define strdup _strdup
 #endif
--- a/hotspot/src/share/vm/adlc/output_c.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/adlc/output_c.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1698,7 +1698,75 @@
     fprintf(fp,"\n");
   } // done generating expand rule
 
-  else if( node->_matrule != NULL ) {
+  // Generate projections for instruction's additional DEFs and KILLs
+  if( ! node->expands() && (node->needs_projections() || node->has_temps())) {
+    // Get string representing the MachNode that projections point at
+    const char *machNode = "this";
+    // Generate the projections
+    fprintf(fp,"  // Add projection edges for additional defs or kills\n");
+
+    // Examine each component to see if it is a DEF or KILL
+    node->_components.reset();
+    // Skip the first component, if already handled as (SET dst (...))
+    Component *comp = NULL;
+    // For kills, the choice of projection numbers is arbitrary
+    int proj_no = 1;
+    bool declared_def  = false;
+    bool declared_kill = false;
+
+    while( (comp = node->_components.iter()) != NULL ) {
+      // Lookup register class associated with operand type
+      Form        *form = (Form*)_globalNames[comp->_type];
+      assert( form, "component type must be a defined form");
+      OperandForm *op   = form->is_operand();
+
+      if (comp->is(Component::TEMP)) {
+        fprintf(fp, "  // TEMP %s\n", comp->_name);
+        if (!declared_def) {
+          // Define the variable "def" to hold new MachProjNodes
+          fprintf(fp, "  MachTempNode *def;\n");
+          declared_def = true;
+        }
+        if (op && op->_interface && op->_interface->is_RegInterface()) {
+          fprintf(fp,"  def = new (C) MachTempNode(state->MachOperGenerator( %s, C ));\n",
+                  machOperEnum(op->_ident));
+          fprintf(fp,"  add_req(def);\n");
+          // The operand for TEMP is already constructed during
+          // this mach node construction, see buildMachNode().
+          //
+          // int idx  = node->operand_position_format(comp->_name);
+          // fprintf(fp,"  set_opnd_array(%d, state->MachOperGenerator( %s, C ));\n",
+          //         idx, machOperEnum(op->_ident));
+        } else {
+          assert(false, "can't have temps which aren't registers");
+        }
+      } else if (comp->isa(Component::KILL)) {
+        fprintf(fp, "  // DEF/KILL %s\n", comp->_name);
+
+        if (!declared_kill) {
+          // Define the variable "kill" to hold new MachProjNodes
+          fprintf(fp, "  MachProjNode *kill;\n");
+          declared_kill = true;
+        }
+
+        assert( op, "Support additional KILLS for base operands");
+        const char *regmask    = reg_mask(*op);
+        const char *ideal_type = op->ideal_type(_globalNames, _register);
+
+        if (!op->is_bound_register()) {
+          syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n",
+                     node->_ident, comp->_type, comp->_name);
+        }
+
+        fprintf(fp,"  kill = ");
+        fprintf(fp,"new (C, 1) MachProjNode( %s, %d, (%s), Op_%s );\n",
+                machNode, proj_no++, regmask, ideal_type);
+        fprintf(fp,"  proj_list.push(kill);\n");
+      }
+    }
+  }
+
+  if( !node->expands() && node->_matrule != NULL ) {
     // Remove duplicated operands and inputs which use the same name.
     // Seach through match operands for the same name usage.
     uint cur_num_opnds = node->num_opnds();
@@ -1752,72 +1820,6 @@
     }
   }
 
-
-  // Generate projections for instruction's additional DEFs and KILLs
-  if( ! node->expands() && (node->needs_projections() || node->has_temps())) {
-    // Get string representing the MachNode that projections point at
-    const char *machNode = "this";
-    // Generate the projections
-    fprintf(fp,"  // Add projection edges for additional defs or kills\n");
-
-    // Examine each component to see if it is a DEF or KILL
-    node->_components.reset();
-    // Skip the first component, if already handled as (SET dst (...))
-    Component *comp = NULL;
-    // For kills, the choice of projection numbers is arbitrary
-    int proj_no = 1;
-    bool declared_def  = false;
-    bool declared_kill = false;
-
-    while( (comp = node->_components.iter()) != NULL ) {
-      // Lookup register class associated with operand type
-      Form        *form = (Form*)_globalNames[comp->_type];
-      assert( form, "component type must be a defined form");
-      OperandForm *op   = form->is_operand();
-
-      if (comp->is(Component::TEMP)) {
-        fprintf(fp, "  // TEMP %s\n", comp->_name);
-        if (!declared_def) {
-          // Define the variable "def" to hold new MachProjNodes
-          fprintf(fp, "  MachTempNode *def;\n");
-          declared_def = true;
-        }
-        if (op && op->_interface && op->_interface->is_RegInterface()) {
-          fprintf(fp,"  def = new (C) MachTempNode(state->MachOperGenerator( %s, C ));\n",
-                  machOperEnum(op->_ident));
-          fprintf(fp,"  add_req(def);\n");
-          int idx  = node->operand_position_format(comp->_name);
-          fprintf(fp,"  set_opnd_array(%d, state->MachOperGenerator( %s, C ));\n",
-                  idx, machOperEnum(op->_ident));
-        } else {
-          assert(false, "can't have temps which aren't registers");
-        }
-      } else if (comp->isa(Component::KILL)) {
-        fprintf(fp, "  // DEF/KILL %s\n", comp->_name);
-
-        if (!declared_kill) {
-          // Define the variable "kill" to hold new MachProjNodes
-          fprintf(fp, "  MachProjNode *kill;\n");
-          declared_kill = true;
-        }
-
-        assert( op, "Support additional KILLS for base operands");
-        const char *regmask    = reg_mask(*op);
-        const char *ideal_type = op->ideal_type(_globalNames, _register);
-
-        if (!op->is_bound_register()) {
-          syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n",
-                     node->_ident, comp->_type, comp->_name);
-        }
-
-        fprintf(fp,"  kill = ");
-        fprintf(fp,"new (C, 1) MachProjNode( %s, %d, (%s), Op_%s );\n",
-                machNode, proj_no++, regmask, ideal_type);
-        fprintf(fp,"  proj_list.push(kill);\n");
-      }
-    }
-  }
-
   // If the node is a MachConstantNode, insert the MachConstantBaseNode edge.
   // NOTE: this edge must be the last input (see MachConstantNode::mach_constant_base_node_input).
   if (node->is_mach_constant()) {
@@ -3776,12 +3778,10 @@
       }
       dont_care = true;
       // For each operand not in the match rule, call MachOperGenerator
-      // with the enum for the opcode that needs to be built
-      // and the node just built, the parent of the operand.
+      // with the enum for the opcode that needs to be built.
       ComponentList clist = inst->_components;
       int         index  = clist.operand_position(comp->_name, comp->_usedef);
       const char *opcode = machOperEnum(comp->_type);
-      const char *parent = "node";
       fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index);
       fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode);
       }
--- a/hotspot/src/share/vm/c1/c1_Compilation.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -491,10 +491,11 @@
       // to start profiling on its own.
       _method->ensure_method_data();
     }
-  } else if (is_profiling() && _would_profile) {
+  } else if (is_profiling()) {
     ciMethodData *md = method->method_data_or_null();
-    assert(md != NULL, "Sanity");
-    md->set_would_profile(_would_profile);
+    if (md != NULL) {
+      md->set_would_profile(_would_profile);
+    }
   }
 }
 
--- a/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -412,13 +412,17 @@
     fail_type = _unloaded_ciinstance_klass;
   }
   KlassHandle found_klass;
-  if (!require_local) {
-    klassOop kls = SystemDictionary::find_constrained_instance_or_array_klass(
-        sym, loader, KILL_COMPILE_ON_FATAL_(fail_type));
-    found_klass = KlassHandle(THREAD, kls);
-  } else {
-    klassOop kls = SystemDictionary::find_instance_or_array_klass(
-        sym, loader, domain, KILL_COMPILE_ON_FATAL_(fail_type));
+  {
+    ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
+    MutexLocker ml(Compile_lock);
+    klassOop kls;
+    if (!require_local) {
+      kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
+                                                                       KILL_COMPILE_ON_FATAL_(fail_type));
+    } else {
+      kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
+                                                           KILL_COMPILE_ON_FATAL_(fail_type));
+    }
     found_klass = KlassHandle(THREAD, kls);
   }
 
--- a/hotspot/src/share/vm/ci/ciField.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/ci/ciField.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -212,9 +212,9 @@
     //    may change.  The three examples are java.lang.System.in,
     //    java.lang.System.out, and java.lang.System.err.
 
-    klassOop k = _holder->get_klassOop();
+    Handle k = _holder->get_klassOop();
     assert( SystemDictionary::System_klass() != NULL, "Check once per vm");
-    if( k == SystemDictionary::System_klass() ) {
+    if( k() == SystemDictionary::System_klass() ) {
       // Check offsets for case 2: System.in, System.out, or System.err
       if( _offset == java_lang_System::in_offset_in_bytes()  ||
           _offset == java_lang_System::out_offset_in_bytes() ||
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -46,6 +46,7 @@
   ciKlass(h_k), _non_static_fields(NULL)
 {
   assert(get_Klass()->oop_is_instance(), "wrong type");
+  assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
   instanceKlass* ik = get_instanceKlass();
 
   AccessFlags access_flags = ik->access_flags();
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -331,7 +331,7 @@
     length, CHECK_(nullHandle));
   constantPoolOop constant_pool =
                       oopFactory::new_constantPool(length,
-                                                   methodOopDesc::IsSafeConc,
+                                                   oopDesc::IsSafeConc,
                                                    CHECK_(nullHandle));
   constantPoolHandle cp (THREAD, constant_pool);
 
@@ -1929,10 +1929,9 @@
   }
 
   // All sizing information for a methodOop is finally available, now create it
-  methodOop m_oop  = oopFactory::new_method(
-    code_length, access_flags, linenumber_table_length,
-    total_lvt_length, checked_exceptions_length,
-    methodOopDesc::IsSafeConc, CHECK_(nullHandle));
+  methodOop m_oop  = oopFactory::new_method(code_length, access_flags, linenumber_table_length,
+                                            total_lvt_length, checked_exceptions_length,
+                                            oopDesc::IsSafeConc, CHECK_(nullHandle));
   methodHandle m (THREAD, m_oop);
 
   ClassLoadingService::add_class_method_size(m_oop->size()*HeapWordSize);
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1290,6 +1290,15 @@
 int ClassLoader::_compile_the_world_counter = 0;
 static int _codecache_sweep_counter = 0;
 
+// Filter out all exceptions except OOMs
+static void clear_pending_exception_if_not_oom(TRAPS) {
+  if (HAS_PENDING_EXCEPTION &&
+      !PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
+    CLEAR_PENDING_EXCEPTION;
+  }
+  // The CHECK at the caller will propagate the exception out
+}
+
 void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) {
   int len = (int)strlen(name);
   if (len > 6 && strcmp(".class", name + len - 6) == 0) {
@@ -1312,12 +1321,12 @@
         k->initialize(THREAD);
       }
       bool exception_occurred = HAS_PENDING_EXCEPTION;
-      CLEAR_PENDING_EXCEPTION;
+      clear_pending_exception_if_not_oom(CHECK);
       if (CompileTheWorldPreloadClasses && k.not_null()) {
         constantPoolKlass::preload_and_initialize_all_classes(k->constants(), THREAD);
         if (HAS_PENDING_EXCEPTION) {
           // If something went wrong in preloading we just ignore it
-          CLEAR_PENDING_EXCEPTION;
+          clear_pending_exception_if_not_oom(CHECK);
           tty->print_cr("Preloading failed for (%d) %s", _compile_the_world_counter, buffer);
         }
       }
@@ -1344,7 +1353,7 @@
               CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_initial_compile,
                                             methodHandle(), 0, "CTW", THREAD);
               if (HAS_PENDING_EXCEPTION) {
-                CLEAR_PENDING_EXCEPTION;
+                clear_pending_exception_if_not_oom(CHECK);
                 tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string());
               }
               if (TieredCompilation) {
@@ -1358,7 +1367,7 @@
                 CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_full_optimization,
                                               methodHandle(), 0, "CTW", THREAD);
                 if (HAS_PENDING_EXCEPTION) {
-                  CLEAR_PENDING_EXCEPTION;
+                  clear_pending_exception_if_not_oom(CHECK);
                   tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string());
                 }
               }
--- a/hotspot/src/share/vm/classfile/loaderConstraints.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/classfile/loaderConstraints.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -322,8 +322,14 @@
 klassOop LoaderConstraintTable::find_constrained_klass(Symbol* name,
                                                        Handle loader) {
   LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
-  if (p != NULL && p->klass() != NULL)
+  if (p != NULL && p->klass() != NULL) {
+    if (Klass::cast(p->klass())->oop_is_instance() && !instanceKlass::cast(p->klass())->is_loaded()) {
+      // Only return fully loaded classes.  Classes found through the
+      // constraints might still be in the process of loading.
+      return NULL;
+    }
     return p->klass();
+  }
 
   // No constraints, or else no klass loaded yet.
   return NULL;
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1690,6 +1690,8 @@
 
 void SystemDictionary::add_to_hierarchy(instanceKlassHandle k, TRAPS) {
   assert(k.not_null(), "just checking");
+  assert_locked_or_safepoint(Compile_lock);
+
   // Link into hierachy. Make sure the vtables are initialized before linking into
   k->append_to_sibling_list();                    // add to superklass/sibling list
   k->process_interfaces(THREAD);                  // handle all "implements" declarations
@@ -2152,6 +2154,9 @@
 }
 
 
+// Try to find a class name using the loader constraints.  The
+// loader constraints might know about a class that isn't fully loaded
+// yet and these will be ignored.
 klassOop SystemDictionary::find_constrained_instance_or_array_klass(
                     Symbol* class_name, Handle class_loader, TRAPS) {
 
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -768,7 +768,9 @@
 // Initialize the compilation queue
 void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) {
   EXCEPTION_MARK;
+#ifndef ZERO
   assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?");
+#endif // !ZERO
   if (c2_compiler_count > 0) {
     _c2_method_queue  = new CompileQueue("C2MethodQueue",  MethodCompileQueue_lock);
   }
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1040,9 +1040,10 @@
     } else {
       // must read from what 'p' points to in each loop.
       klassOop k = ((volatile oopDesc*)p)->klass_or_null();
-      if (k != NULL &&
-          ((oopDesc*)p)->is_parsable() &&
-          ((oopDesc*)p)->is_conc_safe()) {
+      // We trust the size of any object that has a non-NULL
+      // klass and (for those in the perm gen) is parsable
+      // -- irrespective of its conc_safe-ty.
+      if (k != NULL && ((oopDesc*)p)->is_parsable()) {
         assert(k->is_oop(), "Should really be klass oop.");
         oop o = (oop)p;
         assert(o->is_oop(), "Should be an oop");
@@ -1051,6 +1052,7 @@
         assert(res != 0, "Block size should not be 0");
         return res;
       } else {
+        // May return 0 if P-bits not present.
         return c->block_size_if_printezis_bits(p);
       }
     }
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -6360,18 +6360,16 @@
 // A variant of the above (block_size_using_printezis_bits()) except
 // that we return 0 if the P-bits are not yet set.
 size_t CMSCollector::block_size_if_printezis_bits(HeapWord* addr) const {
-  if (_markBitMap.isMarked(addr)) {
-    assert(_markBitMap.isMarked(addr + 1), "Missing Printezis bit?");
+  if (_markBitMap.isMarked(addr + 1)) {
+    assert(_markBitMap.isMarked(addr), "P-bit can be set only for marked objects");
     HeapWord* nextOneAddr = _markBitMap.getNextMarkedWordAddress(addr + 2);
     size_t size = pointer_delta(nextOneAddr + 1, addr);
     assert(size == CompactibleFreeListSpace::adjustObjectSize(size),
            "alignment problem");
     assert(size >= 3, "Necessary for Printezis marks to work");
     return size;
-  } else {
-    assert(!_markBitMap.isMarked(addr + 1), "Bit map inconsistency?");
-    return 0;
-  }
+  }
+  return 0;
 }
 
 HeapWord* CMSCollector::next_card_start_after_block(HeapWord* addr) const {
@@ -9212,7 +9210,6 @@
 
 size_t MarkDeadObjectsClosure::do_blk(HeapWord* addr) {
   size_t res = _sp->block_size_no_stall(addr, _collector);
-  assert(res != 0, "Should always be able to compute a size");
   if (_sp->block_is_obj(addr)) {
     if (_live_bit_map->isMarked(addr)) {
       // It can't have been dead in a previous cycle
@@ -9221,6 +9218,7 @@
       _dead_bit_map->mark(addr);      // mark the dead object
     }
   }
+  // Could be 0, if the block size could not be computed without stalling.
   return res;
 }
 
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -132,8 +132,7 @@
   VM_GenCollectFullConcurrent(unsigned int gc_count_before,
                               unsigned int full_gc_count_before,
                               GCCause::Cause gc_cause)
-    : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */) {
-    _gc_cause = gc_cause;
+    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */) {
     assert(FullGCCount_lock != NULL, "Error");
     assert(UseAsyncConcMarkSweepGC, "Else will hang caller");
   }
--- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
 public:
   VM_G1OperationWithAllocRequest(unsigned int gc_count_before,
                                  size_t       word_size)
-    : VM_GC_Operation(gc_count_before),
+    : VM_GC_Operation(gc_count_before, GCCause::_allocation_failure),
       _word_size(word_size), _result(NULL), _pause_succeeded(false) { }
   HeapWord* result() { return _result; }
   bool pause_succeeded() { return _pause_succeeded; }
@@ -55,9 +55,7 @@
   VM_G1CollectFull(unsigned int gc_count_before,
                    unsigned int full_gc_count_before,
                    GCCause::Cause cause)
-    : VM_GC_Operation(gc_count_before, full_gc_count_before) {
-    _gc_cause = cause;
-  }
+    : VM_GC_Operation(gc_count_before, cause, full_gc_count_before) { }
   virtual VMOp_Type type() const { return VMOp_G1CollectFull; }
   virtual void doit();
   virtual const char* name() const {
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,9 +112,12 @@
   yg_cur_size = MAX2(yg_cur_size, yg_min_size);
 
   og_min_size = align_size_up(og_min_size, og_align);
-  og_max_size = align_size_up(og_max_size, og_align);
+  // Align old gen size down to preserve specified heap size.
+  assert(og_align == yg_align, "sanity");
+  og_max_size = align_size_down(og_max_size, og_align);
+  og_max_size = MAX2(og_max_size, og_min_size);
   size_t og_cur_size =
-    align_size_up(_collector_policy->old_gen_size(), og_align);
+    align_size_down(_collector_policy->old_gen_size(), og_align);
   og_cur_size = MAX2(og_cur_size, og_min_size);
 
   pg_min_size = align_size_up(pg_min_size, pg_align);
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1196,11 +1196,6 @@
   static inline void adjust_pointer(oop* p)       { adjust_pointer(p, false); }
   static inline void adjust_pointer(narrowOop* p) { adjust_pointer(p, false); }
 
-  template <class T>
-  static inline void adjust_pointer(T* p,
-                                    HeapWord* beg_addr,
-                                    HeapWord* end_addr);
-
   // Reference Processing
   static ReferenceProcessor* const ref_processor() { return _ref_processor; }
 
@@ -1408,15 +1403,6 @@
   return ((HeapWord*) k) >= dense_prefix(perm_space_id);
 }
 
-template <class T>
-inline void PSParallelCompact::adjust_pointer(T* p,
-                                              HeapWord* beg_addr,
-                                              HeapWord* end_addr) {
-  if (is_in((HeapWord*)p, beg_addr, end_addr)) {
-    adjust_pointer(p);
-  }
-}
-
 #ifdef ASSERT
 inline void
 PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr)
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -34,7 +34,7 @@
 // The following methods are used by the parallel scavenge collector
 VM_ParallelGCFailedAllocation::VM_ParallelGCFailedAllocation(size_t size,
   bool is_tlab, unsigned int gc_count) :
-  VM_GC_Operation(gc_count),
+  VM_GC_Operation(gc_count, GCCause::_allocation_failure),
   _size(size),
   _is_tlab(is_tlab),
   _result(NULL)
@@ -57,7 +57,7 @@
 
 VM_ParallelGCFailedPermanentAllocation::VM_ParallelGCFailedPermanentAllocation(size_t size,
   unsigned int gc_count, unsigned int full_gc_count) :
-  VM_GC_Operation(gc_count, full_gc_count, true /* full */),
+  VM_GC_Operation(gc_count, GCCause::_allocation_failure, full_gc_count, true /* full */),
   _size(size),
   _result(NULL)
 {
@@ -80,9 +80,8 @@
 VM_ParallelGCSystemGC::VM_ParallelGCSystemGC(unsigned int gc_count,
                                              unsigned int full_gc_count,
                                              GCCause::Cause gc_cause) :
-  VM_GC_Operation(gc_count, full_gc_count, true /* full */)
+  VM_GC_Operation(gc_count, gc_cause, full_gc_count, true /* full */)
 {
-  _gc_cause = gc_cause;
 }
 
 void VM_ParallelGCSystemGC::doit() {
--- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,6 +87,8 @@
 
 bool VM_GC_Operation::doit_prologue() {
   assert(Thread::current()->is_Java_thread(), "just checking");
+  assert(((_gc_cause != GCCause::_no_gc) &&
+          (_gc_cause != GCCause::_no_cause_specified)), "Illegal GCCause");
 
   acquire_pending_list_lock();
   // If the GC count has changed someone beat us to the collection
--- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,6 +85,7 @@
 
  public:
   VM_GC_Operation(unsigned int gc_count_before,
+                  GCCause::Cause _cause,
                   unsigned int full_gc_count_before = 0,
                   bool full = false) {
     _full = full;
@@ -92,7 +93,7 @@
     _gc_count_before    = gc_count_before;
 
     // A subclass constructor will likely overwrite the following
-    _gc_cause           = GCCause::_no_cause_specified;
+    _gc_cause           = _cause;
 
     _gc_locked = false;
 
@@ -136,6 +137,7 @@
   VM_GC_HeapInspection(outputStream* out, bool request_full_gc,
                        bool need_prologue) :
     VM_GC_Operation(0 /* total collections,      dummy, ignored */,
+                    GCCause::_heap_inspection /* GC Cause */,
                     0 /* total full collections, dummy, ignored */,
                     request_full_gc) {
     _out = out;
@@ -160,7 +162,7 @@
   VM_GenCollectForAllocation(size_t size,
                              bool tlab,
                              unsigned int gc_count_before)
-    : VM_GC_Operation(gc_count_before),
+    : VM_GC_Operation(gc_count_before, GCCause::_allocation_failure),
       _size(size),
       _tlab(tlab) {
     _res = NULL;
@@ -182,9 +184,8 @@
                     unsigned int full_gc_count_before,
                     GCCause::Cause gc_cause,
                       int max_level)
-    : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */),
-      _max_level(max_level)
-  { _gc_cause = gc_cause; }
+    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */),
+      _max_level(max_level) { }
   ~VM_GenCollectFull() {}
   virtual VMOp_Type type() const { return VMOp_GenCollectFull; }
   virtual void doit();
@@ -199,7 +200,7 @@
                                       unsigned int gc_count_before,
                                       unsigned int full_gc_count_before,
                                       GCCause::Cause gc_cause)
-    : VM_GC_Operation(gc_count_before, full_gc_count_before, true),
+    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true),
       _size(size) {
     _res = NULL;
     _gc_cause = gc_cause;
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -100,8 +100,7 @@
   }
 }
 
-void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size)
- {
+void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) {
   if (CheckMemoryInitialization && ZapUnusedHeapArea) {
     for (size_t slot = 0; slot < size; slot += 1) {
       assert((*(intptr_t*) (addr + slot)) == ((intptr_t) badHeapWordVal),
--- a/hotspot/src/share/vm/gc_interface/gcCause.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_interface/gcCause.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,28 +92,3 @@
   }
   ShouldNotReachHere();
 }
-
-#ifndef PRODUCT
-
-bool GCCause::is_for_full_collection(GCCause::Cause cause) {
-  bool result;
-
-  // There are more GCCause::Cause types than listed here.
-  // For brevity, we list only those that cause full collections.
-  switch (cause) {
-    case _allocation_failure:
-    case _tenured_generation_full:
-    case _permanent_generation_full:
-    case _cms_generation_full:
-    case _last_ditch_collection:
-      result = true;
-      break;
-
-    default:
-      result = false;
-      break;
-  }
-  return result;
-}
-
-#endif // PRODUCT
--- a/hotspot/src/share/vm/gc_interface/gcCause.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/gc_interface/gcCause.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,8 +85,6 @@
 
   // Return a string describing the GCCause.
   static const char* to_string(GCCause::Cause cause);
-  // Return true if the GCCause is for a full collection.
-  static bool is_for_full_collection(GCCause::Cause cause) PRODUCT_RETURN0;
 };
 
 #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1942,7 +1942,7 @@
         constantPoolOop constants = istate->method()->constants();
         if (!constants->tag_at(index).is_unresolved_klass()) {
           // Make sure klass is initialized and doesn't have a finalizer
-          oop entry = (klassOop) *constants->obj_at_addr(index);
+          oop entry = constants->slot_at(index).get_oop();
           assert(entry->is_klass(), "Should be resolved klass");
           klassOop k_entry = (klassOop) entry;
           assert(k_entry->klass_part()->oop_is_instance(), "Should be instanceKlass");
@@ -2032,7 +2032,7 @@
             if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
               CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
             }
-            klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index));
+            klassOop klassOf = (klassOop) METHOD->constants()->slot_at(index).get_oop();
             klassOop objKlassOop = STACK_OBJECT(-1)->klass(); //ebx
             //
             // Check for compatibilty. This check must not GC!!
@@ -2067,7 +2067,7 @@
             if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
               CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
             }
-            klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index));
+            klassOop klassOf = (klassOop) METHOD->constants()->slot_at(index).get_oop();
             klassOop objKlassOop = STACK_OBJECT(-1)->klass();
             //
             // Check for compatibilty. This check must not GC!!
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -67,13 +67,11 @@
 
 
 // Creates a constant pool cache given a CPC map
-// This creates the constant pool cache initially in a state
-// that is unsafe for concurrent GC processing but sets it to
-// a safe mode before the constant pool cache is returned.
 void Rewriter::make_constant_pool_cache(TRAPS) {
   const int length = _cp_cache_map.length();
   constantPoolCacheOop cache =
-      oopFactory::new_constantPoolCache(length, methodOopDesc::IsUnsafeConc, CHECK);
+      oopFactory::new_constantPoolCache(length, CHECK);
+  No_Safepoint_Verifier nsv;
   cache->initialize(_cp_cache_map);
 
   // Don't bother with the next pass if there is no JVM_CONSTANT_InvokeDynamic.
--- a/hotspot/src/share/vm/libadt/vectset.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/libadt/vectset.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -350,28 +350,11 @@
   return (int)_xor;
 }
 
-//------------------------------iterate----------------------------------------
-SetI_ *VectorSet::iterate(uint &elem) const
-{
-  VSetI_ *foo = (new(ResourceObj::C_HEAP) VSetI_(this));
-  elem = foo->next();
-  return foo;
-}
-
 //=============================================================================
-//------------------------------VSetI_-----------------------------------------
-// Initialize the innards of a VectorSet iterator
-VSetI_::VSetI_( const VectorSet *vset ) : s(vset)
-{
-  i = (uint)-1L;
-  j = (uint)-1L;
-  mask = (unsigned)(1L<<31);
-}
-
 //------------------------------next-------------------------------------------
 // Find and return the next element of a vector set, or return garbage and
-// make "VSetI_::test()" fail.
-uint VSetI_::next(void)
+// make "VectorSetI::test()" fail.
+uint VectorSetI::next(void)
 {
   j++;                          // Next element in word
   mask = (mask & max_jint) << 1;// Next bit in word
--- a/hotspot/src/share/vm/libadt/vectset.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/libadt/vectset.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -98,6 +98,9 @@
   uint Size(void) const;            // Number of elements in the Set.
   void Sort(void);                  // Sort before iterating
   int hash() const;                 // Hash function
+  void Reset(void) {                // Reset a set
+    memset( data, 0, size*sizeof(uint32) );
+  }
 
   /* Removed for MCC BUG
      operator const VectorSet* (void) const { return this; } */
@@ -148,8 +151,7 @@
 
 
 private:
-  friend class VSetI_;
-  SetI_ *iterate(uint&) const;
+  SetI_ *iterate(uint&) const { ShouldNotCallThis(); return NULL; } // Removed
 };
 
 //------------------------------Iteration--------------------------------------
@@ -158,22 +160,26 @@
 // or may not be iterated over; untouched elements will be affected once.
 // Usage:  for( VectorSetI i(s); i.test(); i++ ) { body = i.elem; }
 
-class VSetI_ : public SetI_ {
+class VectorSetI : public StackObj {
   friend class VectorSet;
-  friend class VectorSetI;
   const VectorSet *s;
   uint i, j;
   uint32 mask;
-  VSetI_(const VectorSet *vset);
   uint next(void);
+
+public:
+  uint elem;                    // The publically accessible element
+
+  VectorSetI( const VectorSet *vset ) :
+    s(vset),
+    i((uint)-1L),
+    j((uint)-1L),
+    mask((unsigned)(1L<<31)) {
+    elem = next();
+  }
+
+  void operator ++(void) { elem = next(); }
   int test(void) { return i < s->size; }
 };
 
-class VectorSetI : public SetI {
-public:
-  VectorSetI( const VectorSet *s ) : SetI(s) { }
-  void operator ++(void) { elem = ((VSetI_*)impl)->next(); }
-  int test(void) { return ((VSetI_*)impl)->test(); }
-};
-
 #endif // SHARE_VM_LIBADT_VECTSET_HPP
--- a/hotspot/src/share/vm/memory/allocation.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/memory/allocation.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -157,7 +157,7 @@
 
 void trace_heap_malloc(size_t size, const char* name, void* p) {
   // A lock is not needed here - tty uses a lock internally
-  tty->print_cr("Heap malloc " INTPTR_FORMAT " %7d %s", p, size, name == NULL ? "" : name);
+  tty->print_cr("Heap malloc " INTPTR_FORMAT " " SIZE_FORMAT " %s", p, size, name == NULL ? "" : name);
 }
 
 
@@ -573,22 +573,27 @@
   st->print("AllocatedObj(" INTPTR_FORMAT ")", this);
 }
 
-size_t Arena::_bytes_allocated = 0;
+julong Arena::_bytes_allocated = 0;
+
+void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); }
 
 AllocStats::AllocStats() {
-  start_mallocs = os::num_mallocs;
-  start_frees = os::num_frees;
+  start_mallocs      = os::num_mallocs;
+  start_frees        = os::num_frees;
   start_malloc_bytes = os::alloc_bytes;
-  start_res_bytes = Arena::_bytes_allocated;
+  start_mfree_bytes  = os::free_bytes;
+  start_res_bytes    = Arena::_bytes_allocated;
 }
 
-int     AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; }
-size_t  AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; }
-size_t  AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; }
-int     AllocStats::num_frees() { return os::num_frees - start_frees; }
+julong  AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; }
+julong  AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; }
+julong  AllocStats::num_frees()   { return os::num_frees - start_frees; }
+julong  AllocStats::free_bytes()  { return os::free_bytes - start_mfree_bytes; }
+julong  AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; }
 void    AllocStats::print() {
-  tty->print("%d mallocs (%ldK), %d frees, %ldK resrc",
-             num_mallocs(), alloc_bytes()/K, num_frees(), resource_bytes()/K);
+  tty->print_cr(UINT64_FORMAT " mallocs (" UINT64_FORMAT "MB), "
+                UINT64_FORMAT" frees (" UINT64_FORMAT "MB), " UINT64_FORMAT "MB resrc",
+                num_mallocs(), alloc_bytes()/M, num_frees(), free_bytes()/M, resource_bytes()/M);
 }
 
 
--- a/hotspot/src/share/vm/memory/allocation.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/memory/allocation.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -202,10 +202,11 @@
   char *_hwm, *_max;            // High water mark and max in current chunk
   void* grow(size_t x);         // Get a new Chunk of at least size x
   NOT_PRODUCT(size_t _size_in_bytes;) // Size of arena (used for memory usage tracing)
-  NOT_PRODUCT(static size_t _bytes_allocated;) // total #bytes allocated since start
+  NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start
   friend class AllocStats;
   debug_only(void* malloc(size_t size);)
   debug_only(void* internal_malloc_4(size_t x);)
+  NOT_PRODUCT(void inc_bytes_allocated(size_t x);)
  public:
   Arena();
   Arena(size_t init_size);
@@ -219,7 +220,7 @@
     assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2");
     x = ARENA_ALIGN(x);
     debug_only(if (UseMallocOnly) return malloc(x);)
-    NOT_PRODUCT(_bytes_allocated += x);
+    NOT_PRODUCT(inc_bytes_allocated(x);)
     if (_hwm + x > _max) {
       return grow(x);
     } else {
@@ -232,7 +233,7 @@
   void *Amalloc_4(size_t x) {
     assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
     debug_only(if (UseMallocOnly) return malloc(x);)
-    NOT_PRODUCT(_bytes_allocated += x);
+    NOT_PRODUCT(inc_bytes_allocated(x);)
     if (_hwm + x > _max) {
       return grow(x);
     } else {
@@ -252,7 +253,7 @@
     size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm;
     x += delta;
 #endif
-    NOT_PRODUCT(_bytes_allocated += x);
+    NOT_PRODUCT(inc_bytes_allocated(x);)
     if (_hwm + x > _max) {
       return grow(x); // grow() returns a result aligned >= 8 bytes.
     } else {
@@ -406,15 +407,16 @@
 // for statistics
 #ifndef PRODUCT
 class AllocStats : StackObj {
-  int    start_mallocs, start_frees;
-  size_t start_malloc_bytes, start_res_bytes;
+  julong start_mallocs, start_frees;
+  julong start_malloc_bytes, start_mfree_bytes, start_res_bytes;
  public:
   AllocStats();
 
-  int    num_mallocs();    // since creation of receiver
-  size_t alloc_bytes();
-  size_t resource_bytes();
-  int    num_frees();
+  julong num_mallocs();    // since creation of receiver
+  julong alloc_bytes();
+  julong num_frees();
+  julong free_bytes();
+  julong resource_bytes();
   void   print();
 };
 #endif
--- a/hotspot/src/share/vm/memory/allocation.inline.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/memory/allocation.inline.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -32,6 +32,20 @@
 void trace_heap_malloc(size_t size, const char* name, void *p);
 void trace_heap_free(void *p);
 
+#ifndef PRODUCT
+// Increments unsigned long value for statistics (not atomic on MP).
+inline void inc_stat_counter(volatile julong* dest, julong add_value) {
+#if defined(SPARC) || defined(X86)
+  // Sparc and X86 have atomic jlong (8 bytes) instructions
+  julong value = Atomic::load((volatile jlong*)dest);
+  value += add_value;
+  Atomic::store((jlong)value, (volatile jlong*)dest);
+#else
+  // possible word-tearing during load/store
+  *dest += add_value;
+#endif
+}
+#endif
 
 // allocate using malloc; will fail if no memory available
 inline char* AllocateHeap(size_t size, const char* name = NULL) {
--- a/hotspot/src/share/vm/memory/oopFactory.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/memory/oopFactory.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -111,10 +111,9 @@
 
 
 constantPoolCacheOop oopFactory::new_constantPoolCache(int length,
-                                                       bool is_conc_safe,
                                                        TRAPS) {
   constantPoolCacheKlass* ck = constantPoolCacheKlass::cast(Universe::constantPoolCacheKlassObj());
-  return ck->allocate(length, is_conc_safe, CHECK_NULL);
+  return ck->allocate(length, CHECK_NULL);
 }
 
 
--- a/hotspot/src/share/vm/memory/oopFactory.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/memory/oopFactory.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -69,7 +69,6 @@
                                                     bool is_conc_safe,
                                                     TRAPS);
   static constantPoolCacheOop new_constantPoolCache(int length,
-                                                    bool is_conc_safe,
                                                     TRAPS);
 
   // Instance classes
--- a/hotspot/src/share/vm/oops/arrayKlassKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/arrayKlassKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -128,27 +128,6 @@
   }
   return klassKlass::oop_update_pointers(cm, obj);
 }
-
-int
-arrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                     HeapWord* beg_addr, HeapWord* end_addr) {
-  assert(obj->is_klass(), "must be klass");
-  arrayKlass* ak = arrayKlass::cast(klassOop(obj));
-
-  oop* p;
-  p = ak->adr_component_mirror();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = ak->adr_lower_dimension();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = ak->adr_higher_dimension();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-
-  {
-    HandleMark hm;
-    ak->vtable()->oop_update_pointers(cm, beg_addr, end_addr);
-  }
-  return klassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
-}
 #endif // SERIALGC
 
 // Printing
--- a/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -145,21 +145,6 @@
   PSParallelCompact::adjust_pointer(c->adr_holder_klass());
   return c->object_size();
 }
-
-int compiledICHolderKlass::oop_update_pointers(ParCompactionManager* cm,
-                                               oop obj,
-                                               HeapWord* beg_addr,
-                                               HeapWord* end_addr) {
-  assert(obj->is_compiledICHolder(), "must be compiledICHolder");
-  compiledICHolderOop c = compiledICHolderOop(obj);
-
-  oop* p;
-  p = c->adr_holder_method();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = c->adr_holder_klass();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  return c->object_size();
-}
 #endif // SERIALGC
 
 // Printing
--- a/hotspot/src/share/vm/oops/constMethodKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/constMethodKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -184,21 +184,6 @@
   }
   return cm_oop->object_size();
 }
-
-int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                          HeapWord* beg_addr,
-                                          HeapWord* end_addr) {
-  assert(obj->is_constMethod(), "should be constMethod");
-  constMethodOop cm_oop = constMethodOop(obj);
-
-  oop* const beg_oop = MAX2((oop*)beg_addr, cm_oop->oop_block_beg());
-  oop* const end_oop = MIN2((oop*)end_addr, cm_oop->oop_block_end());
-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
-    PSParallelCompact::adjust_pointer(cur_oop);
-  }
-
-  return cm_oop->object_size();
-}
 #endif // SERIALGC
 
 // Printing
--- a/hotspot/src/share/vm/oops/constantPoolKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/constantPoolKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -55,26 +55,35 @@
 constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) {
   int size = constantPoolOopDesc::object_size(length);
   KlassHandle klass (THREAD, as_klassOop());
-  constantPoolOop c =
-    (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
+  assert(klass()->is_oop(), "Can't be null, else handlizing of c below won't work");
+  constantPoolHandle pool;
+  {
+    constantPoolOop c =
+      (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
+    assert(c->klass_or_null() != NULL, "Handlizing below won't work");
+    pool = constantPoolHandle(THREAD, c);
+  }
 
-  c->set_length(length);
-  c->set_tags(NULL);
-  c->set_cache(NULL);
-  c->set_operands(NULL);
-  c->set_pool_holder(NULL);
-  c->set_flags(0);
+  pool->set_length(length);
+  pool->set_tags(NULL);
+  pool->set_cache(NULL);
+  pool->set_operands(NULL);
+  pool->set_pool_holder(NULL);
+  pool->set_flags(0);
   // only set to non-zero if constant pool is merged by RedefineClasses
-  c->set_orig_length(0);
+  pool->set_orig_length(0);
   // if constant pool may change during RedefineClasses, it is created
   // unsafe for GC concurrent processing.
-  c->set_is_conc_safe(is_conc_safe);
+  pool->set_is_conc_safe(is_conc_safe);
   // all fields are initialized; needed for GC
 
+  // Note: because we may be in this "conc_unsafe" state when allocating
+  // t_oop below, which may in turn cause a GC, it is imperative that our
+  // size be correct, consistent and henceforth stable, at this stage.
+  assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable");
+  assert(size == pool->size(), "size() is wrong");
+
   // initialize tag array
-  // Note: cannot introduce constant pool handle before since it is not
-  //       completely initialized (no class) -> would cause assertion failure
-  constantPoolHandle pool (THREAD, c);
   typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL);
   typeArrayHandle tags (THREAD, t_oop);
   for (int index = 0; index < length; index++) {
@@ -82,6 +91,8 @@
   }
   pool->set_tags(tags());
 
+  // Check that our size was stable at its old value.
+  assert(size == pool->size(), "size() changed");
   return pool();
 }
 
@@ -271,40 +282,6 @@
   return cp->object_size();
 }
 
-int
-constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                       HeapWord* beg_addr, HeapWord* end_addr) {
-  assert (obj->is_constantPool(), "obj must be constant pool");
-  constantPoolOop cp = (constantPoolOop) obj;
-
-  // If the tags array is null we are in the middle of allocating this constant
-  // pool.
-  if (cp->tags() != NULL) {
-    oop* base = (oop*)cp->base();
-    oop* const beg_oop = MAX2((oop*)beg_addr, base);
-    oop* const end_oop = MIN2((oop*)end_addr, base + cp->length());
-    const size_t beg_idx = pointer_delta(beg_oop, base, sizeof(oop*));
-    const size_t end_idx = pointer_delta(end_oop, base, sizeof(oop*));
-    for (size_t cur_idx = beg_idx; cur_idx < end_idx; ++cur_idx, ++base) {
-      if (cp->is_pointer_entry(int(cur_idx))) {
-        PSParallelCompact::adjust_pointer(base);
-      }
-    }
-  }
-
-  oop* p;
-  p = cp->tags_addr();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = cp->cache_addr();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = cp->operands_addr();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = cp->pool_holder_addr();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-
-  return cp->object_size();
-}
-
 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   assert(obj->is_constantPool(), "should be constant pool");
   constantPoolOop cp = (constantPoolOop) obj;
--- a/hotspot/src/share/vm/oops/cpCacheKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/cpCacheKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -49,43 +49,31 @@
 
 
 constantPoolCacheOop constantPoolCacheKlass::allocate(int length,
-                                                      bool is_conc_safe,
                                                       TRAPS) {
   // allocate memory
   int size = constantPoolCacheOopDesc::object_size(length);
 
   KlassHandle klass (THREAD, as_klassOop());
 
-  // This is the original code.  The code from permanent_obj_allocate()
-  // was in-lined to allow the setting of is_conc_safe before the klass
-  // is installed.
+  // Commented out below is the original code.  The code from
+  // permanent_obj_allocate() was in-lined so that we could
+  // set the _length field, necessary to correctly compute its
+  // size(), before setting its klass word further below.
   // constantPoolCacheOop cache = (constantPoolCacheOop)
   //   CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
 
   oop obj = CollectedHeap::permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL);
-  constantPoolCacheOop cache = (constantPoolCacheOop) obj;
-  cache->set_is_conc_safe(is_conc_safe);
-  // The store to is_conc_safe must be visible before the klass
-  // is set.  This should be done safely because _is_conc_safe has
-  // been declared volatile.  If there are any problems, consider adding
-  // OrderAccess::storestore();
-  CollectedHeap::post_allocation_install_obj_klass(klass, obj, size);
   NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value((HeapWord*) obj,
                                                               size));
-
-  // The length field affects the size of the object.  The allocation
-  // above allocates the correct size (see calculation of "size") but
-  // the size() method of the constant pool cache oop will not reflect
-  // that size until the correct length is set.
-  cache->set_length(length);
+  constantPoolCacheOop cache = (constantPoolCacheOop) obj;
+  assert(!UseConcMarkSweepGC || obj->klass_or_null() == NULL,
+         "klass should be NULL here when using CMS");
+  cache->set_length(length);  // should become visible before klass is set below.
+  cache->set_constant_pool(NULL);
 
-  // The store of the length must be visible before is_conc_safe is
-  // set to a safe state.
-  // This should be done safely because _is_conc_safe has
-  // been declared volatile.  If there are any problems, consider adding
-  // OrderAccess::storestore();
-  cache->set_is_conc_safe(methodOopDesc::IsSafeConc);
-  cache->set_constant_pool(NULL);
+  OrderAccess::storestore();
+  obj->set_klass(klass());
+  assert(cache->size() == size, "Incorrect cache->size()");
   return cache;
 }
 
@@ -176,11 +164,6 @@
   return size;
 }
 
-bool constantPoolCacheKlass::oop_is_conc_safe(oop obj) const {
-  assert(obj->is_constantPoolCache(), "should be constant pool");
-  return constantPoolCacheOop(obj)->is_conc_safe();
-}
-
 #ifndef SERIALGC
 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
                                                oop obj) {
@@ -220,25 +203,6 @@
 
   return cache->object_size();
 }
-
-int
-constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                            HeapWord* beg_addr,
-                                            HeapWord* end_addr) {
-  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
-  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
-
-  // Iteration over constant pool cache instance variables
-  oop* p;
-  p = (oop*)cache->constant_pool_addr();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-
-  // Iteration over constant pool cache entries
-  for (int i = 0; i < cache->length(); ++i) {
-    cache->entry_at(i)->update_pointers(beg_addr, end_addr);
-  }
-  return cache->object_size();
-}
 #endif // SERIALGC
 
 void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
--- a/hotspot/src/share/vm/oops/cpCacheKlass.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/cpCacheKlass.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -39,7 +39,7 @@
 
   // Allocation
   DEFINE_ALLOCATE_PERMANENT(constantPoolCacheKlass);
-  constantPoolCacheOop allocate(int length, bool is_conc_safe, TRAPS);
+  constantPoolCacheOop allocate(int length, TRAPS);
   static klassOop create_klass(TRAPS);
 
   // Casting from klassOop
@@ -55,7 +55,6 @@
   // Garbage collection
   void oop_follow_contents(oop obj);
   int oop_adjust_pointers(oop obj);
-  virtual bool oop_is_conc_safe(oop obj) const;
 
   // Parallel Scavenge and Parallel Old
   PARALLEL_GC_DECLS
--- a/hotspot/src/share/vm/oops/cpCacheOop.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -98,15 +98,15 @@
 // Atomically sets f1 if it is still NULL, otherwise it keeps the
 // current value.
 void ConstantPoolCacheEntry::set_f1_if_null_atomic(oop f1) {
-    // Use barriers as in oop_store
-    HeapWord* f1_addr = (HeapWord*) &_f1;
-    update_barrier_set_pre(f1_addr, f1);
-    void* result = Atomic::cmpxchg_ptr(f1, f1_addr, NULL);
-    bool success = (result == NULL);
-    if (success) {
-      update_barrier_set((void*) f1_addr, f1);
-    }
+  // Use barriers as in oop_store
+  oop* f1_addr = (oop*) &_f1;
+  update_barrier_set_pre(f1_addr, f1);
+  void* result = Atomic::cmpxchg_ptr(f1, f1_addr, NULL);
+  bool success = (result == NULL);
+  if (success) {
+    update_barrier_set(f1_addr, f1);
   }
+}
 
 #ifdef ASSERT
 // It is possible to have two different dummy methodOops created
@@ -368,16 +368,6 @@
     PSParallelCompact::adjust_pointer((oop*)&_f2);
   }
 }
-
-void ConstantPoolCacheEntry::update_pointers(HeapWord* beg_addr,
-                                             HeapWord* end_addr) {
-  assert(in_words(size()) == 4, "check code below - may need adjustment");
-  // field[1] is always oop or NULL
-  PSParallelCompact::adjust_pointer((oop*)&_f1, beg_addr, end_addr);
-  if (is_vfinal()) {
-    PSParallelCompact::adjust_pointer((oop*)&_f2, beg_addr, end_addr);
-  }
-}
 #endif // SERIALGC
 
 // RedefineClasses() API support:
--- a/hotspot/src/share/vm/oops/cpCacheOop.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/cpCacheOop.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -287,7 +287,6 @@
 #endif // SERIALGC
 
   void update_pointers();
-  void update_pointers(HeapWord* beg_addr, HeapWord* end_addr);
 
   // RedefineClasses() API support:
   // If this constantPoolCacheEntry refers to old_method then update it
@@ -321,9 +320,6 @@
  private:
   int             _length;
   constantPoolOop _constant_pool;                // the corresponding constant pool
-  // If true, safe for concurrent GC processing,
-  // Set unconditionally in constantPoolCacheKlass::allocate()
-  volatile bool        _is_conc_safe;
 
   // Sizing
   debug_only(friend class ClassVerifier;)
@@ -390,12 +386,6 @@
     return entry_at(primary_index);
   }
 
-  // GC support
-  // If the _length field has not been set, the size of the
-  // constantPoolCache cannot be correctly calculated.
-  bool is_conc_safe()                            { return _is_conc_safe; }
-  void set_is_conc_safe(bool v)                  { _is_conc_safe = v; }
-
   // Code generation
   static ByteSize base_offset()                  { return in_ByteSize(sizeof(constantPoolCacheOopDesc)); }
   static ByteSize entry_offset(int raw_index) {
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -1736,14 +1736,6 @@
     PSParallelCompact::adjust_pointer(p), \
     assert_nothing)
 }
-
-void instanceKlass::update_static_fields(HeapWord* beg_addr, HeapWord* end_addr) {
-  InstanceKlass_BOUNDED_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    beg_addr, end_addr, \
-    PSParallelCompact::adjust_pointer(p), \
-    assert_nothing )
-}
 #endif // SERIALGC
 
 void instanceKlass::oop_follow_contents(oop obj) {
@@ -1876,15 +1868,6 @@
   return size_helper();
 }
 
-int instanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                       HeapWord* beg_addr, HeapWord* end_addr) {
-  InstanceKlass_BOUNDED_OOP_MAP_ITERATE( \
-    obj, beg_addr, end_addr, \
-    PSParallelCompact::adjust_pointer(p), \
-    assert_nothing)
-  return size_helper();
-}
-
 void instanceKlass::push_static_fields(PSPromotionManager* pm) {
   InstanceKlass_OOP_ITERATE( \
     start_of_static_fields(), static_oop_field_size(), \
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -740,7 +740,6 @@
   void follow_static_fields(ParCompactionManager* cm);
   void copy_static_fields(ParCompactionManager* cm);
   void update_static_fields();
-  void update_static_fields(HeapWord* beg_addr, HeapWord* end_addr);
 #endif // SERIALGC
 
   // Naming
--- a/hotspot/src/share/vm/oops/instanceKlassKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlassKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -353,35 +353,6 @@
   return ik->object_size();
 }
 
-int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                            HeapWord* beg_addr,
-                                            HeapWord* end_addr) {
-  assert(obj->is_klass(),"must be a klass");
-  assert(klassOop(obj)->klass_part()->oop_is_instance_slow(),
-         "must be instance klass");
-
-  instanceKlass* ik = instanceKlass::cast(klassOop(obj));
-  ik->update_static_fields(beg_addr, end_addr);
-  ik->vtable()->oop_update_pointers(cm, beg_addr, end_addr);
-  ik->itable()->oop_update_pointers(cm, beg_addr, end_addr);
-
-  oop* const beg_oop = MAX2((oop*)beg_addr, ik->oop_block_beg());
-  oop* const end_oop = MIN2((oop*)end_addr, ik->oop_block_end());
-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
-    PSParallelCompact::adjust_pointer(cur_oop);
-  }
-
-  // The oop_map_cache, jni_ids and jni_id_map are allocated from the C heap,
-  // and so don't lie within any 'Chunk' boundaries.  Update them when the
-  // lowest addressed oop in the instanceKlass 'oop_block' is updated.
-  if (beg_oop == ik->oop_block_beg()) {
-    OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure();
-    iterate_c_heap_oops(ik, closure);
-  }
-
-  klassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
-  return ik->object_size();
-}
 #endif // SERIALGC
 
 klassOop
--- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -344,33 +344,6 @@
   }
   return size_helper();
 }
-
-
-template <class T> void
-specialized_oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                HeapWord* beg_addr, HeapWord* end_addr) {
-  T* p;
-  T* referent_addr = p = (T*)java_lang_ref_Reference::referent_addr(obj);
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  T* next_addr = p = (T*)java_lang_ref_Reference::next_addr(obj);
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  T* discovered_addr = p = (T*)java_lang_ref_Reference::discovered_addr(obj);
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  debug_only(trace_reference_gc("instanceRefKlass::oop_update_ptrs", obj,
-                                referent_addr, next_addr, discovered_addr);)
-}
-
-int
-instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                      HeapWord* beg_addr, HeapWord* end_addr) {
-  instanceKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
-  if (UseCompressedOops) {
-    specialized_oop_update_pointers<narrowOop>(cm, obj, beg_addr, end_addr);
-  } else {
-    specialized_oop_update_pointers<oop>(cm, obj, beg_addr, end_addr);
-  }
-  return size_helper();
-}
 #endif // SERIALGC
 
 void instanceRefKlass::update_nonstatic_oop_maps(klassOop k) {
--- a/hotspot/src/share/vm/oops/klassKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/klassKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -188,19 +188,6 @@
 
   return oop_size(obj);
 }
-
-int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                    HeapWord* beg_addr, HeapWord* end_addr) {
-  Klass* k = Klass::cast(klassOop(obj));
-
-  oop* const beg_oop = MAX2((oop*)beg_addr, k->oop_block_beg());
-  oop* const end_oop = MIN2((oop*)end_addr, k->oop_block_end());
-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
-    PSParallelCompact::adjust_pointer(cur_oop);
-  }
-
-  return oop_size(obj);
-}
 #endif // SERIALGC
 
 
--- a/hotspot/src/share/vm/oops/klassPS.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/klassPS.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -37,17 +37,13 @@
    objects that do (or may) cross chunk boundaries; it updates only those   \
    oops that are in the region [beg_addr, end_addr).  */                    \
   virtual void oop_follow_contents(ParCompactionManager* cm, oop obj);      \
-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj);      \
-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj,       \
-                                   HeapWord* beg_addr, HeapWord* end_addr);
+  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj);
 
 // Pure virtual version for klass.hpp
 #define PARALLEL_GC_DECLS_PV \
   virtual void oop_push_contents(PSPromotionManager* pm, oop obj) = 0;      \
   virtual void oop_follow_contents(ParCompactionManager* cm, oop obj) = 0;  \
-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj) = 0;  \
-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj,       \
-                                   HeapWord* beg_addr, HeapWord* end_addr) = 0;
+  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj) = 0;
 #else  // SERIALGC
 #define PARALLEL_GC_DECLS
 #define PARALLEL_GC_DECLS_PV
--- a/hotspot/src/share/vm/oops/klassVtable.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -677,25 +677,6 @@
     PSParallelCompact::adjust_pointer(adr_method_at(i));
   }
 }
-
-void klassVtable::oop_update_pointers(ParCompactionManager* cm,
-                                      HeapWord* beg_addr, HeapWord* end_addr) {
-  const int n = length();
-  const int entry_size = vtableEntry::size();
-
-  int beg_idx = 0;
-  HeapWord* const method_0 = (HeapWord*)adr_method_at(0);
-  if (beg_addr > method_0) {
-    // it's safe to use cast, as we have guarantees on vtable size to be sane
-    beg_idx = int((pointer_delta(beg_addr, method_0) + entry_size - 1) / entry_size);
-  }
-
-  oop* const beg_oop = adr_method_at(beg_idx);
-  oop* const end_oop = MIN2((oop*)end_addr, adr_method_at(n));
-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; cur_oop += entry_size) {
-    PSParallelCompact::adjust_pointer(cur_oop);
-  }
-}
 #endif // SERIALGC
 
 // Iterators
@@ -820,25 +801,6 @@
     ime++;
   }
 }
-
-void klassItable::oop_update_pointers(ParCompactionManager* cm,
-                                      HeapWord* beg_addr, HeapWord* end_addr) {
-  // offset table
-  itableOffsetEntry* ioe = offset_entry(0);
-  for(int i = 0; i < _size_offset_table; i++) {
-    oop* p = (oop*)&ioe->_interface;
-    PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-    ioe++;
-  }
-
-  // method table
-  itableMethodEntry* ime = method_entry(0);
-  for(int j = 0; j < _size_method_table; j++) {
-    oop* p = (oop*)&ime->_method;
-    PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-    ime++;
-  }
-}
 #endif // SERIALGC
 
 // Iterators
--- a/hotspot/src/share/vm/oops/klassVtable.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/klassVtable.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -99,8 +99,6 @@
   // Parallel Old
   void oop_follow_contents(ParCompactionManager* cm);
   void oop_update_pointers(ParCompactionManager* cm);
-  void oop_update_pointers(ParCompactionManager* cm,
-                           HeapWord* beg_addr, HeapWord* end_addr);
 #endif // SERIALGC
 
   // Iterators
@@ -295,8 +293,6 @@
   // Parallel Old
   void oop_follow_contents(ParCompactionManager* cm);
   void oop_update_pointers(ParCompactionManager* cm);
-  void oop_update_pointers(ParCompactionManager* cm,
-                           HeapWord* beg_addr, HeapWord* end_addr);
 #endif // SERIALGC
 
   // Iterators
--- a/hotspot/src/share/vm/oops/methodDataKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/methodDataKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -188,25 +188,6 @@
   }
   return m->object_size();
 }
-
-int
-methodDataKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                     HeapWord* beg_addr, HeapWord* end_addr) {
-  assert(obj->is_methodData(), "should be method data");
-
-  oop* p;
-  methodDataOop m = methodDataOop(obj);
-
-  p = m->adr_method();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-
-  ResourceMark rm;
-  ProfileData* data;
-  for (data = m->first_data(); m->is_valid(data); data = m->next_data(data)) {
-    data->update_pointers(beg_addr, end_addr);
-  }
-  return m->object_size();
-}
 #endif // SERIALGC
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/oops/methodDataOop.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/methodDataOop.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -271,17 +271,6 @@
     }
   }
 }
-
-void ReceiverTypeData::update_pointers(HeapWord* beg_addr, HeapWord* end_addr) {
-  // The loop bounds could be computed based on beg_addr/end_addr and the
-  // boundary test hoisted outside the loop (see klassVTable for an example);
-  // however, row_limit() is small enough (2) to make that less efficient.
-  for (uint row = 0; row < row_limit(); row++) {
-    if (receiver_unchecked(row) != NULL) {
-      PSParallelCompact::adjust_pointer(adr_receiver(row), beg_addr, end_addr);
-    }
-  }
-}
 #endif // SERIALGC
 
 #ifndef PRODUCT
@@ -764,11 +753,13 @@
   if (TieredCompilation) {
     _invocation_counter.init();
     _backedge_counter.init();
+    _invocation_counter_start = 0;
+    _backedge_counter_start = 0;
     _num_loops = 0;
     _num_blocks = 0;
     _highest_comp_level = 0;
     _highest_osr_comp_level = 0;
-    _would_profile = false;
+    _would_profile = true;
   }
   set_creation_mileage(mileage_of(method()));
 
--- a/hotspot/src/share/vm/oops/methodDataOop.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/methodDataOop.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -452,7 +452,6 @@
   // Parallel old support
   virtual void follow_contents(ParCompactionManager* cm) {}
   virtual void update_pointers() {}
-  virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr) {}
 #endif // SERIALGC
 
   // CI translation: ProfileData can represent both MethodDataOop data
@@ -748,7 +747,6 @@
   // Parallel old support
   virtual void follow_contents(ParCompactionManager* cm);
   virtual void update_pointers();
-  virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr);
 #endif // SERIALGC
 
   oop* adr_receiver(uint row) {
@@ -1224,6 +1222,9 @@
   InvocationCounter _invocation_counter;
   // Same for backedges.
   InvocationCounter _backedge_counter;
+  // Counter values at the time profiling started.
+  int               _invocation_counter_start;
+  int               _backedge_counter_start;
   // Number of loops and blocks is computed when compiling the first
   // time with C1. It is used to determine if method is trivial.
   short             _num_loops;
@@ -1333,6 +1334,28 @@
     return backedge_counter()->count();
   }
 
+  int invocation_count_start() {
+    if (invocation_counter()->carry()) {
+      return 0;
+    }
+    return _invocation_counter_start;
+  }
+
+  int backedge_count_start() {
+    if (backedge_counter()->carry()) {
+      return 0;
+    }
+    return _backedge_counter_start;
+  }
+
+  int invocation_count_delta() { return invocation_count() - invocation_count_start(); }
+  int backedge_count_delta()   { return backedge_count()   - backedge_count_start();   }
+
+  void reset_start_counters() {
+    _invocation_counter_start = invocation_count();
+    _backedge_counter_start = backedge_count();
+  }
+
   InvocationCounter* invocation_counter()     { return &_invocation_counter; }
   InvocationCounter* backedge_counter()       { return &_backedge_counter;   }
 
--- a/hotspot/src/share/vm/oops/methodKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/methodKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -214,27 +214,6 @@
 #endif // COMPILER2
   return m->object_size();
 }
-
-int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                     HeapWord* beg_addr, HeapWord* end_addr) {
-  assert(obj->is_method(), "should be method");
-
-  oop* p;
-  methodOop m = methodOop(obj);
-
-  p = m->adr_constMethod();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = m->adr_constants();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-
-#ifdef COMPILER2
-  if (m->method_data() != NULL) {
-    p = m->adr_method_data();
-    PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  }
-#endif // COMPILER2
-  return m->object_size();
-}
 #endif // SERIALGC
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/oops/methodOop.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/methodOop.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -934,7 +934,7 @@
   assert(m->signature() == signature, "");
   assert(m->is_method_handle_invoke(), "");
 #ifdef CC_INTERP
-  ResultTypeFinder rtf(signature());
+  ResultTypeFinder rtf(signature);
   m->set_result_index(rtf.type());
 #endif
   m->compute_size_of_parameters(THREAD);
@@ -985,9 +985,11 @@
                                               IsUnsafeConc,
                                               CHECK_(methodHandle()));
   methodHandle newm (THREAD, newm_oop);
+  NOT_PRODUCT(int nmsz = newm->is_parsable() ? newm->size() : -1;)
   int new_method_size = newm->method_size();
   // Create a shallow copy of methodOopDesc part, but be careful to preserve the new constMethodOop
   constMethodOop newcm = newm->constMethod();
+  NOT_PRODUCT(int ncmsz = newcm->is_parsable() ? newcm->size() : -1;)
   int new_const_method_size = newm->constMethod()->object_size();
 
   memcpy(newm(), m(), sizeof(methodOopDesc));
@@ -999,9 +1001,19 @@
   // or concurrent marking but those phases will be correct.  Setting and
   // resetting is done in preference to a careful copying into newcm to
   // avoid having to know the precise layout of a constMethodOop.
-  m->constMethod()->set_is_conc_safe(false);
+  m->constMethod()->set_is_conc_safe(oopDesc::IsUnsafeConc);
+  assert(m->constMethod()->is_parsable(), "Should remain parsable");
+
+  // NOTE: this is a reachable object that transiently signals "conc_unsafe"
+  // However, no allocations are done during this window
+  // during which it is tagged conc_unsafe, so we are assured that any concurrent
+  // thread will not wait forever for the object to revert to "conc_safe".
+  // Further, any such conc_unsafe object will indicate a stable size
+  // through the transition.
   memcpy(newcm, m->constMethod(), sizeof(constMethodOopDesc));
-  m->constMethod()->set_is_conc_safe(true);
+  m->constMethod()->set_is_conc_safe(oopDesc::IsSafeConc);
+  assert(m->constMethod()->is_parsable(), "Should remain parsable");
+
   // Reset correct method/const method, method size, and parameter info
   newcm->set_method(newm());
   newm->set_constMethod(newcm);
@@ -1035,6 +1047,8 @@
 
   // Only set is_conc_safe to true when changes to newcm are
   // complete.
+  assert(!newm->is_parsable()  || nmsz  < 0 || newm->size()  == nmsz,  "newm->size()  inconsistency");
+  assert(!newcm->is_parsable() || ncmsz < 0 || newcm->size() == ncmsz, "newcm->size() inconsistency");
   newcm->set_is_conc_safe(true);
   return newm;
 }
@@ -1372,7 +1386,7 @@
 }
 
 // See comment in methodOop.hpp which explains why this exists.
-#if defined(_M_AMD64) && MSC_VER >= 1400
+#if defined(_M_AMD64) && _MSC_VER >= 1400
 #pragma optimize("", off)
 void CompressedLineNumberWriteStream::write_pair(int bci, int line) {
   write_pair_inline(bci, line);
--- a/hotspot/src/share/vm/oops/methodOop.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/methodOop.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -144,9 +144,6 @@
 
  public:
 
-  static const bool IsUnsafeConc         = false;
-  static const bool IsSafeConc           = true;
-
   // accessors for instance variables
   constMethodOop constMethod() const             { return _constMethod; }
   void set_constMethod(constMethodOop xconst)    { oop_store_without_check((oop*)&_constMethod, (oop)xconst); }
@@ -732,8 +729,8 @@
 // Disabling optimization doesn't work for methods in header files
 // so we force it to call through the non-optimized version in the .cpp.
 // It's gross, but it's the only way we can ensure that all callers are
-// fixed.  MSC_VER is defined in build/windows/makefiles/compile.make.
-#if defined(_M_AMD64) && MSC_VER >= 1400
+// fixed.  _MSC_VER is defined by the windows compiler
+#if defined(_M_AMD64) && _MSC_VER >= 1400
   void write_pair(int bci, int line);
 #else
   void write_pair(int bci, int line) { write_pair_inline(bci, line); }
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -470,16 +470,6 @@
   ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p))
   return a->object_size();
 }
-
-int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                       HeapWord* beg_addr, HeapWord* end_addr) {
-  assert (obj->is_objArray(), "obj must be obj array");
-  objArrayOop a = objArrayOop(obj);
-  ObjArrayKlass_BOUNDED_OOP_ITERATE( \
-     a, p, beg_addr, end_addr, \
-     PSParallelCompact::adjust_pointer(p))
-  return a->object_size();
-}
 #endif // SERIALGC
 
 // JVM support
--- a/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -254,22 +254,6 @@
 
   return arrayKlassKlass::oop_update_pointers(cm, obj);
 }
-
-int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                            HeapWord* beg_addr,
-                                            HeapWord* end_addr) {
-  assert(obj->is_klass(), "must be klass");
-  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
-
-  oop* p;
-  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
-  p = oak->element_klass_addr();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-  p = oak->bottom_klass_addr();
-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
-
-  return arrayKlassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
-}
 #endif // SERIALGC
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/oops/oop.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/oop.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -71,6 +71,11 @@
   static BarrierSet* _bs;
 
  public:
+  enum ConcSafeType {
+    IsUnsafeConc = false,
+    IsSafeConc   = true
+  };
+
   markOop  mark() const         { return _mark; }
   markOop* mark_addr() const    { return (markOop*) &_mark; }
 
@@ -317,13 +322,6 @@
 
   // Parallel Old
   void update_contents(ParCompactionManager* cm);
-  void update_contents(ParCompactionManager* cm,
-                       HeapWord* begin_limit,
-                       HeapWord* end_limit);
-  void update_contents(ParCompactionManager* cm,
-                       klassOop old_klass,
-                       HeapWord* begin_limit,
-                       HeapWord* end_limit);
 
   void follow_contents(ParCompactionManager* cm);
   void follow_header(ParCompactionManager* cm);
@@ -364,7 +362,6 @@
 #ifndef SERIALGC
   // Parallel old
   void update_header();
-  void update_header(HeapWord* beg_addr, HeapWord* end_addr);
 #endif // SERIALGC
 
   // mark-sweep support
--- a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,41 +57,6 @@
   // Else skip it.  The typeArrayKlass in the header never needs scavenging.
 }
 
-inline void oopDesc::update_contents(ParCompactionManager* cm,
-                                     HeapWord* begin_limit,
-                                     HeapWord* end_limit) {
-  // The klass field must be updated before anything else
-  // can be done.
-  debug_only(klassOopDesc* original_klass = klass());
-
-  update_contents(cm, klass(), begin_limit, end_limit);
-}
-
-inline void oopDesc::update_contents(ParCompactionManager* cm,
-                                     klassOop old_klass,
-                                     HeapWord* begin_limit,
-                                     HeapWord* end_limit) {
-
-  klassOop updated_klass =
-    PSParallelCompact::summary_data().calc_new_klass(old_klass);
-
-  // Needs to be boundary aware for the 64 bit case
-  // update_header();
-  // The klass has moved.  Is the location of the klass
-  // within the limits?
-  if ((((HeapWord*)&_metadata._klass) >= begin_limit) &&
-      (((HeapWord*)&_metadata._klass) < end_limit)) {
-    set_klass(updated_klass);
-  }
-
-  Klass* klass = updated_klass->klass_part();
-  if (!klass->oop_is_typeArray()) {
-    // It might contain oops beyond the header, so take the virtual call.
-    klass->oop_update_pointers(cm, this, begin_limit, end_limit);
-  }
-  // Else skip it.  The typeArrayKlass in the header never needs scavenging.
-}
-
 inline void oopDesc::follow_contents(ParCompactionManager* cm) {
   assert (PSParallelCompact::mark_bitmap()->is_marked(this),
     "should be marked");
@@ -140,13 +105,4 @@
   }
 }
 
-inline void oopDesc::update_header(HeapWord* beg_addr, HeapWord* end_addr) {
-  if (UseCompressedOops) {
-    PSParallelCompact::adjust_pointer(compressed_klass_addr(),
-                                      beg_addr, end_addr);
-  } else {
-    PSParallelCompact::adjust_pointer(klass_addr(), beg_addr, end_addr);
-  }
-}
-
 #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP
--- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -250,13 +250,6 @@
   assert(obj->is_typeArray(),"must be a type array");
   return typeArrayOop(obj)->object_size();
 }
-
-int
-typeArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
-                                    HeapWord* beg_addr, HeapWord* end_addr) {
-  assert(obj->is_typeArray(),"must be a type array");
-  return typeArrayOop(obj)->object_size();
-}
 #endif // SERIALGC
 
 void typeArrayKlass::initialize(TRAPS) {
--- a/hotspot/src/share/vm/opto/escape.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/escape.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -93,6 +93,9 @@
 ConnectionGraph::ConnectionGraph(Compile * C, PhaseIterGVN *igvn) :
   _nodes(C->comp_arena(), C->unique(), C->unique(), PointsToNode()),
   _processed(C->comp_arena()),
+  pt_ptset(C->comp_arena()),
+  pt_visited(C->comp_arena()),
+  pt_worklist(C->comp_arena(), 4, 0, 0),
   _collecting(true),
   _progress(false),
   _compile(C),
@@ -220,9 +223,7 @@
   PointsToNode::EscapeState orig_es = es;
 
   // compute max escape state of anything this node could point to
-  VectorSet ptset(Thread::current()->resource_area());
-  PointsTo(ptset, n);
-  for(VectorSetI i(&ptset); i.test() && es != PointsToNode::GlobalEscape; ++i) {
+  for(VectorSetI i(PointsTo(n)); i.test() && es != PointsToNode::GlobalEscape; ++i) {
     uint pt = i.elem;
     PointsToNode::EscapeState pes = ptnode_adr(pt)->escape_state();
     if (pes > es)
@@ -236,9 +237,10 @@
   return es;
 }
 
-void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n) {
-  VectorSet visited(Thread::current()->resource_area());
-  GrowableArray<uint>  worklist;
+VectorSet* ConnectionGraph::PointsTo(Node * n) {
+  pt_ptset.Reset();
+  pt_visited.Reset();
+  pt_worklist.clear();
 
 #ifdef ASSERT
   Node *orig_n = n;
@@ -249,8 +251,8 @@
 
   // If we have a JavaObject, return just that object
   if (npt->node_type() == PointsToNode::JavaObject) {
-    ptset.set(n->_idx);
-    return;
+    pt_ptset.set(n->_idx);
+    return &pt_ptset;
   }
 #ifdef ASSERT
   if (npt->_node == NULL) {
@@ -260,10 +262,10 @@
     assert(npt->_node != NULL, "unregistered node");
   }
 #endif
-  worklist.push(n->_idx);
-  while(worklist.length() > 0) {
-    int ni = worklist.pop();
-    if (visited.test_set(ni))
+  pt_worklist.push(n->_idx);
+  while(pt_worklist.length() > 0) {
+    int ni = pt_worklist.pop();
+    if (pt_visited.test_set(ni))
       continue;
 
     PointsToNode* pn = ptnode_adr(ni);
@@ -276,10 +278,10 @@
       uint etgt = pn->edge_target(e);
       PointsToNode::EdgeType et = pn->edge_type(e);
       if (et == PointsToNode::PointsToEdge) {
-        ptset.set(etgt);
+        pt_ptset.set(etgt);
         edges_processed++;
       } else if (et == PointsToNode::DeferredEdge) {
-        worklist.push(etgt);
+        pt_worklist.push(etgt);
         edges_processed++;
       } else {
         assert(false,"neither PointsToEdge or DeferredEdge");
@@ -288,16 +290,17 @@
     if (edges_processed == 0) {
       // no deferred or pointsto edges found.  Assume the value was set
       // outside this method.  Add the phantom object to the pointsto set.
-      ptset.set(_phantom_object);
+      pt_ptset.set(_phantom_object);
     }
   }
+  return &pt_ptset;
 }
 
 void ConnectionGraph::remove_deferred(uint ni, GrowableArray<uint>* deferred_edges, VectorSet* visited) {
   // This method is most expensive during ConnectionGraph construction.
   // Reuse vectorSet and an additional growable array for deferred edges.
   deferred_edges->clear();
-  visited->Clear();
+  visited->Reset();
 
   visited->set(ni);
   PointsToNode *ptn = ptnode_adr(ni);
@@ -1009,7 +1012,6 @@
   uint new_index_start = (uint) _compile->num_alias_types();
   Arena* arena = Thread::current()->resource_area();
   VectorSet visited(arena);
-  VectorSet ptset(arena);
 
 
   //  Phase 1:  Process possible allocations from alloc_worklist.
@@ -1137,10 +1139,9 @@
         }
       }
     } else if (n->is_AddP()) {
-      ptset.Clear();
-      PointsTo(ptset, get_addp_base(n));
-      assert(ptset.Size() == 1, "AddP address is unique");
-      uint elem = ptset.getelem(); // Allocation node's index
+      VectorSet* ptset = PointsTo(get_addp_base(n));
+      assert(ptset->Size() == 1, "AddP address is unique");
+      uint elem = ptset->getelem(); // Allocation node's index
       if (elem == _phantom_object) {
         assert(false, "escaped allocation");
         continue; // Assume the value was set outside this method.
@@ -1157,10 +1158,9 @@
         assert(n->is_Phi(), "loops only through Phi's");
         continue;  // already processed
       }
-      ptset.Clear();
-      PointsTo(ptset, n);
-      if (ptset.Size() == 1) {
-        uint elem = ptset.getelem(); // Allocation node's index
+      VectorSet* ptset = PointsTo(n);
+      if (ptset->Size() == 1) {
+        uint elem = ptset->getelem(); // Allocation node's index
         if (elem == _phantom_object) {
           assert(false, "escaped allocation");
           continue; // Assume the value was set outside this method.
@@ -1434,7 +1434,7 @@
   // Update the memory inputs of MemNodes with the value we computed
   // in Phase 2 and move stores memory users to corresponding memory slices.
 #ifdef ASSERT
-  visited.Clear();
+  visited.Reset();
   Node_Stack old_mems(arena, _compile->unique() >> 2);
 #endif
   for (uint i = 0; i < nodes_size(); i++) {
@@ -1640,7 +1640,6 @@
 #undef CG_BUILD_ITER_LIMIT
 
   Arena* arena = Thread::current()->resource_area();
-  VectorSet ptset(arena);
   VectorSet visited(arena);
   worklist.clear();
 
@@ -1657,7 +1656,7 @@
       if (n->is_AddP()) {
         // Search for objects which are not scalar replaceable
         // and adjust their escape state.
-        verify_escape_state(ni, ptset, igvn);
+        adjust_escape_state(ni, igvn);
       }
     }
   }
@@ -1776,8 +1775,8 @@
   return has_non_escaping_obj;
 }
 
-// Search for objects which are not scalar replaceable.
-void ConnectionGraph::verify_escape_state(int nidx, VectorSet& ptset, PhaseTransform* phase) {
+// Adjust escape state after Connection Graph is built.
+void ConnectionGraph::adjust_escape_state(int nidx, PhaseTransform* phase) {
   PointsToNode* ptn = ptnode_adr(nidx);
   Node* n = ptn->_node;
   assert(n->is_AddP(), "Should be called for AddP nodes only");
@@ -1792,9 +1791,8 @@
 
   int offset = ptn->offset();
   Node* base = get_addp_base(n);
-  ptset.Clear();
-  PointsTo(ptset, base);
-  int ptset_size = ptset.Size();
+  VectorSet* ptset = PointsTo(base);
+  int ptset_size = ptset->Size();
 
   // Check if a oop field's initializing value is recorded and add
   // a corresponding NULL field's value if it is not recorded.
@@ -1814,7 +1812,7 @@
   // Do a simple control flow analysis to distinguish above cases.
   //
   if (offset != Type::OffsetBot && ptset_size == 1) {
-    uint elem = ptset.getelem(); // Allocation node's index
+    uint elem = ptset->getelem(); // Allocation node's index
     // It does not matter if it is not Allocation node since
     // only non-escaping allocations are scalar replaced.
     if (ptnode_adr(elem)->_node->is_Allocate() &&
@@ -1913,7 +1911,7 @@
   //
   if (ptset_size > 1 || ptset_size != 0 &&
       (has_LoadStore || offset == Type::OffsetBot)) {
-    for( VectorSetI j(&ptset); j.test(); ++j ) {
+    for( VectorSetI j(ptset); j.test(); ++j ) {
       set_escape_state(j.elem, PointsToNode::ArgEscape);
       ptnode_adr(j.elem)->_scalar_replaceable = false;
     }
@@ -1937,7 +1935,6 @@
       // Stub calls, objects do not escape but they are not scale replaceable.
       // Adjust escape state for outgoing arguments.
       const TypeTuple * d = call->tf()->domain();
-      VectorSet ptset(Thread::current()->resource_area());
       for (uint i = TypeFunc::Parms; i < d->cnt(); i++) {
         const Type* at = d->field_at(i);
         Node *arg = call->in(i)->uncast();
@@ -1970,9 +1967,7 @@
             //
             arg = get_addp_base(arg);
           }
-          ptset.Clear();
-          PointsTo(ptset, arg);
-          for( VectorSetI j(&ptset); j.test(); ++j ) {
+          for( VectorSetI j(PointsTo(arg)); j.test(); ++j ) {
             uint pt = j.elem;
             set_escape_state(pt, PointsToNode::ArgEscape);
           }
@@ -1990,7 +1985,6 @@
       // fall-through if not a Java method or no analyzer information
       if (call_analyzer != NULL) {
         const TypeTuple * d = call->tf()->domain();
-        VectorSet ptset(Thread::current()->resource_area());
         bool copy_dependencies = false;
         for (uint i = TypeFunc::Parms; i < d->cnt(); i++) {
           const Type* at = d->field_at(i);
@@ -2015,9 +2009,7 @@
               copy_dependencies = true;
             }
 
-            ptset.Clear();
-            PointsTo(ptset, arg);
-            for( VectorSetI j(&ptset); j.test(); ++j ) {
+            for( VectorSetI j(PointsTo(arg)); j.test(); ++j ) {
               uint pt = j.elem;
               if (global_escapes) {
                 //The argument global escapes, mark everything it could point to
@@ -2045,15 +2037,12 @@
     {
       // adjust escape state for  outgoing arguments
       const TypeTuple * d = call->tf()->domain();
-      VectorSet ptset(Thread::current()->resource_area());
       for (uint i = TypeFunc::Parms; i < d->cnt(); i++) {
         const Type* at = d->field_at(i);
         if (at->isa_oopptr() != NULL) {
           Node *arg = call->in(i)->uncast();
           set_escape_state(arg->_idx, PointsToNode::GlobalEscape);
-          ptset.Clear();
-          PointsTo(ptset, arg);
-          for( VectorSetI j(&ptset); j.test(); ++j ) {
+          for( VectorSetI j(PointsTo(arg)); j.test(); ++j ) {
             uint pt = j.elem;
             set_escape_state(pt, PointsToNode::GlobalEscape);
           }
@@ -2515,9 +2504,7 @@
     {
       Node *base = get_addp_base(n);
       // Create a field edge to this node from everything base could point to.
-      VectorSet ptset(Thread::current()->resource_area());
-      PointsTo(ptset, base);
-      for( VectorSetI i(&ptset); i.test(); ++i ) {
+      for( VectorSetI i(PointsTo(base)); i.test(); ++i ) {
         uint pt = i.elem;
         add_field_edge(pt, n_idx, address_offset(n, phase));
       }
@@ -2583,10 +2570,8 @@
 
       // For everything "adr_base" could point to, create a deferred edge from
       // this node to each field with the same offset.
-      VectorSet ptset(Thread::current()->resource_area());
-      PointsTo(ptset, adr_base);
       int offset = address_offset(adr, phase);
-      for( VectorSetI i(&ptset); i.test(); ++i ) {
+      for( VectorSetI i(PointsTo(adr_base)); i.test(); ++i ) {
         uint pt = i.elem;
         add_deferred_edge_to_fields(n_idx, pt, offset);
       }
@@ -2676,9 +2661,7 @@
       Node *val = n->in(MemNode::ValueIn)->uncast();
       // For everything "adr_base" could point to, create a deferred edge
       // to "val" from each field with the same offset.
-      VectorSet ptset(Thread::current()->resource_area());
-      PointsTo(ptset, adr_base);
-      for( VectorSetI i(&ptset); i.test(); ++i ) {
+      for( VectorSetI i(PointsTo(adr_base)); i.test(); ++i ) {
         uint pt = i.elem;
         add_edge_from_fields(pt, val->_idx, address_offset(adr, phase));
       }
--- a/hotspot/src/share/vm/opto/escape.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/escape.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -268,7 +268,12 @@
   // walk the connection graph starting at the node corresponding to "n" and
   // add the index of everything it could point to, to "ptset".  This may cause
   // Phi's encountered to get (re)processed  (which requires "phase".)
-  void PointsTo(VectorSet &ptset, Node * n);
+  VectorSet* PointsTo(Node * n);
+
+  // Reused structures for PointsTo().
+  VectorSet            pt_ptset;
+  VectorSet            pt_visited;
+  GrowableArray<uint>  pt_worklist;
 
   //  Edge manipulation.  The "from_i" and "to_i" arguments are the
   //  node indices of the source and destination of the edge
@@ -334,8 +339,11 @@
   // Set the escape state of a node
   void set_escape_state(uint ni, PointsToNode::EscapeState es);
 
-  // Search for objects which are not scalar replaceable.
-  void verify_escape_state(int nidx, VectorSet& ptset, PhaseTransform* phase);
+  // Adjust escape state after Connection Graph is built.
+  void adjust_escape_state(int nidx, PhaseTransform* phase);
+
+  // Compute the escape information
+  bool compute_escape();
 
 public:
   ConnectionGraph(Compile *C, PhaseIterGVN *igvn);
@@ -346,9 +354,6 @@
   // Perform escape analysis
   static void do_analysis(Compile *C, PhaseIterGVN *igvn);
 
-  // Compute the escape information
-  bool compute_escape();
-
   // escape state of a node
   PointsToNode::EscapeState escape_state(Node *n);
 
--- a/hotspot/src/share/vm/opto/indexSet.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/indexSet.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,12 +39,12 @@
 
 #ifdef ASSERT
 // Initialize statistics counters
-uint IndexSet::_alloc_new = 0;
-uint IndexSet::_alloc_total = 0;
+julong IndexSet::_alloc_new = 0;
+julong IndexSet::_alloc_total = 0;
 
-long IndexSet::_total_bits = 0;
-long IndexSet::_total_used_blocks = 0;
-long IndexSet::_total_unused_blocks = 0;
+julong IndexSet::_total_bits = 0;
+julong IndexSet::_total_used_blocks = 0;
+julong IndexSet::_total_unused_blocks = 0;
 
 // Per set, or all sets operation tracing
 int IndexSet::_serial_count = 1;
@@ -141,7 +141,7 @@
 
 #ifdef ASSERT
   if (CollectIndexSetStatistics) {
-    _alloc_new += bitblock_alloc_chunk_size;
+    inc_stat_counter(&_alloc_new, bitblock_alloc_chunk_size);
   }
 #endif
 }
@@ -154,7 +154,7 @@
 IndexSet::BitBlock *IndexSet::alloc_block() {
 #ifdef ASSERT
   if (CollectIndexSetStatistics) {
-    _alloc_total++;
+    inc_stat_counter(&_alloc_total, 1);
   }
 #endif
   Compile *compile = Compile::current();
@@ -391,13 +391,13 @@
 // Update block/bit counts to reflect that this set has been iterated over.
 
 void IndexSet::tally_iteration_statistics() const {
-  _total_bits += count();
+  inc_stat_counter(&_total_bits, count());
 
   for (uint i = 0; i < _max_blocks; i++) {
     if (_blocks[i] != &_empty_block) {
-      _total_used_blocks++;
+      inc_stat_counter(&_total_used_blocks, 1);
     } else {
-      _total_unused_blocks++;
+      inc_stat_counter(&_total_unused_blocks, 1);
     }
   }
 }
@@ -406,17 +406,17 @@
 // Print statistics about IndexSet usage.
 
 void IndexSet::print_statistics() {
-  long total_blocks = _total_used_blocks + _total_unused_blocks;
+  julong total_blocks = _total_used_blocks + _total_unused_blocks;
   tty->print_cr ("Accumulated IndexSet usage statistics:");
   tty->print_cr ("--------------------------------------");
   tty->print_cr ("  Iteration:");
-  tty->print_cr ("    blocks visited: %d", total_blocks);
-  tty->print_cr ("    blocks empty: %4.2f%%", 100.0*_total_unused_blocks/total_blocks);
-  tty->print_cr ("    bit density (bits/used blocks): %4.2f%%", (double)_total_bits/_total_used_blocks);
-  tty->print_cr ("    bit density (bits/all blocks): %4.2f%%", (double)_total_bits/total_blocks);
+  tty->print_cr ("    blocks visited: " UINT64_FORMAT, total_blocks);
+  tty->print_cr ("    blocks empty: %4.2f%%", 100.0*(double)_total_unused_blocks/total_blocks);
+  tty->print_cr ("    bit density (bits/used blocks): %4.2f", (double)_total_bits/_total_used_blocks);
+  tty->print_cr ("    bit density (bits/all blocks): %4.2f", (double)_total_bits/total_blocks);
   tty->print_cr ("  Allocation:");
-  tty->print_cr ("    blocks allocated: %d", _alloc_new);
-  tty->print_cr ("    blocks used/reused: %d", _alloc_total);
+  tty->print_cr ("    blocks allocated: " UINT64_FORMAT, _alloc_new);
+  tty->print_cr ("    blocks used/reused: " UINT64_FORMAT, _alloc_total);
 }
 
 //---------------------------- IndexSet::verify() -----------------------------
--- a/hotspot/src/share/vm/opto/indexSet.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/indexSet.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -352,13 +352,13 @@
   void tally_iteration_statistics() const;
 
   // BitBlock allocation statistics
-  static uint _alloc_new;
-  static uint _alloc_total;
+  static julong _alloc_new;
+  static julong _alloc_total;
 
   // Block density statistics
-  static long _total_bits;
-  static long _total_used_blocks;
-  static long _total_unused_blocks;
+  static julong _total_bits;
+  static julong _total_used_blocks;
+  static julong _total_unused_blocks;
 
   // Sanity tests
   void verify() const;
--- a/hotspot/src/share/vm/opto/loopnode.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/loopnode.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -1480,6 +1480,8 @@
 // Create a PhaseLoop.  Build the ideal Loop tree.  Map each Ideal Node to
 // its corresponding LoopNode.  If 'optimize' is true, do some loop cleanups.
 void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool do_loop_pred) {
+  ResourceMark rm;
+
   int old_progress = C->major_progress();
 
   // Reset major-progress flag for the driver's heuristics
@@ -2013,7 +2015,7 @@
   if (_dom_stk == NULL) {
     uint init_size = C->unique() / 100; // Guess that 1/100 is a reasonable initial size.
     if (init_size < 10) init_size = 10;
-    _dom_stk = new (C->node_arena()) GrowableArray<uint>(C->node_arena(), init_size, 0, 0);
+    _dom_stk = new GrowableArray<uint>(init_size);
   }
   // Compute new depth for each node.
   for (i = 0; i < _idom_size; i++) {
--- a/hotspot/src/share/vm/opto/loopnode.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/loopnode.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -700,7 +700,7 @@
   PhaseIdealLoop( PhaseIterGVN &igvn) :
     PhaseTransform(Ideal_Loop),
     _igvn(igvn),
-    _dom_lca_tags(C->comp_arena()),
+    _dom_lca_tags(arena()), // Thread::resource_area
     _verify_me(NULL),
     _verify_only(true) {
     build_and_optimize(false, false);
@@ -721,7 +721,7 @@
   PhaseIdealLoop( PhaseIterGVN &igvn, bool do_split_ifs, bool do_loop_pred) :
     PhaseTransform(Ideal_Loop),
     _igvn(igvn),
-    _dom_lca_tags(C->comp_arena()),
+    _dom_lca_tags(arena()), // Thread::resource_area
     _verify_me(NULL),
     _verify_only(false) {
     build_and_optimize(do_split_ifs, do_loop_pred);
@@ -731,7 +731,7 @@
   PhaseIdealLoop( PhaseIterGVN &igvn, const PhaseIdealLoop *verify_me) :
     PhaseTransform(Ideal_Loop),
     _igvn(igvn),
-    _dom_lca_tags(C->comp_arena()),
+    _dom_lca_tags(arena()), // Thread::resource_area
     _verify_me(verify_me),
     _verify_only(false) {
     build_and_optimize(false, false);
--- a/hotspot/src/share/vm/opto/node.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/node.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -743,6 +743,9 @@
 //------------------------------del_req----------------------------------------
 // Delete the required edge and compact the edge array
 void Node::del_req( uint idx ) {
+  assert( idx < _cnt, "oob");
+  assert( !VerifyHashTableKeys || _hash_lock == 0,
+          "remove node from hash table before modifying it");
   // First remove corresponding def-use edge
   Node *n = in(idx);
   if (n != NULL) n->del_out((Node *)this);
--- a/hotspot/src/share/vm/opto/phase.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/opto/phase.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -99,16 +99,18 @@
   tty->print_cr ("    stub compilation     : %3.3f sec.", Phase::_t_stubCompilation.seconds());
   tty->print_cr ("  Phases:");
   tty->print_cr ("    parse          : %3.3f sec", Phase::_t_parser.seconds());
-  if (DoEscapeAnalysis) {
-    tty->print_cr ("    escape analysis   : %3.3f sec", Phase::_t_escapeAnalysis.seconds());
-  }
   tty->print_cr ("    optimizer      : %3.3f sec", Phase::_t_optimizer.seconds());
   if( Verbose || WizardMode ) {
+    if (DoEscapeAnalysis) {
+      // EA is part of Optimizer.
+      tty->print_cr ("      escape analysis: %3.3f sec", Phase::_t_escapeAnalysis.seconds());
+    }
     tty->print_cr ("      iterGVN        : %3.3f sec", Phase::_t_iterGVN.seconds());
     tty->print_cr ("      idealLoop      : %3.3f sec", Phase::_t_idealLoop.seconds());
     tty->print_cr ("      idealLoopVerify: %3.3f sec", Phase::_t_idealLoopVerify.seconds());
     tty->print_cr ("      ccp            : %3.3f sec", Phase::_t_ccp.seconds());
     tty->print_cr ("      iterGVN2       : %3.3f sec", Phase::_t_iterGVN2.seconds());
+    tty->print_cr ("      macroExpand    : %3.3f sec", Phase::_t_macroExpand.seconds());
     tty->print_cr ("      graphReshape   : %3.3f sec", Phase::_t_graphReshaping.seconds());
     double optimizer_subtotal = Phase::_t_iterGVN.seconds() +
       Phase::_t_idealLoop.seconds() + Phase::_t_ccp.seconds() +
@@ -133,18 +135,15 @@
     double percent_of_regalloc = ((regalloc_subtotal == 0.0) ? 0.0 : (regalloc_subtotal / Phase::_t_registerAllocation.seconds() * 100.0));
     tty->print_cr ("      subtotal       : %3.3f sec,  %3.2f %%", regalloc_subtotal, percent_of_regalloc);
   }
-  tty->print_cr ("    macroExpand    : %3.3f sec", Phase::_t_macroExpand.seconds());
   tty->print_cr ("    blockOrdering  : %3.3f sec", Phase::_t_blockOrdering.seconds());
   tty->print_cr ("    peephole       : %3.3f sec", Phase::_t_peephole.seconds());
   tty->print_cr ("    codeGen        : %3.3f sec", Phase::_t_codeGeneration.seconds());
   tty->print_cr ("    install_code   : %3.3f sec", Phase::_t_registerMethod.seconds());
   tty->print_cr ("    -------------- : ----------");
   double phase_subtotal = Phase::_t_parser.seconds() +
-    (DoEscapeAnalysis ? Phase::_t_escapeAnalysis.seconds() : 0.0) +
     Phase::_t_optimizer.seconds() + Phase::_t_graphReshaping.seconds() +
     Phase::_t_matcher.seconds() + Phase::_t_scheduler.seconds() +
     Phase::_t_registerAllocation.seconds() + Phase::_t_blockOrdering.seconds() +
-    Phase::_t_macroExpand.seconds() + Phase::_t_peephole.seconds() +
     Phase::_t_codeGeneration.seconds() + Phase::_t_registerMethod.seconds();
   double percent_of_method_compile = ((phase_subtotal == 0.0) ? 0.0 : phase_subtotal / Phase::_t_methodCompilation.seconds()) * 100.0;
   // counters inside Compile::CodeGen include time for adapters and stubs
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1247,12 +1247,12 @@
   // Constant pools are not easily reused so we allocate a new one
   // each time.
   // merge_cp is created unsafe for concurrent GC processing.  It
-  // should be marked safe before discarding it because, even if
-  // garbage.  If it crosses a card boundary, it may be scanned
+  // should be marked safe before discarding it. Even though
+  // garbage,  if it crosses a card boundary, it may be scanned
   // in order to find the start of the first complete object on the card.
   constantPoolHandle merge_cp(THREAD,
     oopFactory::new_constantPool(merge_cp_length,
-                                 methodOopDesc::IsUnsafeConc,
+                                 oopDesc::IsUnsafeConc,
                                  THREAD));
   int orig_length = old_cp->orig_length();
   if (orig_length == 0) {
@@ -2343,7 +2343,7 @@
     // sized constant pool with the klass to save space.
     constantPoolHandle smaller_cp(THREAD,
       oopFactory::new_constantPool(scratch_cp_length,
-                                   methodOopDesc::IsUnsafeConc,
+                                   oopDesc::IsUnsafeConc,
                                    THREAD));
     // preserve orig_length() value in the smaller copy
     int orig_length = scratch_cp->orig_length();
--- a/hotspot/src/share/vm/prims/methodHandleWalk.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/prims/methodHandleWalk.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1134,8 +1134,9 @@
 
 constantPoolHandle MethodHandleCompiler::get_constant_pool(TRAPS) const {
   constantPoolHandle nullHandle;
-  bool is_conc_safe = true;
-  constantPoolOop cpool_oop = oopFactory::new_constantPool(_constants.length(), is_conc_safe, CHECK_(nullHandle));
+  constantPoolOop cpool_oop = oopFactory::new_constantPool(_constants.length(),
+                                                           oopDesc::IsSafeConc,
+                                                           CHECK_(nullHandle));
   constantPoolHandle cpool(THREAD, cpool_oop);
 
   // Fill the real constant pool skipping the zero element.
@@ -1180,10 +1181,9 @@
   else
     flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC);
 
-  bool is_conc_safe = true;
   methodOop m_oop = oopFactory::new_method(bytecode_length(),
                                            accessFlags_from(flags_bits),
-                                           0, 0, 0, is_conc_safe, CHECK_(nullHandle));
+                                           0, 0, 0, oopDesc::IsSafeConc, CHECK_(nullHandle));
   methodHandle m(THREAD, m_oop);
   m_oop = NULL;  // oop not GC safe
 
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1410,7 +1410,7 @@
   // by ergonomics.
   if (MaxHeapSize <= max_heap_for_compressed_oops()) {
 #if !defined(COMPILER1) || defined(TIERED)
-    if (FLAG_IS_DEFAULT(UseCompressedOops) && !UseG1GC) {
+    if (FLAG_IS_DEFAULT(UseCompressedOops)) {
       FLAG_SET_ERGO(bool, UseCompressedOops, true);
     }
 #endif
@@ -3103,6 +3103,19 @@
   // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled.
   set_aggressive_opts_flags();
 
+  // Turn off biased locking for locking debug mode flags,
+  // which are subtlely different from each other but neither works with
+  // biased locking.
+  if (!UseFastLocking || UseHeavyMonitors) {
+    if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
+      // flag set to true on command line; warn the user that they
+      // can't enable biased locking here
+      warning("Biased Locking is not supported with locking debug flags"
+              "; ignoring UseBiasedLocking flag." );
+    }
+    UseBiasedLocking = false;
+  }
+
 #ifdef CC_INTERP
   // Clear flags not supported by the C++ interpreter
   FLAG_SET_DEFAULT(ProfileInterpreter, false);
--- a/hotspot/src/share/vm/runtime/globals.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -740,6 +740,9 @@
   develop(bool, PrintMalloc, false,                                         \
           "print all malloc/free calls")                                    \
                                                                             \
+  develop(bool, PrintMallocStatistics, false,                               \
+          "print malloc/free statistics")                                   \
+                                                                            \
   develop(bool, ZapResourceArea, trueInDebug,                               \
           "Zap freed resource/arena space with 0xABABABAB")                 \
                                                                             \
@@ -2664,25 +2667,6 @@
   product(bool, UseStringCache, false,                                      \
           "Enable String cache capabilities on String.java")                \
                                                                             \
-  /* byte strings */                                                        \
-  product(bool, UseCompressedStrings, false,                                \
-          "Enable byte-valued strings")                                     \
-                                                                            \
-  product(bool, SpecialStringCompress, true,                                \
-          "special version of string compress")                             \
-                                                                            \
-  product(bool, SpecialStringInflate, true,                                 \
-          "special version of string inflate")                              \
-                                                                            \
-  product(bool, SpecialStringCompareToCC, true,                             \
-          "special version of string compareToCC")                          \
-                                                                            \
-  product(bool, SpecialStringIndexOfCC, true,                               \
-          "special version of string indexOfCC")                            \
-                                                                            \
-  product(bool, SpecialStringEqualsCC, true,                                \
-          "special version of string equalsCC")                             \
-                                                                            \
   /* statistics */                                                          \
   develop(bool, CountCompiledCalls, false,                                  \
           "counts method invocations")                                      \
@@ -3692,7 +3676,7 @@
   product(uintx, SharedReadOnlySize,   10*M,                                \
           "Size of read-only space in permanent generation (in bytes)")     \
                                                                             \
-  product(uintx, SharedMiscDataSize,    4*M,                                \
+  product(uintx, SharedMiscDataSize,    NOT_LP64(4*M) LP64_ONLY(5*M),       \
           "Size of the shared data area adjacent to the heap (in bytes)")   \
                                                                             \
   product(uintx, SharedMiscCodeSize,    4*M,                                \
--- a/hotspot/src/share/vm/runtime/java.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/java.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -326,7 +326,7 @@
   }
 
   print_bytecode_count();
-  if (WizardMode) {
+  if (PrintMallocStatistics) {
     tty->print("allocation stats: ");
     alloc_stats.print();
     tty->cr();
--- a/hotspot/src/share/vm/runtime/os.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/os.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -72,9 +72,10 @@
 size_t            os::_page_sizes[os::page_sizes_max];
 
 #ifndef PRODUCT
-int os::num_mallocs = 0;            // # of calls to malloc/realloc
-size_t os::alloc_bytes = 0;         // # of bytes allocated
-int os::num_frees = 0;              // # of calls to free
+julong os::num_mallocs = 0;         // # of calls to malloc/realloc
+julong os::alloc_bytes = 0;         // # of bytes allocated
+julong os::num_frees = 0;           // # of calls to free
+julong os::free_bytes = 0;          // # of bytes freed
 #endif
 
 // Fill in buffer with current local time as an ISO-8601 string.
@@ -490,9 +491,9 @@
   }
 
   if (start_of_prev_block + space_before + size + space_after == start_of_this_block) {
-    tty->print_cr("### previous object: %p (%ld bytes)", obj, size);
+    tty->print_cr("### previous object: " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", obj, size);
   } else {
-    tty->print_cr("### previous object (not sure if correct): %p (%ld bytes)", obj, size);
+    tty->print_cr("### previous object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", obj, size);
   }
 
   // now find successor block
@@ -504,16 +505,16 @@
       start_of_next_block[1] == badResourceValue &&
       start_of_next_block[2] == badResourceValue &&
       start_of_next_block[3] == badResourceValue) {
-    tty->print_cr("### next object: %p (%ld bytes)", next_obj, next_size);
+    tty->print_cr("### next object: " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", next_obj, next_size);
   } else {
-    tty->print_cr("### next object (not sure if correct): %p (%ld bytes)", next_obj, next_size);
+    tty->print_cr("### next object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", next_obj, next_size);
   }
 }
 
 
 void report_heap_error(void* memblock, void* bad, const char* where) {
-  tty->print_cr("## nof_mallocs = %d, nof_frees = %d", os::num_mallocs, os::num_frees);
-  tty->print_cr("## memory stomp: byte at %p %s object %p", bad, where, memblock);
+  tty->print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees);
+  tty->print_cr("## memory stomp: byte at " PTR_FORMAT " %s object " PTR_FORMAT, bad, where, memblock);
   print_neighbor_blocks(memblock);
   fatal("memory stomping error");
 }
@@ -538,8 +539,8 @@
 #endif
 
 void* os::malloc(size_t size) {
-  NOT_PRODUCT(num_mallocs++);
-  NOT_PRODUCT(alloc_bytes += size);
+  NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
+  NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
 
   if (size == 0) {
     // return a valid pointer if size is zero
@@ -562,26 +563,26 @@
 #endif
   u_char* memblock = ptr + space_before;
   if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) {
-    tty->print_cr("os::malloc caught, %lu bytes --> %p", size, memblock);
+    tty->print_cr("os::malloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock);
     breakpoint();
   }
   debug_only(if (paranoid) verify_block(memblock));
-  if (PrintMalloc && tty != NULL) tty->print_cr("os::malloc %lu bytes --> %p", size, memblock);
+  if (PrintMalloc && tty != NULL) tty->print_cr("os::malloc " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock);
   return memblock;
 }
 
 
 void* os::realloc(void *memblock, size_t size) {
-  NOT_PRODUCT(num_mallocs++);
-  NOT_PRODUCT(alloc_bytes += size);
 #ifndef ASSERT
+  NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
+  NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
   return ::realloc(memblock, size);
 #else
   if (memblock == NULL) {
-    return os::malloc(size);
+    return malloc(size);
   }
   if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) {
-    tty->print_cr("os::realloc caught %p", memblock);
+    tty->print_cr("os::realloc caught " PTR_FORMAT, memblock);
     breakpoint();
   }
   verify_block(memblock);
@@ -589,13 +590,13 @@
   if (size == 0) return NULL;
   // always move the block
   void* ptr = malloc(size);
-  if (PrintMalloc) tty->print_cr("os::remalloc %lu bytes, %p --> %p", size, memblock, ptr);
+  if (PrintMalloc) tty->print_cr("os::remalloc " SIZE_FORMAT " bytes, " PTR_FORMAT " --> " PTR_FORMAT, size, memblock, ptr);
   // Copy to new memory if malloc didn't fail
   if ( ptr != NULL ) {
     memcpy(ptr, memblock, MIN2(size, get_size(memblock)));
     if (paranoid) verify_block(ptr);
     if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) {
-      tty->print_cr("os::realloc caught, %lu bytes --> %p", size, ptr);
+      tty->print_cr("os::realloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, ptr);
       breakpoint();
     }
     free(memblock);
@@ -606,17 +607,14 @@
 
 
 void  os::free(void *memblock) {
-  NOT_PRODUCT(num_frees++);
+  NOT_PRODUCT(inc_stat_counter(&num_frees, 1));
 #ifdef ASSERT
   if (memblock == NULL) return;
   if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) {
-    if (tty != NULL) tty->print_cr("os::free caught %p", memblock);
+    if (tty != NULL) tty->print_cr("os::free caught " PTR_FORMAT, memblock);
     breakpoint();
   }
   verify_block(memblock);
-  if (PrintMalloc && tty != NULL)
-    // tty->print_cr("os::free %p", memblock);
-    fprintf(stderr, "os::free %p\n", memblock);
   NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap());
   // Added by detlefs.
   if (MallocCushion) {
@@ -627,12 +625,18 @@
       *p = (u_char)freeBlockPad;
     }
     size_t size = get_size(memblock);
+    inc_stat_counter(&free_bytes, size);
     u_char* end = ptr + space_before + size;
     for (u_char* q = end; q < end + MallocCushion; q++) {
       guarantee(*q == badResourceValue,
                 "Thing freed should be malloc result.");
       *q = (u_char)freeBlockPad;
     }
+    if (PrintMalloc && tty != NULL)
+      fprintf(stderr, "os::free " SIZE_FORMAT " bytes --> " PTR_FORMAT "\n", size, memblock);
+  } else if (PrintMalloc && tty != NULL) {
+    // tty->print_cr("os::free %p", memblock);
+    fprintf(stderr, "os::free " PTR_FORMAT "\n", memblock);
   }
 #endif
   ::free((char*)memblock - space_before);
--- a/hotspot/src/share/vm/runtime/os.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/os.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -559,9 +559,10 @@
   static char* strdup(const char *);  // Like strdup
 
 #ifndef PRODUCT
-  static int  num_mallocs;            // # of calls to malloc/realloc
-  static size_t  alloc_bytes;         // # of bytes allocated
-  static int  num_frees;              // # of calls to free
+  static julong num_mallocs;         // # of calls to malloc/realloc
+  static julong alloc_bytes;         // # of bytes allocated
+  static julong num_frees;           // # of calls to free
+  static julong free_bytes;          // # of bytes freed
 #endif
 
   // SocketInterface (ex HPI SocketInterface )
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 #include "runtime/arguments.hpp"
 #include "runtime/simpleThresholdPolicy.hpp"
 #include "runtime/simpleThresholdPolicy.inline.hpp"
+#include "code/scopeDesc.hpp"
 
 // Print an event.
 void SimpleThresholdPolicy::print_event(EventType type, methodHandle mh, methodHandle imh,
@@ -48,6 +49,18 @@
     break;
   case COMPILE:
     tty->print("compile");
+    break;
+  case KILL:
+    tty->print("kill");
+    break;
+  case UPDATE:
+    tty->print("update");
+    break;
+  case REPROFILE:
+    tty->print("reprofile");
+    break;
+  default:
+    tty->print("unknown");
   }
 
   tty->print(" level: %d ", level);
@@ -69,13 +82,17 @@
   if (type != COMPILE) {
     methodDataHandle mdh = mh->method_data();
     int mdo_invocations = 0, mdo_backedges = 0;
+    int mdo_invocations_start = 0, mdo_backedges_start = 0;
     if (mdh() != NULL) {
       mdo_invocations = mdh->invocation_count();
       mdo_backedges = mdh->backedge_count();
+      mdo_invocations_start = mdh->invocation_count_start();
+      mdo_backedges_start = mdh->backedge_count_start();
     }
-    tty->print(" total: %d,%d mdo: %d,%d",
+    tty->print(" total: %d,%d mdo: %d(%d),%d(%d)",
                invocation_count, backedge_count,
-               mdo_invocations, mdo_backedges);
+               mdo_invocations, mdo_invocations_start,
+               mdo_backedges, mdo_backedges_start);
     tty->print(" max levels: %d,%d",
                 mh->highest_comp_level(), mh->highest_osr_comp_level());
     if (inlinee_event) {
@@ -138,6 +155,20 @@
   return compile_queue->first();
 }
 
+void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
+  for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) {
+    if (PrintTieredEvents) {
+      methodHandle mh(sd->method());
+      print_event(REPROFILE, mh, mh, InvocationEntryBci, CompLevel_none);
+    }
+    methodDataOop mdo = sd->method()->method_data();
+    if (mdo != NULL) {
+      mdo->reset_start_counters();
+    }
+    if (sd->is_top()) break;
+  }
+}
+
 nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
                                       int branch_bci, int bci, CompLevel comp_level, TRAPS) {
   if (comp_level == CompLevel_none &&
@@ -254,46 +285,35 @@
 
 // Common transition function. Given a predicate determines if a method should transition to another level.
 CompLevel SimpleThresholdPolicy::common(Predicate p, methodOop method, CompLevel cur_level) {
+  if (is_trivial(method)) return CompLevel_simple;
+
   CompLevel next_level = cur_level;
   int i = method->invocation_count();
   int b = method->backedge_count();
 
   switch(cur_level) {
   case CompLevel_none:
-    {
-      methodDataOop mdo = method->method_data();
-      if (mdo != NULL) {
-        int mdo_i = mdo->invocation_count();
-        int mdo_b = mdo->backedge_count();
-        // If we were at full profile level, would we switch to full opt?
-        if ((this->*p)(mdo_i, mdo_b, CompLevel_full_profile)) {
-          next_level = CompLevel_full_optimization;
-        }
-      }
-    }
-    if (next_level == cur_level && (this->*p)(i, b, cur_level)) {
-      if (is_trivial(method)) {
-        next_level = CompLevel_simple;
-      } else {
-        next_level = CompLevel_full_profile;
-      }
+    // If we were at full profile level, would we switch to full opt?
+    if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) {
+      next_level = CompLevel_full_optimization;
+    } else if ((this->*p)(i, b, cur_level)) {
+      next_level = CompLevel_full_profile;
     }
     break;
   case CompLevel_limited_profile:
   case CompLevel_full_profile:
-    if (is_trivial(method)) {
-      next_level = CompLevel_simple;
-    } else {
+    {
       methodDataOop mdo = method->method_data();
-      guarantee(mdo != NULL, "MDO should always exist");
-      if (mdo->would_profile()) {
-        int mdo_i = mdo->invocation_count();
-        int mdo_b = mdo->backedge_count();
-        if ((this->*p)(mdo_i, mdo_b, cur_level)) {
+      if (mdo != NULL) {
+        if (mdo->would_profile()) {
+          int mdo_i = mdo->invocation_count_delta();
+          int mdo_b = mdo->backedge_count_delta();
+          if ((this->*p)(mdo_i, mdo_b, cur_level)) {
+            next_level = CompLevel_full_optimization;
+          }
+        } else {
           next_level = CompLevel_full_optimization;
         }
-      } else {
-        next_level = CompLevel_full_optimization;
       }
     }
     break;
@@ -303,12 +323,6 @@
 
 // Determine if a method should be compiled with a normal entry point at a different level.
 CompLevel SimpleThresholdPolicy::call_event(methodOop method,  CompLevel cur_level) {
-  CompLevel highest_level = (CompLevel)method->highest_comp_level();
-  if (cur_level == CompLevel_none && highest_level > cur_level) {
-    // TODO: We may want to try to do more extensive reprofiling in this case.
-    return highest_level;
-  }
-
   CompLevel osr_level = (CompLevel) method->highest_osr_comp_level();
   CompLevel next_level = common(&SimpleThresholdPolicy::call_predicate, method, cur_level);
 
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@
   void set_c1_count(int x) { _c1_count = x;    }
   void set_c2_count(int x) { _c2_count = x;    }
 
-  enum EventType { CALL, LOOP, COMPILE };
+  enum EventType { CALL, LOOP, COMPILE, KILL, UPDATE, REPROFILE };
   void print_event(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level);
   // Print policy-specific information if necessary
   virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { }
@@ -103,7 +103,7 @@
   virtual void disable_compilation(methodOop method) { }
   // TODO: we should honour reprofiling requests in the future. Currently reprofiling
   // would happen but not to the extent we would ideally like.
-  virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) { }
+  virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
   virtual nmethod* event(methodHandle method, methodHandle inlinee,
                          int branch_bci, int bci, CompLevel comp_level, TRAPS);
   // Select task is called by CompileBroker. We should return a task or NULL.
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -748,7 +748,6 @@
   /***********************************/                                                                                              \
                                                                                                                                      \
      static_field(StubRoutines,                _call_stub_return_address,                     address)                               \
-     IA32_ONLY(static_field(StubRoutines::x86,_call_stub_compiled_return,                     address))                              \
                                                                                                                                      \
   /***************************************/                                                                                          \
   /* PcDesc and other compiled code info */                                                                                          \
--- a/hotspot/src/share/vm/services/heapDumper.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/services/heapDumper.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1397,6 +1397,7 @@
  public:
   VM_HeapDumper(DumpWriter* writer, bool gc_before_heap_dump, bool oome) :
     VM_GC_Operation(0 /* total collections,      dummy, ignored */,
+                    GCCause::_heap_dump /* GC Cause */,
                     0 /* total full collections, dummy, ignored */,
                     gc_before_heap_dump) {
     _local_writer = writer;
--- a/hotspot/src/share/vm/services/management.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/services/management.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -1311,7 +1311,7 @@
     if (locked_monitors) {
       // Constructs Object[] and int[] to contain the object monitor and the stack depth
       // where the thread locked it
-      objArrayOop array = oopFactory::new_system_objArray(num_locked_monitors, CHECK_NULL);
+      objArrayOop array = oopFactory::new_objArray(SystemDictionary::Object_klass(), num_locked_monitors, CHECK_NULL);
       objArrayHandle mh(THREAD, array);
       monitors_array = mh;
 
@@ -1353,7 +1353,7 @@
       GrowableArray<instanceOop>* locks = (tcl != NULL ? tcl->owned_locks() : NULL);
       int num_locked_synchronizers = (locks != NULL ? locks->length() : 0);
 
-      objArrayOop array = oopFactory::new_system_objArray(num_locked_synchronizers, CHECK_NULL);
+      objArrayOop array = oopFactory::new_objArray(SystemDictionary::Object_klass(), num_locked_synchronizers, CHECK_NULL);
       objArrayHandle sh(THREAD, array);
       synchronizers_array = sh;
 
--- a/hotspot/src/share/vm/utilities/errorReporter.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/utilities/errorReporter.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -26,6 +26,7 @@
 #define SHARE_VM_UTILITIES_ERRORREPORTER_HPP
 
 #include "utilities/globalDefinitions.hpp"
+#include "memory/allocation.hpp"
 
 class ErrorReporter : public StackObj {
 
--- a/hotspot/src/share/vm/utilities/hashtable.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/utilities/hashtable.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -276,7 +276,7 @@
   }
 
   int index_for(Symbol* name, Handle loader) {
-    return hash_to_index(compute_hash(name, loader));
+    return this->hash_to_index(compute_hash(name, loader));
   }
 };
 
--- a/hotspot/src/share/vm/utilities/ostream.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/utilities/ostream.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -699,6 +699,17 @@
   defaultStream::instance->release(holder);
 }
 
+bool ttyLocker::release_tty_if_locked() {
+  intx thread_id = os::current_thread_id();
+  if (defaultStream::instance->writer() == thread_id) {
+    // release the lock and return true so callers know if was
+    // previously held.
+    release_tty(thread_id);
+    return true;
+  }
+  return false;
+}
+
 void ttyLocker::break_tty_lock_for_safepoint(intx holder) {
   if (defaultStream::instance != NULL &&
       defaultStream::instance->writer() == holder) {
--- a/hotspot/src/share/vm/utilities/ostream.hpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/src/share/vm/utilities/ostream.hpp	Mon Mar 07 11:37:54 2011 -0800
@@ -123,18 +123,36 @@
 
 // advisory locking for the shared tty stream:
 class ttyLocker: StackObj {
+  friend class ttyUnlocker;
  private:
   intx _holder;
 
  public:
   static intx  hold_tty();                // returns a "holder" token
   static void  release_tty(intx holder);  // must witness same token
+  static bool  release_tty_if_locked();   // returns true if lock was released
   static void  break_tty_lock_for_safepoint(intx holder);
 
   ttyLocker()  { _holder = hold_tty(); }
   ~ttyLocker() { release_tty(_holder); }
 };
 
+// Release the tty lock if it's held and reacquire it if it was
+// locked.  Used to avoid lock ordering problems.
+class ttyUnlocker: StackObj {
+ private:
+  bool _was_locked;
+ public:
+  ttyUnlocker()  {
+    _was_locked = ttyLocker::release_tty_if_locked();
+  }
+  ~ttyUnlocker() {
+    if (_was_locked) {
+      ttyLocker::hold_tty();
+    }
+  }
+};
+
 // for writing to strings; buffer will expand automatically
 class stringStream : public outputStream {
  protected:
--- a/hotspot/test/compiler/6987555/Test6987555.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/hotspot/test/compiler/6987555/Test6987555.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -54,8 +54,8 @@
         if (DEBUG)  System.out.println("boolean=" + x);
         MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class));
         MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class));
-        boolean a = mh1.<boolean>invokeExact(x);
-        boolean b = mh2.<boolean>invokeExact(Boolean.valueOf(x));
+        boolean a = (boolean) mh1.invokeExact(x);
+        boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x));
         assert a == b : a + " != " + b;
     }
 
@@ -80,8 +80,8 @@
         if (DEBUG)  System.out.println("byte=" + x);
         MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class));
         MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class));
-        byte a = mh1.<byte>invokeExact(x);
-        byte b = mh2.<byte>invokeExact(Byte.valueOf(x));
+        byte a = (byte) mh1.invokeExact(x);
+        byte b = (byte) mh2.invokeExact(Byte.valueOf(x));
         assert a == b : a + " != " + b;
     }
 
@@ -104,8 +104,8 @@
         if (DEBUG)  System.out.println("char=" + x);
         MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class));
         MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class));
-        char a = mh1.<char>invokeExact(x);
-        char b = mh2.<char>invokeExact(Character.valueOf(x));
+        char a = (char) mh1.invokeExact(x);
+        char b = (char) mh2.invokeExact(Character.valueOf(x));
         assert a == b : a + " != " + b;
     }
 
@@ -134,8 +134,8 @@
         if (DEBUG)  System.out.println("short=" + x);
         MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class));
         MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class));
-        short a = mh1.<short>invokeExact(x);
-        short b = mh2.<short>invokeExact(Short.valueOf(x));
+        short a = (short) mh1.invokeExact(x);
+        short b = (short) mh2.invokeExact(Short.valueOf(x));
         assert a == b : a + " != " + b;
     }
 
@@ -164,8 +164,8 @@
         if (DEBUG)  System.out.println("int=" + x);
         MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class));
         MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class));
-        int a = mh1.<int>invokeExact(x);
-        int b = mh2.<int>invokeExact(Integer.valueOf(x));
+        int a = (int) mh1.invokeExact(x);
+        int b = (int) mh2.invokeExact(Integer.valueOf(x));
         assert a == b : a + " != " + b;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7017746/Test.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 7017746
+ * @summary Regression : C2 compiler crash due to SIGSEGV in PhaseCFG::schedule_early()
+ *
+ * @run main/othervm -Xbatch Test
+ */
+
+public class Test {
+
+  int i;
+
+  static int test(Test t, int a, int b) {
+    int j = t.i;
+    int x = a - b;
+    if (a < b) x = x + j;
+    return x - j;
+  }
+
+  public static void main(String args[]) {
+    Test t = new Test();
+    for (int n = 0; n < 1000000; n++) {
+      int i = test(t, 1, 2);
+    }
+  }
+}
+
--- a/jaxp/.hgtags	Mon Mar 07 14:31:50 2011 +0000
+++ b/jaxp/.hgtags	Mon Mar 07 11:37:54 2011 -0800
@@ -104,3 +104,6 @@
 c532d6dbc8d18d55b5d693599ee5cd8250e16eb4 jdk7-b127
 a42c6132c746c86e9fc27ec80cbd699f6ee5edca jdk7-b128
 f5b60c5a310f992c6ca627d17ca3e042f0e0b2c3 jdk7-b129
+ab107c1bc4b918404b191838c455e9b2892389f3 jdk7-b130
+eab6f27131e4e2f0af0016b35b18ae65cdd249d9 jdk7-b131
+abe04c59a556a3821c30bd8839e3c74f5d4281d1 jdk7-b132
--- a/jaxp/LICENSE	Mon Mar 07 14:31:50 2011 +0000
+++ b/jaxp/LICENSE	Mon Mar 07 11:37:54 2011 -0800
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Sun Microsystems, Inc.  are subject to
-the following clarification and special exception to the GPL, but only where
-Sun has expressly included in the particular source file's header the words
-"Sun designates this particular file as subject to the "Classpath" exception
-as provided by Sun in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/jaxws/.hgtags	Mon Mar 07 14:31:50 2011 +0000
+++ b/jaxws/.hgtags	Mon Mar 07 11:37:54 2011 -0800
@@ -104,3 +104,6 @@
 ef19f173578c804772d586a959fa3ab8a12c0598 jdk7-b127
 88d74afc55938033e744b537a22714bb2c82c9c0 jdk7-b128
 0f7b39ad902424e949e3d2dca8411b884888a76f jdk7-b129
+ba1fac1c2083196422a12130db174334179a4d44 jdk7-b130
+438abc0356cd97d91b25f67cd1abc9883e22f6ed jdk7-b131
+0e57c3272d377eee04cc32c898e9a558051516b0 jdk7-b132
--- a/jaxws/LICENSE	Mon Mar 07 14:31:50 2011 +0000
+++ b/jaxws/LICENSE	Mon Mar 07 11:37:54 2011 -0800
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Sun Microsystems, Inc.  are subject to
-the following clarification and special exception to the GPL, but only where
-Sun has expressly included in the particular source file's header the words
-"Sun designates this particular file as subject to the "Classpath" exception
-as provided by Sun in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/jdk/.hgtags	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/.hgtags	Mon Mar 07 11:37:54 2011 -0800
@@ -104,3 +104,6 @@
 29e09de1d0b4f84faea114cf10b3ec08b59acc4e jdk7-b127
 f08682e23279d6cccbdcafda1eb0647ba4900874 jdk7-b128
 14cd5d54a8d0b9c368d60ea83a066735b9931015 jdk7-b129
+bdc069d3f9101f89ec3f81c2950ee2d68fa846d3 jdk7-b130
+8ac52c85f9e91336dc00b52ef90b42eecf3230b3 jdk7-b131
+6bbc7a4734952ae7604578f270e1566639fa8752 jdk7-b132
--- a/jdk/LICENSE	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/LICENSE	Mon Mar 07 11:37:54 2011 -0800
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Sun Microsystems, Inc.  are subject to
-the following clarification and special exception to the GPL, but only where
-Sun has expressly included in the particular source file's header the words
-"Sun designates this particular file as subject to the "Classpath" exception
-as provided by Sun in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/jdk/make/common/Defs-windows.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/common/Defs-windows.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -359,7 +359,13 @@
 
   # VS2008 has bufferoverflow baked in:
   LFLAGS_VS2008 = 
-  LFLAGS_VS2010 = 
+
+  # VS2010, always need safe exception handlers, not needed on 64bit
+  ifeq ($(ARCH_DATA_MODEL), 32)
+    LFLAGS_VS2010 =  -SAFESEH
+  else
+    LFLAGS_VS2010 =
+  endif
 
   # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
   BASELFLAGS = -nologo /opt:REF /incremental:no
--- a/jdk/make/common/Release.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/common/Release.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -124,7 +124,7 @@
 	tnameserv.1     \
 	unpack200.1
 
-ifeq ($(ARCH_DATA_MODEL),32)
+ifndef OPENJDK
   JRE_MAN_PAGES += javaws.1
 endif
 
@@ -1098,7 +1098,7 @@
 
 # Common way to emit a line into the release or info file
 define info-file-item # name value
-$(PRINTF) "%s=\"%s\"\n" $1 $2 >> $@
+$(PRINTF) '%s="%s"\n' $1 $2 >> $@
 endef
 
 # Values to emit
--- a/jdk/make/common/shared/Defs-javadoc.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/common/shared/Defs-javadoc.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -61,33 +61,11 @@
 EMPTY:=
 SPACE:=$(EMPTY) $(EMPTY)
 COPYRIGHT_SYMBOL = &\#x00a9;
-# Macros to handle the optional empty args.
+# Macro to construct the copyright line
 #   (The GNU make 3.78.1 "if" conditional is broken, fixed in GNU make 3.81)
-define OptionalCopyrightUrl # url
-$(shell \
-  if [ "$1" != "" ] ; then \
-    printf "<a href=\"%s\">Copyright</a>" "$1"; \
-  else \
-    printf "Copyright"; \
-  fi)
-endef
-define OptionalCopyrightFirstYear # year
-$(shell \
-  if [ "$1" != "" ] ; then \
-    printf "%s," "$1";\
-  fi)
-endef
-define OptionalCompanyAddress # address
-$(shell \
-  if [ "$1" != "" ] ; then \
-    printf "%s" "$1";\
-  fi)
-endef
 define CopyrightLine # optionalurl optionalfirstyear optionaladdress
-$(call OptionalCopyrightUrl,$1) $(COPYRIGHT_SYMBOL)\
-$(call OptionalCopyrightFirstYear,$2) $(COPYRIGHT_YEAR),\
-$(COMPANY_NAME).\
-$(call OptionalCompanyAddress,$3)\
-All rights reserved.
+$(if $(strip $1),<a href=\"$(strip $1)\">Copyright</a>,Copyright) \
+$(COPYRIGHT_SYMBOL) $(if $2,$2${COMMA},) $(COPYRIGHT_YEAR),\
+$(FULL_COMPANY_NAME). $3 All rights reserved.
 endef
 
--- a/jdk/make/common/shared/Defs-utils.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/common/shared/Defs-utils.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -115,7 +115,6 @@
 PKGMK          = $(UTILS_COMMAND_PATH)pkgmk
 PRINTF         = $(UTILS_USR_BIN_PATH)printf
 PWD            = $(UTILS_COMMAND_PATH)pwd
-RC             = $(UTILS_COMMAND_PATH)rc
 READELF        = $(UTILS_USR_BIN_PATH)readelf
 RMDIR          = $(UTILS_COMMAND_PATH)rmdir
 RPM            = $(UTILS_COMMAND_PATH)rpm
@@ -135,6 +134,7 @@
 UNIQ           = $(UTILS_USR_BIN_PATH)uniq
 UNZIP          = $(UTILS_USR_BIN_PATH)unzip
 UNZIPSFX       = $(UTILS_DEVTOOL_PATH)unzipsfx
+XARGS          = $(UTILS_USR_BIN_PATH)xargs
 WC             = $(UTILS_USR_BIN_PATH)wc
 WHICH          = $(UTILS_USR_BIN_PATH)which
 YACC           = $(UTILS_CCS_BIN_PATH)yacc
--- a/jdk/make/common/shared/Defs-windows.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/common/shared/Defs-windows.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -772,9 +772,20 @@
   BANNED_DLLS=msvcp100[.]dll|msvcr100d[.]dll|msvcrtd[.]dll
 endif
 
-# Macro to check it's input file for banned dependencies and verify the
-#   binary was built properly. Relies on process exit code.
-define binary_file_verification # binary_file
+# Check for /safeseh (only used on 32bit)
+define binary_file_safeseh_verification # binary_file
+( \
+  $(ECHO) "Checking for /SAFESEH usage in: $1" && \
+  if [ "`$(DUMPBIN) /loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \
+    $(ECHO) "ERROR: Did not find 'Safe Exception Handler Table' in loadconfig: $1" ; \
+    $(DUMPBIN) /loadconfig $1 ; \
+    exit 6 ; \
+  fi ; \
+)
+endef
+
+# Check for /NXCOMPAT usage
+define binary_file_nxcompat_verification # binary_file
 ( \
   $(ECHO) "Checking for /NXCOMPAT usage in: $1" && \
   if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
@@ -782,12 +793,24 @@
     $(DUMPBIN) /headers $1 ; \
     exit 7 ; \
   fi ; \
+)
+endef
+
+# Check for /DYNAMICBASE usage
+define binary_file_dynamicbase_verification # binary_file
+( \
   $(ECHO) "Checking for /DYNAMICBASE usage in: $1" && \
   if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
     $(ECHO) "ERROR: Did not find 'Dynamic base' in headers: $1" ; \
     $(DUMPBIN) /headers $1 ; \
     exit 8 ; \
   fi ; \
+)
+endef
+
+# Check for banned dll usage
+define binary_file_dll_verification # binary_file
+( \
   $(ECHO) "Checking for banned dependencies in: $1" && \
   if [ "`$(DUMPBIN) /dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
     $(ECHO) "ERROR: Found use of $(BANNED_DLLS)"; \
@@ -797,6 +820,27 @@
 )
 endef
 
+# Macro to check it's input file for properly built executables.
+#   Relies on process exit code. Different for 32bit vs 64bit.
+ifeq ($(ARCH_DATA_MODEL),32)
+define binary_file_verification # binary_file
+( \
+  $(call binary_file_safeseh_verification,$1); \
+  $(call binary_file_nxcompat_verification,$1); \
+  $(call binary_file_dynamicbase_verification,$1); \
+  $(call binary_file_dll_verification,$1); \
+)
+endef
+else
+define binary_file_verification # binary_file
+( \
+  $(call binary_file_nxcompat_verification,$1); \
+  $(call binary_file_dynamicbase_verification,$1); \
+  $(call binary_file_dll_verification,$1); \
+)
+endef
+endif
+
 else
 
 # Macro to check it's input file for banned dependencies and verify the
--- a/jdk/make/common/shared/Sanity.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/common/shared/Sanity.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -1012,11 +1012,6 @@
 	    "" >> $(ERROR_FILE) ; \
 	fi
   else
-    ifeq ($(wildcard $(REBASE)),)
-	@$(ECHO) "ERROR: Cannot find the REBASE utility from path: $(REBASE)\n" \
-	    "      This is normally obtained from the WINDOWSSDKDIR." \
-	    "" >> $(ERROR_FILE)
-    endif
     ifeq ($(wildcard $(RC)),)
 	@$(ECHO) "ERROR: Cannot find the RC utility from path: $(RC)\n" \
 	    "      This is normally obtained from the WINDOWSSDKDIR." \
@@ -1024,7 +1019,7 @@
     endif
     ifeq ($(wildcard $(DUMPBIN)),)
 	@$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \
-	    "      This is normally obtained from the WINDOWSSDKDIR." \
+	    "      This is normally obtained from the COMPILER_PATH." \
 	    "" >> $(ERROR_FILE)
     endif
   endif
--- a/jdk/make/docs/Makefile	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/docs/Makefile	Mon Mar 07 11:37:54 2011 -0800
@@ -166,7 +166,7 @@
 
 # Common bottom argument
 define CommonBottom # year
-<font size=\"-1\"><p> $(call CopyrightLine,,$1,)</font>
+<font size=\"-1\"><br> $(call CopyrightLine,,$1,)</font>
 endef
 
 # Common trademark bottom argument (Not sure why this is used sometimes)
@@ -183,7 +183,7 @@
 see <a href=\"$(DEV_DOCS_URL)\" target=\"_blank\">Java SE Documentation</a>. \
 That documentation contains more detailed, developer-targeted descriptions, \
 with conceptual overviews, definitions of terms, workarounds, \
-and working code examples.<p>\
+and working code examples.<br>\
 $(call CopyrightLine,$(COPYRIGHT_URL),$(FIRST_COPYRIGHT_YEAR),)\
 </font>
 
--- a/jdk/make/java/security/Makefile	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/java/security/Makefile	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1996, 2010 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1996, 2011 Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -65,6 +65,8 @@
 ifndef OPENJDK
   BLACKLIST_SRC =	$(CLOSED_SHARE_SRC)/lib/security/blacklist
   BLACKLIST_BUILD = $(LIBDIR)/security/blacklist
+  TRUSTEDLIBS_SRC = $(CLOSED_SHARE_SRC)/lib/security/trusted.libraries
+  TRUSTEDLIBS_BUILD = $(LIBDIR)/security/trusted.libraries
 endif
 
 FILES_class = $(FILES_java:%.java=$(CLASSBINDIR)/%.class)
@@ -77,7 +79,7 @@
 ifdef OPENJDK
 build: properties policy cacerts
 else
-build: properties policy cacerts blacklist
+build: properties policy cacerts blacklist trustedlibs
 endif
 
 install: all
@@ -90,6 +92,8 @@
 
 blacklist: classes $(BLACKLIST_BUILD)
 
+trustedlibs: classes $(TRUSTEDLIBS_BUILD)
+
 $(PROPS_BUILD): $(PROPS_SRC)
 	$(install-file)
 
@@ -102,9 +106,12 @@
 $(BLACKLIST_BUILD): $(BLACKLIST_SRC)
 	$(install-file)
 
+$(TRUSTEDLIBS_BUILD): $(TRUSTEDLIBS_SRC)
+	$(install-file)
+
 clean clobber:: .delete.classlist
 	$(RM) -r $(CLASSBINDIR)/java/security
-	$(RM) $(PROPS_BUILD) $(POLICY_BUILD) $(CACERTS_BUILD) $(BLACKLIST_BUILD)
+	$(RM) $(PROPS_BUILD) $(POLICY_BUILD) $(CACERTS_BUILD) $(BLACKLIST_BUILD) $(TRUSTEDLIBS_BUILD)
 
 # Additional Rule for building sun.security.util
 $(CLASSBINDIR)/%.class: $(SHARE_SRC)/sun/%.java
--- a/jdk/make/sun/javazic/tzdata/VERSION	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/javazic/tzdata/VERSION	Mon Mar 07 11:37:54 2011 -0800
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2010o
+tzdata2011b
--- a/jdk/make/sun/javazic/tzdata/australasia	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/javazic/tzdata/australasia	Mon Mar 07 11:37:54 2011 -0800
@@ -106,14 +106,13 @@
 Rule	AS	1987	2007	-	Oct	lastSun	2:00s	1:00	-
 Rule	AS	1972	only	-	Feb	27	2:00s	0	-
 Rule	AS	1973	1985	-	Mar	Sun>=1	2:00s	0	-
-Rule	AS	1986	1989	-	Mar	Sun>=15	2:00s	0	-
-Rule	AS	1990	only	-	Mar	Sun>=18	2:00s	0	-
-Rule	AS	1991	only	-	Mar	Sun>=1	2:00s	0	-
-Rule	AS	1992	only	-	Mar	Sun>=18	2:00s	0	-
-Rule	AS	1993	only	-	Mar	Sun>=1	2:00s	0	-
-Rule	AS	1994	only	-	Mar	Sun>=18	2:00s	0	-
+Rule	AS	1986	1990	-	Mar	Sun>=15	2:00s	0	-
+Rule	AS	1991	only	-	Mar	3	2:00s	0	-
+Rule	AS	1992	only	-	Mar	22	2:00s	0	-
+Rule	AS	1993	only	-	Mar	7	2:00s	0	-
+Rule	AS	1994	only	-	Mar	20	2:00s	0	-
 Rule	AS	1995	2005	-	Mar	lastSun	2:00s	0	-
-Rule	AS	2006	only	-	Apr	Sun>=1	2:00s	0	-
+Rule	AS	2006	only	-	Apr	2	2:00s	0	-
 Rule	AS	2007	only	-	Mar	lastSun	2:00s	0	-
 Rule	AS	2008	max	-	Apr	Sun>=1	2:00s	0	-
 Rule	AS	2008	max	-	Oct	Sun>=1	2:00s	1:00	-
--- a/jdk/make/sun/javazic/tzdata/northamerica	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/javazic/tzdata/northamerica	Mon Mar 07 11:37:54 2011 -0800
@@ -368,6 +368,27 @@
 			-7:00	US	M%sT	2003 Oct 26 02:00
 			-6:00	US	C%sT
 
+# From Josh Findley (2011-01-21):
+# ...it appears that Mercer County, North Dakota, changed from the
+# mountain time zone to the central time zone at the last transition from
+# daylight-saving to standard time (on Nov. 7, 2010):
+# <a href="http://www.gpo.gov/fdsys/pkg/FR-2010-09-29/html/2010-24376.htm">
+# http://www.gpo.gov/fdsys/pkg/FR-2010-09-29/html/2010-24376.htm
+# </a>
+# <a href="http://www.bismarcktribune.com/news/local/article_1eb1b588-c758-11df-b472-001cc4c03286.html">
+# http://www.bismarcktribune.com/news/local/article_1eb1b588-c758-11df-b472-001cc4c03286.html
+# </a>
+
+# From Andy Lipscomb (2011-01-24):
+# ...according to the Census Bureau, the largest city is Beulah (although
+# it's commonly referred to as Beulah-Hazen, with Hazen being the next
+# largest city in Mercer County).  Google Maps places Beulah's city hall
+# at 4715'51" north, 10146'40" west, which yields an offset of 6h47'07".
+
+Zone America/North_Dakota/Beulah -6:47:07 - LMT 1883 Nov 18 12:12:53
+			-7:00	US	M%sT	2010 Nov  7 2:00
+			-6:00	US	C%sT
+
 # US mountain time, represented by Denver
 #
 # Colorado, far western Kansas, Montana, western
@@ -493,20 +514,50 @@
 #  three votes for and one against."
 
 # Hawaii
-#
-# From Arthur David Olson:
-# And then there's Hawaii.
-# DST was observed for one day in 1933;
-# standard time was changed by half an hour in 1947;
-# it's always standard as of 1986.
+
+# From Arthur David Olson (2010-12-09):
+# "Hawaiian Time" by Robert C. Schmitt and Doak C. Cox appears on pages 207-225
+# of volume 26 of The Hawaiian Journal of History (1992). As of 2010-12-09,
+# the article is available at
+# <a href="http://evols.library.manoa.hawaii.edu/bitstream/10524/239/2/JL26215.pdf">
+# http://evols.library.manoa.hawaii.edu/bitstream/10524/239/2/JL26215.pdf
+# </a>
+# and indicates that standard time was adopted effective noon, January
+# 13, 1896 (page 218), that in "1933, the Legislature decreed daylight
+# saving for the period between the last Sunday of each April and the
+# last Sunday of each September, but less than a month later repealed the
+# act," (page 220), that year-round daylight saving time was in effect
+# from 1942-02-09 to 1945-09-30 (page 221, with no time of day given for
+# when clocks changed) and that clocks were changed by 30 minutes
+# effective the second Sunday of June, 1947 (page 219, with no time of
+# day given for when clocks changed). A footnote for the 1933 changes
+# cites Session Laws of Hawaii 1933, "Act. 90 (approved 26 Apr. 1933)
+# and Act 163 (approved 21 May 1933)."
+
+# From Arthur David Olson (2011-01-19):
+# The following is from "Laws of the Territory of Hawaii Passed by the
+# Seventeenth Legislature: Regular Session 1933," available (as of
+# 2011-01-19) at American University's Pence Law Library. Page 85: "Act
+# 90...At 2 o'clock ante meridian of the last Sunday in April of each
+# year, the standard time of this Territory shall be advanced one
+# hour...This Act shall take effect upon its approval. Approved this 26th
+# day of April, A. D. 1933. LAWRENCE M JUDD, Governor of the Territory of
+# Hawaii." Page 172:  "Act 163...Act 90 of the Session Laws of 1933 is
+# hereby repealed...This Act shall take effect upon its approval, upon
+# which date the standard time of this Territory shall be restored to
+# that existing immediately prior to the taking effect of said Act 90.
+# Approved this 21st day of May, A. D. 1933. LAWRENCE M. JUDD, Governor
+# of the Territory of Hawaii."
 #
-# From Paul Eggert:
-# Shanks says the 1933 experiment lasted for three weeks.  Go with Shanks.
-#
-Zone Pacific/Honolulu	-10:31:26 -	LMT	1900 Jan  1 12:00
-			-10:30	-	HST	1933 Apr 30 2:00
-			-10:30	1:00	HDT	1933 May 21 2:00
-			-10:30	US	H%sT	1947 Jun  8 2:00
+# Note that 1933-05-21 was a Sunday.
+# We're left to guess the time of day when Act 163 was approved; guess noon.
+
+Zone Pacific/Honolulu	-10:31:26 -	LMT	1896 Jan 13 12:00 #Schmitt&Cox
+			-10:30	-	HST	1933 Apr 30 2:00 #Laws 1933
+			-10:30	1:00	HDT	1933 May 21 12:00 #Laws 1933+12
+			-10:30	-	HST	1942 Feb 09 2:00 #Schmitt&Cox+2
+			-10:30	1:00	HDT	1945 Sep 30 2:00 #Schmitt&Fox+2
+			-10:30	US	H%sT	1947 Jun  8 2:00 #Schmitt&Fox+2
 			-10:00	-	HST
 
 # Now we turn to US areas that have diverged from the consensus since 1970.
--- a/jdk/make/sun/javazic/tzdata/zone.tab	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/javazic/tzdata/zone.tab	Mon Mar 07 11:37:54 2011 -0800
@@ -233,8 +233,8 @@
 HU	+4730+01905	Europe/Budapest
 ID	-0610+10648	Asia/Jakarta	Java & Sumatra
 ID	-0002+10920	Asia/Pontianak	west & central Borneo
-ID	-0507+11924	Asia/Makassar	east & south Borneo, Celebes, Bali, Nusa Tengarra, west Timor
-ID	-0232+14042	Asia/Jayapura	Irian Jaya & the Moluccas
+ID	-0507+11924	Asia/Makassar	east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
+ID	-0232+14042	Asia/Jayapura	west New Guinea (Irian Jaya) & Malukus (Moluccas)
 IE	+5320-00615	Europe/Dublin
 IL	+3146+03514	Asia/Jerusalem
 IM	+5409-00428	Europe/Isle_of_Man
@@ -426,6 +426,7 @@
 US	+450628-0873651	America/Menominee	Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
 US	+470659-1011757	America/North_Dakota/Center	Central Time - North Dakota - Oliver County
 US	+465042-1012439	America/North_Dakota/New_Salem	Central Time - North Dakota - Morton County (except Mandan area)
+US	+471551-1014640	America/North_Dakota/Beulah	Central Time - North Dakota - Mercer County
 US	+394421-1045903	America/Denver	Mountain Time
 US	+433649-1161209	America/Boise	Mountain Time - south Idaho & east Oregon
 US	+364708-1084111	America/Shiprock	Mountain Time - Navajo
--- a/jdk/make/sun/jpeg/Makefile	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/jpeg/Makefile	Mon Mar 07 11:37:54 2011 -0800
@@ -65,6 +65,19 @@
     FILES_reorder += reorder-$(ARCH)
   endif
 endif
+
+ifeq ($(PLATFORM), linux)
+
+  # Suppress gcc warnings like "variable might be clobbered by 'longjmp'
+  # or 'vfork'": this warning indicates that some variable is placed to
+  # a register by optimized compiler and it's value might be lost on longjmp().
+  # Recommended way to avoid such warning is to declare the variable as
+  # volatile to prevent the optimization. However, this approach does not
+  # work because we have to declare all variables as volatile in result.
+
+  OTHER_CFLAGS += -Wno-clobbered
+endif
+
 include $(BUILDDIR)/common/Mapfile-vers.gmk
 include $(BUILDDIR)/common/Library.gmk
 
--- a/jdk/make/sun/jpeg/reorder-i586	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/jpeg/reorder-i586	Mon Mar 07 11:37:54 2011 -0800
@@ -22,7 +22,7 @@
 text: .text%alloc_small: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o;
 text: .text%reset_marker_reader: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%jIInCtlr;
-text: .text%GET_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o;
+# text: .text%GET_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o;
 text: .text%jReadHeader;
 text: .text%jConsumeInput;
 text: .text%reset_input_controller: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
@@ -30,36 +30,36 @@
 text: .text%sun_jpeg_init_source;
 text: .text%consume_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
 text: .text%read_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
-text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%sun_jpeg_fill_input_buffer;
-text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o;
-text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o;
+# text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%emit_message: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jerror.o;
-text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%get_interesting_appn: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
-text: .text%examine_app0: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%examine_app0: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%skip_variable: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%sun_jpeg_skip_input_data;
-text: .text%examine_app14: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%examine_app14: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%get_dqt: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%jAlcQTable;
 text: .text%get_sof: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
-text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%get_dht: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%jAlcHTable;
 text: .text%get_sos: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
-text: .text%initial_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
+# text: .text%initial_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
 text: .text%jDivRound;
-text: .text%default_decompress_parms: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapimin.o;
+# text: .text%default_decompress_parms: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapimin.o;
 text: .text%jHasMultScn;
 text: .text%jStrtDecompress;
 text: .text%jIDMaster;
-text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
+# text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%jCalcDimensions;
-text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
-text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
+# text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
+# text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%jIDColor;
-text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o;
+# text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o;
 text: .text%jIUpsampler;
 text: .text%jRound;
 text: .text%alloc_sarray: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o;
@@ -70,16 +70,16 @@
 text: .text%jIHDecoder;
 text: .text%jIDCoefC;
 text: .text%jIDMainC;
-text: .text%alloc_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
+# text: .text%alloc_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
 text: .text%realize_virt_arrays: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o;
 text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
-text: .text%per_scan_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
-text: .text%latch_quant_tables: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
+# text: .text%per_scan_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
+# text: .text%latch_quant_tables: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
 text: .text%start_pass_huff_decoder: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o;
 text: .text%jMkDDerived;
 text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
-text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
-text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapistd.o;
+# text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
+# text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapistd.o;
 text: .text%prepare_for_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%start_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jddctmgr.o;
 text: .text%start_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
@@ -87,7 +87,7 @@
 text: .text%start_pass_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o;
 text: .text%start_pass_dpost: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdpostct.o;
 text: .text%start_pass_main: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
-text: .text%make_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
+# text: .text%make_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
 text: .text%jReadScanlines;
 text: .text%process_data_context_main: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
 text: .text%decompress_onepass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
@@ -100,11 +100,11 @@
 text: .text%fullsize_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o;
 text: .text%h2v2_fancy_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o;
 text: .text%ycc_rgb_convert: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o;
-text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
-text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o;
+# text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
+# text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o;
 text: .text%read_restart_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%finish_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
-text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
+# text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
 text: .text%jFinDecompress;
 text: .text%finish_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%sun_jpeg_term_source;
--- a/jdk/make/sun/jpeg/reorder-sparc	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/jpeg/reorder-sparc	Mon Mar 07 11:37:54 2011 -0800
@@ -30,10 +30,10 @@
 text: .text%sun_jpeg_init_source;
 text: .text%consume_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
 text: .text%read_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
-text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%sun_jpeg_fill_input_buffer;
 text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o;
-text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%emit_message: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jerror.o;
 text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%get_interesting_appn: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
@@ -44,7 +44,7 @@
 text: .text%get_dqt: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%jAlcQTable;
 text: .text%get_sof: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
-text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
+# text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%get_dht: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%jAlcHTable;
 text: .text%get_sos: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
@@ -56,10 +56,10 @@
 text: .text%jIDMaster;
 text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%jCalcDimensions;
-text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
-text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
+# text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
+# text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%jIDColor;
-text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o;
+# text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o;
 text: .text%jIUpsampler;
 text: .text%jRound;
 text: .text%alloc_sarray: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o;
@@ -78,7 +78,7 @@
 text: .text%start_pass_huff_decoder: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o;
 text: .text%jMkDDerived;
 text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
-text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
+# text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o;
 text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapistd.o;
 text: .text%prepare_for_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%start_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jddctmgr.o;
@@ -100,11 +100,11 @@
 text: .text%fullsize_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o;
 text: .text%h2v2_fancy_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o;
 text: .text%ycc_rgb_convert: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o;
-text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
-text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o;
+# text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
+#text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o;
 text: .text%read_restart_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o;
 text: .text%finish_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o;
-text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
+# text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o;
 text: .text%jFinDecompress;
 text: .text%finish_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o;
 text: .text%sun_jpeg_term_source;
--- a/jdk/make/sun/jpeg/reorder-sparcv9	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/make/sun/jpeg/reorder-sparcv9	Mon Mar 07 11:37:54 2011 -0800
@@ -30,10 +30,10 @@
 text: .text%sun_jpeg_init_source;
 text: .text%consume_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdinput.o;
 text: .text%read_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
-text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
+# text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
 text: .text%sun_jpeg_fill_input_buffer;
 text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jpegdecoder.o;
-text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
+# text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
 text: .text%emit_message: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jerror.o;
 text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
 text: .text%get_interesting_appn: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
@@ -44,7 +44,7 @@
 text: .text%get_dqt: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
 text: .text%jAlcQTable;
 text: .text%get_sof: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
-text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
+# text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
 text: .text%get_dht: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
 text: .text%jAlcHTable;
 text: .text%get_sos: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
@@ -56,10 +56,10 @@
 text: .text%jIDMaster;
 text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o;
 text: .text%jCalcDimensions;
-text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o;
-text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o;
+# text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o;
+# text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o;
 text: .text%jIDColor;
-text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcolor.o;
+# text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcolor.o;
 text: .text%jIUpsampler;
 text: .text%jRound;
 text: .text%alloc_sarray: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jmemmgr.o;
@@ -78,7 +78,7 @@
 text: .text%start_pass_huff_decoder: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdhuff.o;
 text: .text%jMkDDerived;
 text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcoefct.o;
-text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcoefct.o;
+# text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcoefct.o;
 text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdapistd.o;
 text: .text%prepare_for_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o;
 text: .text%start_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jddctmgr.o;
@@ -100,11 +100,11 @@
 text: .text%fullsize_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdsample.o;
 text: .text%h2v2_fancy_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdsample.o;
 text: .text%ycc_rgb_convert: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcolor.o;
-text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o;
+# text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o;
 text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdhuff.o;
 text: .text%read_restart_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o;
 text: .text%finish_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdinput.o;
-text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o;
+# text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o;
 text: .text%jFinDecompress;
 text: .text%finish_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o;
 text: .text%sun_jpeg_term_source;
--- a/jdk/src/share/classes/com/sun/media/sound/services/javax.sound.sampled.spi.FormatConversionProvider	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/com/sun/media/sound/services/javax.sound.sampled.spi.FormatConversionProvider	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 # Providers for FormatConversion
+com.sun.media.sound.AudioFloatFormatConverter
 com.sun.media.sound.UlawCodec
 com.sun.media.sound.AlawCodec
 com.sun.media.sound.PCMtoPCMCodec
-com.sun.media.sound.AudioFloatFormatConverter
--- a/jdk/src/share/classes/java/dyn/CallSite.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/CallSite.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -78,7 +78,7 @@
 }
 private static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String name, MethodType type) {
   // ignore caller and name, but match the type:
-  return new ConstantCallSite(MethodHandles.collectArguments(printArgs, type));
+  return new ConstantCallSite(printArgs.asType(type));
 }
 </pre></blockquote>
  * @author John Rose, JSR 292 EG
@@ -86,6 +86,7 @@
 abstract
 public class CallSite {
     private static final Access IMPL_TOKEN = Access.getToken();
+    static { MethodHandleImpl.initStatics(); }
 
     // Fields used only by the JVM.  Do not use or change.
     private MemberName vmmethod; // supplied by the JVM (ref. to calling method)
@@ -125,8 +126,8 @@
     }
 
     /**
-     * Report the type of this call site's target.
-     * Although targets may change, the call site's type can never change.
+     * Returns the type of this call site's target.
+     * Although targets may change, any call site's type is permanent, and can never change to an unequal type.
      * The {@code setTarget} method enforces this invariant by refusing any new target that does
      * not have the previous target's type.
      * @return the type of the current target, which is also the type of any future target
@@ -154,73 +155,40 @@
     }
 
     /**
-     * Report the current linkage state of the call site, a value which may change over time.
-     * <p>
-     * If a {@code CallSite} object is returned
-     * from the bootstrap method of the {@code invokedynamic} instruction,
-     * the {@code CallSite} is permanently bound to that instruction.
-     * When the {@code invokedynamic} instruction is executed, the target method
-     * of its associated call site object is invoked directly.
-     * It is as if the instruction calls {@code getTarget} and then
-     * calls {@link MethodHandle#invokeExact invokeExact} on the result.
-     * <p>
-     * Unless specified differently by a subclass,
-     * the interactions of {@code getTarget} with memory are the same
-     * as of a read from an ordinary variable, such as an array element or a
-     * non-volatile, non-final field.
-     * <p>
-     * In particular, the current thread may choose to reuse the result
-     * of a previous read of the target from memory, and may fail to see
-     * a recent update to the target by another thread.
-     * <p>
-     * In a {@linkplain ConstantCallSite constant call site}, the {@code getTarget} method behaves
-     * like a read from a {@code final} field of the {@code CallSite}.
-     * <p>
-     * In a {@linkplain VolatileCallSite volatile call site}, the {@code getTarget} method behaves
-     * like a read from a {@code volatile} field of the {@code CallSite}.
-     * <p>
-     * This method may not be overridden by application code.
+     * Returns the target method of the call site, according to the
+     * behavior defined by this call site's specific class.
+     * The immediate subclasses of {@code CallSite} document the
+     * class-specific behaviors of this method.
+     *
      * @return the current linkage state of the call site, its target method handle
      * @see ConstantCallSite
      * @see VolatileCallSite
      * @see #setTarget
+     * @see ConstantCallSite#getTarget
+     * @see MutableCallSite#getTarget
+     * @see VolatileCallSite#getTarget
      */
-    public final MethodHandle getTarget() {
-        return getTarget0();
-    }
+    public abstract MethodHandle getTarget();
 
     /**
-     * Privileged implementations can override this to force final or volatile semantics on getTarget.
-     */
-    /*package-private*/
-    MethodHandle getTarget0() {
-        return target;
-    }
-
-    /**
-     * Set the target method of this call site.
+     * Updates the target method of this call site, according to the
+     * behavior defined by this call site's specific class.
+     * The immediate subclasses of {@code CallSite} document the
+     * class-specific behaviors of this method.
      * <p>
-     * Unless a subclass of CallSite documents otherwise,
-     * the interactions of {@code setTarget} with memory are the same
-     * as of a write to an ordinary variable, such as an array element or a
-     * non-volatile, non-final field.
-     * <p>
-     * In particular, unrelated threads may fail to see the updated target
-     * until they perform a read from memory.
-     * Stronger guarantees can be created by putting appropriate operations
-     * into the bootstrap method and/or the target methods used
-     * at any given call site.
+     * The type of the new target must be {@linkplain MethodType#equals equal to}
+     * the type of the old target.
+     *
      * @param newTarget the new target
      * @throws NullPointerException if the proposed new target is null
      * @throws WrongMethodTypeException if the proposed new target
      *         has a method type that differs from the previous target
-     * @throws UnsupportedOperationException if the call site is
-     *         in fact a {@link ConstantCallSite}
+     * @see CallSite#getTarget
+     * @see ConstantCallSite#setTarget
+     * @see MutableCallSite#setTarget
+     * @see VolatileCallSite#setTarget
      */
-    public void setTarget(MethodHandle newTarget) {
-        checkTargetChange(this.target, newTarget);
-        setTargetNormal(newTarget);
-    }
+    public abstract void setTarget(MethodHandle newTarget);
 
     void checkTargetChange(MethodHandle oldTarget, MethodHandle newTarget) {
         MethodType oldType = oldTarget.type();
@@ -236,31 +204,31 @@
     /**
      * Produce a method handle equivalent to an invokedynamic instruction
      * which has been linked to this call site.
-     * <p>If this call site is a {@linkplain ConstantCallSite constant call site},
-     * this method simply returns the call site's target, since that will never change.
-     * <p>Otherwise, this method is equivalent to the following code:
-     * <p><blockquote><pre>
+     * <p>
+     * This method is equivalent to the following code:
+     * <blockquote><pre>
      * MethodHandle getTarget, invoker, result;
-     * getTarget = MethodHandles.lookup().bind(this, "getTarget", MethodType.methodType(MethodHandle.class));
+     * getTarget = MethodHandles.publicLookup().bind(this, "getTarget", MethodType.methodType(MethodHandle.class));
      * invoker = MethodHandles.exactInvoker(this.type());
      * result = MethodHandles.foldArguments(invoker, getTarget)
      * </pre></blockquote>
+     *
      * @return a method handle which always invokes this call site's current target
      */
-    public final MethodHandle dynamicInvoker() {
-        if (this instanceof ConstantCallSite) {
-            return getTarget0();  // will not change dynamically
-        }
+    public abstract MethodHandle dynamicInvoker();
+
+    /*non-public*/ MethodHandle makeDynamicInvoker() {
         MethodHandle getTarget = MethodHandleImpl.bindReceiver(IMPL_TOKEN, GET_TARGET, this);
         MethodHandle invoker = MethodHandles.exactInvoker(this.type());
         return MethodHandles.foldArguments(invoker, getTarget);
     }
+
     private static final MethodHandle GET_TARGET;
     static {
         try {
             GET_TARGET = MethodHandles.Lookup.IMPL_LOOKUP.
                 findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
-        } catch (NoAccessException ignore) {
+        } catch (ReflectiveOperationException ignore) {
             throw new InternalError();
         }
     }
--- a/jdk/src/share/classes/java/dyn/ClassValue.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/ClassValue.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -31,10 +31,14 @@
 import java.lang.reflect.UndeclaredThrowableException;
 
 /**
- * Lazily associate a computed value with (potentially) every class.
+ * Lazily associate a computed value with (potentially) every type.
+ * For example, if a dynamic language needs to construct a message dispatch
+ * table for each class encountered at a message send call site,
+ * it can use a {@code ClassValue} to cache information needed to
+ * perform the message send quickly, for each class encountered.
  * @author John Rose, JSR 292 EG
  */
-public class ClassValue<T> {
+public abstract class ClassValue<T> {
     /**
      * Compute the given class's derived value for this {@code ClassValue}.
      * <p>
@@ -45,61 +49,41 @@
      * but it may be invoked again if there has been a call to
      * {@link #remove remove}.
      * <p>
-     * If there is no override from a subclass, this method returns
-     * the result of applying the {@code ClassValue}'s {@code computeValue}
-     * method handle, which was supplied at construction time.
+     * If this method throws an exception, the corresponding call to {@code get}
+     * will terminate abnormally with that exception, and no class value will be recorded.
      *
+     * @param type the type whose class value must be computed
      * @return the newly computed value associated with this {@code ClassValue}, for the given class or interface
-     * @throws UndeclaredThrowableException if the {@code computeValue} method handle invocation throws something other than a {@code RuntimeException} or {@code Error}
-     * @throws UnsupportedOperationException if the {@code computeValue} method handle is null (subclasses must override)
+     * @see #get
+     * @see #remove
      */
-    protected T computeValue(Class<?> type) {
-        if (computeValue == null)
-            return null;
-        try {
-            return (T) (Object) computeValue.invokeGeneric(type);
-        } catch (Throwable ex) {
-            if (ex instanceof Error)             throw (Error) ex;
-            if (ex instanceof RuntimeException)  throw (RuntimeException) ex;
-            throw new UndeclaredThrowableException(ex);
-        }
-    }
-
-    private final MethodHandle computeValue;
-
-    /**
-     * Creates a new class value.
-     * Subclasses which use this constructor must override
-     * the {@link #computeValue computeValue} method,
-     * since the default {@code computeValue} method requires a method handle,
-     * which this constructor does not provide.
-     */
-    protected ClassValue() {
-        this.computeValue = null;
-    }
-
-    /**
-     * Creates a new class value, whose {@link #computeValue computeValue} method
-     * will return the result of {@code computeValue.invokeGeneric(type)}.
-     * @throws NullPointerException  if the method handle parameter is null
-     */
-    public ClassValue(MethodHandle computeValue) {
-        computeValue.getClass();  // trigger NPE if null
-        this.computeValue = computeValue;
-    }
+    protected abstract T computeValue(Class<?> type);
 
     /**
      * Returns the value for the given class.
      * If no value has yet been computed, it is obtained by
-     * by an invocation of the {@link #computeValue computeValue} method.
+     * an invocation of the {@link #computeValue computeValue} method.
      * <p>
      * The actual installation of the value on the class
      * is performed atomically.
-     * At that point, if racing threads have
+     * At that point, if several racing threads have
      * computed values, one is chosen, and returned to
      * all the racing threads.
+     * <p>
+     * The {@code type} parameter is typically a class, but it may be any type,
+     * such as an interface, a primitive type (like {@code int.class}), or {@code void.class}.
+     * <p>
+     * In the absence of {@code remove} calls, a class value has a simple
+     * state diagram:  uninitialized and initialized.
+     * When {@code remove} calls are made,
+     * the rules for value observation are more complex.
+     * See the documentation for {@link #remove remove} for more information.
      *
+     * @param type the type whose class value must be computed or retrieved
      * @return the current value associated with this {@code ClassValue}, for the given class or interface
+     * @throws NullPointerException if the argument is null
+     * @see #remove
+     * @see #computeValue
      */
     public T get(Class<?> type) {
         ClassValueMap map = getMap(type);
@@ -119,12 +103,51 @@
      * This may result in an additional invocation of the
      * {@code computeValue computeValue} method for the given class.
      * <p>
-     * If racing threads perform a combination of {@code get} and {@code remove} calls,
-     * the calls are serialized.
-     * A value produced by a call to {@code computeValue} will be discarded, if
-     * the corresponding {@code get} call was followed by a {@code remove} call
-     * before the {@code computeValue} could complete.
-     * In such a case, the {@code get} call will re-invoke {@code computeValue}.
+     * In order to explain the interaction between {@code get} and {@code remove} calls,
+     * we must model the state transitions of a class value to take into account
+     * the alternation between uninitialized and initialized states.
+     * To do this, number these states sequentially from zero, and note that
+     * uninitialized (or removed) states are numbered with even numbers,
+     * while initialized (or re-initialized) states have odd numbers.
+     * <p>
+     * When a thread {@code T} removes a class value in state {@code 2N},
+     * nothing happens, since the class value is already uninitialized.
+     * Otherwise, the state is advanced atomically to {@code 2N+1}.
+     * <p>
+     * When a thread {@code T} queries a class value in state {@code 2N},
+     * the thread first attempts to initialize the class value to state {@code 2N+1}
+     * by invoking {@code computeValue} and installing the resulting value.
+     * <p>
+     * When {@code T} attempts to install the newly computed value,
+     * if the state is still at {@code 2N}, the class value will be initialized
+     * with the computed value, advancing it to state {@code 2N+1}.
+     * <p>
+     * Otherwise, whether the new state is even or odd,
+     * {@code T} will discard the newly computed value
+     * and retry the {@code get} operation.
+     * <p>
+     * Discarding and retrying is an important proviso,
+     * since otherwise {@code T} could potentially install
+     * a disastrously stale value.  For example:
+     * <ul>
+     * <li>{@code T} calls {@code CV.get(C)} and sees state {@code 2N}
+     * <li>{@code T} quickly computes a time-dependent value {@code V0} and gets ready to install it
+     * <li>{@code T} is hit by an unlucky paging or scheduling event, and goes to sleep for a long time
+     * <li>...meanwhile, {@code T2} also calls {@code CV.get(C)} and sees state {@code 2N}
+     * <li>{@code T2} quickly computes a similar time-dependent value {@code V1} and installs it on {@code CV.get(C)}
+     * <li>{@code T2} (or a third thread) then calls {@code CV.remove(C)}, undoing {@code T2}'s work
+     * <li> the previous actions of {@code T2} are repeated several times
+     * <li> also, the relevant computed values change over time: {@code V1}, {@code V2}, ...
+     * <li>...meanwhile, {@code T} wakes up and attempts to install {@code V0}; <em>this must fail</em>
+     * </ul>
+     * We can assume in the above scenario that {@code CV.computeValue} uses locks to properly
+     * observe the time-dependent states as it computes {@code V1}, etc.
+     * This does not remove the threat of a stale value, since there is a window of time
+     * between the return of {@code computeValue} in {@code T} and the installation
+     * of the the new value.  No user synchronization is possible during this time.
+     *
+     * @param type the type whose class value must be removed
+     * @throws NullPointerException if the argument is null
      */
     public void remove(Class<?> type) {
         ClassValueMap map = getMap(type);
@@ -137,9 +160,9 @@
 
     /// Implementation...
 
-    /** The hash code for this type is based on the identity of the object,
-     *  and is well-dispersed for power-of-two tables.
-     */
+    // The hash code for this type is based on the identity of the object,
+    // and is well-dispersed for power-of-two tables.
+    /** @deprecated This override, which is implementation-specific, will be removed for PFD. */
     public final int hashCode() { return hashCode; }
     private final int hashCode = HASH_CODES.getAndAdd(0x61c88647);
     private static final AtomicInteger HASH_CODES = new AtomicInteger();
--- a/jdk/src/share/classes/java/dyn/ConstantCallSite.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/ConstantCallSite.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -32,16 +32,46 @@
  * @author John Rose, JSR 292 EG
  */
 public class ConstantCallSite extends CallSite {
-    /** Create a call site with a permanent target.
+    /**
+     * Creates a call site with a permanent target.
+     * @param target the target to be permanently associated with this call site
      * @throws NullPointerException if the proposed target is null
      */
     public ConstantCallSite(MethodHandle target) {
         super(target);
     }
+
     /**
-     * Throw an {@link UnsupportedOperationException}, because this kind of call site cannot change its target.
+     * Returns the target method of the call site, which behaves
+     * like a {@code final} field of the {@code ConstantCallSite}.
+     * That is, the the target is always the original value passed
+     * to the constructor call which created this instance.
+     *
+     * @return the immutable linkage state of this call site, a constant method handle
+     * @throws UnsupportedOperationException because this kind of call site cannot change its target
+     */
+    @Override public final MethodHandle getTarget() {
+        return target;
+    }
+
+    /**
+     * Always throws an {@link UnsupportedOperationException}.
+     * This kind of call site cannot change its target.
+     * @param ignore a new target proposed for the call site, which is ignored
+     * @throws UnsupportedOperationException because this kind of call site cannot change its target
      */
     @Override public final void setTarget(MethodHandle ignore) {
         throw new UnsupportedOperationException("ConstantCallSite");
     }
+
+    /**
+     * Returns this call site's permanent target.
+     * Since that target will never change, this is a correct implementation
+     * of {@link CallSite#dynamicInvoker CallSite.dynamicInvoker}.
+     * @return the immutable linkage state of this call site, a constant method handle
+     */
+    @Override
+    public final MethodHandle dynamicInvoker() {
+        return getTarget();
+    }
 }
--- a/jdk/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java	Mon Mar 07 11:37:54 2011 -0800
@@ -31,8 +31,8 @@
  * {@linkplain BootstrapMethod bootstrap method},
  * or the bootstrap method has
  * failed to provide a
- * {@linkplain CallSite} call site with a non-null {@linkplain MethodHandle target}
- * of the correct {@linkplain MethodType method type}.
+ * {@linkplain CallSite call site} with a {@linkplain CallSite#getTarget target}
+ * of the correct {@linkplain MethodHandle#type method type}.
  *
  * @author John Rose, JSR 292 EG
  * @since 1.7
--- a/jdk/src/share/classes/java/dyn/Linkage.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/Linkage.java	Mon Mar 07 11:37:54 2011 -0800
@@ -88,7 +88,7 @@
         MethodHandle bootstrapMethod;
         try {
             bootstrapMethod = lookup.findStatic(runtime, name, BOOTSTRAP_METHOD_TYPE);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             throw new IllegalArgumentException("no such bootstrap method in "+runtime+": "+name, ex);
         }
         MethodHandleImpl.registerBootstrap(IMPL_TOKEN, callerClass, bootstrapMethod);
@@ -101,8 +101,9 @@
     /**
      * <em>METHOD WILL BE REMOVED FOR PFD:</em>
      * Invalidate all <code>invokedynamic</code> call sites everywhere.
-     * @deprecated Use {@linkplain CallSite#setTarget call site target setting}
-     * and {@link VolatileCallSite#invalidateAll call site invalidation} instead.
+     * @deprecated Use {@linkplain MutableCallSite#setTarget call site target setting},
+     * {@link MutableCallSite#syncAll call site update pushing},
+     * and {@link SwitchPoint#guardWithTest target switching} instead.
      */
     public static
     Object invalidateAll() {
@@ -113,8 +114,9 @@
      * <em>METHOD WILL BE REMOVED FOR PFD:</em>
      * Invalidate all {@code invokedynamic} call sites in the bytecodes
      * of any methods of the given class.
-     * @deprecated Use {@linkplain CallSite#setTarget call site target setting}
-     * and {@link VolatileCallSite#invalidateAll call site invalidation} instead.
+     * @deprecated Use {@linkplain MutableCallSite#setTarget call site target setting},
+     * {@link MutableCallSite#syncAll call site update pushing},
+     * and {@link SwitchPoint#guardWithTest target switching} instead.
      */
     public static
     Object invalidateCallerClass(Class<?> callerClass) {
--- a/jdk/src/share/classes/java/dyn/MethodHandle.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/MethodHandle.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -34,7 +34,7 @@
 import static sun.dyn.MemberName.newIllegalArgumentException;  // utility
 
 /**
- * A method handle is a typed, directly executable reference to a method,
+ * A method handle is a typed, directly executable reference to an underlying method,
  * constructor, field, or similar low-level operation, with optional
  * transformations of arguments or return values.
  * These transformations are quite general, and include such patterns as
@@ -48,99 +48,182 @@
  *     will be removed before the Proposed Final Draft.
  *     Also, the final version will not include any public or
  *     protected constructors.</em>
- * <p>
- * Method handles are strongly typed according to signature.
- * They are not distinguished by method name or enclosing class.
- * A method handle must be invoked under a signature which matches
- * the method handle's own {@linkplain MethodType method type}.
+ *
+ * <h3>Method handle contents</h3>
+ * Method handles are dynamically and strongly typed according to type descriptor.
+ * They are not distinguished by the name or defining class of their underlying methods.
+ * A method handle must be invoked using type descriptor which matches
+ * the method handle's own {@linkplain #type method type}.
  * <p>
  * Every method handle reports its type via the {@link #type type} accessor.
- * The structure of this type is a series of classes, one of which is
+ * This type descriptor is a {@link java.dyn.MethodType MethodType} object,
+ * whose structure is a series of classes, one of which is
  * the return type of the method (or {@code void.class} if none).
  * <p>
- * Every method handle appears as an object containing a method named
- * {@link #invokeExact invokeExact}, whose signature exactly matches
- * the method handle's type.
- * A Java method call expression, which compiles to an
- * {@code invokevirtual} instruction,
- * can invoke this method from Java source code.
+ * A method handle's type controls the types of invocations it accepts,
+ * and the kinds of transformations that apply to it.
+ * <p>
+ * A method handle contains a pair of special invoker methods
+ * called {@link #invokeExact invokeExact} and {@link #invokeGeneric invokeGeneric}.
+ * Both invoker methods provide direct access to the method handle's
+ * underlying method, constructor, field, or other operation,
+ * as modified by transformations of arguments and return values.
+ * Both invokers accept calls which exactly match the method handle's own type.
+ * The {@code invokeGeneric} invoker also accepts a range of other call types.
+ * <p>
+ * Method handles are immutable and have no visible state.
+ * Of course, they can be bound to underlying methods or data which exhibit state.
+ * With respect to the Java Memory Model, any method handle will behave
+ * as if all of its (internal) fields are final variables.  This means that any method
+ * handle made visible to the application will always be fully formed.
+ * This is true even if the method handle is published through a shared
+ * variable in a data race.
+ * <p>
+ * Method handles cannot be subclassed by the user.
+ * Implementations may (or may not) create internal subclasses of {@code MethodHandle}
+ * which may be visible via the {@link java.lang.Object#getClass Object.getClass}
+ * operation.  The programmer should not draw conclusions about a method handle
+ * from its specific class, as the method handle class hierarchy (if any)
+ * may change from time to time or across implementations from different vendors.
+ *
+ * <h3>Method handle compilation</h3>
+ * A Java method call expression naming {@code invokeExact} or {@code invokeGeneric}
+ * can invoke a method handle from Java source code.
+ * From the viewpoint of source code, these methods can take any arguments
+ * and their result can be cast to any return type.
+ * Formally this is accomplished by giving the invoker methods
+ * {@code Object} return types and variable-arity {@code Object} arguments,
+ * but they have an additional quality called <em>signature polymorphism</em>
+ * which connects this freedom of invocation directly to the JVM execution stack.
  * <p>
- * Every call to a method handle specifies an intended method type,
- * which must exactly match the type of the method handle.
- * (The type is specified in the {@code invokevirtual} instruction,
- * via a {@code CONSTANT_NameAndType} constant pool entry.)
- * The call looks within the receiver object for a method
- * named {@code invokeExact} of the intended method type.
- * The call fails with a {@link WrongMethodTypeException}
- * if the method does not exist, even if there is an {@code invokeExact}
- * method of a closely similar signature.
- * As with other kinds
- * of methods in the JVM, signature matching during method linkage
- * is exact, and does not allow for language-level implicit conversions
- * such as {@code String} to {@code Object} or {@code short} to {@code int}.
+ * As is usual with virtual methods, source-level calls to {@code invokeExact}
+ * and {@code invokeGeneric} compile to an {@code invokevirtual} instruction.
+ * More unusually, the compiler must record the actual argument types,
+ * and may not perform method invocation conversions on the arguments.
+ * Instead, it must push them on the stack according to their own unconverted types.
+ * The method handle object itself is pushed on the stack before the arguments.
+ * The compiler then calls the method handle with a type descriptor which
+ * describes the argument and return types.
+ * <p>
+ * To issue a complete type descriptor, the compiler must also determine
+ * the return type.  This is based on a cast on the method invocation expression,
+ * if there is one, or else {@code Object} if the invocation is an expression
+ * or else {@code void} if the invocation is a statement.
+ * The cast may be to a primitive type (but not {@code void}).
  * <p>
- * Each individual method handle also contains a method named
- * {@link #invokeGeneric invokeGeneric}, whose type is the same
- * as {@code invokeExact}, and is therefore also reported by
- * the {@link #type type} accessor.
+ * As a corner case, an uncasted {@code null} argument is given
+ * a type descriptor of {@code java.lang.Void}.
+ * The ambiguity with the type {@code Void} is harmless, since there are no references of type
+ * {@code Void} except the null reference.
+ *
+ * <h3>Method handle invocation</h3>
+ * The first time a {@code invokevirtual} instruction is executed
+ * it is linked, by symbolically resolving the names in the instruction
+ * and verifying that the method call is statically legal.
+ * This is true of calls to {@code invokeExact} and {@code invokeGeneric}.
+ * In this case, the type descriptor emitted by the compiler is checked for
+ * correct syntax and names it contains are resolved.
+ * Thus, an {@code invokevirtual} instruction which invokes
+ * a method handle will always link, as long
+ * as the type descriptor is syntactically well-formed
+ * and the types exist.
+ * <p>
+ * When the {@code invokevirtual} is executed after linking,
+ * the receiving method handle's type is first checked by the JVM
+ * to ensure that it matches the descriptor.
+ * If the type match fails, it means that the method which the
+ * caller is invoking is not present on the individual
+ * method handle being invoked.
+ * <p>
+ * In the case of {@code invokeExact}, the type descriptor of the invocation
+ * (after resolving symbolic type names) must exactly match the method type
+ * of the receiving method handle.
+ * In the case of {@code invokeGeneric}, the resolved type descriptor
+ * must be a valid argument to the receiver's {@link #asType asType} method.
+ * Thus, {@code invokeGeneric} is more permissive than {@code invokeExact}.
+ * <p>
+ * After type matching, a call to {@code invokeExact} directly
+ * and immediately invoke the method handle's underlying method
+ * (or other behavior, as the case may be).
+ * <p>
  * A call to {@code invokeGeneric} works the same as a call to
- * {@code invokeExact}, if the signature specified by the caller
+ * {@code invokeExact}, if the type descriptor specified by the caller
  * exactly matches the method handle's own type.
  * If there is a type mismatch, {@code invokeGeneric} attempts
- * to adjust the type of the target method handle
- * (as if by a call to {@link #asType asType})
- * to obtain an exactly invokable target.
+ * to adjust the type of the receiving method handle,
+ * as if by a call to {@link #asType asType},
+ * to obtain an exactly invokable method handle {@code M2}.
  * This allows a more powerful negotiation of method type
  * between caller and callee.
  * <p>
- * A method handle is an unrestricted capability to call a method.
- * A method handle can be formed on a non-public method by a class
- * that has access to that method; the resulting handle can be used
- * in any place by any caller who receives a reference to it.  Thus, access
- * checking is performed when the method handle is created, not
- * (as in reflection) every time it is called.  Handles to non-public
- * methods, or in non-public classes, should generally be kept secret.
+ * (Note: The adjusted method handle {@code M2} is not directly observable,
+ * and implementations are therefore not required to materialize it.)
+ *
+ * <h3>Invocation checking</h3>
+ * In typical programs, method handle type matching will usually succeed.
+ * But if a match fails, the JVM will throw a {@link WrongMethodTypeException},
+ * either directly (in the case of {@code invokeExact}) or indirectly as if
+ * by a failed call to {@code asType} (in the case of {@code invokeGeneric}).
+ * <p>
+ * Thus, a method type mismatch which might show up as a linkage error
+ * in a statically typed program can show up as
+ * a dynamic {@code WrongMethodTypeException}
+ * in a program which uses method handles.
+ * <p>
+ * Because method types contain "live" {@code Class} objects,
+ * method type matching takes into account both types names and class loaders.
+ * Thus, even if a method handle {@code M} is created in one
+ * class loader {@code L1} and used in another {@code L2},
+ * method handle calls are type-safe, because the caller's type
+ * descriptor, as resolved in {@code L2},
+ * is matched against the original callee method's type descriptor,
+ * as resolved in {@code L1}.
+ * The resolution in {@code L1} happens when {@code M} is created
+ * and its type is assigned, while the resolution in {@code L2} happens
+ * when the {@code invokevirtual} instruction is linked.
+ * <p>
+ * Apart from the checking of type descriptors,
+ * a method handle's capability to call its underlying method is unrestricted.
+ * If a method handle is formed on a non-public method by a class
+ * that has access to that method, the resulting handle can be used
+ * in any place by any caller who receives a reference to it.
+ * <p>
+ * Unlike with the Core Reflection API, where access is checked every time
+ * a reflective method is invoked,
+ * method handle access checking is performed
+ * <a href="MethodHandles.Lookup.html#access">when the method handle is created</a>.
+ * In the case of {@code ldc} (see below), access checking is performed as part of linking
+ * the constant pool entry underlying the constant method handle.
+ * <p>
+ * Thus, handles to non-public methods, or to methods in non-public classes,
+ * should generally be kept secret.
  * They should not be passed to untrusted code unless their use from
  * the untrusted code would be harmless.
- * <p>
- * Bytecode in the JVM can directly call a method handle's
- * {@code invokeExact} method from an {@code invokevirtual} instruction.
- * The receiver class type must be {@code MethodHandle} and the method name
- * must be {@code invokeExact}.  The signature of the invocation
- * (after resolving symbolic type names) must exactly match the method type
- * of the target method.
- * Similarly, bytecode can directly call a method handle's {@code invokeGeneric}
- * method.  The signature of the invocation (after resolving symbolic type names)
- * must either exactly match the method type or be a valid argument to
- * the target's {@link #asType asType} method.
+ *
+ * <h3>Method handle creation</h3>
+ * Java code can create a method handle that directly accesses
+ * any method, constructor, or field that is accessible to that code.
+ * This is done via a reflective, capability-based API called
+ * {@link java.dyn.MethodHandles.Lookup MethodHandles.Lookup}
+ * For example, a static method handle can be obtained
+ * from {@link java.dyn.MethodHandles.Lookup#findStatic Lookup.findStatic}.
+ * There are also conversion methods from Core Reflection API objects,
+ * such as {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}.
  * <p>
- * Every {@code invokeExact} and {@code invokeGeneric} method always
- * throws {@link java.lang.Throwable Throwable},
- * which is to say that there is no static restriction on what a method handle
- * can throw.  Since the JVM does not distinguish between checked
- * and unchecked exceptions (other than by their class, of course),
- * there is no particular effect on bytecode shape from ascribing
- * checked exceptions to method handle invocations.  But in Java source
- * code, methods which perform method handle calls must either explicitly
- * throw {@code java.lang.Throwable Throwable}, or else must catch all
- * throwables locally, rethrowing only those which are legal in the context,
- * and wrapping ones which are illegal.
- * <p>
- * Bytecode in the JVM can directly obtain a method handle
- * for any accessible method from a {@code ldc} instruction
- * which refers to a {@code CONSTANT_MethodHandle} constant pool entry.
- * (Each such entry refers directly to a {@code CONSTANT_Methodref},
+ * Like classes and strings, method handles that correspond to accessible
+ * fields, methods, and constructors can also be represented directly
+ * in a class file's constant pool as constants to be loaded by {@code ldc} bytecodes.
+ * A new type of constant pool entry, {@code CONSTANT_MethodHandle},
+ * refers directly to an associated {@code CONSTANT_Methodref},
  * {@code CONSTANT_InterfaceMethodref}, or {@code CONSTANT_Fieldref}
  * constant pool entry.
- * For more details, see the <a href="package-summary.html#mhcon">package summary</a>.)
+ * (For more details on method handle constants,
+ * see the <a href="package-summary.html#mhcon">package summary</a>.)
  * <p>
- * Java code can also use a reflective API called
- * {@link java.dyn.MethodHandles.Lookup MethodHandles.Lookup}
- * for creating and calling method handles.
- * For example, a static method handle can be obtained
- * from {@link java.dyn.MethodHandles.Lookup#findStatic Lookup.findStatic}.
- * There are also bridge methods from Core Reflection API objects,
- * such as {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.ureflect}.
+ * Method handles produced by lookups or constant loads from methods or
+ * constructors with the variable arity modifier bit ({@code 0x0080})
+ * have a corresponding variable arity, as if they were defined with
+ * the help of {@link #asVarargsCollector asVarargsCollector}.
  * <p>
  * A method reference may refer either to a static or non-static method.
  * In the non-static case, the method handle type includes an explicit
@@ -153,61 +236,191 @@
  * When a method handle to a virtual method is invoked, the method is
  * always looked up in the receiver (that is, the first argument).
  * <p>
- * A non-virtual method handles to a specific virtual method implementation
+ * A non-virtual method handle to a specific virtual method implementation
  * can also be created.  These do not perform virtual lookup based on
  * receiver type.  Such a method handle simulates the effect of
  * an {@code invokespecial} instruction to the same method.
- * <p>
+ *
+ * <h3>Usage examples</h3>
  * Here are some examples of usage:
  * <p><blockquote><pre>
 Object x, y; String s; int i;
 MethodType mt; MethodHandle mh;
 MethodHandles.Lookup lookup = MethodHandles.lookup();
-// mt is {(char,char) =&gt; String}
+// mt is (char,char)String
 mt = MethodType.methodType(String.class, char.class, char.class);
 mh = lookup.findVirtual(String.class, "replace", mt);
-// (Ljava/lang/String;CC)Ljava/lang/String;
 s = (String) mh.invokeExact("daddy",'d','n');
+// invokeExact(Ljava/lang/String;CC)Ljava/lang/String;
 assert(s.equals("nanny"));
 // weakly typed invocation (using MHs.invoke)
 s = (String) mh.invokeWithArguments("sappy", 'p', 'v');
 assert(s.equals("savvy"));
-// mt is {Object[] =&gt; List}
+// mt is (Object[])List
 mt = MethodType.methodType(java.util.List.class, Object[].class);
 mh = lookup.findStatic(java.util.Arrays.class, "asList", mt);
-// mt is {(Object,Object,Object) =&gt; Object}
+assert(mh.isVarargsCollector());
+x = mh.invokeGeneric("one", "two");
+// invokeGeneric(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;
+assert(x.equals(java.util.Arrays.asList("one","two")));
+// mt is (Object,Object,Object)Object
 mt = MethodType.genericMethodType(3);
-mh = MethodHandles.collectArguments(mh, mt);
-// mt is {(Object,Object,Object) =&gt; Object}
-// (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
+mh = mh.asType(mt);
 x = mh.invokeExact((Object)1, (Object)2, (Object)3);
+// invokeExact(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
 assert(x.equals(java.util.Arrays.asList(1,2,3)));
 // mt is { =&gt; int}
 mt = MethodType.methodType(int.class);
 mh = lookup.findVirtual(java.util.List.class, "size", mt);
-// (Ljava/util/List;)I
 i = (int) mh.invokeExact(java.util.Arrays.asList(1,2,3));
+// invokeExact(Ljava/util/List;)I
 assert(i == 3);
 mt = MethodType.methodType(void.class, String.class);
 mh = lookup.findVirtual(java.io.PrintStream.class, "println", mt);
 mh.invokeExact(System.out, "Hello, world.");
-// (Ljava/io/PrintStream;Ljava/lang/String;)V
+// invokeExact(Ljava/io/PrintStream;Ljava/lang/String;)V
  * </pre></blockquote>
- * Each of the above calls generates a single invokevirtual instruction
- * with the name {@code invoke} and the type descriptors indicated in the comments.
- * The argument types are taken directly from the actual arguments,
- * while the return type is taken from the cast immediately applied to the call.
- * This cast may be to a primitive.
- * If it is missing, the type defaults to {@code Object} if the call
- * occurs in a context which uses the return value.
- * If the call occurs as a statement, a cast is impossible,
- * and there is no return type; the call is {@code void}.
+ * Each of the above calls to {@code invokeExact} or {@code invokeGeneric}
+ * generates a single invokevirtual instruction with
+ * the type descriptor indicated in the following comment.
+ *
+ * <h3>Exceptions</h3>
+ * The methods {@code invokeExact} and {@code invokeGeneric} are declared
+ * to throw {@link java.lang.Throwable Throwable},
+ * which is to say that there is no static restriction on what a method handle
+ * can throw.  Since the JVM does not distinguish between checked
+ * and unchecked exceptions (other than by their class, of course),
+ * there is no particular effect on bytecode shape from ascribing
+ * checked exceptions to method handle invocations.  But in Java source
+ * code, methods which perform method handle calls must either explicitly
+ * throw {@code java.lang.Throwable Throwable}, or else must catch all
+ * throwables locally, rethrowing only those which are legal in the context,
+ * and wrapping ones which are illegal.
+ *
+ * <h3><a name="sigpoly"></a>Signature polymorphism</h3>
+ * The unusual compilation and linkage behavior of
+ * {@code invokeExact} and {@code invokeGeneric}
+ * is referenced by the term <em>signature polymorphism</em>.
+ * A signature polymorphic method is one which can operate with
+ * any of a wide range of call signatures and return types.
+ * In order to make this work, both the Java compiler and the JVM must
+ * give special treatment to signature polymorphic methods.
+ * <p>
+ * In source code, a call to a signature polymorphic method will
+ * compile, regardless of the requested type descriptor.
+ * As usual, the Java compiler emits an {@code invokevirtual}
+ * instruction with the given type descriptor against the named method.
+ * The unusual part is that the type descriptor is derived from
+ * the actual argument and return types, not from the method declaration.
+ * <p>
+ * When the JVM processes bytecode containing signature polymorphic calls,
+ * it will successfully link any such call, regardless of its type descriptor.
+ * (In order to retain type safety, the JVM will guard such calls with suitable
+ * dynamic type checks, as described elsewhere.)
+ * <p>
+ * Bytecode generators, including the compiler back end, are required to emit
+ * untransformed type descriptors for these methods.
+ * Tools which determine symbolic linkage are required to accept such
+ * untransformed descriptors, without reporting linkage errors.
+ * <p>
+ * For the sake of tools (but not as a programming API), the signature polymorphic
+ * methods are marked with a private yet standard annotation,
+ * {@code @java.dyn.MethodHandle.PolymorphicSignature}.
+ * The annotation's retention is {@code RUNTIME}, so that all tools can see it.
+ *
+ * <h3>Formal rules for processing signature polymorphic methods</h3>
+ * <p>
+ * The following methods (and no others) are signature polymorphic:
+ * <ul>
+ * <li>{@link java.dyn.MethodHandle#invokeExact   MethodHandle.invokeExact}
+ * <li>{@link java.dyn.MethodHandle#invokeGeneric MethodHandle.invokeGeneric}
+ * </ul>
+ * <p>
+ * A signature polymorphic method will be declared with the following properties:
+ * <ul>
+ * <li>It must be native.
+ * <li>It must take a single varargs parameter of the form {@code Object...}.
+ * <li>It must produce a return value of type {@code Object}.
+ * <li>It must be contained within the {@code java.dyn} package.
+ * </ul>
+ * Because of these requirements, a signature polymorphic method is able to accept
+ * any number and type of actual arguments, and can, with a cast, produce a value of any type.
+ * However, the JVM will treat these declaration features as a documentation convention,
+ * rather than a description of the actual structure of the methods as executed.
  * <p>
- * <em>A note on generic typing:</em>  Method handles do not represent
- * their function types in terms of Java parameterized (generic) types,
- * because there are three mismatches between function types and parameterized
+ * When a call to a signature polymorphic method is compiled, the associated linkage information for
+ * its arguments is not array of {@code Object} (as for other similar varargs methods)
+ * but rather the erasure of the static types of all the arguments.
+ * <p>
+ * In an argument position of a method invocation on a signature polymorphic method,
+ * a null literal has type {@code java.lang.Void}, unless cast to a reference type.
+ * (Note: This typing rule allows the null type to have its own encoding in linkage information
+ * distinct from other types.
+ * <p>
+ * The linkage information for the return type is derived from a context-dependent target typing convention.
+ * The return type for a signature polymorphic method invocation is determined as follows:
+ * <ul>
+ * <li>If the method invocation expression is an expression statement, the method is {@code void}.
+ * <li>Otherwise, if the method invocation expression is the immediate operand of a cast,
+ * the return type is the erasure of the cast type.
+ * <li>Otherwise, the return type is the method's nominal return type, {@code Object}.
+ * </ul>
+ * (Programmers are encouraged to use explicit casts unless it is clear that a signature polymorphic
+ * call will be used as a plain {@code Object} expression.)
+ * <p>
+ * The linkage information for argument and return types is stored in the descriptor for the
+ * compiled (bytecode) call site. As for any invocation instruction, the arguments and return value
+ * will be passed directly on the JVM stack, in accordance with the descriptor,
+ * and without implicit boxing or unboxing.
+ *
+ * <h3>Interoperation between method handles and the Core Reflection API</h3>
+ * Using factory methods in the {@link java.dyn.MethodHandles.Lookup Lookup} API,
+ * any class member represented by a Core Reflection API object
+ * can be converted to a behaviorally equivalent method handle.
+ * For example, a reflective {@link java.lang.reflect.Method Method} can
+ * be converted to a method handle using
+ * {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}.
+ * The resulting method handles generally provide more direct and efficient
+ * access to the underlying class members.
+ * <p>
+ * As a special case,
+ * when the Core Reflection API is used to view the signature polymorphic
+ * methods {@code invokeExact} or {@code invokeGeneric} in this class,
+ * they appear as single, non-polymorphic native methods.
+ * Calls to these native methods do not result in method handle invocations.
+ * Since {@code invokevirtual} instructions can natively
+ * invoke method handles under any type descriptor, this reflective view conflicts
+ * with the normal presentation via bytecodes.
+ * Thus, these two native methods, as viewed by
+ * {@link java.lang.Class#getDeclaredMethod Class.getDeclaredMethod},
+ * are placeholders only.
+ * If invoked via {@link java.lang.reflect.Method#invoke Method.invoke},
+ * they will throw {@code UnsupportedOperationException}.
+ * <p>
+ * In order to obtain an invoker method for a particular type descriptor,
+ * use {@link java.dyn.MethodHandles#exactInvoker MethodHandles.exactInvoker},
+ * or {@link java.dyn.MethodHandles#genericInvoker MethodHandles.genericInvoker}.
+ * The {@link java.dyn.MethodHandles.Lookup#findVirtual Lookup.findVirtual}
+ * API is also able to return a method handle
+ * to call {@code invokeExact} or {@code invokeGeneric},
+ * for any specified type descriptor .
+ *
+ * <h3>Interoperation between method handles and Java generics</h3>
+ * A method handle can be obtained on a method, constructor, or field
+ * which is declared with Java generic types.
+ * As with the Core Reflection API, the type of the method handle
+ * will constructed from the erasure of the source-level type.
+ * When a method handle is invoked, the types of its arguments
+ * or the return value cast type may be generic types or type instances.
+ * If this occurs, the compiler will replace those
+ * types by their erasures when when it constructs the type descriptor
+ * for the {@code invokevirtual} instruction.
+ * <p>
+ * Method handles do not represent
+ * their function-like types in terms of Java parameterized (generic) types,
+ * because there are three mismatches between function-like types and parameterized
  * Java types.
- * <ol>
+ * <ul>
  * <li>Method types range over all possible arities,
  * from no arguments to up to 255 of arguments (a limit imposed by the JVM).
  * Generics are not variadic, and so cannot represent this.</li>
@@ -217,29 +430,7 @@
  * often generic across a wide range of function types, including
  * those of multiple arities.  It is impossible to represent such
  * genericity with a Java type parameter.</li>
- * </ol>
- * Signature polymorphic methods in this class appear to be documented
- * as having type parameters for return types and a parameter, but that is
- * merely a documentation convention.  These type parameters do
- * not play a role in type-checking method handle invocations.
- * <p>
- * Like classes and strings, method handles that correspond to accessible
- * fields, methods, and constructors can be represented directly
- * in a class file's constant pool as constants to be loaded by {@code ldc} bytecodes.
- * Loading such a constant causes the component classes of its type to be loaded as necessary.
- * <p>
- * Method handles cannot be subclassed by the user.
- * Implementations may (or may not) create internal subclasses of {@code MethodHandle}
- * which may be visible via the {@code java.lang.Object#getClass Object.getClass}
- * operation.  The programmer should not draw conclusions about a method handle
- * from its specific class, as the method handle class hierarchy (if any)
- * may change from time to time or across implementations from different vendors.
- * <p>
- * With respect to the Java Memory Model, any method handle will behave
- * as if all of its fields are final variables.  This means that any method
- * handle made visible to the application will always be fully formed.
- * This is true even if the method handle is published through a shared
- * variables in a data race.
+ * </ul>
  *
  * @see MethodType
  * @see MethodHandles
@@ -251,15 +442,16 @@
         extends MethodHandleImpl
 {
     private static Access IMPL_TOKEN = Access.getToken();
+    static { MethodHandleImpl.initStatics(); }
 
     // interface MethodHandle<R throws X extends Exception,A...>
     // { MethodType<R throws X,A...> type(); public R invokeExact(A...) throws X; }
 
     /**
      * Internal marker interface which distinguishes (to the Java compiler)
-     * those methods which are signature polymorphic.
+     * those methods which are <a href="MethodHandle.html#sigpoly">signature polymorphic</a>.
      */
-    @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.TYPE})
+    @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD})
     @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
     @interface PolymorphicSignature { }
 
@@ -270,7 +462,7 @@
      * Every invocation of this method handle via {@code invokeExact} must exactly match this type.
      * @return the method handle type
      */
-    public final MethodType type() {
+    public MethodType type() {
         return type;
     }
 
@@ -307,40 +499,27 @@
     }
 
     /**
-     * Returns a string representation of the method handle,
-     * starting with the string {@code "MethodHandle"} and
-     * ending with the string representation of the method handle's type.
-     * In other words, this method returns a string equal to the value of:
-     * <blockquote><pre>
-     * "MethodHandle" + type().toString()
-     * </pre></blockquote>
-     * <p>
-     * Note:  Future releases of this API may add further information
-     * to the string representation.
-     * Therefore, the present syntax should not be parsed by applications.
-     *
-     * @return a string representation of the method handle
-     */
-    @Override
-    public String toString() {
-        return MethodHandleImpl.getNameString(IMPL_TOKEN, this);
-    }
-
-    /**
-     * Invoke the method handle, allowing any caller signature, but requiring an exact signature match.
-     * The signature at the call site of {@code invokeExact} must
+     * Invoke the method handle, allowing any caller type descriptor, but requiring an exact type match.
+     * The type descriptor at the call site of {@code invokeExact} must
      * exactly match this method handle's {@link #type type}.
      * No conversions are allowed on arguments or return values.
-     * @throws WrongMethodTypeException if the target's type is not identical with the caller's type signature
+     * <p>
+     * When this method is observed via the Core Reflection API,
+     * it will appear as a single native method, taking an object array and returning an object.
+     * If this native method is invoked directly via
+     * {@link java.lang.reflect.Method#invoke Method.invoke}, via JNI,
+     * or indirectly via {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect},
+     * it will throw an {@code UnsupportedOperationException}.
+     * @throws WrongMethodTypeException if the target's type is not identical with the caller's type descriptor
      * @throws Throwable anything thrown by the underlying method propagates unchanged through the method handle call
      */
     public final native @PolymorphicSignature Object invokeExact(Object... args) throws Throwable;
 
     /**
-     * Invoke the method handle, allowing any caller signature,
-     * and optionally performing conversions for arguments and return types.
+     * Invoke the method handle, allowing any caller type descriptor,
+     * and optionally performing conversions on arguments and return values.
      * <p>
-     * If the call site signature exactly matches this method handle's {@link #type type},
+     * If the call site type descriptor exactly matches this method handle's {@link #type type},
      * the call proceeds as if by {@link #invokeExact invokeExact}.
      * <p>
      * Otherwise, the call proceeds as if this method handle were first
@@ -353,14 +532,20 @@
      * adaptations directly on the caller's arguments,
      * and call the target method handle according to its own exact type.
      * <p>
-     * If the method handle is equipped with a
-     * {@linkplain #withTypeHandler type handler}, the handler must produce
-     * an entry point of the call site's exact type.
-     * Otherwise, the signature at the call site of {@code invokeGeneric} must
-     * be a valid argument to the standard {@code asType} method.
+     * The type descriptor at the call site of {@code invokeGeneric} must
+     * be a valid argument to the receivers {@code asType} method.
      * In particular, the caller must specify the same argument arity
-     * as the callee's type.
-     * @throws WrongMethodTypeException if the target's type cannot be adjusted to the caller's type signature
+     * as the callee's type,
+     * if the callee is not a {@linkplain #asVarargsCollector variable arity collector}.
+     * <p>
+     * When this method is observed via the Core Reflection API,
+     * it will appear as a single native method, taking an object array and returning an object.
+     * If this native method is invoked directly via
+     * {@link java.lang.reflect.Method#invoke Method.invoke}, via JNI,
+     * or indirectly via {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect},
+     * it will throw an {@code UnsupportedOperationException}.
+     * @throws WrongMethodTypeException if the target's type cannot be adjusted to the caller's type descriptor
+     * @throws ClassCastException if the target's type can be adjusted to the caller, but a reference cast fails
      * @throws Throwable anything thrown by the underlying method propagates unchanged through the method handle call
      */
     public final native @PolymorphicSignature Object invokeGeneric(Object... args) throws Throwable;
@@ -400,16 +585,22 @@
      * <p>
      * This call is equivalent to the following code:
      * <p><blockquote><pre>
-     * MethodHandle invoker = MethodHandles.varargsInvoker(this.type(), 0);
+     * MethodHandle invoker = MethodHandles.spreadInvoker(this.type(), 0);
      * Object result = invoker.invokeExact(this, arguments);
      * </pre></blockquote>
+     * <p>
+     * Unlike the signature polymorphic methods {@code invokeExact} and {@code invokeGeneric},
+     * {@code invokeWithArguments} can be accessed normally via the Core Reflection API and JNI.
+     * It can therefore be used as a bridge between native or reflective code and method handles.
+     *
      * @param arguments the arguments to pass to the target
      * @return the result returned by the target
-     * @throws WrongMethodTypeException if the target's type cannot be adjusted to take the arguments
+     * @throws ClassCastException if an argument cannot be converted by reference casting
+     * @throws WrongMethodTypeException if the target's type cannot be adjusted to take the given number of {@code Object} arguments
      * @throws Throwable anything thrown by the target method invocation
-     * @see MethodHandles#varargsInvoker
+     * @see MethodHandles#spreadInvoker
      */
-    public final Object invokeWithArguments(Object... arguments) throws Throwable {
+    public Object invokeWithArguments(Object... arguments) throws Throwable {
         int argc = arguments == null ? 0 : arguments.length;
         MethodType type = type();
         if (type.parameterCount() != argc) {
@@ -417,7 +608,7 @@
             return asType(MethodType.genericMethodType(argc)).invokeWithArguments(arguments);
         }
         if (argc <= 10) {
-            MethodHandle invoker = MethodHandles.invokers(type).genericInvoker();
+            MethodHandle invoker = invokers(type).genericInvoker();
             switch (argc) {
                 case 0:  return invoker.invokeExact(this);
                 case 1:  return invoker.invokeExact(this,
@@ -456,19 +647,11 @@
         }
 
         // more than ten arguments get boxed in a varargs list:
-        MethodHandle invoker = MethodHandles.invokers(type).varargsInvoker(0);
+        MethodHandle invoker = invokers(type).spreadInvoker(0);
         return invoker.invokeExact(this, arguments);
     }
     /** Equivalent to {@code invokeWithArguments(arguments.toArray())}. */
-    public final Object invokeWithArguments(java.util.List<?> arguments) throws Throwable {
-        return invokeWithArguments(arguments.toArray());
-    }
-    @Deprecated
-    public final Object invokeVarargs(Object... arguments) throws Throwable {
-        return invokeWithArguments(arguments);
-    }
-    @Deprecated
-    public final Object invokeVarargs(java.util.List<?> arguments) throws Throwable {
+    public Object invokeWithArguments(java.util.List<?> arguments) throws Throwable {
         return invokeWithArguments(arguments.toArray());
     }
 
@@ -488,13 +671,7 @@
      * to match up the caller's and callee's types.
      * <p>
      * This method is equivalent to {@link MethodHandles#convertArguments convertArguments},
-     * except for method handles produced by {@link #withTypeHandler withTypeHandler},
-     * in which case the specified type handler is used for calls to {@code asType}.
-     * <p>
-     * Note that the default behavior of {@code asType} only performs
-     * pairwise argument conversion and return value conversion.
-     * Because of this, unless the method handle has a type handler,
-     * the original type and new type must have the same number of arguments.
+     * except for variable arity method handles produced by {@link #asVarargsCollector asVarargsCollector}.
      *
      * @param newType the expected type of the new method handle
      * @return a method handle which delegates to {@code this} after performing
@@ -508,14 +685,16 @@
     }
 
     /**
-     * Produce a method handle which adapts, as its <i>target</i>,
+     * Make an adapter which accepts a trailing array argument
+     * and spreads its elements as positional arguments.
+     * The new method handle adapts, as its <i>target</i>,
      * the current method handle.  The type of the adapter will be
      * the same as the type of the target, except that the final
      * {@code arrayLength} parameters of the target's type are replaced
      * by a single array parameter of type {@code arrayType}.
      * <p>
      * If the array element type differs from any of the corresponding
-     * argument types on original target,
+     * argument types on the original target,
      * the original target is adapted to take the array elements directly,
      * as if by a call to {@link #asType asType}.
      * <p>
@@ -539,8 +718,9 @@
      * @throws IllegalArgumentException if target does not have at least
      *         {@code arrayLength} parameter types
      * @throws WrongMethodTypeException if the implied {@code asType} call fails
+     * @see #asCollector
      */
-    public final MethodHandle asSpreader(Class<?> arrayType, int arrayLength) {
+    public MethodHandle asSpreader(Class<?> arrayType, int arrayLength) {
         Class<?> arrayElement = arrayType.getComponentType();
         if (arrayElement == null)  throw newIllegalArgumentException("not an array type");
         MethodType oldType = type();
@@ -553,13 +733,15 @@
     }
 
     /**
-     * Produce a method handle which adapts, as its <i>target</i>,
+     * Make an adapter which accepts a given number of trailing
+     * positional arguments and collects them into an array argument.
+     * The new method handle adapts, as its <i>target</i>,
      * the current method handle.  The type of the adapter will be
      * the same as the type of the target, except that a single trailing
      * parameter (usually of type {@code arrayType}) is replaced by
      * {@code arrayLength} parameters whose type is element type of {@code arrayType}.
      * <p>
-     * If the array type differs from the final argument type on original target,
+     * If the array type differs from the final argument type on the original target,
      * the original target is adapted to take the array type directly,
      * as if by a call to {@link #asType asType}.
      * <p>
@@ -570,21 +752,31 @@
      * What the target eventually returns is returned unchanged by the adapter.
      * <p>
      * (The array may also be a shared constant when {@code arrayLength} is zero.)
-     * @param arrayType usually {@code Object[]}, the type of the array argument which will collect the arguments
+     * <p>
+     * (<em>Note:</em> The {@code arrayType} is often identical to the last
+     * parameter type of the original target.
+     * It is an explicit argument for symmetry with {@code asSpreader}, and also
+     * to allow the target to use a simple {@code Object} as its last parameter type.)
+     * <p>
+     * In order to create a collecting adapter which is not restricted to a particular
+     * number of collected arguments, use {@link #asVarargsCollector asVarargsCollector} instead.
+     * @param arrayType often {@code Object[]}, the type of the array argument which will collect the arguments
      * @param arrayLength the number of arguments to collect into a new array argument
      * @return a new method handle which collects some trailing argument
      *         into an array, before calling the original method handle
      * @throws IllegalArgumentException if {@code arrayType} is not an array type
-               or {@code arrayType} is not assignable to this method handle's trailing parameter type
-     * @throws IllegalArgumentException if {@code arrayLength} is not
-     *         a legal array size
+     *         or {@code arrayType} is not assignable to this method handle's trailing parameter type,
+     *         or {@code arrayLength} is not a legal array size
      * @throws WrongMethodTypeException if the implied {@code asType} call fails
+     * @see #asSpreader
+     * @see #asVarargsCollector
      */
-    public final MethodHandle asCollector(Class<?> arrayType, int arrayLength) {
+    public MethodHandle asCollector(Class<?> arrayType, int arrayLength) {
         Class<?> arrayElement = arrayType.getComponentType();
         if (arrayElement == null)  throw newIllegalArgumentException("not an array type");
         MethodType oldType = type();
         int nargs = oldType.parameterCount();
+        if (nargs == 0)  throw newIllegalArgumentException("no trailing argument");
         MethodType newType = oldType.dropParameterTypes(nargs-1, nargs);
         newType = newType.insertParameterTypes(nargs-1,
                     java.util.Collections.<Class<?>>nCopies(arrayLength, arrayElement));
@@ -592,8 +784,185 @@
     }
 
     /**
-     * Produce a method handle which binds the given argument
-     * to the current method handle as <i>target</i>.
+     * Make a <em>variable arity</em> adapter which is able to accept
+     * any number of trailing positional arguments and collect them
+     * into an array argument.
+     * <p>
+     * The type and behavior of the adapter will be the same as
+     * the type and behavior of the target, except that certain
+     * {@code invokeGeneric} and {@code asType} requests can lead to
+     * trailing positional arguments being collected into target's
+     * trailing parameter.
+     * Also, the last parameter type of the adapter will be
+     * {@code arrayType}, even if the target has a different
+     * last parameter type.
+     * <p>
+     * When called with {@link #invokeExact invokeExact}, the adapter invokes
+     * the target with no argument changes.
+     * (<em>Note:</em> This behavior is different from a
+     * {@linkplain #asCollector fixed arity collector},
+     * since it accepts a whole array of indeterminate length,
+     * rather than a fixed number of arguments.)
+     * <p>
+     * When called with {@link #invokeGeneric invokeGeneric}, if the caller
+     * type is the same as the adapter, the adapter invokes the target as with
+     * {@code invokeExact}.
+     * (This is the normal behavior for {@code invokeGeneric} when types match.)
+     * <p>
+     * Otherwise, if the caller and adapter arity are the same, and the
+     * trailing parameter type of the caller is a reference type identical to
+     * or assignable to the trailing parameter type of the adapter,
+     * the arguments and return values are converted pairwise,
+     * as if by {@link MethodHandles#convertArguments convertArguments}.
+     * (This is also normal behavior for {@code invokeGeneric} in such a case.)
+     * <p>
+     * Otherwise, the arities differ, or the adapter's trailing parameter
+     * type is not assignable from the corresponding caller type.
+     * In this case, the adapter replaces all trailing arguments from
+     * the original trailing argument position onward, by
+     * a new array of type {@code arrayType}, whose elements
+     * comprise (in order) the replaced arguments.
+     * <p>
+     * The caller type must provides as least enough arguments,
+     * and of the correct type, to satisfy the target's requirement for
+     * positional arguments before the trailing array argument.
+     * Thus, the caller must supply, at a minimum, {@code N-1} arguments,
+     * where {@code N} is the arity of the target.
+     * Also, there must exist conversions from the incoming arguments
+     * to the target's arguments.
+     * As with other uses of {@code invokeGeneric}, if these basic
+     * requirements are not fulfilled, a {@code WrongMethodTypeException}
+     * may be thrown.
+     * <p>
+     * In all cases, what the target eventually returns is returned unchanged by the adapter.
+     * <p>
+     * In the final case, it is exactly as if the target method handle were
+     * temporarily adapted with a {@linkplain #asCollector fixed arity collector}
+     * to the arity required by the caller type.
+     * (As with {@code asCollector}, if the array length is zero,
+     * a shared constant may be used instead of a new array.
+     * If the implied call to {@code asCollector} would throw
+     * an {@code IllegalArgumentException} or {@code WrongMethodTypeException},
+     * the call to the variable arity adapter must throw
+     * {@code WrongMethodTypeException}.)
+     * <p>
+     * The behavior of {@link #asType asType} is also specialized for
+     * variable arity adapters, to maintain the invariant that
+     * {@code invokeGeneric} is always equivalent to an {@code asType}
+     * call to adjust the target type, followed by {@code invokeExact}.
+     * Therefore, a variable arity adapter responds
+     * to an {@code asType} request by building a fixed arity collector,
+     * if and only if the adapter and requested type differ either
+     * in arity or trailing argument type.
+     * The resulting fixed arity collector has its type further adjusted
+     * (if necessary) to the requested type by pairwise conversion,
+     * as if by another application of {@code asType}.
+     * <p>
+     * When a method handle is obtained by executing an {@code ldc} instruction
+     * of a {@code CONSTANT_MethodHandle} constant, and the target method is marked
+     * as a variable arity method (with the modifier bit {@code 0x0080}),
+     * the method handle will accept multiple arities, as if the method handle
+     * constant were created by means of a call to {@code asVarargsCollector}.
+     * <p>
+     * In order to create a collecting adapter which collects a predetermined
+     * number of arguments, and whose type reflects this predetermined number,
+     * use {@link #asCollector asCollector} instead.
+     * <p>
+     * No method handle transformations produce new method handles with
+     * variable arity, unless they are documented as doing so.
+     * Therefore, besides {@code asVarargsCollector},
+     * all methods in {@code MethodHandle} and {@code MethodHandles}
+     * will return a method handle with fixed arity,
+     * except in the cases where they are specified to return their original
+     * operand (e.g., {@code asType} of the method handle's own type).
+     * <p>
+     * Calling {@code asVarargsCollector} on a method handle which is already
+     * of variable arity will produce a method handle with the same type and behavior.
+     * It may (or may not) return the original variable arity method handle.
+     * <p>
+     * Here is an example, of a list-making variable arity method handle:
+     * <blockquote><pre>
+MethodHandle asList = publicLookup()
+  .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class))
+  .asVarargsCollector(Object[].class);
+assertEquals("[]", asList.invokeGeneric().toString());
+assertEquals("[1]", asList.invokeGeneric(1).toString());
+assertEquals("[two, too]", asList.invokeGeneric("two", "too").toString());
+Object[] argv = { "three", "thee", "tee" };
+assertEquals("[three, thee, tee]", asList.invokeGeneric(argv).toString());
+List ls = (List) asList.invokeGeneric((Object)argv);
+assertEquals(1, ls.size());
+assertEquals("[three, thee, tee]", Arrays.toString((Object[])ls.get(0)));
+     * </pre></blockquote>
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * These rules are designed as a dynamically-typed variation
+     * of the Java rules for variable arity methods.
+     * In both cases, callers to a variable arity method or method handle
+     * can either pass zero or more positional arguments, or else pass
+     * pre-collected arrays of any length.  Users should be aware of the
+     * special role of the final argument, and of the effect of a
+     * type match on that final argument, which determines whether
+     * or not a single trailing argument is interpreted as a whole
+     * array or a single element of an array to be collected.
+     * Note that the dynamic type of the trailing argument has no
+     * effect on this decision, only a comparison between the static
+     * type descriptor of the call site and the type of the method handle.)
+     * <p style="font-size:smaller;">
+     * As a result of the previously stated rules, the variable arity behavior
+     * of a method handle may be suppressed, by binding it to the exact invoker
+     * of its own type, as follows:
+     * <blockquote><pre>
+MethodHandle vamh = publicLookup()
+  .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class))
+  .asVarargsCollector(Object[].class);
+MethodHandle mh = MethodHandles.exactInvoker(vamh.type()).bindTo(vamh);
+assert(vamh.type().equals(mh.type()));
+assertEquals("[1, 2, 3]", vamh.invokeGeneric(1,2,3).toString());
+boolean failed = false;
+try { mh.invokeGeneric(1,2,3); }
+catch (WrongMethodTypeException ex) { failed = true; }
+assert(failed);
+     * </pre></blockquote>
+     * This transformation has no behavioral effect if the method handle is
+     * not of variable arity.
+     *
+     * @param arrayType often {@code Object[]}, the type of the array argument which will collect the arguments
+     * @return a new method handle which can collect any number of trailing arguments
+     *         into an array, before calling the original method handle
+     * @throws IllegalArgumentException if {@code arrayType} is not an array type
+     *         or {@code arrayType} is not assignable to this method handle's trailing parameter type
+     * @see #asCollector
+     * @see #isVarargsCollector
+     */
+    public MethodHandle asVarargsCollector(Class<?> arrayType) {
+        Class<?> arrayElement = arrayType.getComponentType();
+        if (arrayElement == null)  throw newIllegalArgumentException("not an array type");
+        return MethodHandles.asVarargsCollector(this, arrayType);
+    }
+
+    /**
+     * Determine if this method handle
+     * supports {@linkplain #asVarargsCollector variable arity} calls.
+     * Such method handles arise from the following sources:
+     * <ul>
+     * <li>a call to {@linkplain #asVarargsCollector asVarargsCollector}
+     * <li>a call to a {@linkplain java.dyn.MethodHandles.Lookup lookup method}
+     *     which resolves to a variable arity Java method or constructor
+     * <li>an {@code ldc} instruction of a {@code CONSTANT_MethodHandle}
+     *     which resolves to a variable arity Java method or constructor
+     * </ul>
+     * @return true if this method handle accepts more than one arity of {@code invokeGeneric} calls
+     * @see #asVarargsCollector
+     */
+    public boolean isVarargsCollector() {
+        return false;
+    }
+
+    /**
+     * Bind a value {@code x} to the first argument of a method handle, without invoking it.
+     * The new method handle adapts, as its <i>target</i>,
+     * to the current method handle.
      * The type of the bound handle will be
      * the same as the type of the target, except that a single leading
      * reference parameter will be omitted.
@@ -614,79 +983,27 @@
      *         to the leading parameter type of the target
      * @see MethodHandles#insertArguments
      */
-    public final MethodHandle bindTo(Object x) {
+    public MethodHandle bindTo(Object x) {
         return MethodHandles.insertArguments(this, 0, x);
     }
 
     /**
-     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
-     * Create a new method handle with the same type as this one,
-     * but whose {@code asType} method invokes the given
-     * {@code typeHandler} on this method handle,
-     * instead of the standard {@code MethodHandles.convertArguments}.
-     * <p>
-     * The new method handle will have the same behavior as the
-     * old one when invoked by {@code invokeExact}.
-     * For {@code invokeGeneric} calls which exactly match
-     * the method type, the two method handles will also
-     * have the same behavior.
-     * For other {@code invokeGeneric} calls, the {@code typeHandler}
-     * will control the behavior of the new method handle.
-     * <p>
-     * Thus, a method handle with an {@code asType} handler can
-     * be configured to accept more than one arity of {@code invokeGeneric}
-     * call, and potentially every possible arity.
-     * It can also be configured to supply default values for
-     * optional arguments, when the caller does not specify them.
-     * <p>
-     * The given method handle must take two arguments and return
-     * one result.  The result it returns must be a method handle
-     * of exactly the requested type.  If the result returned by
-     * the target is null, a {@link NullPointerException} is thrown,
-     * else if the type of the target does not exactly match
-     * the requested type, a {@link WrongMethodTypeException} is thrown.
-     * <p>
-     * A method handle's type handler is not guaranteed to be called every
-     * time its {@code asType} or {@code invokeGeneric} method is called.
-     * If the implementation is faced is able to prove that an equivalent
-     * type handler call has already occurred (on the same two arguments),
-     * it may substitute the result of that previous invocation, without
-     * making a new invocation.  Thus, type handlers should not (in general)
-     * perform significant side effects.
-     * <p>
-     * Therefore, the type handler is invoked as if by this code:
+     * Returns a string representation of the method handle,
+     * starting with the string {@code "MethodHandle"} and
+     * ending with the string representation of the method handle's type.
+     * In other words, this method returns a string equal to the value of:
      * <blockquote><pre>
-     * MethodHandle target = this;      // original method handle
-     * MethodHandle adapter = ...;      // adapted method handle
-     * MethodType requestedType = ...;  // argument to asType()
-     * if (type().equals(requestedType))
-     *    return adapter;
-     * MethodHandle result = (MethodHandle)
-     *    typeHandler.invokeGeneric(target, requestedType);
-     * if (!result.type().equals(requestedType))
-     *    throw new WrongMethodTypeException();
-     * return result;
+     * "MethodHandle" + type().toString()
      * </pre></blockquote>
      * <p>
-     * For example, here is a list-making variable-arity method handle:
-     * <blockquote><pre>
-MethodHandle makeEmptyList = MethodHandles.constant(List.class, Arrays.asList());
-MethodHandle asList = lookup()
-  .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class));
-static MethodHandle collectingTypeHandler(MethodHandle base, MethodType newType) {
-  return asList.asCollector(Object[].class, newType.parameterCount()).asType(newType);
-}
-MethodHandle collectingTypeHandler = lookup()
-  .findStatic(lookup().lookupClass(), "collectingTypeHandler",
-     methodType(MethodHandle.class, MethodHandle.class, MethodType.class));
-MethodHandle makeAnyList = makeEmptyList.withTypeHandler(collectingTypeHandler);
-
-assertEquals("[]", makeAnyList.invokeGeneric().toString());
-assertEquals("[1]", makeAnyList.invokeGeneric(1).toString());
-assertEquals("[two, too]", makeAnyList.invokeGeneric("two", "too").toString());
-     * <pre><blockquote>
+     * Note:  Future releases of this API may add further information
+     * to the string representation.
+     * Therefore, the present syntax should not be parsed by applications.
+     *
+     * @return a string representation of the method handle
      */
-    public MethodHandle withTypeHandler(MethodHandle typeHandler) {
-        return MethodHandles.withTypeHandler(this, typeHandler);
+    @Override
+    public String toString() {
+        return MethodHandleImpl.getNameString(IMPL_TOKEN, this);
     }
 }
--- a/jdk/src/share/classes/java/dyn/MethodHandles.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/MethodHandles.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import sun.dyn.Access;
 import sun.dyn.MemberName;
 import sun.dyn.MethodHandleImpl;
+import sun.dyn.WrapperInstance;
 import sun.dyn.util.ValueConversions;
 import sun.dyn.util.VerifyAccess;
 import sun.dyn.util.Wrapper;
@@ -45,10 +46,10 @@
  * This class consists exclusively of static methods that operate on or return
  * method handles. They fall into several categories:
  * <ul>
- * <li>Factory methods which create method handles for methods and fields.
- * <li>Invoker methods which can invoke method handles on dynamically typed arguments and/or varargs arrays.
- * <li>Combinator methods, which combine or transforming pre-existing method handles into new ones.
- * <li>Factory methods which create method handles that emulate other common JVM operations or control flow patterns.
+ * <li>Lookup methods which help create method handles for methods and fields.
+ * <li>Combinator methods, which combine or transform pre-existing method handles into new ones.
+ * <li>Other factory methods to create method handles that emulate other common JVM operations or control flow patterns.
+ * <li>Wrapper methods which can convert between method handles and other function-like "SAM types".
  * </ul>
  * <p>
  * @author John Rose, JSR 292 EG
@@ -97,47 +98,155 @@
      * when the creation requires access checking.
      * Method handles do not perform
      * access checks when they are called, but rather when they are created.
-     * (This is a major difference
-     * from reflective {@link Method}, which performs access checking
-     * against every caller, on every call.)
      * Therefore, method handle access
      * restrictions must be enforced when a method handle is created.
      * The caller class against which those restrictions are enforced
      * is known as the {@linkplain #lookupClass lookup class}.
-     * A lookup object embodies an
-     * authenticated lookup class, and can be used to create any number
+     * <p>
+     * A lookup class which needs to create method handles will call
+     * {@link MethodHandles#lookup MethodHandles.lookup} to create a factory for itself.
+     * When the {@code Lookup} factory object is created, the identity of the lookup class is
+     * determined, and securely stored in the {@code Lookup} object.
+     * The lookup class (or its delegates) may then use factory methods
+     * on the {@code Lookup} object to create method handles for access-checked members.
+     * This includes all methods, constructors, and fields which are allowed to the lookup class,
+     * even private ones.
+     * <p>
+     * The factory methods on a {@code Lookup} object correspond to all major
+     * use cases for methods, constructors, and fields.
+     * Here is a summary of the correspondence between these factory methods and
+     * the behavior the resulting method handles:
+     * <code>
+     * <table border=1 cellpadding=5 summary="lookup method behaviors">
+     * <tr><th>lookup expression</th><th>member</th><th>behavior</th></tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findGetter lookup.findGetter(C.class,"f",FT.class)}</td>
+     *     <td>FT f;</td><td>(T) this.f;</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticGetter lookup.findStaticGetter(C.class,"f",FT.class)}</td>
+     *     <td>static<br>FT f;</td><td>(T) C.f;</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findSetter lookup.findSetter(C.class,"f",FT.class)}</td>
+     *     <td>FT f;</td><td>this.f = x;</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticSetter lookup.findStaticSetter(C.class,"f",FT.class)}</td>
+     *     <td>static<br>FT f;</td><td>C.f = arg;</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findVirtual lookup.findVirtual(C.class,"m",MT)}</td>
+     *     <td>T m(A*);</td><td>(T) this.m(arg*);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findStatic lookup.findStatic(C.class,"m",MT)}</td>
+     *     <td>static<br>T m(A*);</td><td>(T) C.m(arg*);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findSpecial lookup.findSpecial(C.class,"m",MT,this.class)}</td>
+     *     <td>T m(A*);</td><td>(T) super.m(arg*);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findConstructor lookup.findConstructor(C.class,MT)}</td>
+     *     <td>C(A*);</td><td>(T) new C(arg*);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflectGetter lookup.unreflectGetter(aField)}</td>
+     *     <td>(static)?<br>FT f;</td><td>(FT) aField.get(thisOrNull);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflectSetter lookup.unreflectSetter(aField)}</td>
+     *     <td>(static)?<br>FT f;</td><td>aField.set(thisOrNull, arg);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
+     *     <td>(static)?<br>T m(A*);</td><td>(T) aMethod.invoke(thisOrNull, arg*);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflectConstructor lookup.unreflectConstructor(aConstructor)}</td>
+     *     <td>C(A*);</td><td>(C) aConstructor.newInstance(arg*);</td>
+     * </tr>
+     * <tr>
+     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
+     *     <td>(static)?<br>T m(A*);</td><td>(T) aMethod.invoke(thisOrNull, arg*);</td>
+     * </tr>
+     * </table>
+     * </code>
+     * Here, the type {@code C} is the class or interface being searched for a member,
+     * documented as a parameter named {@code refc} in the lookup methods.
+     * The method or constructor type {@code MT} is composed from the return type {@code T}
+     * and the sequence of argument types {@code A*}.
+     * Both {@code MT} and the field type {@code FT} are documented as a parameter named {@code type}.
+     * The formal parameter {@code this} stands for the self-reference of type {@code C};
+     * if it is present, it is always the leading argument to the method handle invocation.
+     * The name {@code arg} stands for all the other method handle arguments.
+     * In the code examples for the Core Reflection API, the name {@code thisOrNull}
+     * stands for a null reference if the accessed method or field is static,
+     * and {@code this} otherwise.
+     * The names {@code aMethod}, {@code aField}, and {@code aConstructor} stand
+     * for reflective objects corresponding to the given members.
+     * <p>
+     * The equivalence between looked-up method handles and underlying
+     * class members can break down in a few ways:
+     * <ul>
+     * <li>If {@code C} is not symbolically accessible from the lookup class's loader,
+     * the lookup can still succeed, even when there is no equivalent
+     * Java expression or bytecoded constant.
+     * <li>Likewise, if {@code T} or {@code MT}
+     * is not symbolically accessible from the lookup class's loader,
+     * the lookup can still succeed.
+     * For example, lookups for {@code MethodHandle.invokeExact} and
+     * {@code MethodHandle.invokeGeneric} will always succeed, regardless of requested type.
+     * <li>If there is a security manager installed, it can forbid the lookup
+     * on various grounds (<a href="#secmgr">see below</a>).
+     * By contrast, the {@code ldc} instruction is not subject to
+     * security manager checks.
+     * </ul>
+     *
+     * <h3><a name="access"></a>Access checking</h3>
+     * Access checks are applied in the factory methods of {@code Lookup},
+     * when a method handle is created.
+     * This is a key difference from the Core Reflection API, since
+     * {@link java.lang.reflect.Method#invoke Method.invoke}
+     * performs access checking against every caller, on every call.
+     * <p>
+     * All access checks start from a {@code Lookup} object, which
+     * compares its recorded lookup class against all requests to
+     * create method handles.
+     * A single {@code Lookup} object can be used to create any number
      * of access-checked method handles, all checked against a single
      * lookup class.
      * <p>
-     * A class which needs to create method handles will call
-     * {@link MethodHandles#lookup MethodHandles.lookup} to create a factory for itself.
-     * It may then use this factory to create method handles on
-     * all of its methods, including private ones.
-     * It may also delegate the lookup (e.g., to a metaobject protocol)
-     * by passing the lookup object to other code.
-     * If this other code creates method handles, they will be access
-     * checked against the original lookup class, and not with any higher
-     * privileges.
+     * A {@code Lookup} object can be shared with other trusted code,
+     * such as a metaobject protocol.
+     * A shared {@code Lookup} object delegates the capability
+     * to create method handles on private members of the lookup class.
+     * Even if privileged code uses the {@code Lookup} object,
+     * the access checking is confined to the privileges of the
+     * original lookup class.
      * <p>
-     * Access checks only apply to named and reflected methods.
-     * Other method handle creation methods, such as
-     * {@link #convertArguments MethodHandles.convertArguments},
-     * do not require any access checks, and can be done independently
-     * of any lookup class.
-     * <h3>How access errors are handled</h3>
      * A lookup can fail, because
      * the containing class is not accessible to the lookup class, or
      * because the desired class member is missing, or because the
      * desired class member is not accessible to the lookup class.
-     * It can also fail if a security manager is installed and refuses
-     * access.  In any of these cases, an exception will be
-     * thrown from the attempted lookup.
+     * In any of these cases, a {@code ReflectiveOperationException} will be
+     * thrown from the attempted lookup.  The exact class will be one of
+     * the following:
+     * <ul>
+     * <li>NoSuchMethodException &mdash; if a method is requested but does not exist
+     * <li>NoSuchFieldException &mdash; if a field is requested but does not exist
+     * <li>IllegalAccessException &mdash; if the member exists but an access check fails
+     * </ul>
      * <p>
      * In general, the conditions under which a method handle may be
-     * created for a method {@code M} are exactly as restrictive as the conditions
-     * under which the lookup class could have compiled a call to {@code M}.
+     * looked up for a method {@code M} are exactly equivalent to the conditions
+     * under which the lookup class could have compiled and resolved a call to {@code M}.
+     * And the effect of invoking the method handle resulting from the lookup
+     * is exactly equivalent to executing the compiled and resolved call to {@code M}.
+     * The same point is true of fields and constructors.
      * <p>
-     * In some cases, this access is obtained by the Java compiler by creating
+     * In some cases, access between nested classes is obtained by the Java compiler by creating
      * an wrapper method to access a private method of another class
      * in the same top-level declaration.
      * For example, a nested class {@code C.D}
@@ -149,6 +258,61 @@
      * A workaround for this limitation is the {@link Lookup#in Lookup.in} method,
      * which can transform a lookup on {@code C.E} into one on any of those other
      * classes, without special elevation of privilege.
+     * <p>
+     * Although bytecode instructions can only refer to classes in
+     * a related class loader, this API can search for methods in any
+     * class, as long as a reference to its {@code Class} object is
+     * available.  Such cross-loader references are also possible with the
+     * Core Reflection API, and are impossible to bytecode instructions
+     * such as {@code invokestatic} or {@code getfield}.
+     * There is a {@linkplain java.lang.SecurityManager security manager API}
+     * to allow applications to check such cross-loader references.
+     * These checks apply to both the {@code MethodHandles.Lookup} API
+     * and the Core Reflection API
+     * (as found on {@link java.lang.Class Class}).
+     * <p>
+     * Access checks only apply to named and reflected methods,
+     * constructors, and fields.
+     * Other method handle creation methods, such as
+     * {@link #convertArguments MethodHandles.convertArguments},
+     * do not require any access checks, and are done
+     * with static methods of {@link MethodHandles},
+     * independently of any {@code Lookup} object.
+     *
+     * <h3>Security manager interactions</h3>
+     * <a name="secmgr"></a>
+     * If a security manager is present, member lookups are subject to
+     * additional checks.
+     * From one to four calls are made to the security manager.
+     * Any of these calls can refuse access by throwing a
+     * {@link java.lang.SecurityException SecurityException}.
+     * Define {@code smgr} as the security manager,
+     * {@code refc} as the containing class in which the member
+     * is being sought, and {@code defc} as the class in which the
+     * member is actually defined.
+     * The calls are made according to the following rules:
+     * <ul>
+     * <li>In all cases, {@link SecurityManager#checkMemberAccess
+     *     smgr.checkMemberAccess(refc, Member.PUBLIC)} is called.
+     * <li>If the class loader of the lookup class is not
+     *     the same as or an ancestor of the class loader of {@code refc},
+     *     then {@link SecurityManager#checkPackageAccess
+     *     smgr.checkPackageAccess(refcPkg)} is called,
+     *     where {@code refcPkg} is the package of {@code refc}.
+     * <li>If the retrieved member is not public,
+     *     {@link SecurityManager#checkMemberAccess
+     *     smgr.checkMemberAccess(defc, Member.DECLARED)} is called.
+     *     (Note that {@code defc} might be the same as {@code refc}.)
+     * <li>If the retrieved member is not public,
+     *     and if {@code defc} and {@code refc} are in different class loaders,
+     *     and if the class loader of the lookup class is not
+     *     the same as or an ancestor of the class loader of {@code defc},
+     *     then {@link SecurityManager#checkPackageAccess
+     *     smgr.checkPackageAccess(defcPkg)} is called,
+     *     where {@code defcPkg} is the package of {@code defc}.
+     * </ul>
+     * In all cases, the requesting class presented to the security
+     * manager will be the lookup class from the current {@code Lookup} object.
      */
     public static final
     class Lookup {
@@ -194,12 +358,12 @@
             return (mods != 0) ? mods : PACKAGE;
         }
 
-        /** Which class is performing the lookup?  It is this class against
+        /** Tells which class is performing the lookup.  It is this class against
          *  which checks are performed for visibility and access permissions.
          *  <p>
          *  The class implies a maximum level of access permission,
          *  but the permissions may be additionally limited by the bitmask
-         *  {@link #lookupModes}, which controls whether non-public members
+         *  {@link #lookupModes lookupModes}, which controls whether non-public members
          *  can be accessed.
          */
         public Class<?> lookupClass() {
@@ -211,7 +375,7 @@
             return (allowedModes == TRUSTED) ? null : lookupClass;
         }
 
-        /** Which types of members can this lookup object produce?
+        /** Tells which access-protection classes of members this lookup object can produce.
          *  The result is a bit-mask of the bits
          *  {@linkplain #PUBLIC PUBLIC (0x01)},
          *  {@linkplain #PRIVATE PRIVATE (0x02)},
@@ -257,7 +421,7 @@
         }
 
         /**
-         * Create a lookup on the specified new lookup class.
+         * Creates a lookup on the specified new lookup class.
          * The resulting object will report the specified
          * class as its own {@link #lookupClass lookupClass}.
          * <p>
@@ -275,6 +439,10 @@
          * then no members, not even public members, will be accessible.
          * (In all other cases, public members will continue to be accessible.)
          * </ul>
+         *
+         * @param requestedLookupClass the desired lookup class for the new lookup object
+         * @return a lookup object which reports the desired lookup class
+         * @throws NullPointerException if the argument is null
          */
         public Lookup in(Class<?> requestedLookupClass) {
             requestedLookupClass.getClass();  // null check
@@ -322,11 +490,12 @@
         }
 
         /**
-         * Display the name of the class from which lookups are to be made.
+         * Displays the name of the class from which lookups are to be made.
          * (The name is the one reported by {@link java.lang.Class#getName() Class.getName}.)
          * If there are restrictions on the access permitted to this lookup,
          * this is indicated by adding a suffix to the class name, consisting
-         * of a slash and a keyword.  The keyword is chosen as follows:
+         * of a slash and a keyword.  The keyword represents the strongest
+         * allowed access, and is chosen as follows:
          * <ul>
          * <li>If no access is allowed, the suffix is "/noaccess".
          * <li>If only public access is allowed, the suffix is "/public".
@@ -337,26 +506,37 @@
          * access (public, package, private, and protected) is allowed.
          * In this case, no suffix is added.
          * This is true only of an object obtained originally from
-         * {@link java.dyn.MethodHandles#lookup() MethodHandles.lookup}.
-         * Objects created by {@link java.dyn.MethodHandles.Lookup#in() Lookup#in}
+         * {@link java.dyn.MethodHandles#lookup MethodHandles.lookup}.
+         * Objects created by {@link java.dyn.MethodHandles.Lookup#in Lookup.in}
          * always have restricted access, and will display a suffix.
+         * <p>
+         * (It may seem strange that protected access should be
+         * stronger than private access.  Viewed independently from
+         * package access, protected access is the first to be lost,
+         * because it requires a direct subclass relationship between
+         * caller and callee.)
+         * @see #in
          */
         @Override
         public String toString() {
             String cname = lookupClass.getName();
             switch (allowedModes) {
-            case TRUSTED:
-                return "/trusted";  // internal only
+            case 0:  // no privileges
+                return cname + "/noaccess";
             case PUBLIC:
                 return cname + "/public";
             case PUBLIC|PACKAGE:
                 return cname + "/package";
-            case 0:  // no privileges
-                return cname + "/noaccess";
+            case ALL_MODES & ~PROTECTED:
+                return cname + "/private";
             case ALL_MODES:
                 return cname;
-            default:
-                return cname + "/private";
+            case TRUSTED:
+                return "/trusted";  // internal only; not exported
+            default:  // Should not happen, but it's a bitfield...
+                cname = cname + "/" + Integer.toHexString(allowedModes);
+                assert(false) : cname;
+                return cname;
             }
         }
 
@@ -371,29 +551,37 @@
         }
 
         /**
-         * Produce a method handle for a static method.
+         * Produces a method handle for a static method.
          * The type of the method handle will be that of the method.
          * (Since static methods do not take receivers, there is no
          * additional receiver argument inserted into the method handle type,
-         * as there would be with {@link #findVirtual} or {@link #findSpecial}.)
+         * as there would be with {@link #findVirtual findVirtual} or {@link #findSpecial findSpecial}.)
          * The method and all its argument types must be accessible to the lookup class.
          * If the method's class has not yet been initialized, that is done
          * immediately, before the method handle is returned.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
          * @param refc the class from which the method is accessed
          * @param name the name of the method
          * @param type the type of the method
          * @return the desired method handle
-         * @exception NoAccessException if the method does not exist or access checking fails
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails, or if the method is not {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
         public
-        MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoAccessException {
+        MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
             MemberName method = resolveOrFail(refc, name, type, true);
             checkMethod(refc, method, true);
             return MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, lookupClassOrNull());
         }
 
         /**
-         * Produce a method handle for a virtual method.
+         * Produces a method handle for a virtual method.
          * The type of the method handle will be that of the method,
          * with the receiver type (usually {@code refc}) prepended.
          * The method and all its argument types must be accessible to the lookup class.
@@ -403,13 +591,31 @@
          * implementation to enter.
          * (The dispatching action is identical with that performed by an
          * {@code invokevirtual} or {@code invokeinterface} instruction.)
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
+         * <p>
+         * Because of the general equivalence between {@code invokevirtual}
+         * instructions and method handles produced by {@code findVirtual},
+         * if the class is {@code MethodHandle} and the name string is
+         * {@code invokeExact} or {@code invokeGeneric}, the resulting
+         * method handle is equivalent to one produced by
+         * {@link java.dyn.MethodHandles#exactInvoker MethodHandles.exactInvoker} or
+         * {@link java.dyn.MethodHandles#genericInvoker MethodHandles.genericInvoker}
+         * with the same {@code type} argument.
+         *
          * @param refc the class or interface from which the method is accessed
          * @param name the name of the method
          * @param type the type of the method, with the receiver argument omitted
          * @return the desired method handle
-         * @exception NoAccessException if the method does not exist or access checking fails
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails, or if the method is {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle findVirtual(Class<?> refc, String name, MethodType type) throws NoAccessException {
+        public MethodHandle findVirtual(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
             MemberName method = resolveOrFail(refc, name, type, false);
             checkMethod(refc, method, false);
             MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull());
@@ -417,7 +623,7 @@
         }
 
         /**
-         * Produce a method handle which creates an object and initializes it, using
+         * Produces a method handle which creates an object and initializes it, using
          * the constructor of the specified type.
          * The parameter types of the method handle will be those of the constructor,
          * while the return type will be a reference to the constructor's class.
@@ -426,23 +632,47 @@
          * immediately, before the method handle is returned.
          * <p>
          * Note:  The requested type must have a return type of {@code void}.
-         * This is consistent with the JVM's treatment of constructor signatures.
+         * This is consistent with the JVM's treatment of constructor type descriptors.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the constructor's variable arity modifier bit ({@code 0x0080}) is set.
          * @param refc the class or interface from which the method is accessed
          * @param type the type of the method, with the receiver argument omitted, and a void return type
          * @return the desired method handle
-         * @exception NoAccessException if the method does not exist or access checking fails
+         * @throws NoSuchMethodException if the constructor does not exist
+         * @throws IllegalAccessException if access checking fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoAccessException {
+        public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
             String name = "<init>";
             MemberName ctor = resolveOrFail(refc, name, type, false, false, lookupClassOrNull());
             assert(ctor.isConstructor());
             checkAccess(refc, ctor);
             MethodHandle rawMH = MethodHandleImpl.findMethod(IMPL_TOKEN, ctor, false, lookupClassOrNull());
-            return MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawMH);
+            MethodHandle allocMH = MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawMH);
+            return fixVarargs(allocMH, rawMH);
+        }
+
+        /** Return a version of MH which matches matchMH w.r.t. isVarargsCollector. */
+        private static MethodHandle fixVarargs(MethodHandle mh, MethodHandle matchMH) {
+            boolean va1 = mh.isVarargsCollector();
+            boolean va2 = matchMH.isVarargsCollector();
+            if (va1 == va2) {
+                return mh;
+            } else if (va2) {
+                MethodType type = mh.type();
+                int arity = type.parameterCount();
+                return mh.asVarargsCollector(type.parameterType(arity-1));
+            } else {
+                throw new InternalError("already varargs, but template is not: "+mh);
+            }
         }
 
         /**
-         * Produce an early-bound method handle for a virtual method,
+         * Produces an early-bound method handle for a virtual method,
          * as if called from an {@code invokespecial}
          * instruction from {@code caller}.
          * The type of the method handle will be that of the method,
@@ -458,15 +688,23 @@
          * If the explicitly specified caller class is not identical with the
          * lookup class, or if this lookup object does not have private access
          * privileges, the access fails.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
          * @param refc the class or interface from which the method is accessed
          * @param name the name of the method (which must not be "&lt;init&gt;")
          * @param type the type of the method, with the receiver argument omitted
          * @param specialCaller the proposed calling class to perform the {@code invokespecial}
          * @return the desired method handle
-         * @exception NoAccessException if the method does not exist or access checking fails
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
         public MethodHandle findSpecial(Class<?> refc, String name, MethodType type,
-                                        Class<?> specialCaller) throws NoAccessException {
+                                        Class<?> specialCaller) throws NoSuchMethodException, IllegalAccessException {
             checkSpecialCaller(specialCaller);
             MemberName method = resolveOrFail(refc, name, type, false, false, specialCaller);
             checkMethod(refc, method, false);
@@ -475,69 +713,89 @@
         }
 
         /**
-         * Produce a method handle giving read access to a non-static field.
+         * Produces a method handle giving read access to a non-static field.
          * The type of the method handle will have a return type of the field's
          * value type.
          * The method handle's single argument will be the instance containing
          * the field.
          * Access checking is performed immediately on behalf of the lookup class.
+         * @param refc the class or interface from which the method is accessed
          * @param name the field's name
          * @param type the field's type
          * @return a method handle which can load values from the field
-         * @exception NoAccessException if access checking fails
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle findGetter(Class<?> refc, String name, Class<?> type) throws NoAccessException {
+        public MethodHandle findGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
             return makeAccessor(refc, name, type, false, false);
         }
 
         /**
-         * Produce a method handle giving write access to a non-static field.
+         * Produces a method handle giving write access to a non-static field.
          * The type of the method handle will have a void return type.
          * The method handle will take two arguments, the instance containing
          * the field, and the value to be stored.
          * The second argument will be of the field's value type.
          * Access checking is performed immediately on behalf of the lookup class.
+         * @param refc the class or interface from which the method is accessed
          * @param name the field's name
          * @param type the field's type
          * @return a method handle which can store values into the field
-         * @exception NoAccessException if access checking fails
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle findSetter(Class<?> refc, String name, Class<?> type) throws NoAccessException {
+        public MethodHandle findSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
             return makeAccessor(refc, name, type, false, true);
         }
 
         /**
-         * Produce a method handle giving read access to a static field.
+         * Produces a method handle giving read access to a static field.
          * The type of the method handle will have a return type of the field's
          * value type.
          * The method handle will take no arguments.
          * Access checking is performed immediately on behalf of the lookup class.
+         * @param refc the class or interface from which the method is accessed
          * @param name the field's name
          * @param type the field's type
          * @return a method handle which can load values from the field
-         * @exception NoAccessException if access checking fails
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is not {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle findStaticGetter(Class<?> refc, String name, Class<?> type) throws NoAccessException {
+        public MethodHandle findStaticGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
             return makeAccessor(refc, name, type, true, false);
         }
 
         /**
-         * Produce a method handle giving write access to a static field.
+         * Produces a method handle giving write access to a static field.
          * The type of the method handle will have a void return type.
          * The method handle will take a single
          * argument, of the field's value type, the value to be stored.
          * Access checking is performed immediately on behalf of the lookup class.
+         * @param refc the class or interface from which the method is accessed
          * @param name the field's name
          * @param type the field's type
          * @return a method handle which can store values into the field
-         * @exception NoAccessException if access checking fails
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is not {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle findStaticSetter(Class<?> refc, String name, Class<?> type) throws NoAccessException {
+        public MethodHandle findStaticSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
             return makeAccessor(refc, name, type, true, true);
         }
 
         /**
-         * Produce an early-bound method handle for a non-static method.
+         * Produces an early-bound method handle for a non-static method.
          * The receiver must have a supertype {@code defc} in which a method
          * of the given name and type is accessible to the lookup class.
          * The method and all its argument types must be accessible to the lookup class.
@@ -547,28 +805,47 @@
          * so that every call to the method handle will invoke the
          * requested method on the given receiver.
          * <p>
-         * This is equivalent to the following expression:
-         * <code>
-         * {@link #insertArguments insertArguments}({@link #findVirtual findVirtual}(defc, name, type), receiver)
-         * </code>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set
+         * <em>and</em> the trailing array argument is not the only argument.
+         * (If the trailing array argument is the only argument,
+         * the given receiver value will be bound to it.)
+         * <p>
+         * This is equivalent to the following code:
+         * <blockquote><pre>
+MethodHandle mh0 = {@link #findVirtual findVirtual}(defc, name, type);
+MethodHandle mh1 = mh0.{@link MethodHandle#bindTo bindTo}(receiver);
+MethodType mt1 = mh1.type();
+if (mh0.isVarargsCollector() && mt1.parameterCount() > 0) {
+  mh1 = mh1.asVarargsCollector(mt1.parameterType(mt1.parameterCount()-1));
+return mh1;
+         * </pre></blockquote>
          * where {@code defc} is either {@code receiver.getClass()} or a super
          * type of that class, in which the requested method is accessible
          * to the lookup class.
+         * (Note that {@code bindTo} does not preserve variable arity.)
          * @param receiver the object from which the method is accessed
          * @param name the name of the method
          * @param type the type of the method, with the receiver argument omitted
          * @return the desired method handle
-         * @exception NoAccessException if the method does not exist or access checking fails
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle bind(Object receiver, String name, MethodType type) throws NoAccessException {
+        public MethodHandle bind(Object receiver, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
             Class<? extends Object> refc = receiver.getClass(); // may get NPE
             MemberName method = resolveOrFail(refc, name, type, false);
             checkMethod(refc, method, false);
             MethodHandle dmh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull());
             MethodHandle bmh = MethodHandleImpl.bindReceiver(IMPL_TOKEN, dmh, receiver);
             if (bmh == null)
-                throw newNoAccessException(method, lookupClass());
-            return bmh;
+                throw newNoAccessException(method, this);
+            if (dmh.type().parameterCount() == 0)
+                return dmh;  // bound the trailing parameter; no varargs possible
+            return fixVarargs(bmh, dmh);
         }
 
         /**
@@ -581,11 +858,16 @@
          * If the method's {@code accessible} flag is not set,
          * access checking is performed immediately on behalf of the lookup class.
          * If <i>m</i> is not public, do not share the resulting handle with untrusted parties.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
          * @param m the reflected method
          * @return a method handle which can invoke the reflected method
-         * @exception NoAccessException if access checking fails
+         * @throws IllegalAccessException if access checking fails
+         * @throws NullPointerException if the argument is null
          */
-        public MethodHandle unreflect(Method m) throws NoAccessException {
+        public MethodHandle unreflect(Method m) throws IllegalAccessException {
             MemberName method = new MemberName(m);
             assert(method.isMethod());
             if (!m.isAccessible())  checkMethod(method.getDeclaringClass(), method, method.isStatic());
@@ -595,7 +877,7 @@
         }
 
         /**
-         * Produce a method handle for a reflected method.
+         * Produces a method handle for a reflected method.
          * It will bypass checks for overriding methods on the receiver,
          * as if by a {@code invokespecial} instruction from within the {@code specialCaller}.
          * The type of the method handle will be that of the method,
@@ -603,12 +885,17 @@
          * If the method's {@code accessible} flag is not set,
          * access checking is performed immediately on behalf of the lookup class,
          * as if {@code invokespecial} instruction were being linked.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
          * @param m the reflected method
          * @param specialCaller the class nominally calling the method
          * @return a method handle which can invoke the reflected method
-         * @exception NoAccessException if access checking fails
+         * @throws IllegalAccessException if access checking fails
+         * @throws NullPointerException if any argument is null
          */
-        public MethodHandle unreflectSpecial(Method m, Class<?> specialCaller) throws NoAccessException {
+        public MethodHandle unreflectSpecial(Method m, Class<?> specialCaller) throws IllegalAccessException {
             checkSpecialCaller(specialCaller);
             MemberName method = new MemberName(m);
             assert(method.isMethod());
@@ -619,7 +906,7 @@
         }
 
         /**
-         * Produce a method handle for a reflected constructor.
+         * Produces a method handle for a reflected constructor.
          * The type of the method handle will be that of the constructor,
          * with the return type changed to the declaring class.
          * The method handle will perform a {@code newInstance} operation,
@@ -628,20 +915,26 @@
          * <p>
          * If the constructor's {@code accessible} flag is not set,
          * access checking is performed immediately on behalf of the lookup class.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the constructor's variable arity modifier bit ({@code 0x0080}) is set.
          * @param c the reflected constructor
          * @return a method handle which can invoke the reflected constructor
-         * @exception NoAccessException if access checking fails
+         * @throws IllegalAccessException if access checking fails
+         * @throws NullPointerException if the argument is null
          */
-        public MethodHandle unreflectConstructor(Constructor c) throws NoAccessException {
+        public MethodHandle unreflectConstructor(Constructor c) throws IllegalAccessException {
             MemberName ctor = new MemberName(c);
             assert(ctor.isConstructor());
             if (!c.isAccessible())  checkAccess(c.getDeclaringClass(), ctor);
             MethodHandle rawCtor = MethodHandleImpl.findMethod(IMPL_TOKEN, ctor, false, lookupClassOrNull());
-            return MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawCtor);
+            MethodHandle allocator = MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawCtor);
+            return fixVarargs(allocator, rawCtor);
         }
 
         /**
-         * Produce a method handle giving read access to a reflected field.
+         * Produces a method handle giving read access to a reflected field.
          * The type of the method handle will have a return type of the field's
          * value type.
          * If the field is static, the method handle will take no arguments.
@@ -651,14 +944,15 @@
          * access checking is performed immediately on behalf of the lookup class.
          * @param f the reflected field
          * @return a method handle which can load values from the reflected field
-         * @exception NoAccessException if access checking fails
+         * @throws IllegalAccessException if access checking fails
+         * @throws NullPointerException if the argument is null
          */
-        public MethodHandle unreflectGetter(Field f) throws NoAccessException {
+        public MethodHandle unreflectGetter(Field f) throws IllegalAccessException {
             return makeAccessor(f.getDeclaringClass(), new MemberName(f), f.isAccessible(), false);
         }
 
         /**
-         * Produce a method handle giving write access to a reflected field.
+         * Produces a method handle giving write access to a reflected field.
          * The type of the method handle will have a void return type.
          * If the field is static, the method handle will take a single
          * argument, of the field's value type, the value to be stored.
@@ -668,40 +962,47 @@
          * access checking is performed immediately on behalf of the lookup class.
          * @param f the reflected field
          * @return a method handle which can store values into the reflected field
-         * @exception NoAccessException if access checking fails
+         * @throws IllegalAccessException if access checking fails
+         * @throws NullPointerException if the argument is null
          */
-        public MethodHandle unreflectSetter(Field f) throws NoAccessException {
+        public MethodHandle unreflectSetter(Field f) throws IllegalAccessException {
             return makeAccessor(f.getDeclaringClass(), new MemberName(f), f.isAccessible(), true);
         }
 
         /// Helper methods, all package-private.
 
-        MemberName resolveOrFail(Class<?> refc, String name, Class<?> type, boolean isStatic) throws NoAccessException {
+        MemberName resolveOrFail(Class<?> refc, String name, Class<?> type, boolean isStatic) throws NoSuchFieldException, IllegalAccessException {
             checkSymbolicClass(refc);  // do this before attempting to resolve
+            name.getClass(); type.getClass();  // NPE
             int mods = (isStatic ? Modifier.STATIC : 0);
-            return IMPL_NAMES.resolveOrFail(new MemberName(refc, name, type, mods), true, lookupClassOrNull());
+            return IMPL_NAMES.resolveOrFail(new MemberName(refc, name, type, mods), true, lookupClassOrNull(),
+                                            NoSuchFieldException.class);
         }
 
-        MemberName resolveOrFail(Class<?> refc, String name, MethodType type, boolean isStatic) throws NoAccessException {
+        MemberName resolveOrFail(Class<?> refc, String name, MethodType type, boolean isStatic) throws NoSuchMethodException, IllegalAccessException {
             checkSymbolicClass(refc);  // do this before attempting to resolve
+            name.getClass(); type.getClass();  // NPE
             int mods = (isStatic ? Modifier.STATIC : 0);
-            return IMPL_NAMES.resolveOrFail(new MemberName(refc, name, type, mods), true, lookupClassOrNull());
+            return IMPL_NAMES.resolveOrFail(new MemberName(refc, name, type, mods), true, lookupClassOrNull(),
+                                            NoSuchMethodException.class);
         }
 
         MemberName resolveOrFail(Class<?> refc, String name, MethodType type, boolean isStatic,
-                                 boolean searchSupers, Class<?> specialCaller) throws NoAccessException {
+                                 boolean searchSupers, Class<?> specialCaller) throws NoSuchMethodException, IllegalAccessException {
             checkSymbolicClass(refc);  // do this before attempting to resolve
+            name.getClass(); type.getClass();  // NPE
             int mods = (isStatic ? Modifier.STATIC : 0);
-            return IMPL_NAMES.resolveOrFail(new MemberName(refc, name, type, mods), searchSupers, specialCaller);
+            return IMPL_NAMES.resolveOrFail(new MemberName(refc, name, type, mods), searchSupers, specialCaller,
+                                            NoSuchMethodException.class);
         }
 
-        void checkSymbolicClass(Class<?> refc) throws NoAccessException {
+        void checkSymbolicClass(Class<?> refc) throws IllegalAccessException {
             Class<?> caller = lookupClassOrNull();
             if (caller != null && !VerifyAccess.isClassAccessible(refc, caller))
-                throw newNoAccessException("symbolic reference class is not public", new MemberName(refc), caller);
+                throw newNoAccessException("symbolic reference class is not public", new MemberName(refc), this);
         }
 
-        void checkMethod(Class<?> refc, MemberName m, boolean wantStatic) throws NoAccessException {
+        void checkMethod(Class<?> refc, MemberName m, boolean wantStatic) throws IllegalAccessException {
             String message;
             if (m.isConstructor())
                 message = "expected a method, not a constructor";
@@ -711,10 +1012,10 @@
                 message = wantStatic ? "expected a static method" : "expected a non-static method";
             else
                 { checkAccess(refc, m); return; }
-            throw newNoAccessException(message, m, lookupClass());
+            throw newNoAccessException(message, m, this);
         }
 
-        void checkAccess(Class<?> refc, MemberName m) throws NoAccessException {
+        void checkAccess(Class<?> refc, MemberName m) throws IllegalAccessException {
             int allowedModes = this.allowedModes;
             if (allowedModes == TRUSTED)  return;
             int mods = m.getModifiers();
@@ -729,22 +1030,25 @@
                 && VerifyAccess.isSamePackage(m.getDeclaringClass(), lookupClass()))
                 // Protected members can also be checked as if they were package-private.
                 return;
-            throw newNoAccessException(accessFailedMessage(refc, m), m, lookupClass());
+            throw newNoAccessException(accessFailedMessage(refc, m), m, this);
         }
 
         String accessFailedMessage(Class<?> refc, MemberName m) {
             Class<?> defc = m.getDeclaringClass();
             int mods = m.getModifiers();
-            if (!VerifyAccess.isClassAccessible(defc, lookupClass()))
+            // check the class first:
+            boolean classOK = (Modifier.isPublic(defc.getModifiers()) &&
+                               (defc == refc ||
+                                Modifier.isPublic(refc.getModifiers())));
+            if (!classOK && (allowedModes & PACKAGE) != 0) {
+                classOK = (VerifyAccess.isClassAccessible(defc, lookupClass()) &&
+                           (defc == refc ||
+                            VerifyAccess.isClassAccessible(refc, lookupClass())));
+            }
+            if (!classOK)
                 return "class is not public";
-            if (refc != defc && !VerifyAccess.isClassAccessible(refc, lookupClass()))
-                return "symbolic reference "+refc.getName()+" is not public";
             if (Modifier.isPublic(mods))
                 return "access to public member failed";  // (how?)
-            else if (allowedModes == PUBLIC)
-                return "member is not public";
-            else if (allowedModes == 0)
-                return "attempted member access through a non-public class";
             if (Modifier.isPrivate(mods))
                 return "member is private";
             if (Modifier.isProtected(mods))
@@ -754,17 +1058,17 @@
 
         private static final boolean ALLOW_NESTMATE_ACCESS = false;
 
-        void checkSpecialCaller(Class<?> specialCaller) throws NoAccessException {
+        void checkSpecialCaller(Class<?> specialCaller) throws IllegalAccessException {
             if (allowedModes == TRUSTED)  return;
             if ((allowedModes & PRIVATE) == 0
                 || (specialCaller != lookupClass()
                     && !(ALLOW_NESTMATE_ACCESS &&
                          VerifyAccess.isSamePackageMember(specialCaller, lookupClass()))))
                 throw newNoAccessException("no private access for invokespecial",
-                                           new MemberName(specialCaller), lookupClass());
+                                           new MemberName(specialCaller), this);
         }
 
-        MethodHandle restrictProtectedReceiver(MemberName method, MethodHandle mh) throws NoAccessException {
+        MethodHandle restrictProtectedReceiver(MemberName method, MethodHandle mh) throws IllegalAccessException {
             // The accessing class only has the right to use a protected member
             // on itself or a subclass.  Enforce that restriction, from JVMS 5.4.4, etc.
             if (!method.isProtected() || method.isStatic()
@@ -776,7 +1080,7 @@
             else
                 return restrictReceiver(method, mh, lookupClass());
         }
-        MethodHandle restrictReceiver(MemberName method, MethodHandle mh, Class<?> caller) throws NoAccessException {
+        MethodHandle restrictReceiver(MemberName method, MethodHandle mh, Class<?> caller) throws IllegalAccessException {
             assert(!method.isStatic());
             Class<?> defc = method.getDeclaringClass();  // receiver type of mh is too wide
             if (defc.isInterface() || !defc.isAssignableFrom(caller)) {
@@ -785,22 +1089,23 @@
             MethodType rawType = mh.type();
             if (rawType.parameterType(0) == caller)  return mh;
             MethodType narrowType = rawType.changeParameterType(0, caller);
-            return MethodHandleImpl.convertArguments(IMPL_TOKEN, mh, narrowType, rawType, null);
+            MethodHandle narrowMH = MethodHandleImpl.convertArguments(IMPL_TOKEN, mh, narrowType, rawType, null);
+            return fixVarargs(narrowMH, mh);
         }
 
         MethodHandle makeAccessor(Class<?> refc, String name, Class<?> type,
-                                  boolean isStatic, boolean isSetter) throws NoAccessException {
+                                  boolean isStatic, boolean isSetter) throws NoSuchFieldException, IllegalAccessException {
             MemberName field = resolveOrFail(refc, name, type, isStatic);
             if (isStatic != field.isStatic())
                 throw newNoAccessException(isStatic
                                            ? "expected a static field"
                                            : "expected a non-static field",
-                                           field, lookupClass());
+                                           field, this);
             return makeAccessor(refc, field, false, isSetter);
         }
 
         MethodHandle makeAccessor(Class<?> refc, MemberName field,
-                                  boolean trusted, boolean isSetter) throws NoAccessException {
+                                  boolean trusted, boolean isSetter) throws IllegalAccessException {
             assert(field.isField());
             if (trusted)
                 return MethodHandleImpl.accessField(IMPL_TOKEN, field, isSetter, lookupClassOrNull());
@@ -811,12 +1116,13 @@
     }
 
     /**
-     * Produce a method handle giving read access to elements of an array.
+     * Produces a method handle giving read access to elements of an array.
      * The type of the method handle will have a return type of the array's
      * element type.  Its first argument will be the array type,
      * and the second will be {@code int}.
      * @param arrayClass an array type
      * @return a method handle which can load values from the given array type
+     * @throws NullPointerException if the argument is null
      * @throws  IllegalArgumentException if arrayClass is not an array type
      */
     public static
@@ -825,11 +1131,12 @@
     }
 
     /**
-     * Produce a method handle giving write access to elements of an array.
+     * Produces a method handle giving write access to elements of an array.
      * The type of the method handle will have a void return type.
      * Its last argument will be the array's element type.
      * The first and second arguments will be the array type and int.
      * @return a method handle which can store values into the array type
+     * @throws NullPointerException if the argument is null
      * @throws IllegalArgumentException if arrayClass is not an array type
      */
     public static
@@ -840,47 +1147,7 @@
     /// method handle invocation (reflective style)
 
     /**
-     * Produce a method handle which will invoke any method handle of the
-     * given type on a standard set of {@code Object} type arguments.
-     * The resulting invoker will be a method handle with the following
-     * arguments:
-     * <ul>
-     * <li>a single {@code MethodHandle} target
-     * <li>zero or more {@code Object} values (one for each argument in {@code type})
-     * </ul>
-     * <p>
-     * The invoker will behave like a call to {@link MethodHandle.invokeGeneric} with
-     * the indicated {@code type}.
-     * That is, if the target is exactly of the given {@code type}, it will behave
-     * like {@code invokeExact}; otherwise it behave as if {@link MethodHandle.asType}
-     * is used to convert the target to the required {@code type}.
-     * <p>
-     * The type of the returned invoker will not be the given {@code type}, but rather
-     * will have all parameter and return types replaced by {@code Object}.
-     * <p>
-     * Before invoking its target, the invoker will apply reference casts as
-     * necessary and unbox and widen primitive arguments, as if by {@link #convertArguments}.
-     * The return value of the invoker will be an {@code Object} reference,
-     * boxing a primitive value if the original type returns a primitive,
-     * and always null if the original type returns void.
-     * <p>
-     * This method is equivalent to the following code (though it may be more efficient):
-     * <p><blockquote><pre>
-     * MethodHandle invoker = lookup().findVirtual(MethodHandle.class, "invokeGeneric", type);
-     * MethodType genericType = type.generic();
-     * genericType = genericType.insertParameterType(0, MethodHandle.class);
-     * return invoker.asType(genericType);
-     * </pre></blockquote>
-     * @param type the type of target methods which the invoker will apply to
-     * @return a method handle suitable for invoking any method handle of the given type
-     */
-    static public
-    MethodHandle genericInvoker(MethodType type) {
-        return invokers(type).genericInvoker();
-    }
-
-    /**
-     * Produce a method handle which will invoke any method handle of the
+     * Produces a method handle which will invoke any method handle of the
      * given {@code type} on a standard set of {@code Object} type arguments
      * and a single trailing {@code Object[]} array.
      * The resulting invoker will be a method handle with the following
@@ -891,10 +1158,10 @@
      * <li>an {@code Object[]} array containing more arguments
      * </ul>
      * <p>
-     * The invoker will behave like a call to {@link MethodHandle.invokeGeneric} with
+     * The invoker will behave like a call to {@link MethodHandle#invokeGeneric invokeGeneric} with
      * the indicated {@code type}.
      * That is, if the target is exactly of the given {@code type}, it will behave
-     * like {@code invokeExact}; otherwise it behave as if {@link MethodHandle.asType}
+     * like {@code invokeExact}; otherwise it behave as if {@link MethodHandle#asType asType}
      * is used to convert the target to the required {@code type}.
      * <p>
      * The type of the returned invoker will not be the given {@code type}, but rather
@@ -909,34 +1176,56 @@
      * <p>
      * This method is equivalent to the following code (though it may be more efficient):
      * <p><blockquote><pre>
-     * MethodHandle invoker = lookup().findVirtual(MethodHandle.class, "invokeGeneric", type);
-     * MethodType vaType = MethodType.genericMethodType(objectArgCount, true);
-     * vaType = vaType.insertParameterType(0, MethodHandle.class);
-     * int spreadArgCount = type.parameterCount - objectArgCount;
-     * invoker = invoker.asSpreader(Object.class, spreadArgCount);
-     * return invoker.asType(vaType);
+MethodHandle invoker = MethodHandles.genericInvoker(type);
+int spreadArgCount = type.parameterCount - objectArgCount;
+invoker = invoker.asSpreader(Object[].class, spreadArgCount);
+return invoker;
      * </pre></blockquote>
+     * <p>
+     * This method throws no reflective or security exceptions.
      * @param type the desired target type
      * @param objectArgCount number of fixed (non-varargs) {@code Object} arguments
      * @return a method handle suitable for invoking any method handle of the given type
      */
     static public
-    MethodHandle varargsInvoker(MethodType type, int objectArgCount) {
+    MethodHandle spreadInvoker(MethodType type, int objectArgCount) {
         if (objectArgCount < 0 || objectArgCount > type.parameterCount())
             throw new IllegalArgumentException("bad argument count "+objectArgCount);
-        return invokers(type).varargsInvoker(objectArgCount);
+        return invokers(type).spreadInvoker(objectArgCount);
     }
 
     /**
-     * Produce a method handle which will take a invoke any method handle of the
-     * given type.  The resulting invoker will have a type which is
+     * Produces a special <em>invoker method handle</em> which can be used to
+     * invoke any method handle of the given type, as if by {@code invokeExact}.
+     * The resulting invoker will have a type which is
      * exactly equal to the desired type, except that it will accept
      * an additional leading argument of type {@code MethodHandle}.
      * <p>
      * This method is equivalent to the following code (though it may be more efficient):
      * <p><blockquote><pre>
-     * lookup().findVirtual(MethodHandle.class, "invokeExact", type);
+publicLookup().findVirtual(MethodHandle.class, "invokeExact", type)
      * </pre></blockquote>
+     *
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * Invoker method handles can be useful when working with variable method handles
+     * of unknown types.
+     * For example, to emulate an {@code invokeExact} call to a variable method
+     * handle {@code M}, extract its type {@code T},
+     * look up the invoker method {@code X} for {@code T},
+     * and call the invoker method, as {@code X.invokeGeneric(T, A...)}.
+     * (It would not work to call {@code X.invokeExact}, since the type {@code T}
+     * is unknown.)
+     * If spreading, collecting, or other argument transformations are required,
+     * they can be applied once to the invoker {@code X} and reused on many {@code M}
+     * method handle values, as long as they are compatible with the type of {@code X}.
+     * <p>
+     * <em>(Note:  The invoker method is not available via the Core Reflection API.
+     * An attempt to call {@linkplain java.lang.reflect.Method#invoke Method.invoke}
+     * on the declared {@code invokeExact} or {@code invokeGeneric} method will raise an
+     * {@link java.lang.UnsupportedOperationException UnsupportedOperationException}.)</em>
+     * <p>
+     * This method throws no reflective or security exceptions.
      * @param type the desired target type
      * @return a method handle suitable for invoking any method handle of the given type
      */
@@ -945,12 +1234,38 @@
         return invokers(type).exactInvoker();
     }
 
+    /**
+     * Produces a special <em>invoker method handle</em> which can be used to
+     * invoke any method handle of the given type, as if by {@code invokeGeneric}.
+     * The resulting invoker will have a type which is
+     * exactly equal to the desired type, except that it will accept
+     * an additional leading argument of type {@code MethodHandle}.
+     * <p>
+     * Before invoking its target, the invoker will apply reference casts as
+     * necessary and unbox and widen primitive arguments, as if by {@link #convertArguments convertArguments}.
+     * The return value of the invoker will be an {@code Object} reference,
+     * boxing a primitive value if the original type returns a primitive,
+     * and always null if the original type returns void.
+     * <p>
+     * This method is equivalent to the following code (though it may be more efficient):
+     * <p><blockquote><pre>
+publicLookup().findVirtual(MethodHandle.class, "invokeGeneric", type)
+     * </pre></blockquote>
+     * <p>
+     * This method throws no reflective or security exceptions.
+     * @param type the desired target type
+     * @return a method handle suitable for invoking any method handle convertible to the given type
+     */
+    static public
+    MethodHandle genericInvoker(MethodType type) {
+        return invokers(type).genericInvoker();
+    }
+
     static Invokers invokers(MethodType type) {
         return MethodTypeImpl.invokers(IMPL_TOKEN, type);
     }
 
     /**
-     * <em>WORK IN PROGRESS:</em>
      * Perform value checking, exactly as if for an adapted method handle.
      * It is assumed that the given value is either null, of type T0,
      * or (if T0 is primitive) of the wrapper type corresponding to T0.
@@ -1021,7 +1336,7 @@
     /// method handle modification (creation from other method handles)
 
     /**
-     * Produce a method handle which adapts the type of the
+     * Produces a method handle which adapts the type of the
      * given method handle to a new type by pairwise argument conversion.
      * The original type and new type must have the same number of arguments.
      * The resulting method handle is guaranteed to report a type
@@ -1060,6 +1375,7 @@
      * @return a method handle which delegates to {@code target} after performing
      *           any necessary argument conversions, and arranges for any
      *           necessary return value conversions
+     * @throws NullPointerException if either argument is null
      * @throws WrongMethodTypeException if the conversion cannot be made
      * @see MethodHandle#asType
      * @see MethodHandles#explicitCastArguments
@@ -1081,7 +1397,7 @@
     }
 
     /**
-     * Produce a method handle which adapts the type of the
+     * Produces a method handle which adapts the type of the
      * given method handle to a new type by pairwise argument conversion.
      * The original type and new type must have the same number of arguments.
      * The resulting method handle is guaranteed to report a type
@@ -1113,6 +1429,7 @@
      * @return a method handle which delegates to {@code target} after performing
      *           any necessary argument conversions, and arranges for any
      *           necessary return value conversions
+     * @throws NullPointerException if either argument is null
      * @throws WrongMethodTypeException if the conversion cannot be made
      * @see MethodHandle#asType
      * @see MethodHandles#convertArguments
@@ -1160,7 +1477,7 @@
     */
 
     /**
-     * Produce a method handle which adapts the calling sequence of the
+     * Produces a method handle which adapts the calling sequence of the
      * given method handle to a new type, by reordering the arguments.
      * The resulting method handle is guaranteed to report a type
      * which is equal to the desired new type.
@@ -1208,6 +1525,7 @@
      * @param reorder a string which controls the reordering
      * @return a method handle which delegates to {@code target} after it
      *           drops unused arguments and moves and/or duplicates the other arguments
+     * @throws NullPointerException if any argument is null
      */
     public static
     MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
@@ -1233,11 +1551,10 @@
     }
 
     /**
-     * <em>METHOD WILL BE REMOVED FOR PFD:</em>
      * Equivalent to the following code:
      * <p><blockquote><pre>
      * int spreadPos = newType.parameterCount() - 1;
-     * Class<?> spreadType = newType.parameterType(spreadPos);
+     * Class&lt;?&gt; spreadType = newType.parameterType(spreadPos);
      * int spreadCount = target.type().parameterCount() - spreadPos;
      * MethodHandle adapter = target.asSpreader(spreadType, spreadCount);
      * adapter = adapter.asType(newType);
@@ -1247,9 +1564,8 @@
      * @param newType the expected type of the new method handle
      * @return a method handle which spreads its final argument,
      *         before calling the original method handle
-     * @deprecated Use {@link MethodHandle#asSpreader}
      */
-    public static
+    /*non-public*/ static
     MethodHandle spreadArguments(MethodHandle target, MethodType newType) {
         MethodType oldType = target.type();
         int inargs  = newType.parameterCount();
@@ -1267,11 +1583,10 @@
     }
 
     /**
-     * <em>METHOD WILL BE REMOVED FOR PFD:</em>
      * Equivalent to the following code:
      * <p><blockquote><pre>
      * int collectPos = target.type().parameterCount() - 1;
-     * Class<?> collectType = target.type().parameterType(collectPos);
+     * Class&lt;?&gt; collectType = target.type().parameterType(collectPos);
      * if (!collectType.isArray())  collectType = Object[].class;
      * int collectCount = newType.parameterCount() - collectPos;
      * MethodHandle adapter = target.asCollector(collectType, collectCount);
@@ -1282,9 +1597,8 @@
      * @param newType the expected type of the new method handle
      * @return a method handle which collects some trailing argument
      *         into an array, before calling the original method handle
-     * @deprecated Use {@link MethodHandle#asCollector} instead.
      */
-    public static
+    /*non-public*/ static
     MethodHandle collectArguments(MethodHandle target, MethodType newType) {
         MethodType oldType = target.type();
         int inargs  = newType.parameterCount();
@@ -1301,7 +1615,7 @@
     }
 
     /**
-     * Produce a method handle of the requested return type which returns the given
+     * Produces a method handle of the requested return type which returns the given
      * constant value every time it is invoked.
      * <p>
      * Before the method handle is returned, the passed-in value is converted to the requested type.
@@ -1312,12 +1626,15 @@
      * @param type the return type of the desired method handle
      * @param value the value to return
      * @return a method handle of the given return type and no arguments, which always returns the given value
-     * @throws WrongMethodTypeException if the value cannot be converted to the required return type
+     * @throws NullPointerException if the {@code type} argument is null
+     * @throws ClassCastException if the value cannot be converted to the required return type
+     * @throws IllegalArgumentException if the given type is {@code void.class}
      */
     public static
     MethodHandle constant(Class<?> type, Object value) {
         if (type.isPrimitive()) {
-            if (type == void.class)  return identity(type);
+            if (type == void.class)
+                throw newIllegalArgumentException("void type");
             Wrapper w = Wrapper.forPrimitiveType(type);
             return identity(type).bindTo(w.convert(value, type));
         } else {
@@ -1326,64 +1643,22 @@
     }
 
     /**
-     * Produce a method handle of the requested type which returns the given
-     * constant value every time it is invoked.
-     * <p>
-     * Before the method handle is returned, the passed-in value is converted to the requested return type,
-     * as if by {@link #explicitCastArguments #explicitCastArguments}.
-     * That is, if the return type is primitive, the value is unboxed,
-     * and the primitive value is widened and/or narrowed.
-     * Otherwise, reference conversions are attempted.
-     * @param type the type of the desired method handle
-     * @param value the value to return
-     * @return a method handle of the given return type and no arguments, which always returns the given value
-     * @throws WrongMethodTypeException if the value cannot be converted to the required return type
+     * Produces a method handle which returns its sole argument when invoked.
+     * <p>The identity function for {@code void} takes no arguments and returns no values.
+     * @param type the type of the sole parameter and return value of the desired method handle
+     * @return a unary method handle which accepts and returns the given type
+     * @throws NullPointerException if the argument is null
+     * @throws IllegalArgumentException if the given type is {@code void.class}
      */
     public static
-    MethodHandle constant(MethodType type, Object value) {
-        MethodHandle target = constant(type.returnType(), value);
-        int len = type.parameterCount();
-        if (len == 0)
-            return target.asType(type);
-        target = target.asType(type.dropParameterTypes(0, len));
-        return dropArguments(target, 0, type.parameterList().subList(0, len));
-    }
-
-     /**
-      * Produce a method handle which returns its sole argument when invoked.
-      * <p>The identity function for {@code void} takes no arguments and returns no values.
-      * @param type the type of the sole parameter and return value of the desired method handle
-      * @return a unary method handle which accepts and returns the given type
-      */
-    public static
     MethodHandle identity(Class<?> type) {
+        if (type == void.class)
+            throw newIllegalArgumentException("void type");
         return ValueConversions.identity(type);
     }
 
-     /**
-      * Produce a method handle of the requested type which returns its argument when invoked.
-      * If the return type differs from the first argument type, the argument will be
-      * converted as if by {@link #explicitCastArguments explicitCastArguments}.
-      * If there are additional arguments beyond the first, they are discarded.
-      * <p>The identity function for {@code void} discards all its arguments.
-      * @param type the type of the desired method handle
-      * @return a method handle of the given type, which always returns its first argument
-      * @throws WrongMethodTypeException if the first argument cannot be converted to the required return type
-      */
-    public static
-    MethodHandle identity(MethodType type) {
-        MethodHandle target = identity(type.returnType());
-        int len = type.parameterCount();
-        if (len == 1)
-            return explicitCastArguments(target, type);
-        if (len == 0)
-            throw new IllegalArgumentException("not enough arguments");
-        target = explicitCastArguments(target, type.dropParameterTypes(1, len));
-        return dropArguments(target, 1, type.parameterList().subList(1, len));
-    }
-
     /**
-     * Produce a method handle which calls the original method handle {@code target},
+     * Produces a method handle which calls the original method handle {@code target},
      * after inserting the given argument(s) at the given position.
      * The formal parameters to {@code target} which will be supplied by those
      * arguments are called <em>bound parameters</em>, because the new method
@@ -1404,6 +1679,7 @@
      * @param values the series of arguments to insert
      * @return a method handle which inserts an additional argument,
      *         before calling the original method handle
+     * @throws NullPointerException if the {@code target} argument or the {@code values} array is null
      * @see MethodHandle#bindTo
      */
     public static
@@ -1438,7 +1714,7 @@
     }
 
     /**
-     * Produce a method handle which calls the original method handle,
+     * Produces a method handle which calls the original method handle,
      * after dropping the given argument(s) at the given position.
      * The type of the new method handle will insert the given argument
      * type(s), at that position, into the original handle's type.
@@ -1470,6 +1746,9 @@
      * @param pos position of first argument to drop (zero for the leftmost)
      * @return a method handle which drops arguments of the given types,
      *         before calling the original method handle
+     * @throws NullPointerException if the {@code target} argument is null,
+     *                              or if the {@code valueTypes} list or any of its elements is null
+     * @throws IllegalArgumentException if any of the {@code valueTypes} is {@code void.class}
      */
     public static
     MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
@@ -1487,7 +1766,7 @@
     }
 
     /**
-     * Produce a method handle which calls the original method handle,
+     * Produces a method handle which calls the original method handle,
      * after dropping the given argument(s) at the given position.
      * The type of the new method handle will insert the given argument
      * type(s), at that position, into the original handle's type.
@@ -1500,6 +1779,9 @@
      * @param pos position of first argument to drop (zero for the leftmost)
      * @return a method handle which drops arguments of the given types,
      *         before calling the original method handle
+     * @throws NullPointerException if the {@code target} argument is null,
+     *                              or if the {@code valueTypes} array or any of its elements is null
+     * @throws IllegalArgumentException if any of the {@code valueTypes} is {@code void.class}
      */
     public static
     MethodHandle dropArguments(MethodHandle target, int pos, Class<?>... valueTypes) {
@@ -1514,7 +1796,8 @@
      * <p>
      * The pre-processing is performed by one or more method handles,
      * specified in the elements of the {@code filters} array.
-     * (If there are no elements in the array, the original target is returned.)
+     * Null arguments in the array are ignored, and the corresponding arguments left unchanged.
+     * (If there are no non-null elements in the array, the original target is returned.)
      * Each filter is applied to the corresponding argument of the adapter.
      * <p>
      * If a filter {@code F} applies to the {@code N}th argument of
@@ -1544,12 +1827,16 @@
 MethodHandle f2 = filterArguments(cat, 0, upcase, upcase);
 assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY
      * </pre></blockquote>
+     *
      * @param target the method handle to invoke after arguments are filtered
      * @param pos the position of the first argument to filter
      * @param filters method handles to call initially on filtered arguments
      * @return method handle which incorporates the specified argument filtering logic
-     * @throws IllegalArgumentException if an element of {@code filters} is null or
-     *          does not match a corresponding argument type of {@code target} as described above
+     * @throws NullPointerException if the {@code target} argument is null
+     *                              or if the {@code filters} array is null
+     * @throws IllegalArgumentException if a non-null element of {@code filters}
+     *          does not match a corresponding argument type of {@code target} as described above,
+     *          or if the {@code pos+filters.length} is greater than {@code target.type().parameterCount()}
      */
     public static
     MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) {
@@ -1557,17 +1844,18 @@
         MethodHandle adapter = target;
         MethodType adapterType = targetType;
         int maxPos = targetType.parameterCount();
-        int curPos = pos;
+        if (pos + filters.length > maxPos)
+            throw newIllegalArgumentException("too many filters");
+        int curPos = pos-1;  // pre-incremented
         for (MethodHandle filter : filters) {
-            if (curPos >= maxPos)
-                throw newIllegalArgumentException("too many filters");
+            curPos += 1;
+            if (filter == null)  continue;  // ignore null elements of filters
             MethodType filterType = filter.type();
             if (filterType.parameterCount() != 1
                 || filterType.returnType() != targetType.parameterType(curPos))
                 throw newIllegalArgumentException("target and filter types do not match");
             adapterType = adapterType.changeParameterType(curPos, filterType.parameterType(0));
             adapter = MethodHandleImpl.filterArgument(IMPL_TOKEN, adapter, curPos, filter);
-            curPos += 1;
         }
         MethodType midType = adapter.type();
         if (midType != adapterType)
@@ -1602,7 +1890,8 @@
      * @param target the method handle to invoke before filtering the return value
      * @param filter method handle to call on the return value
      * @return method handle which incorporates the specified return value filtering logic
-     * @throws IllegalArgumentException if {@code filter} is null or
+     * @throws NullPointerException if either argument is null
+     * @throws IllegalArgumentException if {@code filter}
      *          does not match the return type of {@code target} as described above
      */
     public static
@@ -1612,9 +1901,11 @@
         if (filterType.parameterCount() != 1
             || filterType.parameterType(0) != targetType.returnType())
             throw newIllegalArgumentException("target and filter types do not match");
+        // result = fold( lambda(retval, arg...) { filter(retval) },
+        //                lambda(        arg...) { target(arg...) } )
         // FIXME: Too many nodes here.
-        MethodHandle returner = dropArguments(filter, 0, targetType.parameterList());
-        return foldArguments(returner, exactInvoker(target.type()).bindTo(target));
+        MethodHandle returner = dropArguments(filter, 1, targetType.parameterList());
+        return foldArguments(returner, target);
     }
 
     /**
@@ -1637,7 +1928,7 @@
      * (Note that {@link #dropArguments(MethodHandle,int,List) dropArguments} can be used to remove any arguments
      * that either the {@code combiner} or {@code target} does not wish to receive.
      * If some of the incoming arguments are destined only for the combiner,
-     * consider using {@link MethodHandle#asCollector} instead, since those
+     * consider using {@link MethodHandle#asCollector asCollector} instead, since those
      * arguments will not need to be live on the stack on entry to the
      * target.)
      * <p>
@@ -1656,6 +1947,7 @@
      * @param target the method handle to invoke after arguments are combined
      * @param combiner method handle to call initially on the incoming arguments
      * @return method handle which incorporates the specified argument folding logic
+     * @throws NullPointerException if either argument is null
      * @throws IllegalArgumentException if the first argument type of
      *          {@code target} is not the same as {@code combiner}'s return type,
      *          or if the following argument types of {@code target}
@@ -1704,6 +1996,7 @@
      * @param target method handle to call if test passes
      * @param fallback method handle to call if test fails
      * @return method handle which incorporates the specified if/then/else logic
+     * @throws NullPointerException if any argument is null
      * @throws IllegalArgumentException if {@code test} does not return boolean,
      *          or if all three method types do not match (with the return
      *          type of {@code test} changed to match that of {@code target}).
@@ -1772,6 +2065,7 @@
      * @param exType the type of exception which the handler will catch
      * @param handler method handle to call if a matching exception is thrown
      * @return method handle which incorporates the specified try/catch logic
+     * @throws NullPointerException if any argument is null
      * @throws IllegalArgumentException if {@code handler} does not accept
      *          the given exception type, or if the method handle types do
      *          not match in their return types and their
@@ -1802,12 +2096,14 @@
     }
 
     /**
-     * Produce a method handle which will throw exceptions of the given {@code exType}.
+     * Produces a method handle which will throw exceptions of the given {@code exType}.
      * The method handle will accept a single argument of {@code exType},
      * and immediately throw it as an exception.
      * The method type will nominally specify a return of {@code returnType}.
      * The return type may be anything convenient:  It doesn't matter to the
      * method handle's behavior, since it will never return normally.
+     * @return method handle which can throw the given exceptions
+     * @throws NullPointerException if either argument is null
      */
     public static
     MethodHandle throwException(Class<?> returnType, Class<? extends Throwable> exType) {
@@ -1815,18 +2111,43 @@
     }
 
     /**
-     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
-     * Produce a wrapper instance of the given "SAM" interface which redirects
+     * Produces an instance of the given "SAM" interface which redirects
      * its calls to the given method handle.
+     * <p>
      * A SAM interface is an interface which declares a single abstract method.
-     * The type must be public.  (No additional access checks are performed.)
+     * When determining the unique abstract method of a SAM interface,
+     * the public {@code Object} methods ({@code toString}, {@code equals}, {@code hashCode})
+     * are disregarded.  For example, {@link java.util.Comparator} is a SAM interface,
+     * even though it re-declares the {@code Object.equals} method.
+     * Also, if the SAM interface has a supertype,
+     * the SAM interface may override an inherited method.
+     * Any such overrides are respected, and the method handle will be accessible
+     * by either the inherited method or the SAM method.
+     * In particular, a {@linkplain java.lang.reflect.Method#isBridge bridge method}
+     * may be created if the methods have different return types.
+     * <p>
+     * The type must be public.  No additional access checks are performed.
      * <p>
      * The resulting instance of the required SAM type will respond to
      * invocation of the SAM type's single abstract method by calling
      * the given {@code target} on the incoming arguments,
      * and returning or throwing whatever the {@code target}
      * returns or throws.  The invocation will be as if by
-     * {@code target.invokeExact}.
+     * {@code target.invokeGeneric}.
+     * The target's type will be checked before the SAM
+     * instance is created, as if by a call to {@code asType},
+     * which may result in a {@code WrongMethodTypeException}.
+     * <p>
+     * The wrapper instance will implement the requested SAM interface
+     * and its super-types, but no other SAM types.
+     * This means that the SAM instance will not unexpectedly
+     * pass an {@code instanceof} test for any unrequested type.
+     * <p style="font-size:smaller;">
+     * <em>Implementation Note:</em>
+     * Therefore, each SAM instance must implement a unique SAM type.
+     * Implementations may not bundle together
+     * multiple SAM types onto single implementation classes
+     * in the style of {@link java.awt.AWTEventMulticaster}.
      * <p>
      * The method handle may throw an <em>undeclared exception</em>,
      * which means any checked exception (or other checked throwable)
@@ -1835,54 +2156,46 @@
      * {@link java.lang.reflect.UndeclaredThrowableException UndeclaredThrowableException}
      * and thrown in that wrapped form.
      * <p>
-     * The wrapper instance is guaranteed to be of a non-public
-     * implementation class C in a package containing no classes
-     * or methods except system-defined classes and methods.
-     * The implementation class C will have no public supertypes
-     * or public methods beyond the following:
-     * <ul>
-     * <li>the SAM type itself and any methods in the SAM type
-     * <li>the supertypes of the SAM type (if any) and their methods
-     * <li>{@link Object} and its methods
-     * <li>{@link java.dyn.AsInstanceObject AsInstanceObject} and its methods</li>
-     * </ul>
-     * <p>
-     * (Note: When determining the unique abstract method of a SAM interface,
-     * the public {@code Object} methods ({@code toString}, {@code equals}, {@code hashCode})
-     * are disregarded.  For example, {@link java.util.Comparator} is a SAM interface,
-     * even though it re-declares the {@code Object.equals} method.)
+     * Like {@link java.lang.Integer#valueOf Integer.valueOf},
+     * {@code asInstance} is a factory method whose results are defined
+     * by their behavior.
+     * It is not guaranteed to return a new instance for every call.
      * <p>
-     * No stable mapping is promised between the SAM type and
-     * the implementation class C.  Over time, several implementation
-     * classes might be used for the same SAM type.
-     * <p>
-     * This method is not guaranteed to return a distinct
-     * wrapper object for each separate call.  If the implementation is able
-     * to prove that a wrapper of the required SAM type
-     * has already been created for a given
-     * method handle, or for another method handle with the
-     * same behavior, the implementation may return that wrapper in place of
-     * a new wrapper.
-     * <p>
-     * This method is designed to apply to common use cases
-     * where a single method handle must interoperate with
-     * a type (class or interface) that implements a function-like
-     * API.  Additional variations, such as SAM classes with
-     * private constructors, or interfaces with multiple but related
-     * entry points, must be covered by hand-written or automatically
-     * generated adapter classes.  In those cases, consider implementing
-     * {@link java.dyn.MethodHandles.AsInstanceObject AsInstanceObject}
-     * in the adapters, so that generic code can extract the underlying
-     * method handle without knowing where the SAM adapter came from.
+     * Future versions of this API may accept additional types,
+     * such as abstract classes with single abstract methods.
+     * Future versions of this API may also equip wrapper instances
+     * with one or more additional public "marker" interfaces.
+     *
      * @param target the method handle to invoke from the wrapper
      * @param samType the desired type of the wrapper, a SAM type
      * @return a correctly-typed wrapper for the given {@code target}
-     * @throws IllegalArgumentException if the {@code target} throws
-     *         an undeclared exception
+     * @throws NullPointerException if either argument is null
+     * @throws IllegalArgumentException if the {@code samType} is not a
+     *         valid argument to this method
+     * @throws WrongMethodTypeException if the {@code target} cannot
+     *         be converted to the type required by the SAM type
      */
-    // ISSUE: Should we delegate equals/hashCode to the targets?
-    // Not useful unless there is a stable equals/hashCode behavior
-    // for MethodHandle, but there isn't.
+    // Other notes to implementors:
+    // <p>
+    // No stable mapping is promised between the SAM type and
+    // the implementation class C.  Over time, several implementation
+    // classes might be used for the same SAM type.
+    // <p>
+    // If the implementation is able
+    // to prove that a wrapper of the required SAM type
+    // has already been created for a given
+    // method handle, or for another method handle with the
+    // same behavior, the implementation may return that wrapper in place of
+    // a new wrapper.
+    // <p>
+    // This method is designed to apply to common use cases
+    // where a single method handle must interoperate with
+    // an interface that implements a function-like
+    // API.  Additional variations, such as SAM classes with
+    // private constructors, or interfaces with multiple but related
+    // entry points, must be covered by hand-written or automatically
+    // generated adapter classes.
+    //
     public static
     <T> T asInstance(final MethodHandle target, final Class<T> samType) {
         // POC implementation only; violates the above contract several ways
@@ -1890,22 +2203,23 @@
         if (sam == null)
             throw new IllegalArgumentException("not a SAM type: "+samType.getName());
         MethodType samMT = MethodType.methodType(sam.getReturnType(), sam.getParameterTypes());
-        if (!samMT.equals(target.type()))
-            throw new IllegalArgumentException("wrong method type: "+target+" should match "+sam);
+        MethodHandle checkTarget = target.asType(samMT);  // make throw WMT
+        checkTarget = checkTarget.asType(checkTarget.type().changeReturnType(Object.class));
+        final MethodHandle vaTarget = checkTarget.asSpreader(Object[].class, samMT.parameterCount());
         return samType.cast(Proxy.newProxyInstance(
                 samType.getClassLoader(),
-                new Class[]{ samType, AsInstanceObject.class },
+                new Class[]{ samType, WrapperInstance.class },
                 new InvocationHandler() {
                     private Object getArg(String name) {
-                        if ((Object)name == "getAsInstanceTarget")  return target;
-                        if ((Object)name == "getAsInstanceType")    return samType;
+                        if ((Object)name == "getWrapperInstanceTarget")  return target;
+                        if ((Object)name == "getWrapperInstanceType")    return samType;
                         throw new AssertionError();
                     }
                     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-                        if (method.getDeclaringClass() == AsInstanceObject.class)
+                        if (method.getDeclaringClass() == WrapperInstance.class)
                             return getArg(method.getName());
                         if (method.equals(sam))
-                            return target.invokeVarargs(args);
+                            return vaTarget.invokeExact(args);
                         if (isObjectMethod(method))
                             return callObjectMethod(this, method, args);
                         throw new InternalError();
@@ -1914,21 +2228,49 @@
     }
 
     /**
-     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
-     * Interface implemented by every object which is produced by {@link #asInstance asInstance}.
-     * The methods of this interface allow a caller to recover the parameters
-     * to {@code asInstance}.
-     * This allows applications to repeatedly convert between method handles
-     * and SAM objects, without the risk of creating unbounded delegation chains.
+     * Determine if the given object was produced by a call to {@link #asInstance asInstance}.
+     * @param x any reference
+     * @return true if the reference is not null and points to an object produced by {@code asInstance}
      */
-    public interface AsInstanceObject {
-        /** Produce or recover a target method handle which is behaviorally
-         *  equivalent to the SAM method of this object.
-         */
-        public MethodHandle getAsInstanceTarget();
-        /** Recover the SAM type for which this object was created.
-         */
-        public Class<?> getAsInstanceType();
+    public static
+    boolean isWrapperInstance(Object x) {
+        return x instanceof WrapperInstance;
+    }
+
+    private static WrapperInstance asWrapperInstance(Object x) {
+        try {
+            if (x != null)
+                return (WrapperInstance) x;
+        } catch (ClassCastException ex) {
+        }
+        throw new IllegalArgumentException("not a wrapper instance");
+    }
+
+    /**
+     * Produces or recovers a target method handle which is behaviorally
+     * equivalent to the SAM method of this wrapper instance.
+     * The object {@code x} must have been produced by a call to {@link #asInstance asInstance}.
+     * This requirement may be tested via {@link #isWrapperInstance isWrapperInstance}.
+     * @param x any reference
+     * @return a method handle implementing the SAM method
+     * @throws IllegalArgumentException if the reference x is not to a wrapper instance
+     */
+    public static
+    MethodHandle wrapperInstanceTarget(Object x) {
+        return asWrapperInstance(x).getWrapperInstanceTarget();
+    }
+
+    /**
+     * Recover the SAM type for which this wrapper instance was created.
+     * The object {@code x} must have been produced by a call to {@link #asInstance asInstance}.
+     * This requirement may be tested via {@link #isWrapperInstance isWrapperInstance}.
+     * @param x any reference
+     * @return the SAM type for which the wrapper was created
+     * @throws IllegalArgumentException if the reference x is not to a wrapper instance
+     */
+    public static
+    Class<?> wrapperInstanceType(Object x) {
+        return asWrapperInstance(x).getWrapperInstanceType();
     }
 
     private static
@@ -1991,7 +2333,7 @@
     }
 
     /*non-public*/
-    static MethodHandle withTypeHandler(MethodHandle target, MethodHandle typeHandler) {
-        return MethodHandleImpl.withTypeHandler(IMPL_TOKEN, target, typeHandler);
+    static MethodHandle asVarargsCollector(MethodHandle target, Class<?> arrayType) {
+        return MethodHandleImpl.asVarargsCollector(IMPL_TOKEN, target, arrayType);
     }
 }
--- a/jdk/src/share/classes/java/dyn/MethodType.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/MethodType.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -31,6 +31,7 @@
 import java.util.List;
 import sun.dyn.Access;
 import sun.dyn.Invokers;
+import sun.dyn.MethodHandleImpl;
 import sun.dyn.MethodTypeImpl;
 import sun.dyn.util.BytecodeDescriptor;
 import static sun.dyn.MemberName.newIllegalArgumentException;
@@ -41,8 +42,8 @@
  * and expected  by a method handle caller.  Method types must be properly
  * matched between a method handle and all its callers,
  * and the JVM's operations enforce this matching at, specifically
- * during calls to {@link MethodHandle#invokeExact}
- * and {@link MethodHandle#invokeGeneric}, and during execution
+ * during calls to {@link MethodHandle#invokeExact MethodHandle.invokeExact}
+ * and {@link MethodHandle#invokeGeneric MethodHandle.invokeGeneric}, and during execution
  * of {@code invokedynamic} instructions.
  * <p>
  * The structure is a return type accompanied by any number of parameter types.
@@ -70,8 +71,9 @@
  * with the instructions in a class file's constant pool.
  * <p>
  * Like classes and strings, method types can also be represented directly
- * in a class file's constant pool as constants. The may be loaded by an {@code ldc}
- * instruction which refers to a suitable {@code CONSTANT_MethodType} constant pool entry.
+ * in a class file's constant pool as constants.
+ * A method type may be loaded by an {@code ldc} instruction which refers
+ * to a suitable {@code CONSTANT_MethodType} constant pool entry.
  * The entry refers to a {@code CONSTANT_Utf8} spelling for the descriptor string.
  * For more details, see the <a href="package-summary.html#mtcon">package summary</a>.
  * <p>
@@ -82,9 +84,14 @@
  * @author John Rose, JSR 292 EG
  */
 public final
-class MethodType {
+class MethodType implements java.io.Serializable {
+    private static final long serialVersionUID = 292L;  // {rtype, {ptype...}}
+
+    // The rtype and ptypes fields define the structural identity of the method type:
     private final Class<?>   rtype;
     private final Class<?>[] ptypes;
+
+    // The remaining fields are caches of various sorts:
     private MethodTypeForm form; // erased form, plus cached data about primitives
     private MethodType wrapAlt;  // alternative wrapped/unwrapped version
     private Invokers invokers;   // cache of handy higher-order adapters
@@ -117,6 +124,9 @@
         });
     }
 
+    /**
+     * Check the given parameters for validity and store them into the final fields.
+     */
     private MethodType(Class<?> rtype, Class<?>[] ptypes) {
         checkRtype(rtype);
         checkPtypes(ptypes);
@@ -124,15 +134,32 @@
         this.ptypes = ptypes;
     }
 
-    private void checkRtype(Class<?> rtype) {
+    private static void checkRtype(Class<?> rtype) {
         rtype.equals(rtype);  // null check
     }
-    private void checkPtypes(Class<?>[] ptypes) {
+    private static int checkPtype(Class<?> ptype) {
+        ptype.getClass();  //NPE
+        if (ptype == void.class)
+            throw newIllegalArgumentException("parameter type cannot be void");
+        if (ptype == double.class || ptype == long.class)  return 1;
+        return 0;
+    }
+    /** Return number of extra slots (count of long/double args). */
+    private static int checkPtypes(Class<?>[] ptypes) {
+        int slots = 0;
         for (Class<?> ptype : ptypes) {
-            ptype.equals(ptype);  // null check
-            if (ptype == void.class)
-                throw newIllegalArgumentException("parameter type cannot be void");
+            slots += checkPtype(ptype);
         }
+        checkSlotCount(ptypes.length + slots);
+        return slots;
+    }
+    private static void checkSlotCount(int count) {
+        if ((count & 0xFF) != count)
+            throw newIllegalArgumentException("bad parameter count "+count);
+    }
+    private static IndexOutOfBoundsException newIndexOutOfBoundsException(Object num) {
+        if (num instanceof Integer)  num = "bad index: "+num;
+        return new IndexOutOfBoundsException(num.toString());
     }
 
     static final HashMap<MethodType,MethodType> internTable
@@ -140,27 +167,39 @@
 
     static final Class<?>[] NO_PTYPES = {};
 
-    /** Find or create an instance of the given method type.
+    /**
+     * Find or create an instance of the given method type.
      * @param rtype  the return type
      * @param ptypes the parameter types
-     * @return a method type with the given parts
-     * @throws NullPointerException if rtype or any ptype is null
-     * @throws IllegalArgumentException if any of the ptypes is void
+     * @return a method type with the given components
+     * @throws NullPointerException if {@code rtype} or {@code ptypes} or any element of {@code ptypes} is null
+     * @throws IllegalArgumentException if any element of {@code ptypes} is {@code void.class}
      */
     public static
     MethodType methodType(Class<?> rtype, Class<?>[] ptypes) {
         return makeImpl(rtype, ptypes, false);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}. */
+    /**
+     * Finds or creates a method type with the given components.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * @return a method type with the given components
+     * @throws NullPointerException if {@code rtype} or {@code ptypes} or any element of {@code ptypes} is null
+     * @throws IllegalArgumentException if any element of {@code ptypes} is {@code void.class}
+     */
     public static
-    MethodType methodType(Class<?> rtype, List<? extends Class<?>> ptypes) {
+    MethodType methodType(Class<?> rtype, List<Class<?>> ptypes) {
         boolean notrust = false;  // random List impl. could return evil ptypes array
         return makeImpl(rtype, ptypes.toArray(NO_PTYPES), notrust);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     *  The leading parameter type is prepended to the remaining array.
+    /**
+     * Finds or creates a method type with the given components.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * The leading parameter type is prepended to the remaining array.
+     * @return a method type with the given components
+     * @throws NullPointerException if {@code rtype} or {@code ptype0} or {@code ptypes} or any element of {@code ptypes} is null
+     * @throws IllegalArgumentException if {@code ptype0} or {@code ptypes} or any element of {@code ptypes} is {@code void.class}
      */
     public static
     MethodType methodType(Class<?> rtype, Class<?> ptype0, Class<?>... ptypes) {
@@ -170,25 +209,37 @@
         return makeImpl(rtype, ptypes1, true);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     *  The resulting method has no parameter types.
+    /**
+     * Finds or creates a method type with the given components.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * The resulting method has no parameter types.
+     * @return a method type with the given return value
+     * @throws NullPointerException if {@code rtype} is null
      */
     public static
     MethodType methodType(Class<?> rtype) {
         return makeImpl(rtype, NO_PTYPES, true);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     *  The resulting method has the single given parameter type.
+    /**
+     * Finds or creates a method type with the given components.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * The resulting method has the single given parameter type.
+     * @return a method type with the given return value and parameter type
+     * @throws NullPointerException if {@code rtype} or {@code ptype0} is null
+     * @throws IllegalArgumentException if {@code ptype0} is {@code void.class}
      */
     public static
     MethodType methodType(Class<?> rtype, Class<?> ptype0) {
         return makeImpl(rtype, new Class<?>[]{ ptype0 }, true);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     *  The resulting method has the same parameter types as {@code ptypes},
-     *  and the specified return type.
+    /**
+     * Finds or creates a method type with the given components.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * The resulting method has the same parameter types as {@code ptypes},
+     * and the specified return type.
+     * @throws NullPointerException if {@code rtype} or {@code ptypes} is null
      */
     public static
     MethodType methodType(Class<?> rtype, MethodType ptypes) {
@@ -237,17 +288,20 @@
     private static final MethodType[] objectOnlyTypes = new MethodType[20];
 
     /**
-     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
+     * Finds or creates a method type whose components are {@code Object} with an optional trailing {@code Object[]} array.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * All parameters and the return type will be {@code Object},
      * except the final varargs parameter if any, which will be {@code Object[]}.
      * @param objectArgCount number of parameters (excluding the varargs parameter if any)
      * @param varargs whether there will be a varargs parameter, of type {@code Object[]}
      * @return a totally generic method type, given only its count of parameters and varargs
+     * @throws IllegalArgumentException if {@code objectArgCount} is negative or greater than 255
      * @see #genericMethodType(int)
      */
     public static
     MethodType genericMethodType(int objectArgCount, boolean varargs) {
         MethodType mt;
+        checkSlotCount(objectArgCount);
         int ivarargs = (!varargs ? 0 : 1);
         int ootIndex = objectArgCount*2 + ivarargs;
         if (ootIndex < objectOnlyTypes.length) {
@@ -265,9 +319,12 @@
     }
 
     /**
+     * Finds or creates a method type whose components are all {@code Object}.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * All parameters and the return type will be Object.
      * @param objectArgCount number of parameters
      * @return a totally generic method type, given only its count of parameters
+     * @throws IllegalArgumentException if {@code objectArgCount} is negative or greater than 255
      * @see #genericMethodType(int, boolean)
      */
     public static
@@ -275,27 +332,41 @@
         return genericMethodType(objectArgCount, false);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
+    /**
+     * Finds or creates a method type with a single different parameter type.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * @param num    the index (zero-based) of the parameter type to change
      * @param nptype a new parameter type to replace the old one with
      * @return the same type, except with the selected parameter changed
+     * @throws IndexOutOfBoundsException if {@code num} is not a valid index into {@code parameterArray()}
+     * @throws IllegalArgumentException if {@code nptype} is {@code void.class}
+     * @throws NullPointerException if {@code nptype} is null
      */
     public MethodType changeParameterType(int num, Class<?> nptype) {
         if (parameterType(num) == nptype)  return this;
+        checkPtype(nptype);
         Class<?>[] nptypes = ptypes.clone();
         nptypes[num] = nptype;
         return makeImpl(rtype, nptypes, true);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
+    /**
+     * Finds or creates a method type with additional parameter types.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * @param num    the position (zero-based) of the inserted parameter type(s)
-     * @param ptypesToInsert zero or more a new parameter types to insert into the parameter list
+     * @param ptypesToInsert zero or more new parameter types to insert into the parameter list
      * @return the same type, except with the selected parameter(s) inserted
+     * @throws IndexOutOfBoundsException if {@code num} is negative or greater than {@code parameterCount()}
+     * @throws IllegalArgumentException if any element of {@code ptypesToInsert} is {@code void.class}
+     *                                  or if the resulting method type would have more than 255 parameter slots
+     * @throws NullPointerException if {@code ptypesToInsert} or any of its elements is null
      */
     public MethodType insertParameterTypes(int num, Class<?>... ptypesToInsert) {
         int len = ptypes.length;
         if (num < 0 || num > len)
-            throw newIllegalArgumentException("num="+num); //SPECME
+            throw newIndexOutOfBoundsException(num);
+        int ins = checkPtypes(ptypesToInsert);
+        checkSlotCount(parameterSlotCount() + ptypesToInsert.length + ins);
         int ilen = ptypesToInsert.length;
         if (ilen == 0)  return this;
         Class<?>[] nptypes = Arrays.copyOfRange(ptypes, 0, len+ilen);
@@ -304,40 +375,61 @@
         return makeImpl(rtype, nptypes, true);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     * @param ptypesToInsert zero or more a new parameter types to insert after the end of the parameter list
+    /**
+     * Finds or creates a method type with additional parameter types.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * @param ptypesToInsert zero or more new parameter types to insert after the end of the parameter list
      * @return the same type, except with the selected parameter(s) appended
+     * @throws IllegalArgumentException if any element of {@code ptypesToInsert} is {@code void.class}
+     *                                  or if the resulting method type would have more than 255 parameter slots
+     * @throws NullPointerException if {@code ptypesToInsert} or any of its elements is null
      */
     public MethodType appendParameterTypes(Class<?>... ptypesToInsert) {
         return insertParameterTypes(parameterCount(), ptypesToInsert);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     * @param ptypesToInsert zero or more a new parameter types to insert after the end of the parameter list
+    /**
+     * Finds or creates a method type with additional parameter types.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * @param num    the position (zero-based) of the inserted parameter type(s)
+     * @param ptypesToInsert zero or more new parameter types to insert into the parameter list
+     * @return the same type, except with the selected parameter(s) inserted
+     * @throws IndexOutOfBoundsException if {@code num} is negative or greater than {@code parameterCount()}
+     * @throws IllegalArgumentException if any element of {@code ptypesToInsert} is {@code void.class}
+     *                                  or if the resulting method type would have more than 255 parameter slots
+     * @throws NullPointerException if {@code ptypesToInsert} or any of its elements is null
+     */
+    public MethodType insertParameterTypes(int num, List<Class<?>> ptypesToInsert) {
+        return insertParameterTypes(num, ptypesToInsert.toArray(NO_PTYPES));
+    }
+
+    /**
+     * Finds or creates a method type with additional parameter types.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
+     * @param ptypesToInsert zero or more new parameter types to insert after the end of the parameter list
      * @return the same type, except with the selected parameter(s) appended
+     * @throws IllegalArgumentException if any element of {@code ptypesToInsert} is {@code void.class}
+     *                                  or if the resulting method type would have more than 255 parameter slots
+     * @throws NullPointerException if {@code ptypesToInsert} or any of its elements is null
      */
     public MethodType appendParameterTypes(List<Class<?>> ptypesToInsert) {
         return insertParameterTypes(parameterCount(), ptypesToInsert);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     * @param num    the position (zero-based) of the inserted parameter type(s)
-     * @param ptypesToInsert zero or more a new parameter types to insert into the parameter list
-     * @return the same type, except with the selected parameter(s) inserted
-     */
-    public MethodType insertParameterTypes(int num, List<Class<?>> ptypesToInsert) {
-        return insertParameterTypes(num, ptypesToInsert.toArray(NO_PTYPES));
-    }
-
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
+    /**
+     * Finds or creates a method type with some parameter types omitted.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * @param start  the index (zero-based) of the first parameter type to remove
      * @param end    the index (greater than {@code start}) of the first parameter type after not to remove
      * @return the same type, except with the selected parameter(s) removed
+     * @throws IndexOutOfBoundsException if {@code start} is negative or greater than {@code parameterCount()}
+     *                                  or if {@code end} is negative or greater than {@code parameterCount()}
+     *                                  or if {@code start} is greater than {@code end}
      */
     public MethodType dropParameterTypes(int start, int end) {
         int len = ptypes.length;
         if (!(0 <= start && start <= end && end <= len))
-            throw newIllegalArgumentException("start="+start+" end="+end); //SPECME
+            throw newIndexOutOfBoundsException("start="+start+" end="+end);
         if (start == end)  return this;
         Class<?>[] nptypes;
         if (start == 0) {
@@ -361,17 +453,20 @@
         return makeImpl(rtype, nptypes, true);
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
+    /**
+     * Finds or creates a method type with a different return type.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * @param nrtype a return parameter type to replace the old one with
      * @return the same type, except with the return type change
+     * @throws NullPointerException if {@code nrtype} is null
      */
     public MethodType changeReturnType(Class<?> nrtype) {
         if (returnType() == nrtype)  return this;
         return makeImpl(nrtype, ptypes, true);
     }
 
-    /** Convenience method.
-     * Report if this type contains a primitive argument or return value.
+    /**
+     * Reports if this type contains a primitive argument or return value.
      * The return type {@code void} counts as a primitive.
      * @return true if any of the types are primitives
      */
@@ -379,8 +474,8 @@
         return form.hasPrimitives();
     }
 
-    /** Convenience method.
-     * Report if this type contains a wrapper argument or return value.
+    /**
+     * Reports if this type contains a wrapper argument or return value.
      * Wrappers are types which box primitive values, such as {@link Integer}.
      * The reference type {@code java.lang.Void} counts as a wrapper.
      * @return true if any of the types are wrappers
@@ -389,8 +484,9 @@
         return unwrap() != this;
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     * Erase all reference types to {@code Object}.
+    /**
+     * Erases all reference types to {@code Object}.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * All primitive types (including {@code void}) will remain unchanged.
      * @return a version of the original type with all reference types replaced
      */
@@ -398,8 +494,9 @@
         return form.erasedType();
     }
 
-    /** Convenience method for {@link #genericMethodType(int)}.
-     * Convert all types, both reference and primitive, to {@code Object}.
+    /**
+     * Converts all types, both reference and primitive, to {@code Object}.
+     * Convenience method for {@link #genericMethodType(int) genericMethodType}.
      * The expression {@code type.wrap().erase()} produces the same value
      * as {@code type.generic()}.
      * @return a version of the original type with all types replaced
@@ -408,8 +505,9 @@
         return genericMethodType(parameterCount());
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     * Convert all primitive types to their corresponding wrapper types.
+    /**
+     * Converts all primitive types to their corresponding wrapper types.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * All reference types (including wrapper types) will remain unchanged.
      * A {@code void} return type is changed to the type {@code java.lang.Void}.
      * The expression {@code type.wrap().erase()} produces the same value
@@ -420,8 +518,9 @@
         return hasPrimitives() ? wrapWithPrims(this) : this;
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
+    /**
      * Convert all wrapper types to their corresponding primitive types.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * All primitive types (including {@code void}) will remain unchanged.
      * A return type of {@code java.lang.Void} is changed to {@code void}.
      * @return a version of the original type with all wrapper types replaced
@@ -456,23 +555,33 @@
         return uwt;
     }
 
-    /** @param num the index (zero-based) of the desired parameter type
-     *  @return the selected parameter type
+    /**
+     * Returns the parameter type at the specified index, within this method type.
+     * @param num the index (zero-based) of the desired parameter type
+     * @return the selected parameter type
+     * @throws IndexOutOfBoundsException if {@code num} is not a valid index into {@code parameterArray()}
      */
     public Class<?> parameterType(int num) {
         return ptypes[num];
     }
-    /** @return the number of parameter types */
+    /**
+     * Returns the number of parameter types in this method type.
+     * @return the number of parameter types
+     */
     public int parameterCount() {
         return ptypes.length;
     }
-    /** @return the return type */
+    /**
+     * Returns the return type of this method type.
+     * @return the return type
+     */
     public Class<?> returnType() {
         return rtype;
     }
 
     /**
-     * Convenience method to present the arguments as a list.
+     * Presents the parameter types as a list (a convenience method).
+     * The list will be immutable.
      * @return the parameter types (as an immutable list)
      */
     public List<Class<?>> parameterList() {
@@ -480,7 +589,7 @@
     }
 
     /**
-     * Convenience method to present the arguments as an array.
+     * Presents the parameter types as an array (a convenience method).
      * Changes to the array will not result in changes to the type.
      * @return the parameter types (as a fresh copy if necessary)
      */
@@ -524,14 +633,14 @@
     }
 
     /**
+     * Returns a string representation of the method type,
+     * of the form {@code "(PT0,PT1...)RT"}.
      * The string representation of a method type is a
      * parenthesis enclosed, comma separated list of type names,
      * followed immediately by the return type.
      * <p>
      * Each type is represented by its
      * {@link java.lang.Class#getSimpleName simple name}.
-     * If a type name name is array, it the base type followed
-     * by [], rather than the Class.getName of the array type.
      */
     @Override
     public String toString() {
@@ -548,21 +657,22 @@
 
     /// Queries which have to do with the bytecode architecture
 
-    /** The number of JVM stack slots required to invoke a method
+    /** Reports the number of JVM stack slots required to invoke a method
      * of this type.  Note that (for historic reasons) the JVM requires
      * a second stack slot to pass long and double arguments.
-     * So this method returns {@link #parameterCount()} plus the
+     * So this method returns {@link #parameterCount() parameterCount} plus the
      * number of long and double parameters (if any).
      * <p>
      * This method is included for the benfit of applications that must
      * generate bytecodes that process method handles and invokedynamic.
      * @return the number of JVM stack slots for this type's parameters
+     * @deprecated Will be removed for PFD.
      */
     public int parameterSlotCount() {
         return form.parameterSlotCount();
     }
 
-    /** Number of JVM stack slots which carry all parameters including and after
+    /** Reports the number of JVM stack slots which carry all parameters including and after
      * the given position, which must be in the range of 0 to
      * {@code parameterCount} inclusive.  Successive parameters are
      * more shallowly stacked, and parameters are indexed in the bytecodes
@@ -583,6 +693,8 @@
      * @param num an index (zero-based, inclusive) within the parameter types
      * @return the index of the (shallowest) JVM stack slot transmitting the
      *         given parameter
+     * @throws IllegalArgumentException if {@code num} is negative or greater than {@code parameterCount()}
+     * @deprecated Will be removed for PFD.
      */
     public int parameterSlotDepth(int num) {
         if (num < 0 || num > ptypes.length)
@@ -590,7 +702,7 @@
         return form.parameterToArgSlot(num-1);
     }
 
-    /** The number of JVM stack slots required to receive a return value
+    /** Reports the number of JVM stack slots required to receive a return value
      * from a method of this type.
      * If the {@link #returnType() return type} is void, it will be zero,
      * else if the return type is long or double, it will be two, else one.
@@ -598,13 +710,15 @@
      * This method is included for the benfit of applications that must
      * generate bytecodes that process method handles and invokedynamic.
      * @return the number of JVM stack slots (0, 1, or 2) for this type's return value
+     * @deprecated Will be removed for PFD.
      */
     public int returnSlotCount() {
         return form.returnSlotCount();
     }
 
-    /** Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[])}.
-     * Find or create an instance of the given method type.
+    /**
+     * Find or create an instance of a method type, given the spelling of its bytecode descriptor.
+     * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * Any class or interface name embedded in the descriptor string
      * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
      * on the given loader (or if it is null, on the system class loader).
@@ -614,10 +728,10 @@
      * not all reachable from a common class loader.
      * <p>
      * This method is included for the benfit of applications that must
-     * generate bytecodes that process method handles and invokedynamic.
-     * @param descriptor a bytecode-level signature string "(T...)T"
+     * generate bytecodes that process method handles and {@code invokedynamic}.
+     * @param descriptor a bytecode-level type descriptor string "(T...)T"
      * @param loader the class loader in which to look up the types
-     * @return a method type matching the bytecode-level signature
+     * @return a method type matching the bytecode-level type descriptor
      * @throws IllegalArgumentException if the string is not well-formed
      * @throws TypeNotPresentException if a named type cannot be found
      */
@@ -631,19 +745,121 @@
     }
 
     /**
-     * Create a bytecode descriptor representation of the method type.
+     * Produces a bytecode descriptor representation of the method type.
      * <p>
-     * Note that this is not a strict inverse of {@link #fromMethodDescriptorString}.
+     * Note that this is not a strict inverse of {@link #fromMethodDescriptorString fromMethodDescriptorString}.
      * Two distinct classes which share a common name but have different class loaders
      * will appear identical when viewed within descriptor strings.
      * <p>
      * This method is included for the benfit of applications that must
-     * generate bytecodes that process method handles and invokedynamic.
-     * {@link #fromMethodDescriptorString(java.lang.String, java.lang.ClassLoader)},
+     * generate bytecodes that process method handles and {@code invokedynamic}.
+     * {@link #fromMethodDescriptorString(java.lang.String, java.lang.ClassLoader) fromMethodDescriptorString},
      * because the latter requires a suitable class loader argument.
-     * @return the bytecode signature representation
+     * @return the bytecode type descriptor representation
      */
     public String toMethodDescriptorString() {
         return BytecodeDescriptor.unparse(this);
     }
+
+    /// Serialization.
+
+    /**
+     * There are no serializable fields for {@code MethodType}.
+     */
+    private static final java.io.ObjectStreamField[] serialPersistentFields = { };
+
+    /**
+     * Save the {@code MethodType} instance to a stream.
+     *
+     * @serialData
+     * For portability, the serialized format does not refer to named fields.
+     * Instead, the return type and parameter type arrays are written directly
+     * from the {@code writeObject} method, using two calls to {@code s.writeObject}
+     * as follows:
+     * <blockquote><pre>
+s.writeObject(this.returnType());
+s.writeObject(this.parameterArray());
+     * </pre></blockquote>
+     * <p>
+     * The deserialized field values are checked as if they were
+     * provided to the factory method {@link #methodType(Class,Class[]) methodType}.
+     * For example, null values, or {@code void} parameter types,
+     * will lead to exceptions during deserialization.
+     * @param the stream to write the object to
+     */
+    private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
+        s.defaultWriteObject();  // requires serialPersistentFields to be an empty array
+        s.writeObject(returnType());
+        s.writeObject(parameterArray());
+    }
+
+    /**
+     * Reconstitute the {@code MethodType} instance from a stream (that is,
+     * deserialize it).
+     * This instance is a scratch object with bogus final fields.
+     * It provides the parameters to the factory method called by
+     * {@link #readResolve readResolve}.
+     * After that call it is discarded.
+     * @param the stream to read the object from
+     * @see #MethodType()
+     * @see #readResolve
+     * @see #writeObject
+     */
+    private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
+        s.defaultReadObject();  // requires serialPersistentFields to be an empty array
+
+        Class<?>   returnType     = (Class<?>)   s.readObject();
+        Class<?>[] parameterArray = (Class<?>[]) s.readObject();
+
+        // Probably this object will never escape, but let's check
+        // the field values now, just to be sure.
+        checkRtype(returnType);
+        checkPtypes(parameterArray);
+
+        parameterArray = parameterArray.clone();  // make sure it is unshared
+        MethodType_init(returnType, parameterArray);
+    }
+
+    /**
+     * For serialization only.
+     * Sets the final fields to null, pending {@code Unsafe.putObject}.
+     */
+    private MethodType() {
+        this.rtype = null;
+        this.ptypes = null;
+    }
+    private void MethodType_init(Class<?> rtype, Class<?>[] ptypes) {
+        // In order to communicate these values to readResolve, we must
+        // store them into the implementation-specific final fields.
+        checkRtype(rtype);
+        checkPtypes(ptypes);
+        unsafe.putObject(this, rtypeOffset, rtype);
+        unsafe.putObject(this, ptypesOffset, ptypes);
+    }
+
+    // Support for resetting final fields while deserializing
+    private static final sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
+    private static final long rtypeOffset, ptypesOffset;
+    static {
+        try {
+            rtypeOffset = unsafe.objectFieldOffset
+                (MethodType.class.getDeclaredField("rtype"));
+            ptypesOffset = unsafe.objectFieldOffset
+                (MethodType.class.getDeclaredField("ptypes"));
+        } catch (Exception ex) {
+            throw new Error(ex);
+        }
+    }
+
+    /**
+     * Resolves and initializes a {@code MethodType} object
+     * after serialization.
+     * @return the fully initialized {@code MethodType} object
+     */
+    private Object readResolve() {
+        // Do not use a trusted path for deserialization:
+        //return makeImpl(rtype, ptypes, true);
+        // Verify all operands, and make sure ptypes is unshared:
+        return methodType(rtype, ptypes);
+    }
 }
--- a/jdk/src/share/classes/java/dyn/MutableCallSite.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/MutableCallSite.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -73,7 +73,7 @@
  * (This is a normal consequence of the Java Memory Model as applied
  * to object fields.)
  * <p>
- * The {@link #sync sync} operation provides a way to force threads
+ * The {@link #syncAll syncAll} operation provides a way to force threads
  * to accept a new target value, even if there is no other synchronization.
  * <p>
  * For target values which will be frequently updated, consider using
@@ -82,13 +82,17 @@
  */
 public class MutableCallSite extends CallSite {
     /**
-     * Make a blank call site object with the given method type.
-     * An initial target method is supplied which will throw
-     * an {@link IllegalStateException} if called.
+     * Creates a blank call site object with the given method type.
+     * The initial target is set to a method handle of the given type
+     * which will throw an {@link IllegalStateException} if called.
+     * <p>
+     * The type of the call site is permanently set to the given type.
      * <p>
      * Before this {@code CallSite} object is returned from a bootstrap method,
+     * or invoked in some other manner,
      * it is usually provided with a more useful target method,
      * via a call to {@link CallSite#setTarget(MethodHandle) setTarget}.
+     * @param type the method type that this call site will have
      * @throws NullPointerException if the proposed type is null
      */
     public MutableCallSite(MethodType type) {
@@ -96,8 +100,9 @@
     }
 
     /**
-     * Make a blank call site object, possibly equipped with an initial target method handle.
-     * @param target the method handle which will be the initial target of the call site
+     * Creates a call site object with an initial target method handle.
+     * The type of the call site is permanently set to the initial target's type.
+     * @param target the method handle that will be the initial target of the call site
      * @throws NullPointerException if the proposed target is null
      */
     public MutableCallSite(MethodHandle target) {
@@ -105,7 +110,59 @@
     }
 
     /**
-     * Perform a synchronization operation on each call site in the given array,
+     * Returns the target method of the call site, which behaves
+     * like a normal field of the {@code MutableCallSite}.
+     * <p>
+     * The interactions of {@code getTarget} with memory are the same
+     * as of a read from an ordinary variable, such as an array element or a
+     * non-volatile, non-final field.
+     * <p>
+     * In particular, the current thread may choose to reuse the result
+     * of a previous read of the target from memory, and may fail to see
+     * a recent update to the target by another thread.
+     *
+     * @return the linkage state of this call site, a method handle which can change over time
+     * @see #setTarget
+     */
+    @Override public final MethodHandle getTarget() {
+        return target;
+    }
+
+    /**
+     * Updates the target method of this call site, as a normal variable.
+     * The type of the new target must agree with the type of the old target.
+     * <p>
+     * The interactions with memory are the same
+     * as of a write to an ordinary variable, such as an array element or a
+     * non-volatile, non-final field.
+     * <p>
+     * In particular, unrelated threads may fail to see the updated target
+     * until they perform a read from memory.
+     * Stronger guarantees can be created by putting appropriate operations
+     * into the bootstrap method and/or the target methods used
+     * at any given call site.
+     *
+     * @param newTarget the new target
+     * @throws NullPointerException if the proposed new target is null
+     * @throws WrongMethodTypeException if the proposed new target
+     *         has a method type that differs from the previous target
+     * @see #getTarget
+     */
+    @Override public void setTarget(MethodHandle newTarget) {
+        checkTargetChange(this.target, newTarget);
+        setTargetNormal(newTarget);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public final MethodHandle dynamicInvoker() {
+        return makeDynamicInvoker();
+    }
+
+    /**
+     * Performs a synchronization operation on each call site in the given array,
      * forcing all other threads to throw away any cached values previously
      * loaded from the target of any of the call sites.
      * <p>
@@ -115,19 +172,29 @@
      * <p>
      * The overall effect is to force all future readers of each call site's target
      * to accept the most recently stored value.
-     * ("Most recently" is reckoned relative to the {@code sync} itself.)
-     * Conversely, the {@code sync} call may block until all readers have
+     * ("Most recently" is reckoned relative to the {@code syncAll} itself.)
+     * Conversely, the {@code syncAll} call may block until all readers have
      * (somehow) decached all previous versions of each call site's target.
      * <p>
-     * To avoid race conditions, calls to {@code setTarget} and {@code sync}
+     * To avoid race conditions, calls to {@code setTarget} and {@code syncAll}
      * should generally be performed under some sort of mutual exclusion.
      * Note that reader threads may observe an updated target as early
      * as the {@code setTarget} call that install the value
-     * (and before the {@code sync} that confirms the value).
+     * (and before the {@code syncAll} that confirms the value).
      * On the other hand, reader threads may observe previous versions of
-     * the target until the {@code sync} call returns
+     * the target until the {@code syncAll} call returns
      * (and after the {@code setTarget} that attempts to convey the updated version).
      * <p>
+     * This operation is likely to be expensive and should be used sparingly.
+     * If possible, it should be buffered for batch processing on sets of call sites.
+     * <p>
+     * If {@code sites} contains a null element,
+     * a {@code NullPointerException} will be raised.
+     * In this case, some non-null elements in the array may be
+     * processed before the method returns abnormally.
+     * Which elements these are (if any) is implementation-dependent.
+     *
+     * <h3>Java Memory Model details</h3>
      * In terms of the Java Memory Model, this operation performs a synchronization
      * action which is comparable in effect to the writing of a volatile variable
      * by the current thread, and an eventual volatile read by every other thread
@@ -171,18 +238,17 @@
      * thereby ensuring communication of the new target value.
      * <p>
      * As long as the constraints of the Java Memory Model are obeyed,
-     * implementations may delay the completion of a {@code sync}
+     * implementations may delay the completion of a {@code syncAll}
      * operation while other threads ({@code T} above) continue to
      * use previous values of {@code S}'s target.
      * However, implementations are (as always) encouraged to avoid
      * livelock, and to eventually require all threads to take account
      * of the updated target.
-     * <p>
-     * This operation is likely to be expensive and should be used sparingly.
-     * If possible, it should be buffered for batch processing on sets of call sites.
+     *
      * <p style="font-size:smaller;">
-     * (This is a static method on a set of call sites, not a
-     * virtual method on a single call site, for performance reasons.
+     * <em>Discussion:</em>
+     * For performance reasons, {@code syncAll} is not a virtual method
+     * on a single call site, but rather applies to a set of call sites.
      * Some implementations may incur a large fixed overhead cost
      * for processing one or more synchronization operations,
      * but a small incremental cost for each additional call site.
@@ -191,15 +257,25 @@
      * in order to make them notice the updated target value.
      * However, it may be observed that a single call to synchronize
      * several sites has the same formal effect as many calls,
-     * each on just one of the sites.)
-     * <p>
+     * each on just one of the sites.
+     *
+     * <p style="font-size:smaller;">
+     * <em>Implementation Note:</em>
      * Simple implementations of {@code MutableCallSite} may use
      * a volatile variable for the target of a mutable call site.
-     * In such an implementation, the {@code sync} method can be a no-op,
+     * In such an implementation, the {@code syncAll} method can be a no-op,
      * and yet it will conform to the JMM behavior documented above.
+     *
+     * @param sites an array of call sites to be synchronized
+     * @throws NullPointerException if the {@code sites} array reference is null
+     *                              or the array contains a null
      */
-    public static void sync(MutableCallSite[] sites) {
+    public static void syncAll(MutableCallSite[] sites) {
+        if (sites.length == 0)  return;
         STORE_BARRIER.lazySet(0);
+        for (int i = 0; i < sites.length; i++) {
+            sites[i].getClass();  // trigger NPE on first null
+        }
         // FIXME: NYI
     }
     private static final AtomicInteger STORE_BARRIER = new AtomicInteger();
--- a/jdk/src/share/classes/java/dyn/NoAccessException.java	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2008, 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 java.dyn;
-
-/**
- * Thrown to indicate that a caller has attempted to create a method handle
- * which accesses a field, method, or class to which the caller does not have access.
- * This unchecked exception is analogous to {@link IllegalAccessException},
- * which is a checked exception thrown when reflective invocation fails
- * because of an access check.  With method handles, this same access
- * checking is performed by the {@link MethodHandles.Lookup lookup object}
- * on behalf of the method handle creator,
- * at the time of creation.
- * @author John Rose, JSR 292 EG
- * @since 1.7
- */
-public class NoAccessException extends ReflectiveOperationException {
-    private static final long serialVersionUID = 292L;
-
-    /**
-     * Constructs a {@code NoAccessException} with no detail message.
-     */
-    public NoAccessException() {
-        super();
-    }
-
-    /**
-     * Constructs a {@code NoAccessException} with the specified
-     * detail message.
-     *
-     * @param s the detail message
-     */
-    public NoAccessException(String s) {
-        super(s);
-    }
-
-    /**
-     * Constructs a {@code NoAccessException} with the specified cause.
-     *
-     * @param cause the underlying cause of the exception
-     */
-    public NoAccessException(Throwable cause) {
-        super(cause);
-    }
-
-    /**
-     * Constructs a {@code NoAccessException} with the specified
-     * detail message and cause.
-     *
-     * @param s the detail message
-     * @param cause the underlying cause of the exception
-     */
-    public NoAccessException(String s, Throwable cause) {
-        super(s, cause);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/SwitchPoint.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2010, 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 java.dyn;
+
+/**
+ * <p>
+ * A {@code SwitchPoint} is an object which can publish state transitions to other threads.
+ * A switch point is initially in the <em>valid</em> state, but may at any time be
+ * changed to the <em>invalid</em> state.  Invalidation cannot be reversed.
+ * A switch point can combine a <em>guarded pair</em> of method handles into a
+ * <em>guarded delegator</em>.
+ * The guarded delegator is a method handle which delegates to one of the old method handles.
+ * The state of the switch point determines which of the two gets the delegation.
+ * <p>
+ * A single switch point may be used to control any number of method handles.
+ * (Indirectly, therefore, it can control any number of call sites.)
+ * This is done by using the single switch point as a factory for combining
+ * any number of guarded method handle pairs into guarded delegators.
+ * <p>
+ * When a guarded delegator is created from a guarded pair, the pair
+ * is wrapped in a new method handle {@code M},
+ * which is permanently associated with the switch point that created it.
+ * Each pair consists of a target {@code T} and a fallback {@code F}.
+ * While the switch point is valid, invocations to {@code M} are delegated to {@code T}.
+ * After it is invalidated, invocations are delegated to {@code F}.
+ * <p>
+ * Invalidation is global and immediate, as if the switch point contained a
+ * volatile boolean variable consulted on every call to {@code M}.
+ * The invalidation is also permanent, which means the switch point
+ * can change state only once.
+ * The switch point will always delegate to {@code F} after being invalidated.
+ * At that point {@code guardWithTest} may ignore {@code T} and return {@code F}.
+ * <p>
+ * Here is an example of a switch point in action:
+ * <blockquote><pre>
+MethodType MT_str2 = MethodType.methodType(String.class, String.class);
+MethodHandle MH_strcat = MethodHandles.lookup()
+    .findVirtual(String.class, "concat", MT_str2);
+SwitchPoint spt = new SwitchPoint();
+// the following steps may be repeated to re-use the same switch point:
+MethodHandle worker1 = strcat;
+MethodHandle worker2 = MethodHandles.permuteArguments(strcat, MT_str2, 1, 0);
+MethodHandle worker = spt.guardWithTest(worker1, worker2);
+assertEquals("method", (String) worker.invokeExact("met", "hod"));
+SwitchPoint.invalidateAll(new SwitchPoint[]{ spt });
+assertEquals("hodmet", (String) worker.invokeExact("met", "hod"));
+ * </pre></blockquote>
+ * <p style="font-size:smaller;">
+ * <em>Discussion:</em>
+ * Switch points are useful without subclassing.  They may also be subclassed.
+ * This may be useful in order to associate application-specific invalidation logic
+ * with the switch point.
+ * <p style="font-size:smaller;">
+ * <em>Implementation Note:</em>
+ * A switch point behaves as if implemented on top of {@link MutableCallSite},
+ * approximately as follows:
+ * <blockquote><pre>
+public class SwitchPoint {
+  private static final MethodHandle
+    K_true  = MethodHandles.constant(boolean.class, true),
+    K_false = MethodHandles.constant(boolean.class, false);
+  private final MutableCallSite mcs;
+  private final MethodHandle mcsInvoker;
+  public SwitchPoint() {
+    this.mcs = new MutableCallSite(K_true);
+    this.mcsInvoker = mcs.dynamicInvoker();
+  }
+  public MethodHandle guardWithTest(
+                MethodHandle target, MethodHandle fallback) {
+    // Note:  mcsInvoker is of type ()boolean.
+    // Target and fallback may take any arguments, but must have the same type.
+    return MethodHandles.guardWithTest(this.mcsInvoker, target, fallback);
+  }
+  public static void invalidateAll(SwitchPoint[] spts) {
+    List&lt;MutableCallSite&gt; mcss = new ArrayList&lt;&gt;();
+    for (SwitchPoint spt : spts)  mcss.add(spt.mcs);
+    for (MutableCallSite mcs : mcss)  mcs.setTarget(K_false);
+    MutableCallSite.syncAll(mcss.toArray(new MutableCallSite[0]));
+  }
+}
+ * </pre></blockquote>
+ * @author Remi Forax, JSR 292 EG
+ */
+public class SwitchPoint {
+    private static final MethodHandle
+        K_true  = MethodHandles.constant(boolean.class, true),
+        K_false = MethodHandles.constant(boolean.class, false);
+
+    private final MutableCallSite mcs;
+    private final MethodHandle mcsInvoker;
+
+    /**
+     * Creates a new switch point.
+     */
+    public SwitchPoint() {
+        this.mcs = new MutableCallSite(K_true);
+        this.mcsInvoker = mcs.dynamicInvoker();
+    }
+
+    /**
+     * Returns a method handle which always delegates either to the target or the fallback.
+     * The method handle will delegate to the target exactly as long as the switch point is valid.
+     * After that, it will permanently delegate to the fallback.
+     * <p>
+     * The target and fallback must be of exactly the same method type,
+     * and the resulting combined method handle will also be of this type.
+     *
+     * @param target the method handle selected by the switch point as long as it is valid
+     * @param fallback the method handle selected by the switch point after it is invalidated
+     * @return a combined method handle which always calls either the target or fallback
+     * @throws NullPointerException if either argument is null
+     * @see MethodHandles#guardWithTest
+     */
+    public MethodHandle guardWithTest(MethodHandle target, MethodHandle fallback) {
+        if (mcs.getTarget() == K_false)
+            return fallback;  // already invalid
+        return MethodHandles.guardWithTest(mcsInvoker, target, fallback);
+    }
+
+    /**
+     * Sets all of the given switch points into the invalid state.
+     * After this call executes, no thread will observe any of the
+     * switch points to be in a valid state.
+     * <p>
+     * This operation is likely to be expensive and should be used sparingly.
+     * If possible, it should be buffered for batch processing on sets of switch points.
+     * <p>
+     * If {@code switchPoints} contains a null element,
+     * a {@code NullPointerException} will be raised.
+     * In this case, some non-null elements in the array may be
+     * processed before the method returns abnormally.
+     * Which elements these are (if any) is implementation-dependent.
+     *
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * For performance reasons, {@code invalidateAll} is not a virtual method
+     * on a single switch point, but rather applies to a set of switch points.
+     * Some implementations may incur a large fixed overhead cost
+     * for processing one or more invalidation operations,
+     * but a small incremental cost for each additional invalidation.
+     * In any case, this operation is likely to be costly, since
+     * other threads may have to be somehow interrupted
+     * in order to make them notice the updated switch point state.
+     * However, it may be observed that a single call to invalidate
+     * several switch points has the same formal effect as many calls,
+     * each on just one of the switch points.
+     *
+     * <p style="font-size:smaller;">
+     * <em>Implementation Note:</em>
+     * Simple implementations of {@code SwitchPoint} may use
+     * a private {@link MutableCallSite} to publish the state of a switch point.
+     * In such an implementation, the {@code invalidateAll} method can
+     * simply change the call site's target, and issue one call to
+     * {@linkplain MutableCallSite#syncAll synchronize} all the
+     * private call sites.
+     *
+     * @param switchPoints an array of call sites to be synchronized
+     * @throws NullPointerException if the {@code switchPoints} array reference is null
+     *                              or the array contains a null
+     */
+    public static void invalidateAll(SwitchPoint[] switchPoints) {
+        if (switchPoints.length == 0)  return;
+        MutableCallSite[] sites = new MutableCallSite[switchPoints.length];
+        for (int i = 0; i < switchPoints.length; i++) {
+            SwitchPoint spt = switchPoints[i];
+            if (spt == null)  break;  // MSC.syncAll will trigger a NPE
+            sites[i] = spt.mcs;
+            spt.mcs.setTarget(K_false);
+        }
+        MutableCallSite.syncAll(sites);
+    }
+}
--- a/jdk/src/share/classes/java/dyn/Switcher.java	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 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 java.dyn;
-
-/**
- * <p>
- * A {@code Switcher} is an object which can publish state transitions to other threads.
- * A switcher is initially in the <em>valid</em> state, but may at any time be
- * changed to the <em>invalid</em> state.  Invalidation cannot be reversed.
- * <p>
- * A single switcher may be used to create any number of guarded method handle pairs.
- * Each guarded pair is wrapped in a new method handle {@code M},
- * which is permanently associated with the switcher that created it.
- * Each pair consists of a target {@code T} and a fallback {@code F}.
- * While the switcher is valid, invocations to {@code M} are delegated to {@code T}.
- * After it is invalidated, invocations are delegated to {@code F}.
- * <p>
- * Invalidation is global and immediate, as if the switcher contained a
- * volatile boolean variable consulted on every call to {@code M}.
- * The invalidation is also permanent, which means the switcher
- * can change state only once.
- * <p>
- * Here is an example of a switcher in action:
- * <blockquote><pre>
-MethodType MT_str2 = MethodType.methodType(String.class, String.class);
-MethodHandle MH_strcat = MethodHandles.lookup()
-    .findVirtual(String.class, "concat", MT_str2);
-Switcher switcher = new Switcher();
-// the following steps may be repeated to re-use the same switcher:
-MethodHandle worker1 = strcat;
-MethodHandle worker2 = MethodHandles.permuteArguments(strcat, MT_str2, 1, 0);
-MethodHandle worker = switcher.guardWithTest(worker1, worker2);
-assertEquals("method", (String) worker.invokeExact("met", "hod"));
-switcher.invalidate();
-assertEquals("hodmet", (String) worker.invokeExact("met", "hod"));
- * </pre></blockquote>
- * <p>
- * <em>Implementation Note:</em>
- * A switcher behaves as if implemented on top of {@link MutableCallSite},
- * approximately as follows:
- * <blockquote><pre>
-public class Switcher {
-  private static final MethodHandle
-    K_true  = MethodHandles.constant(boolean.class, true),
-    K_false = MethodHandles.constant(boolean.class, false);
-  private final MutableCallSite mcs;
-  private final MethodHandle mcsInvoker;
-  public Switcher() {
-    this.mcs = new MutableCallSite(K_true);
-    this.mcsInvoker = mcs.dynamicInvoker();
-  }
-  public MethodHandle guardWithTest(
-                MethodHandle target, MethodHandle fallback) {
-    // Note:  mcsInvoker is of type boolean().
-    // Target and fallback may take any arguments, but must have the same type.
-    return MethodHandles.guardWithTest(this.mcsInvoker, target, fallback);
-  }
-  public static void invalidateAll(Switcher[] switchers) {
-    List<MutableCallSite> mcss = new ArrayList<>();
-    for (Switcher s : switchers)  mcss.add(s.mcs);
-    for (MutableCallSite mcs : mcss)  mcs.setTarget(K_false);
-    MutableCallSite.sync(mcss.toArray(new MutableCallSite[0]));
-  }
-}
- * </pre></blockquote>
- * @author Remi Forax, JSR 292 EG
- */
-public class Switcher {
-    private static final MethodHandle
-        K_true  = MethodHandles.constant(boolean.class, true),
-        K_false = MethodHandles.constant(boolean.class, false);
-
-    private final MutableCallSite mcs;
-    private final MethodHandle mcsInvoker;
-
-    /** Create a switcher. */
-    public Switcher() {
-        this.mcs = new MutableCallSite(K_true);
-        this.mcsInvoker = mcs.dynamicInvoker();
-    }
-
-    /**
-     * Return a method handle which always delegates either to the target or the fallback.
-     * The method handle will delegate to the target exactly as long as the switcher is valid.
-     * After that, it will permanently delegate to the fallback.
-     * <p>
-     * The target and fallback must be of exactly the same method type,
-     * and the resulting combined method handle will also be of this type.
-     * @see MethodHandles#guardWithTest
-     */
-    public MethodHandle guardWithTest(MethodHandle target, MethodHandle fallback) {
-        if (mcs.getTarget() == K_false)
-            return fallback;  // already invalid
-        return MethodHandles.guardWithTest(mcsInvoker, target, fallback);
-    }
-
-    /** Set all of the given switchers into the invalid state. */
-    public static void invalidateAll(Switcher[] switchers) {
-        MutableCallSite[] sites = new MutableCallSite[switchers.length];
-        int fillp = 0;
-        for (Switcher switcher : switchers) {
-            sites[fillp++] = switcher.mcs;
-            switcher.mcs.setTarget(K_false);
-        }
-        MutableCallSite.sync(sites);
-    }
-}
--- a/jdk/src/share/classes/java/dyn/VolatileCallSite.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/VolatileCallSite.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -34,7 +34,7 @@
  * There may be a performance penalty for such tight coupling between threads.
  * <p>
  * Unlike {@code MutableCallSite}, there is no
- * {@linkplain MutableCallSite#sync sync operation} on volatile
+ * {@linkplain MutableCallSite#syncAll syncAll operation} on volatile
  * call sites, since every write to a volatile variable is implicitly
  * synchronized with reader threads.
  * <p>
@@ -44,36 +44,68 @@
  * @author John Rose, JSR 292 EG
  */
 public class VolatileCallSite extends CallSite {
-    /** Create a call site with a volatile target.
-     *  The initial target is set to a method handle
-     *  of the given type which will throw {@code IllegalStateException}.
+    /**
+     * Creates a call site with a volatile binding to its target.
+     * The initial target is set to a method handle
+     * of the given type which will throw an {@code IllegalStateException} if called.
+     * @param type the method type that this call site will have
      * @throws NullPointerException if the proposed type is null
      */
     public VolatileCallSite(MethodType type) {
         super(type);
     }
 
-    /** Create a call site with a volatile target.
-     *  The target is set to the given value.
+    /**
+     * Creates a call site with a volatile binding to its target.
+     * The target is set to the given value.
+     * @param target the method handle that will be the initial target of the call site
      * @throws NullPointerException if the proposed target is null
      */
     public VolatileCallSite(MethodHandle target) {
         super(target);
     }
 
-    /** Internal override to nominally final getTarget. */
-    @Override
-    MethodHandle getTarget0() {
+    /**
+     * Returns the target method of the call site, which behaves
+     * like a {@code volatile} field of the {@code VolatileCallSite}.
+     * <p>
+     * The interactions of {@code getTarget} with memory are the same
+     * as of a read from a {@code volatile} field.
+     * <p>
+     * In particular, the current thread is required to issue a fresh
+     * read of the target from memory, and must not fail to see
+     * a recent update to the target by another thread.
+     *
+     * @return the linkage state of this call site, a method handle which can change over time
+     * @see #setTarget
+     */
+    @Override public final MethodHandle getTarget() {
         return getTargetVolatile();
     }
 
     /**
-     * Set the target method of this call site, as a volatile variable.
-     * Has the same effect as {@link CallSite#setTarget CallSite.setTarget}, with the additional
-     * effects associated with volatiles, in the Java Memory Model.
+     * Updates the target method of this call site, as a volatile variable.
+     * The type of the new target must agree with the type of the old target.
+     * <p>
+     * The interactions with memory are the same as of a write to a volatile field.
+     * In particular, any threads is guaranteed to see the updated target
+     * the next time it calls {@code getTarget}.
+     * @param newTarget the new target
+     * @throws NullPointerException if the proposed new target is null
+     * @throws WrongMethodTypeException if the proposed new target
+     *         has a method type that differs from the previous target
+     * @see #getTarget
      */
     @Override public void setTarget(MethodHandle newTarget) {
         checkTargetChange(getTargetVolatile(), newTarget);
         setTargetVolatile(newTarget);
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public final MethodHandle dynamicInvoker() {
+        return makeDynamicInvoker();
+    }
 }
--- a/jdk/src/share/classes/java/dyn/WrongMethodTypeException.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/WrongMethodTypeException.java	Mon Mar 07 11:37:54 2011 -0800
@@ -29,7 +29,7 @@
  * Thrown to indicate that code has attempted to call a method handle
  * via the wrong method type.  As with the bytecode representation of
  * normal Java method calls, method handle calls are strongly typed
- * to a specific signature associated with a call site.
+ * to a specific type descriptor associated with a call site.
  * <p>
  * This exception may also be thrown when two method handles are
  * composed, and the system detects that their types cannot be
--- a/jdk/src/share/classes/java/dyn/package-info.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/dyn/package-info.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -24,21 +24,20 @@
  */
 
 /**
- * This package contains dynamic language support provided directly by
+ * The {@code java.lang.invoke} package contains dynamic language support provided directly by
  * the Java core class libraries and virtual machine.
+ *
+ * <p style="font-size:smaller;">
+ * <em>Historic Note:</em> In some early versions of Java SE 7,
+ * the name of this package is {@code java.dyn}.
  * <p>
  * Certain types in this package have special relations to dynamic
  * language support in the virtual machine:
  * <ul>
- * <li>In source code, a call to
- * {@link java.dyn.MethodHandle#invokeExact   MethodHandle.invokeExact} or
- * {@link java.dyn.MethodHandle#invokeGeneric MethodHandle.invokeGeneric}
- * will compile and link, regardless of the requested type signature.
- * As usual, the Java compiler emits an {@code invokevirtual}
- * instruction with the given signature against the named method.
- * The JVM links any such call (regardless of signature) to a dynamically
- * typed method handle invocation.  In the case of {@code invokeGeneric},
- * argument and return value conversions are applied.
+ * <li>The class {@link java.dyn.MethodHandle MethodHandle} contains
+ * <a href="MethodHandle.html#sigpoly">signature polymorphic methods</a>
+ * which can be linked regardless of their type descriptor.
+ * Normally, method linkage requires exact matching of type descriptors.
  * </li>
  *
  * <li>The JVM bytecode format supports immediate constants of
@@ -58,12 +57,11 @@
  * The final two bytes are reserved for future use and required to be zero.
  * The constant pool reference of an {@code invokedynamic} instruction is to a entry
  * with tag {@code CONSTANT_InvokeDynamic} (decimal 18).  See below for its format.
- * (The tag value 17 is also temporarily allowed.  See below.)
  * The entry specifies the following information:
  * <ul>
  * <li>a bootstrap method (a {@link java.dyn.MethodHandle MethodHandle} constant)</li>
  * <li>the dynamic invocation name (a UTF8 string)</li>
- * <li>the argument and return types of the call (encoded as a signature in a UTF8 string)</li>
+ * <li>the argument and return types of the call (encoded as a type descriptor in a UTF8 string)</li>
  * <li>optionally, a sequence of additional <em>static arguments</em> to the bootstrap method ({@code ldc}-type constants)</li>
  * </ul>
  * <p>
@@ -78,9 +76,9 @@
  * as <a href="#bsm">described below</a>.
  *
  * <p style="font-size:smaller;">
- * (Historic Note: Some older JVMs may allow the index of a {@code CONSTANT_NameAndType}
+ * <em>Historic Note:</em> Some older JVMs may allow the index of a {@code CONSTANT_NameAndType}
  * instead of a {@code CONSTANT_InvokeDynamic}.  In earlier, obsolete versions of this API, the
- * bootstrap method was specified dynamically, in a per-class basis, during class initialization.)
+ * bootstrap method was specified dynamically, in a per-class basis, during class initialization.
  *
  * <h3><a name="indycon"></a>constant pool entries for {@code invokedynamic} instructions</h3>
  * If a constant pool entry has the tag {@code CONSTANT_InvokeDynamic} (decimal 18),
@@ -90,33 +88,21 @@
  * <em>bootstrap method table</em>, which is stored in the {@code BootstrapMethods}
  * attribute as <a href="#bsmattr">described below</a>.
  * The second pair of bytes must be an index to a {@code CONSTANT_NameAndType}.
- * This table is not part of the constant pool.  Instead, it is stored
- * in a class attribute named {@code BootstrapMethods}, described below.
  * <p>
  * The first index specifies a bootstrap method used by the associated dynamic call sites.
  * The second index specifies the method name, argument types, and return type of the dynamic call site.
  * The structure of such an entry is therefore analogous to a {@code CONSTANT_Methodref},
  * except that the bootstrap method specifier reference replaces
  * the {@code CONSTANT_Class} reference of a {@code CONSTANT_Methodref} entry.
- * <p>
- * Some older JVMs may allow an older constant pool entry tag of decimal 17.
- * The format and behavior of a constant pool entry with this tag is identical to
- * an entry with a tag of decimal 18, except that the first index refers directly
- * to a {@code CONSTANT_MethodHandle} to use as the bootstrap method.
- * This format does not require the bootstrap method table.
- *
- * <p style="font-size:smaller;">
- * <em>(Note: The Proposed Final Draft of this specification is likely to support
- * only the tag 18, not the tag 17.)</em>
  *
  * <h3><a name="mtcon"></a>constant pool entries for {@linkplain java.dyn.MethodType method types}</h3>
  * If a constant pool entry has the tag {@code CONSTANT_MethodType} (decimal 16),
  * it must contain exactly two more bytes, which must be an index to a {@code CONSTANT_Utf8}
- * entry which represents a method type signature.
+ * entry which represents a method type descriptor.
  * <p>
  * The JVM will ensure that on first
  * execution of an {@code ldc} instruction for this entry, a {@link java.dyn.MethodType MethodType}
- * will be created which represents the signature.
+ * will be created which represents the type descriptor.
  * Any classes mentioned in the {@code MethodType} will be loaded if necessary,
  * but not initialized.
  * Access checking and error reporting is performed exactly as it is for
@@ -141,38 +127,75 @@
  * type is created.  Any classes mentioned in this reification will be loaded if necessary,
  * but not initialized, and access checking and error reporting performed as usual.
  * <p>
+ * Unlike the reflective {@code Lookup} API, there are no security manager calls made
+ * when these constants are resolved.
+ * <p>
  * The method handle itself will have a type and behavior determined by the subtag as follows:
  * <code>
  * <table border=1 cellpadding=5 summary="CONSTANT_MethodHandle subtypes">
- * <tr><th>N</th><th>subtag name</th><th>member</th><th>MH type</th><th>MH behavior</th></tr>
- * <tr><td>1</td><td>REF_getField</td><td>C.f:T</td><td>(C)T</td><td>getfield C.f:T</td></tr>
- * <tr><td>2</td><td>REF_getStatic</td><td>C.f:T</td><td>(&nbsp;)T</td><td>getstatic C.f:T</td></tr>
- * <tr><td>3</td><td>REF_putField</td><td>C.f:T</td><td>(C,T)void</td><td>putfield C.f:T</td></tr>
- * <tr><td>4</td><td>REF_putStatic</td><td>C.f:T</td><td>(T)void</td><td>putstatic C.f:T</td></tr>
- * <tr><td>5</td><td>REF_invokeVirtual</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokevirtual C.m(A*)T</td></tr>
- * <tr><td>6</td><td>REF_invokeStatic</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokestatic C.m(A*)T</td></tr>
- * <tr><td>7</td><td>REF_invokeSpecial</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokespecial C.m(A*)T</td></tr>
- * <tr><td>8</td><td>REF_newInvokeSpecial</td><td>C.&lt;init&gt;(A*)void</td><td>(A*)C</td><td>new C; dup; invokespecial C.&lt;init&gt;(A*)void</td></tr>
- * <tr><td>9</td><td>REF_invokeInterface</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokeinterface C.m(A*)T</td></tr>
+ * <tr><th>N</th><th>subtag name</th><th>member</th><th>MH type</th><th>bytecode behavior</th><th>lookup expression</th></tr>
+ * <tr><td>1</td><td>REF_getField</td><td>C.f:T</td><td>(C)T</td><td>getfield C.f:T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findGetter findGetter(C.class,"f",T.class)}</td></tr>
+ * <tr><td>2</td><td>REF_getStatic</td><td>C.f:T</td><td>(&nbsp;)T</td><td>getstatic C.f:T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticGetter findStaticGetter(C.class,"f",T.class)}</td></tr>
+ * <tr><td>3</td><td>REF_putField</td><td>C.f:T</td><td>(C,T)void</td><td>putfield C.f:T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findSetter findSetter(C.class,"f",T.class)}</td></tr>
+ * <tr><td>4</td><td>REF_putStatic</td><td>C.f:T</td><td>(T)void</td><td>putstatic C.f:T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticSetter findStaticSetter(C.class,"f",T.class)}</td></tr>
+ * <tr><td>5</td><td>REF_invokeVirtual</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokevirtual C.m(A*)T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}</td></tr>
+ * <tr><td>6</td><td>REF_invokeStatic</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokestatic C.m(A*)T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findStatic findStatic(C.class,"m",MT)}</td></tr>
+ * <tr><td>7</td><td>REF_invokeSpecial</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokespecial C.m(A*)T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findSpecial findSpecial(C.class,"m",MT,this.class)}</td></tr>
+ * <tr><td>8</td><td>REF_newInvokeSpecial</td><td>C.&lt;init&gt;(A*)void</td><td>(A*)C</td><td>new C; dup; invokespecial C.&lt;init&gt;(A*)void</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findConstructor findConstructor(C.class,MT)}</td></tr>
+ * <tr><td>9</td><td>REF_invokeInterface</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokeinterface C.m(A*)T</td>
+ *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}</td></tr>
  * </table>
  * </code>
+ * Here, the type {@code C} is taken from the {@code CONSTANT_Class} reference associated
+ * with the {@code CONSTANT_NameAndType} descriptor.
+ * The field name {@code f} or method name {@code m} is taken from the {@code CONSTANT_NameAndType}
+ * as is the result type {@code T} and (in the case of a method or constructor) the argument type sequence
+ * {@code A*}.
+ * <p>
+ * Each method handle constant has an equivalent instruction sequence called its <em>bytecode behavior</em>.
+ * In general, creating a method handle constant can be done in exactly the same circumstances that
+ * the JVM would successfully resolve the symbolic references in the bytecode behavior.
+ * Also, the type of a method handle constant is such that a valid {@code invokeExact} call
+ * on the method handle has exactly the same JVM stack effects as the <em>bytecode behavior</em>.
+ * Finally, calling a method handle constant on a valid set of arguments has exactly the same effect
+ * and returns the same result (if any) as the corresponding <em>bytecode behavior</em>.
+ * <p>
+ * Each method handle constant also has an equivalent reflective <em>lookup expression</em>,
+ * which is a query to a method in {@link java.dyn.MethodHandles.Lookup}.
+ * In the example lookup method expression given in the table above, the name {@code MT}
+ * stands for a {@code MethodType} built from {@code T} and the sequence of argument types {@code A*}.
+ * (Note that the type {@code C} is not prepended to the query type {@code MT} even if the member is non-static.)
+ * In the case of {@code findSpecial}, the name {@code this.class} refers to the class containing
+ * the bytecodes.
  * <p>
  * The special name {@code <clinit>} is not allowed.
  * The special name {@code <init>} is not allowed except for subtag 8 as shown.
  * <p>
  * The JVM verifier and linker apply the same access checks and restrictions for these references as for the hypothetical
- * bytecode instructions specified in the last column of the table.  In particular, method handles to
+ * bytecode instructions specified in the last column of the table.
+ * A method handle constant will successfully resolve to a method handle if the symbolic references
+ * of the corresponding bytecode instruction(s) would also resolve successfully.
+ * Otherwise, an attempt to resolve the constant will throw equivalent linkage errors.
+ * In particular, method handles to
  * private and protected members can be created in exactly those classes for which the corresponding
  * normal accesses are legal.
  * <p>
  * A constant may refer to a method or constructor with the {@code varargs}
- * bit (hexadecimal {@code 80}) set in its modifier bitmask.
- * The method handle constant produced for such a method behaves the same
+ * bit (hexadecimal {@code 0x0080}) set in its modifier bitmask.
+ * The method handle constant produced for such a method behaves as if
+ * it were created by {@link java.dyn.MethodHandle#asVarargsCollector asVarargsCollector}.
+ * In other words, the constant method handle will exhibit variable arity,
+ * when invoked via {@code invokeGeneric}.
+ * On the other hand, its behavior with respect to {@code invokeExact} will be the same
  * as if the {@code varargs} bit were not set.
- * The argument-collecting behavior of {@code varargs} can be emulated by
- * adapting the method handle constant with
- * {@link java.dyn.MethodHandle#asCollector asCollector}.
- * There is no provision for doing this automatically.
  * <p>
  * Although the {@code CONSTANT_MethodHandle} and {@code CONSTANT_MethodType} constant types
  * resolve class names, they do not force class initialization.
@@ -186,14 +209,14 @@
  * by the execution of {@code invokedynamic} and {@code ldc} instructions.
  * (Roughly speaking, this means that every use of a constant pool entry
  * must lead to the same outcome.
- * If the resoultion succeeds, the same object reference is produced
+ * If the resolution succeeds, the same object reference is produced
  * by every subsequent execution of the same instruction.
  * If the resolution of the constant causes an error to occur,
  * the same error will be re-thrown on every subsequent attempt
  * to use this particular constant.)
  * <p>
  * Constants created by the resolution of these constant pool types are not necessarily
- * interned.  Except for {@link CONSTANT_Class} and {@link CONSTANT_String} entries,
+ * interned.  Except for {@code CONSTANT_Class} and {@code CONSTANT_String} entries,
  * two distinct constant pool entries might not resolve to the same reference
  * even if they contain the same symbolic reference.
  *
@@ -207,31 +230,31 @@
  * <p>
  * Each {@code invokedynamic} instruction statically specifies its own
  * bootstrap method as a constant pool reference.
- * The constant pool reference also specifies the call site's name and type signature,
+ * The constant pool reference also specifies the call site's name and type descriptor,
  * just like {@code invokevirtual} and the other invoke instructions.
  * <p>
  * Linking starts with resolving the constant pool entry for the
  * bootstrap method, and resolving a {@link java.dyn.MethodType MethodType} object for
- * the type signature of the dynamic call site.
+ * the type descriptor of the dynamic call site.
  * This resolution process may trigger class loading.
  * It may therefore throw an error if a class fails to load.
  * This error becomes the abnormal termination of the dynamic
  * call site execution.
  * Linkage does not trigger class initialization.
  * <p>
- * Next, the bootstrap method call is started, with four or five values being stacked:
+ * Next, the bootstrap method call is started, with at least four values being stacked:
  * <ul>
  * <li>a {@code MethodHandle}, the resolved bootstrap method itself </li>
  * <li>a {@code MethodHandles.Lookup}, a lookup object on the <em>caller class</em> in which dynamic call site occurs </li>
  * <li>a {@code String}, the method name mentioned in the call site </li>
- * <li>a {@code MethodType}, the resolved type signature of the call </li>
- * <li>optionally, a single object representing one or more <a href="#args">additional static arguments</a> </li>
+ * <li>a {@code MethodType}, the resolved type descriptor of the call </li>
+ * <li>optionally, one or more <a href="#args">additional static arguments</a> </li>
  * </ul>
  * The method handle is then applied to the other values as if by
  * {@link java.dyn.MethodHandle#invokeGeneric invokeGeneric}.
  * The returned result must be a {@link java.dyn.CallSite CallSite} (or a subclass).
  * The type of the call site's target must be exactly equal to the type
- * derived from the dynamic call site signature and passed to
+ * derived from the dynamic call site's type descriptor and passed to
  * the bootstrap method.
  * The call site then becomes permanently linked to the dynamic call site.
  * <p>
@@ -299,11 +322,11 @@
  * chosen target object.
  *
  * <p style="font-size:smaller;">
- * (Historic Note: Unlike some previous versions of this specification,
+ * <em>Historic Note:</em> Unlike some previous versions of this specification,
  * these rules do not enable the JVM to duplicate dynamic call sites,
  * or to issue &ldquo;causeless&rdquo; bootstrap method calls.
  * Every dynamic call site transitions at most once from unlinked to linked,
- * just before its first invocation.)
+ * just before its first invocation.
  *
  * <h3><a name="bsmattr">the {@code BootstrapMethods} attribute </h3>
  * Each {@code CONSTANT_InvokeDynamic} entry contains an index which references
@@ -349,7 +372,6 @@
  * Static arguments are specified constant pool indexes stored in the {@code BootstrapMethods} attribute.
  * Before the bootstrap method is invoked, each index is used to compute an {@code Object}
  * reference to the indexed value in the constant pool.
- * If the value is a primitive type, it is converted to a reference by boxing conversion.
  * The valid constant pool entries are listed in this table:
  * <code>
  * <table border=1 cellpadding=5 summary="Static argument types">
@@ -369,21 +391,43 @@
  * the instruction's bootstrap method will be invoked on three arguments,
  * conveying the instruction's caller class, name, and method type.
  * If the {@code invokedynamic} instruction specifies one or more static arguments,
- * a fourth argument will be passed to the bootstrap argument,
- * either an {@code Object} reference to the sole extra argument (if there is one)
- * or an {@code Object} array of references to all the arguments (if there are two or more),
- * as if the bootstrap method is a variable-arity method.
+ * those values will be passed as additional arguments to the method handle.
+ * (Note that because there is a limit of 255 arguments to any method,
+ * at most 252 extra arguments can be supplied.)
+ * The bootstrap method will be invoked as if by either {@code invokeGeneric}
+ * or {@code invokeWithArguments}.  (There is no way to tell the difference.)
+ * <p>
+ * The normal argument conversion rules for {@code invokeGeneric} apply to all stacked arguments.
+ * For example, if a pushed value is a primitive type, it may be converted to a reference by boxing conversion.
+ * If the bootstrap method is a variable arity method (its modifier bit {@code 0x0080} is set),
+ * then some or all of the arguments specified here may be collected into a trailing array parameter.
+ * (This is not a special rule, but rather a useful consequence of the interaction
+ * between {@code CONSTANT_MethodHandle} constants, the modifier bit for variable arity methods,
+ * and the {@code java.dyn.MethodHandle#asVarargsCollector asVarargsCollector} transformation.)
+ * <p>
+ * Given these rules, here are examples of legal bootstrap method declarations,
+ * given various numbers {@code N} of extra arguments.
+ * The first rows (marked {@code *}) will work for any number of extra arguments.
  * <code>
  * <table border=1 cellpadding=5 summary="Static argument types">
  * <tr><th>N</th><th>sample bootstrap method</th></tr>
+ * <tr><td>*</td><td><code>CallSite bootstrap(Lookup caller, String name, MethodType type, Object... args)</code></td></tr>
+ * <tr><td>*</td><td><code>CallSite bootstrap(Object... args)</code></td></tr>
+ * <tr><td>*</td><td><code>CallSite bootstrap(Object caller, Object... nameAndTypeWithArgs)</code></td></tr>
  * <tr><td>0</td><td><code>CallSite bootstrap(Lookup caller, String name, MethodType type)</code></td></tr>
+ * <tr><td>0</td><td><code>CallSite bootstrap(Lookup caller, Object... nameAndType)</code></td></tr>
  * <tr><td>1</td><td><code>CallSite bootstrap(Lookup caller, String name, MethodType type, Object arg)</code></td></tr>
  * <tr><td>2</td><td><code>CallSite bootstrap(Lookup caller, String name, MethodType type, Object... args)</code></td></tr>
+ * <tr><td>2</td><td><code>CallSite bootstrap(Lookup caller, String name, MethodType type, String... args)</code></td></tr>
+ * <tr><td>2</td><td><code>CallSite bootstrap(Lookup caller, String name, MethodType type, String x, int y)</code></td></tr>
  * </table>
  * </code>
+ * The last example assumes that the extra arguments are of type
+ * {@code CONSTANT_String} and {@code CONSTANT_Integer}, respectively.
+ * The second-to-last example assumes that all extra arguments are of type
+ * {@code CONSTANT_String}.
+ * The other examples work with all types of extra arguments.
  * <p>
- * The argument and return types listed here are used by the {@code invokeGeneric}
- * call to the bootstrap method.
  * As noted above, the actual method type of the bootstrap method can vary.
  * For example, the fourth argument could be {@code MethodHandle},
  * if that is the type of the corresponding constant in
@@ -391,14 +435,8 @@
  * In that case, the {@code invokeGeneric} call will pass the extra method handle
  * constant as an {@code Object}, but the type matching machinery of {@code invokeGeneric}
  * will cast the reference back to {@code MethodHandle} before invoking the bootstrap method.
- * (If a string constant were passed instead, by badly generated code, that cast would then fail.)
- * <p>
- * If the fourth argument is an array, the array element type must be {@code Object},
- * since object arrays (as produced by the JVM at this point) cannot be converted
- * to other array types.
- * <p>
- * If an array is provided, it will appear to be freshly allocated.
- * That is, the same array will not appear to two bootstrap method calls.
+ * (If a string constant were passed instead, by badly generated code, that cast would then fail,
+ * resulting in an {@code InvokeDynamicBootstrapError}.)
  * <p>
  * Extra bootstrap method arguments are intended to allow language implementors
  * to safely and compactly encode metadata.
@@ -406,24 +444,6 @@
  * since each call site could be given its own unique bootstrap method.
  * Such a practice is likely to produce large class files and constant pools.
  *
- * <p style="font-size:smaller;">
- * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
- * (Usage Note: There is no mechanism for specifying five or more positional arguments to the bootstrap method.
- * If there are two or more arguments, the Java code of the bootstrap method is required to extract them from
- * a varargs-style object array.
- * This design uses varargs because it anticipates some use cases where bootstrap arguments
- * contribute components of variable-length structures, such as virtual function tables
- * or interpreter token streams.
- * Such parameters would be awkward or impossible to manage if represented
- * as normal positional method arguments,
- * since there would need to be one Java method per length.
- * On balance, leaving out the varargs feature would cause more trouble to users than keeping it.
- * Also, this design allows bootstrap methods to be called in a limited JVM stack depth.
- * At both the user and JVM level, the difference between varargs and non-varargs
- * calling sequences can easily be bridged via the
- * {@link java.dyn.MethodHandle#asSpreader asSpreader}
- * and {@link java.dyn.MethodHandle#asSpreader asCollector} methods.)
- *
  * <h2><a name="structs"></a>Structure Summary</h2>
  * <blockquote><pre>// summary of constant and attribute structures
 struct CONSTANT_MethodHandle_info {
@@ -435,11 +455,6 @@
   u1 tag = 16;
   u2 descriptor_index;    // index to CONSTANT_Utf8, as in NameAndType
 }
-struct CONSTANT_InvokeDynamic_17_info {
-  u1 tag = 17;
-  u2 bootstrap_method_index;   // index to CONSTANT_MethodHandle
-  u2 name_and_type_index;      // same as for CONSTANT_Methodref, etc.
-}
 struct CONSTANT_InvokeDynamic_info {
   u1 tag = 18;
   u2 bootstrap_method_attr_index;  // index into BootstrapMethods_attr
@@ -456,9 +471,6 @@
  } bootstrap_methods[bootstrap_method_count];
 }
  * </pre></blockquote>
- * <p>
- * <em>Note: The Proposed Final Draft of JSR 292 may remove the constant tag 17,
- * for the sake of simplicity.</em>
  *
  * @author John Rose, JSR 292 EG
  */
--- a/jdk/src/share/classes/java/io/Console.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/io/Console.java	Mon Mar 07 11:37:54 2011 -0800
@@ -308,17 +308,29 @@
         char[] passwd = null;
         synchronized (writeLock) {
             synchronized(readLock) {
-                if (fmt.length() != 0)
-                    pw.format(fmt, args);
                 try {
                     echoOff = echo(false);
+                } catch (IOException x) {
+                    throw new IOError(x);
+                }
+                IOError ioe = null;
+                try {
+                    if (fmt.length() != 0)
+                        pw.format(fmt, args);
                     passwd = readline(true);
                 } catch (IOException x) {
-                    throw new IOError(x);
+                    ioe = new IOError(x);
                 } finally {
                     try {
                         echoOff = echo(true);
-                    } catch (IOException xx) {}
+                    } catch (IOException x) {
+                        if (ioe == null)
+                            ioe = new IOError(x);
+                        else
+                            ioe.addSuppressed(x);
+                    }
+                    if (ioe != null)
+                        throw ioe;
                 }
                 pw.println();
             }
--- a/jdk/src/share/classes/java/lang/System.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/lang/System.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1102,6 +1102,18 @@
      * Initialize the system class.  Called after thread initialization.
      */
     private static void initializeSystemClass() {
+
+        // VM might invoke JNU_NewStringPlatform() to set those encoding
+        // sensitive properties (user.home, user.name, boot.class.path, etc.)
+        // during "props" initialization, in which it may need access, via
+        // System.getProperty(), to the related system encoding property that
+        // have been initialized (put into "props") at early stage of the
+        // initialization. So make sure the "props" is available at the
+        // very beginning of the initialization and all system properties to
+        // be put into it directly.
+        props = new Properties();
+        initProperties(props);  // initialized by the VM
+
         // There are certain system configurations that may be controlled by
         // VM options such as the maximum amount of direct memory and
         // Integer cache size used to support the object identity semantics
@@ -1112,7 +1124,12 @@
         //
         // See java.lang.Integer.IntegerCache and the
         // sun.misc.VM.saveAndRemoveProperties method for example.
-        props = initSystemProperties();
+        //
+        // Save a private copy of the system properties object that
+        // can only be accessed by the internal implementation.  Remove
+        // certain system properties that are not intended for public access.
+        sun.misc.VM.saveAndRemoveProperties(props);
+
 
         lineSeparator = props.getProperty("line.separator");
         sun.misc.Version.init();
@@ -1123,7 +1140,6 @@
         setIn0(new BufferedInputStream(fdIn));
         setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
         setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true));
-
         // Load the zip library now in order to keep java.util.zip.ZipFile
         // from trying to use itself to load this library later.
         loadLibrary("zip");
@@ -1151,18 +1167,6 @@
         setJavaLangAccess();
     }
 
-    private static Properties initSystemProperties() {
-        Properties props = new Properties();
-        initProperties(props);  // initialized by the VM
-
-        // Save a private copy of the system properties object that
-        // can only be accessed by the internal implementation.  Remove
-        // certain system properties that are not intended for public access.
-        sun.misc.VM.saveAndRemoveProperties(props);
-
-        return props;
-    }
-
     private static void setJavaLangAccess() {
         // Allow privileged classes outside of java.lang
         sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
--- a/jdk/src/share/classes/java/lang/Thread.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/lang/Thread.java	Mon Mar 07 11:37:54 2011 -0800
@@ -254,12 +254,6 @@
      */
     public final static int MAX_PRIORITY = 10;
 
-    /* If stop was called before start */
-    private boolean stopBeforeStart;
-
-    /* Remembered Throwable from stop before start */
-    private Throwable throwableFromStop;
-
     /**
      * Returns a reference to the currently executing thread object.
      *
@@ -706,10 +700,6 @@
                   it will be passed up the call stack */
             }
         }
-
-        if (stopBeforeStart) {
-            stop0(throwableFromStop);
-        }
     }
 
     private native void start0();
@@ -820,12 +810,7 @@
      */
     @Deprecated
     public final void stop() {
-        // If the thread is already dead, return.
-        // A zero status value corresponds to "NEW".
-        if ((threadStatus != 0) && !isAlive()) {
-            return;
-        }
-        stop1(new ThreadDeath());
+        stop(new ThreadDeath());
     }
 
     /**
@@ -879,36 +864,25 @@
      */
     @Deprecated
     public final synchronized void stop(Throwable obj) {
-        stop1(obj);
-    }
+        if (obj == null)
+            throw new NullPointerException();
 
-    /**
-     * Common impl for stop() and stop(Throwable).
-     */
-    private final synchronized void stop1(Throwable th) {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             checkAccess();
             if ((this != Thread.currentThread()) ||
-                (!(th instanceof ThreadDeath))) {
+                (!(obj instanceof ThreadDeath))) {
                 security.checkPermission(SecurityConstants.STOP_THREAD_PERMISSION);
             }
         }
-        // A zero status value corresponds to "NEW"
+        // A zero status value corresponds to "NEW", it can't change to
+        // not-NEW because we hold the lock.
         if (threadStatus != 0) {
             resume(); // Wake up thread if it was suspended; no-op otherwise
-            stop0(th);
-        } else {
+        }
 
-            // Must do the null arg check that the VM would do with stop0
-            if (th == null) {
-                throw new NullPointerException();
-            }
-
-            // Remember this stop attempt for if/when start is used
-            stopBeforeStart = true;
-            throwableFromStop = th;
-        }
+        // The VM can handle all thread states
+        stop0(obj);
     }
 
     /**
--- a/jdk/src/share/classes/java/util/Hashtable.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/util/Hashtable.java	Mon Mar 07 11:37:54 2011 -0800
@@ -845,24 +845,36 @@
      *             for each key-value mapping represented by the Hashtable
      *             The key-value mappings are emitted in no particular order.
      */
-    private synchronized void writeObject(java.io.ObjectOutputStream s)
-        throws IOException
-    {
-        // Write out the length, threshold, loadfactor
-        s.defaultWriteObject();
+    private void writeObject(java.io.ObjectOutputStream s)
+            throws IOException {
+        Entry<Object, Object> entryStack = null;
+
+        synchronized (this) {
+            // Write out the length, threshold, loadfactor
+            s.defaultWriteObject();
+
+            // Write out length, count of elements
+            s.writeInt(table.length);
+            s.writeInt(count);
 
-        // Write out length, count of elements and then the key/value objects
-        s.writeInt(table.length);
-        s.writeInt(count);
-        for (int index = table.length-1; index >= 0; index--) {
-            Entry entry = table[index];
+            // Stack copies of the entries in the table
+            for (int index = 0; index < table.length; index++) {
+                Entry entry = table[index];
 
-            while (entry != null) {
-                s.writeObject(entry.key);
-                s.writeObject(entry.value);
-                entry = entry.next;
+                while (entry != null) {
+                    entryStack =
+                        new Entry<>(0, entry.key, entry.value, entryStack);
+                    entry = entry.next;
+                }
             }
         }
+
+        // Write out the key/value objects from the stacked entries
+        while (entryStack != null) {
+            s.writeObject(entryStack.key);
+            s.writeObject(entryStack.value);
+            entryStack = entryStack.next;
+        }
     }
 
     /**
--- a/jdk/src/share/classes/java/util/SimpleTimeZone.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/util/SimpleTimeZone.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -825,10 +825,7 @@
      * @since 1.2
      */
     public int getDSTSavings() {
-        if (useDaylight) {
-            return dstSavings;
-        }
-        return 0;
+        return useDaylight ? dstSavings : 0;
     }
 
     /**
@@ -842,6 +839,20 @@
     }
 
     /**
+     * Returns {@code true} if this {@code SimpleTimeZone} observes
+     * Daylight Saving Time. This method is equivalent to {@link
+     * #useDaylightTime()}.
+     *
+     * @return {@code true} if this {@code SimpleTimeZone} observes
+     * Daylight Saving Time; {@code false} otherwise.
+     * @since 1.7
+     */
+    @Override
+    public boolean observesDaylightTime() {
+        return useDaylightTime();
+    }
+
+    /**
      * Queries if the given date is in daylight saving time.
      * @return true if daylight saving time is in effective at the
      * given date; false otherwise.
--- a/jdk/src/share/classes/java/util/TimeZone.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/util/TimeZone.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -455,17 +455,28 @@
     /**
      * Returns the amount of time to be added to local standard time
      * to get local wall clock time.
-     * <p>
-     * The default implementation always returns 3600000 milliseconds
-     * (i.e., one hour) if this time zone observes Daylight Saving
-     * Time. Otherwise, 0 (zero) is returned.
-     * <p>
-     * If an underlying TimeZone implementation subclass supports
-     * historical Daylight Saving Time changes, this method returns
-     * the known latest daylight saving value.
+     *
+     * <p>The default implementation returns 3600000 milliseconds
+     * (i.e., one hour) if a call to {@link #useDaylightTime()}
+     * returns {@code true}. Otherwise, 0 (zero) is returned.
+     *
+     * <p>If an underlying {@code TimeZone} implementation subclass
+     * supports historical and future Daylight Saving Time schedule
+     * changes, this method returns the amount of saving time of the
+     * last known Daylight Saving Time rule that can be a future
+     * prediction.
+     *
+     * <p>If the amount of saving time at any given time stamp is
+     * required, construct a {@link Calendar} with this {@code
+     * TimeZone} and the time stamp, and call {@link Calendar#get(int)
+     * Calendar.get}{@code (}{@link Calendar#DST_OFFSET}{@code )}.
      *
      * @return the amount of saving time in milliseconds
      * @since 1.4
+     * @see #inDaylightTime(Date)
+     * @see #getOffset(long)
+     * @see #getOffset(int,int,int,int,int,int)
+     * @see Calendar#ZONE_OFFSET
      */
     public int getDSTSavings() {
         if (useDaylightTime()) {
@@ -475,24 +486,51 @@
     }
 
     /**
-     * Queries if this time zone uses daylight savings time.
-     * <p>
-     * If an underlying <code>TimeZone</code> implementation subclass
-     * supports historical Daylight Saving Time schedule changes, the
-     * method refers to the latest Daylight Saving Time schedule
-     * information.
+     * Queries if this {@code TimeZone} uses Daylight Saving Time.
      *
-     * @return true if this time zone uses daylight savings time,
-     * false, otherwise.
+     * <p>If an underlying {@code TimeZone} implementation subclass
+     * supports historical and future Daylight Saving Time schedule
+     * changes, this method refers to the last known Daylight Saving Time
+     * rule that can be a future prediction and may not be the same as
+     * the current rule. Consider calling {@link #observesDaylightTime()}
+     * if the current rule should also be taken into account.
+     *
+     * @return {@code true} if this {@code TimeZone} uses Daylight Saving Time,
+     *         {@code false}, otherwise.
+     * @see #inDaylightTime(Date)
+     * @see Calendar#DST_OFFSET
      */
     public abstract boolean useDaylightTime();
 
     /**
-     * Queries if the given date is in daylight savings time in
-     * this time zone.
-     * @param date the given Date.
-     * @return true if the given date is in daylight savings time,
-     * false, otherwise.
+     * Returns {@code true} if this {@code TimeZone} is currently in
+     * Daylight Saving Time, or if a transition from Standard Time to
+     * Daylight Saving Time occurs at any future time.
+     *
+     * <p>The default implementation returns {@code true} if
+     * {@code useDaylightTime()} or {@code inDaylightTime(new Date())}
+     * returns {@code true}.
+     *
+     * @return {@code true} if this {@code TimeZone} is currently in
+     * Daylight Saving Time, or if a transition from Standard Time to
+     * Daylight Saving Time occurs at any future time; {@code false}
+     * otherwise.
+     * @since 1.7
+     * @see #useDaylightTime()
+     * @see #inDaylightTime(Date)
+     * @see Calendar#DST_OFFSET
+     */
+    public boolean observesDaylightTime() {
+        return useDaylightTime() || inDaylightTime(new Date());
+    }
+
+    /**
+     * Queries if the given {@code date} is in Daylight Saving Time in
+     * this {@code TimeZone}.
+     *
+     * @param date the given {@code Date}.
+     * @return {@code true} if the given {@code date} is in Daylight Saving Time,
+     *         {@code false}, otherwise.
      */
     abstract public boolean inDaylightTime(Date date);
 
--- a/jdk/src/share/classes/java/util/Vector.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/util/Vector.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1050,13 +1050,21 @@
 
     /**
      * Save the state of the {@code Vector} instance to a stream (that
-     * is, serialize it).  This method is present merely for synchronization.
-     * It just calls the default writeObject method.
+     * is, serialize it).
+     * This method performs synchronization to ensure the consistency
+     * of the serialized data.
      */
-    private synchronized void writeObject(java.io.ObjectOutputStream s)
-        throws java.io.IOException
-    {
-        s.defaultWriteObject();
+    private void writeObject(java.io.ObjectOutputStream s)
+            throws java.io.IOException {
+        final java.io.ObjectOutputStream.PutField fields = s.putFields();
+        final Object[] data;
+        synchronized (this) {
+            fields.put("capacityIncrement", capacityIncrement);
+            fields.put("elementCount", elementCount);
+            data = elementData.clone();
+        }
+        fields.put("elementData", data);
+        s.writeFields();
     }
 
     /**
--- a/jdk/src/share/classes/java/util/jar/JarFile.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/util/jar/JarFile.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,11 +27,13 @@
 
 import java.io.*;
 import java.lang.ref.SoftReference;
+import java.net.URL;
 import java.util.*;
 import java.util.zip.*;
 import java.security.CodeSigner;
 import java.security.cert.Certificate;
 import java.security.AccessController;
+import java.security.CodeSource;
 import sun.security.action.GetPropertyAction;
 import sun.security.util.ManifestEntryVerifier;
 import sun.misc.SharedSecrets;
@@ -262,7 +264,7 @@
                 throw new RuntimeException(e);
             }
             if (certs == null && jv != null) {
-                certs = jv.getCerts(getName());
+                certs = jv.getCerts(JarFile.this, this);
             }
             return certs == null ? null : certs.clone();
         }
@@ -273,7 +275,7 @@
                 throw new RuntimeException(e);
             }
             if (signers == null && jv != null) {
-                signers = jv.getCodeSigners(getName());
+                signers = jv.getCodeSigners(JarFile.this, this);
             }
             return signers == null ? null : signers.clone();
         }
@@ -544,4 +546,191 @@
         }
         return false;
     }
+
+    private synchronized void ensureInitialization() {
+        try {
+            maybeInstantiateVerifier();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        if (jv != null && !jvInitialized) {
+            initializeVerifier();
+            jvInitialized = true;
+        }
+    }
+
+    JarEntry newEntry(ZipEntry ze) {
+        return new JarFileEntry(ze);
+    }
+
+    Enumeration<String> entryNames(CodeSource[] cs) {
+        ensureInitialization();
+        if (jv != null) {
+            return jv.entryNames(this, cs);
+        }
+
+        /*
+         * JAR file has no signed content. Is there a non-signing
+         * code source?
+         */
+        boolean includeUnsigned = false;
+        for (int i = 0; i < cs.length; i++) {
+            if (cs[i].getCodeSigners() == null) {
+                includeUnsigned = true;
+                break;
+            }
+        }
+        if (includeUnsigned) {
+            return unsignedEntryNames();
+        } else {
+            return new Enumeration<String>() {
+
+                public boolean hasMoreElements() {
+                    return false;
+                }
+
+                public String nextElement() {
+                    throw new NoSuchElementException();
+                }
+            };
+        }
+    }
+
+    /**
+     * Returns an enumeration of the zip file entries
+     * excluding internal JAR mechanism entries and including
+     * signed entries missing from the ZIP directory.
+     */
+    Enumeration<JarEntry> entries2() {
+        ensureInitialization();
+        if (jv != null) {
+            return jv.entries2(this, super.entries());
+        }
+
+        // screen out entries which are never signed
+        final Enumeration enum_ = super.entries();
+        return new Enumeration<JarEntry>() {
+
+            ZipEntry entry;
+
+            public boolean hasMoreElements() {
+                if (entry != null) {
+                    return true;
+                }
+                while (enum_.hasMoreElements()) {
+                    ZipEntry ze = (ZipEntry) enum_.nextElement();
+                    if (JarVerifier.isSigningRelated(ze.getName())) {
+                        continue;
+                    }
+                    entry = ze;
+                    return true;
+                }
+                return false;
+            }
+
+            public JarFileEntry nextElement() {
+                if (hasMoreElements()) {
+                    ZipEntry ze = entry;
+                    entry = null;
+                    return new JarFileEntry(ze);
+                }
+                throw new NoSuchElementException();
+            }
+        };
+    }
+
+    CodeSource[] getCodeSources(URL url) {
+        ensureInitialization();
+        if (jv != null) {
+            return jv.getCodeSources(this, url);
+        }
+
+        /*
+         * JAR file has no signed content. Is there a non-signing
+         * code source?
+         */
+        Enumeration unsigned = unsignedEntryNames();
+        if (unsigned.hasMoreElements()) {
+            return new CodeSource[]{JarVerifier.getUnsignedCS(url)};
+        } else {
+            return null;
+        }
+    }
+
+    private Enumeration<String> unsignedEntryNames() {
+        final Enumeration entries = entries();
+        return new Enumeration<String>() {
+
+            String name;
+
+            /*
+             * Grab entries from ZIP directory but screen out
+             * metadata.
+             */
+            public boolean hasMoreElements() {
+                if (name != null) {
+                    return true;
+                }
+                while (entries.hasMoreElements()) {
+                    String value;
+                    ZipEntry e = (ZipEntry) entries.nextElement();
+                    value = e.getName();
+                    if (e.isDirectory() || JarVerifier.isSigningRelated(value)) {
+                        continue;
+                    }
+                    name = value;
+                    return true;
+                }
+                return false;
+            }
+
+            public String nextElement() {
+                if (hasMoreElements()) {
+                    String value = name;
+                    name = null;
+                    return value;
+                }
+                throw new NoSuchElementException();
+            }
+        };
+    }
+
+    CodeSource getCodeSource(URL url, String name) {
+        ensureInitialization();
+        if (jv != null) {
+            if (jv.eagerValidation) {
+                CodeSource cs = null;
+                JarEntry je = getJarEntry(name);
+                if (je != null) {
+                    cs = jv.getCodeSource(url, this, je);
+                } else {
+                    cs = jv.getCodeSource(url, name);
+                }
+                return cs;
+            } else {
+                return jv.getCodeSource(url, name);
+            }
+        }
+
+        return JarVerifier.getUnsignedCS(url);
+    }
+
+    void setEagerValidation(boolean eager) {
+        try {
+            maybeInstantiateVerifier();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        if (jv != null) {
+            jv.setEagerValidation(eager);
+        }
+    }
+
+    List getManifestDigests() {
+        ensureInitialization();
+        if (jv != null) {
+            return jv.getManifestDigests();
+        }
+        return new ArrayList();
+    }
 }
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -26,9 +26,11 @@
 package java.util.jar;
 
 import java.io.*;
+import java.net.URL;
 import java.util.*;
 import java.security.*;
 import java.security.cert.CertificateException;
+import java.util.zip.ZipEntry;
 
 import sun.security.util.ManifestDigester;
 import sun.security.util.ManifestEntryVerifier;
@@ -81,6 +83,15 @@
     /** the bytes for the manDig object */
     byte manifestRawBytes[] = null;
 
+    /** controls eager signature validation */
+    boolean eagerValidation;
+
+    /** makes code source singleton instances unique to us */
+    private Object csdomain = new Object();
+
+    /** collect -DIGEST-MANIFEST values for blacklist */
+    private List manifestDigests;
+
     public JarVerifier(byte rawBytes[]) {
         manifestRawBytes = rawBytes;
         sigFileSigners = new Hashtable();
@@ -88,6 +99,7 @@
         sigFileData = new Hashtable(11);
         pendingBlocks = new ArrayList();
         baos = new ByteArrayOutputStream();
+        manifestDigests = new ArrayList();
     }
 
     /**
@@ -247,7 +259,7 @@
                             }
 
                             sfv.setSignatureFile(bytes);
-                            sfv.process(sigFileSigners);
+                            sfv.process(sigFileSigners, manifestDigests);
                         }
                     }
                     return;
@@ -290,7 +302,7 @@
                         sfv.setSignatureFile(bytes);
                     }
                 }
-                sfv.process(sigFileSigners);
+                sfv.process(sigFileSigners, manifestDigests);
 
             } catch (IOException ioe) {
                 // e.g. sun.security.pkcs.ParsingException
@@ -312,12 +324,18 @@
     /**
      * Return an array of java.security.cert.Certificate objects for
      * the given file in the jar.
+     * @deprecated
      */
     public java.security.cert.Certificate[] getCerts(String name)
     {
         return mapSignersToCertArray(getCodeSigners(name));
     }
 
+    public java.security.cert.Certificate[] getCerts(JarFile jar, JarEntry entry)
+    {
+        return mapSignersToCertArray(getCodeSigners(jar, entry));
+    }
+
     /**
      * return an array of CodeSigner objects for
      * the given file in the jar. this array is not cloned.
@@ -328,6 +346,28 @@
         return (CodeSigner[])verifiedSigners.get(name);
     }
 
+    public CodeSigner[] getCodeSigners(JarFile jar, JarEntry entry)
+    {
+        String name = entry.getName();
+        if (eagerValidation && sigFileSigners.get(name) != null) {
+            /*
+             * Force a read of the entry data to generate the
+             * verification hash.
+             */
+            try {
+                InputStream s = jar.getInputStream(entry);
+                byte[] buffer = new byte[1024];
+                int n = buffer.length;
+                while (n != -1) {
+                    n = s.read(buffer, 0, buffer.length);
+                }
+                s.close();
+            } catch (IOException e) {
+            }
+        }
+        return getCodeSigners(name);
+    }
+
     /*
      * Convert an array of signers into an array of concatenated certificate
      * arrays.
@@ -444,4 +484,393 @@
         }
 
     }
+
+    // Extended JavaUtilJarAccess CodeSource API Support
+
+    private Map urlToCodeSourceMap = new HashMap();
+    private Map signerToCodeSource = new HashMap();
+    private URL lastURL;
+    private Map lastURLMap;
+
+    /*
+     * Create a unique mapping from codeSigner cache entries to CodeSource.
+     * In theory, multiple URLs origins could map to a single locally cached
+     * and shared JAR file although in practice there will be a single URL in use.
+     */
+    private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) {
+        Map map;
+        if (url == lastURL) {
+            map = lastURLMap;
+        } else {
+            map = (Map) urlToCodeSourceMap.get(url);
+            if (map == null) {
+                map = new HashMap();
+                urlToCodeSourceMap.put(url, map);
+            }
+            lastURLMap = map;
+            lastURL = url;
+        }
+        CodeSource cs = (CodeSource) map.get(signers);
+        if (cs == null) {
+            cs = new VerifierCodeSource(csdomain, url, signers);
+            signerToCodeSource.put(signers, cs);
+        }
+        return cs;
+    }
+
+    private CodeSource[] mapSignersToCodeSources(URL url, List signers, boolean unsigned) {
+        List sources = new ArrayList();
+
+        for (int i = 0; i < signers.size(); i++) {
+            sources.add(mapSignersToCodeSource(url, (CodeSigner[]) signers.get(i)));
+        }
+        if (unsigned) {
+            sources.add(mapSignersToCodeSource(url, null));
+        }
+        return (CodeSource[]) sources.toArray(new CodeSource[sources.size()]);
+    }
+    private CodeSigner[] emptySigner = new CodeSigner[0];
+
+    /*
+     * Match CodeSource to a CodeSigner[] in the signer cache.
+     */
+    private CodeSigner[] findMatchingSigners(CodeSource cs) {
+        if (cs instanceof VerifierCodeSource) {
+            VerifierCodeSource vcs = (VerifierCodeSource) cs;
+            if (vcs.isSameDomain(csdomain)) {
+                return ((VerifierCodeSource) cs).getPrivateSigners();
+            }
+        }
+
+        /*
+         * In practice signers should always be optimized above
+         * but this handles a CodeSource of any type, just in case.
+         */
+        CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true);
+        List sourceList = new ArrayList();
+        for (int i = 0; i < sources.length; i++) {
+            sourceList.add(sources[i]);
+        }
+        int j = sourceList.indexOf(cs);
+        if (j != -1) {
+            CodeSigner[] match;
+            match = ((VerifierCodeSource) sourceList.get(j)).getPrivateSigners();
+            if (match == null) {
+                match = emptySigner;
+            }
+            return match;
+        }
+        return null;
+    }
+
+    /*
+     * Instances of this class hold uncopied references to internal
+     * signing data that can be compared by object reference identity.
+     */
+    private static class VerifierCodeSource extends CodeSource {
+
+        URL vlocation;
+        CodeSigner[] vsigners;
+        java.security.cert.Certificate[] vcerts;
+        Object csdomain;
+
+        VerifierCodeSource(Object csdomain, URL location, CodeSigner[] signers) {
+            super(location, signers);
+            this.csdomain = csdomain;
+            vlocation = location;
+            vsigners = signers; // from signerCache
+        }
+
+        VerifierCodeSource(Object csdomain, URL location, java.security.cert.Certificate[] certs) {
+            super(location, certs);
+            this.csdomain = csdomain;
+            vlocation = location;
+            vcerts = certs; // from signerCache
+        }
+
+        /*
+         * All VerifierCodeSource instances are constructed based on
+         * singleton signerCache or signerCacheCert entries for each unique signer.
+         * No CodeSigner<->Certificate[] conversion is required.
+         * We use these assumptions to optimize equality comparisons.
+         */
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof VerifierCodeSource) {
+                VerifierCodeSource that = (VerifierCodeSource) obj;
+
+                /*
+                 * Only compare against other per-signer singletons constructed
+                 * on behalf of the same JarFile instance. Otherwise, compare
+                 * things the slower way.
+                 */
+                if (isSameDomain(that.csdomain)) {
+                    if (that.vsigners != this.vsigners
+                            || that.vcerts != this.vcerts) {
+                        return false;
+                    }
+                    if (that.vlocation != null) {
+                        return that.vlocation.equals(this.vlocation);
+                    } else if (this.vlocation != null) {
+                        return this.vlocation.equals(that.vlocation);
+                    } else { // both null
+                        return true;
+                    }
+                }
+            }
+            return super.equals(obj);
+        }
+
+        boolean isSameDomain(Object csdomain) {
+            return this.csdomain == csdomain;
+        }
+
+        private CodeSigner[] getPrivateSigners() {
+            return vsigners;
+        }
+
+        private java.security.cert.Certificate[] getPrivateCertificates() {
+            return vcerts;
+        }
+    }
+    private Map signerMap;
+
+    private synchronized Map signerMap() {
+        if (signerMap == null) {
+            /*
+             * Snapshot signer state so it doesn't change on us. We care
+             * only about the asserted signatures. Verification of
+             * signature validity happens via the JarEntry apis.
+             */
+            signerMap = new HashMap(verifiedSigners.size() + sigFileSigners.size());
+            signerMap.putAll(verifiedSigners);
+            signerMap.putAll(sigFileSigners);
+        }
+        return signerMap;
+    }
+
+    public synchronized Enumeration<String> entryNames(JarFile jar, final CodeSource[] cs) {
+        final Map map = signerMap();
+        final Iterator itor = map.entrySet().iterator();
+        boolean matchUnsigned = false;
+
+        /*
+         * Grab a single copy of the CodeSigner arrays. Check
+         * to see if we can optimize CodeSigner equality test.
+         */
+        List req = new ArrayList(cs.length);
+        for (int i = 0; i < cs.length; i++) {
+            CodeSigner[] match = findMatchingSigners(cs[i]);
+            if (match != null) {
+                if (match.length > 0) {
+                    req.add(match);
+                } else {
+                    matchUnsigned = true;
+                }
+            }
+        }
+
+        final List signersReq = req;
+        final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
+
+        return new Enumeration<String>() {
+
+            String name;
+
+            public boolean hasMoreElements() {
+                if (name != null) {
+                    return true;
+                }
+
+                while (itor.hasNext()) {
+                    Map.Entry e = (Map.Entry) itor.next();
+                    if (signersReq.contains((CodeSigner[]) e.getValue())) {
+                        name = (String) e.getKey();
+                        return true;
+                    }
+                }
+                while (enum2.hasMoreElements()) {
+                    name = (String) enum2.nextElement();
+                    return true;
+                }
+                return false;
+            }
+
+            public String nextElement() {
+                if (hasMoreElements()) {
+                    String value = name;
+                    name = null;
+                    return value;
+                }
+                throw new NoSuchElementException();
+            }
+        };
+    }
+
+    /*
+     * Like entries() but screens out internal JAR mechanism entries
+     * and includes signed entries with no ZIP data.
+     */
+    public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration e) {
+        final Map map = new HashMap();
+        map.putAll(signerMap());
+        final Enumeration enum_ = e;
+        return new Enumeration<JarEntry>() {
+
+            Enumeration signers = null;
+            JarEntry entry;
+
+            public boolean hasMoreElements() {
+                if (entry != null) {
+                    return true;
+                }
+                while (enum_.hasMoreElements()) {
+                    ZipEntry ze = (ZipEntry) enum_.nextElement();
+                    if (JarVerifier.isSigningRelated(ze.getName())) {
+                        continue;
+                    }
+                    entry = jar.newEntry(ze);
+                    return true;
+                }
+                if (signers == null) {
+                    signers = Collections.enumeration(map.keySet());
+                }
+                while (signers.hasMoreElements()) {
+                    String name = (String) signers.nextElement();
+                    entry = jar.newEntry(new ZipEntry(name));
+                    return true;
+                }
+
+                // Any map entries left?
+                return false;
+            }
+
+            public JarEntry nextElement() {
+                if (hasMoreElements()) {
+                    JarEntry je = entry;
+                    map.remove(je.getName());
+                    entry = null;
+                    return je;
+                }
+                throw new NoSuchElementException();
+            }
+        };
+    }
+    private Enumeration emptyEnumeration = new Enumeration<String>() {
+
+        public boolean hasMoreElements() {
+            return false;
+        }
+
+        public String nextElement() {
+            throw new NoSuchElementException();
+        }
+    };
+
+    // true if file is part of the signature mechanism itself
+    static boolean isSigningRelated(String name) {
+        name = name.toUpperCase(Locale.ENGLISH);
+        if (!name.startsWith("META-INF/")) {
+            return false;
+        }
+        name = name.substring(9);
+        if (name.indexOf('/') != -1) {
+            return false;
+        }
+        if (name.endsWith(".DSA")
+                || name.endsWith(".RSA")
+                || name.endsWith(".SF")
+                || name.endsWith(".EC")
+                || name.startsWith("SIG-")
+                || name.equals("MANIFEST.MF")) {
+            return true;
+        }
+        return false;
+    }
+
+    private Enumeration<String> unsignedEntryNames(JarFile jar) {
+        final Map map = signerMap();
+        final Enumeration entries = jar.entries();
+        return new Enumeration<String>() {
+
+            String name;
+
+            /*
+             * Grab entries from ZIP directory but screen out
+             * metadata.
+             */
+            public boolean hasMoreElements() {
+                if (name != null) {
+                    return true;
+                }
+                while (entries.hasMoreElements()) {
+                    String value;
+                    ZipEntry e = (ZipEntry) entries.nextElement();
+                    value = e.getName();
+                    if (e.isDirectory() || isSigningRelated(value)) {
+                        continue;
+                    }
+                    if (map.get(value) == null) {
+                        name = value;
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            public String nextElement() {
+                if (hasMoreElements()) {
+                    String value = name;
+                    name = null;
+                    return value;
+                }
+                throw new NoSuchElementException();
+            }
+        };
+    }
+    private List jarCodeSigners;
+
+    private synchronized List getJarCodeSigners() {
+        CodeSigner[] signers;
+        if (jarCodeSigners == null) {
+            HashSet set = new HashSet();
+            set.addAll(signerMap().values());
+            jarCodeSigners = new ArrayList();
+            jarCodeSigners.addAll(set);
+        }
+        return jarCodeSigners;
+    }
+
+    public synchronized CodeSource[] getCodeSources(JarFile jar, URL url) {
+        boolean hasUnsigned = unsignedEntryNames(jar).hasMoreElements();
+
+        return mapSignersToCodeSources(url, getJarCodeSigners(), hasUnsigned);
+    }
+
+    public CodeSource getCodeSource(URL url, String name) {
+        CodeSigner[] signers;
+
+        signers = (CodeSigner[]) signerMap().get(name);
+        return mapSignersToCodeSource(url, signers);
+    }
+
+    public CodeSource getCodeSource(URL url, JarFile jar, JarEntry je) {
+        CodeSigner[] signers;
+
+        return mapSignersToCodeSource(url, getCodeSigners(jar, je));
+    }
+
+    public void setEagerValidation(boolean eager) {
+        eagerValidation = eager;
+    }
+
+    public synchronized List getManifestDigests() {
+        return Collections.unmodifiableList(manifestDigests);
+    }
+
+    static CodeSource getUnsignedCS(URL url) {
+        return new VerifierCodeSource(null, url, (java.security.cert.Certificate[]) null);
+    }
 }
--- a/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,10 +26,38 @@
 package java.util.jar;
 
 import java.io.IOException;
+import java.net.URL;
+import java.security.CodeSource;
+import java.util.Enumeration;
+import java.util.List;
 import sun.misc.JavaUtilJarAccess;
 
 class JavaUtilJarAccessImpl implements JavaUtilJarAccess {
     public boolean jarFileHasClassPathAttribute(JarFile jar) throws IOException {
         return jar.hasClassPathAttribute();
     }
+
+    public CodeSource[] getCodeSources(JarFile jar, URL url) {
+        return jar.getCodeSources(url);
+    }
+
+    public CodeSource getCodeSource(JarFile jar, URL url, String name) {
+        return jar.getCodeSource(url, name);
+    }
+
+    public Enumeration<String> entryNames(JarFile jar, CodeSource[] cs) {
+        return jar.entryNames(cs);
+    }
+
+    public Enumeration<JarEntry> entries2(JarFile jar) {
+        return jar.entries2();
+    }
+
+    public void setEagerValidation(JarFile jar, boolean eager) {
+        jar.setEagerValidation(eager);
+    }
+
+    public List getManifestDigests(JarFile jar) {
+        return jar.getManifestDigests();
+    }
 }
--- a/jdk/src/share/classes/javax/script/ScriptEngineFactory.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/script/ScriptEngineFactory.java	Mon Mar 07 11:37:54 2011 -0800
@@ -115,20 +115,19 @@
      * with respect to concurrent execution of scripts and maintenance of state is also defined.
      * These values for the <code><b>THREADING</b></code> key are:<br><br>
      * <ul>
-     * <p><code>null</code> - The engine implementation is not thread safe, and cannot
+     * <li><code>null</code> - The engine implementation is not thread safe, and cannot
      * be used to execute scripts concurrently on multiple threads.
-     * <p><code>&quot;MULTITHREADED&quot;</code> - The engine implementation is internally
+     * <li><code>&quot;MULTITHREADED&quot;</code> - The engine implementation is internally
      * thread-safe and scripts may execute concurrently although effects of script execution
      * on one thread may be visible to scripts on other threads.
-     * <p><code>&quot;THREAD-ISOLATED&quot;</code> - The implementation satisfies the requirements
+     * <li><code>&quot;THREAD-ISOLATED&quot;</code> - The implementation satisfies the requirements
      * of &quot;MULTITHREADED&quot;, and also, the engine maintains independent values
      * for symbols in scripts executing on different threads.
-     * <p><code>&quot;STATELESS&quot;</code> - The implementation satisfies the requirements of
-     * <code>&quot;THREAD-ISOLATED&quot;</code>.  In addition, script executions do not alter the
+     * <li><code>&quot;STATELESS&quot;</code> - The implementation satisfies the requirements of
+     * <li><code>&quot;THREAD-ISOLATED&quot;</code>.  In addition, script executions do not alter the
      * mappings in the <code>Bindings</code> which is the engine scope of the
      * <code>ScriptEngine</code>.  In particular, the keys in the <code>Bindings</code>
      * and their associated values are the same before and after the execution of the script.
-     * </li>
      * </ul>
      * <br><br>
      * Implementations may define implementation-specific keys.
@@ -145,22 +144,23 @@
      * of the supported scripting language.  For instance, an implementaton for a Javascript
      * engine might be;
      * <p>
-     * <code><pre>
+     * <pre>
+     * <code>
      * public String getMethodCallSyntax(String obj,
      *                                   String m, String... args) {
      *      String ret = obj;
      *      ret += "." + m + "(";
      *      for (int i = 0; i < args.length; i++) {
      *          ret += args[i];
-     *          if (i == args.length - 1) {
-     *              ret += ")";
-     *          } else {
+     *          if (i < args.length - 1) {
      *              ret += ",";
      *          }
      *      }
+     *      ret += ")";
      *      return ret;
      * }
-     *</pre></code>
+     *</code>
+     *</pre>
      * <p>
      *
      * @param obj The name representing the object whose method is to be invoked. The
--- a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java	Mon Mar 07 11:37:54 2011 -0800
@@ -670,6 +670,12 @@
      * <p>The returned <code>TargetDataLine</code>'s default
      * audio format will be initialized with <code>format</code>.
      *
+     * <p>If the system property
+     * {@code javax.sound.sampled.TargetDataLine}
+     * is defined or it is defined in the file &quot;sound.properties&quot;,
+     * it is used to retrieve the default target data line.
+     * For details, refer to the {@link AudioSystem class description}.
+     *
      * @param format an <code>AudioFormat</code> object specifying
      *        the supported audio format of the returned line,
      *        or <code>null</code> for any audio format
@@ -712,12 +718,6 @@
      * <p>The returned <code>TargetDataLine</code>'s default
      * audio format will be initialized with <code>format</code>.
      *
-     * <p>If the system property
-     * <code>javax.sound.sampled.TargetDataLine</code>
-     * is defined or it is defined in the file &quot;sound.properties&quot;,
-     * it is used to retrieve the default target data line.
-     * For details, refer to the {@link AudioSystem class description}.
-     *
      * @param format an <code>AudioFormat</code> object specifying
      *        the supported audio format of the returned line,
      *        or <code>null</code> for any audio format
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java	Mon Mar 07 11:37:54 2011 -0800
@@ -57,10 +57,10 @@
     private char buf[];
 
     /**
-     * Internal Clob representation if SerialClob is intialized with a
-     * Clob
+     * Internal Clob representation if SerialClob is initialized with a
+     * Clob. Null if SerialClob is initialized with a char[].
      */
-    private Clob clob;
+    private final Clob clob;
 
     /**
      * The length in characters of this <code>SerialClob</code> object's
@@ -71,12 +71,12 @@
     private long len;
 
     /**
-     * The original length in characters of tgus <code>SerialClob</code>
-     * objects internal array of characters.
+     * The original length in characters of this <code>SerialClob</code>
+     * object's internal array of characters.
      *
      * @serial
      */
-    private long origLen;
+    private final long origLen;
 
     /**
      * Constructs a <code>SerialClob</code> object that is a serialized version of
@@ -104,6 +104,7 @@
            buf[i] = ch[i];
         }
         origLen = len;
+        clob = null;
     }
 
     /**
@@ -117,19 +118,19 @@
      * the database. Otherwise, the new <code>SerialClob</code> object
      * object will contain no data.
      * <p>
-     * Note: The <code>Clob</code> object supplied to this constructor cannot
-     * return <code>null</code> for the <code>Clob.getCharacterStream()</code>
+     * Note: The <code>Clob</code> object supplied to this constructor must
+     * return non-null for both the <code>Clob.getCharacterStream()</code>
      * and <code>Clob.getAsciiStream</code> methods. This <code>SerialClob</code>
-     * constructor cannot  serialize a <code>Clob</code> object in this instance
+     * constructor cannot serialize a <code>Clob</code> object in this instance
      * and will throw an <code>SQLException</code> object.
      *
      * @param  clob the <code>Clob</code> object from which this
      *     <code>SerialClob</code> object is to be constructed; cannot be null
      * @throws SerialException if an error occurs during serialization
      * @throws SQLException if a SQL error occurs in capturing the CLOB;
-     *     if the <code>Clob</code> object is a null; or if both the
+     *     if the <code>Clob</code> object is a null; or if either of the
      *     <code>Clob.getCharacterStream()</code> and <code>Clob.getAsciiStream()</code>
-     *     methods on the <code>Clob</code> return a null
+     *     methods on the <code>Clob</code> returns a null
      * @see java.sql.Clob
      */
     public SerialClob(Clob clob) throws SerialException, SQLException {
@@ -144,19 +145,27 @@
         int read = 0;
         int offset = 0;
 
-        BufferedReader reader;
-        if ( (((reader = new BufferedReader(clob.getCharacterStream())) == null)) &&
-            (clob.getAsciiStream() == null)) {
-            throw new SQLException("Invalid Clob object. Calls to getCharacterStream " +
-                "and getAsciiStream return null which cannot be serialized.");
-        }
+        try (Reader charStream = clob.getCharacterStream()) {
+            if (charStream == null) {
+                throw new SQLException("Invalid Clob object. The call to getCharacterStream " +
+                    "returned null which cannot be serialized.");
+            }
 
-        try {
-            do {
-                read = reader.read(buf, offset, (int)(len - offset));
-                offset += read;
-            } while (read > 0);
+            // Note: get an ASCII stream in order to null-check it,
+            // even though we don't do anything with it.
+            try (InputStream asciiStream = clob.getAsciiStream()) {
+                if (asciiStream == null) {
+                    throw new SQLException("Invalid Clob object. The call to getAsciiStream " +
+                        "returned null which cannot be serialized.");
+                }
+            }
 
+            try (Reader reader = new BufferedReader(charStream)) {
+                do {
+                    read = reader.read(buf, offset, (int)(len - offset));
+                    offset += read;
+                } while (read > 0);
+            }
         } catch (java.io.IOException ex) {
             throw new SerialException("SerialClob: " + ex.getMessage());
         }
@@ -207,13 +216,13 @@
      *     used to create this <code>SerialClob</code> object
      */
     public java.io.InputStream getAsciiStream() throws SerialException, SQLException {
-       if (this.clob != null) {
-             return this.clob.getAsciiStream();
-         } else {
-             throw new SerialException("Unsupported operation. SerialClob cannot " +
+        if (this.clob != null) {
+            return this.clob.getAsciiStream();
+        } else {
+            throw new SerialException("Unsupported operation. SerialClob cannot " +
                 "return a the CLOB value as an ascii stream, unless instantiated " +
                 "with a fully implemented Clob object.");
-         }
+        }
     }
 
     /**
--- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java	Mon Mar 07 11:37:54 2011 -0800
@@ -32,6 +32,7 @@
 import javax.sql.*;
 
 import java.io.FileInputStream;
+import java.io.InputStream;
 import java.io.IOException;
 import java.io.FileNotFoundException;
 
@@ -366,7 +367,9 @@
                     // Load user's implementation of SyncProvider
                     // here. -Drowset.properties=/abc/def/pqr.txt
                     ROWSET_PROPERTIES = strRowsetProperties;
-                    properties.load(new FileInputStream(ROWSET_PROPERTIES));
+                    try (FileInputStream fis = new FileInputStream(ROWSET_PROPERTIES)) {
+                        properties.load(fis);
+                    }
                     parseProperties(properties);
                 }
 
@@ -376,12 +379,19 @@
                 ROWSET_PROPERTIES = "javax" + strFileSep + "sql" +
                         strFileSep + "rowset" + strFileSep +
                         "rowset.properties";
-                // properties.load(
-                //                ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES));
 
                 ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
-                properties.load(cl.getResourceAsStream(ROWSET_PROPERTIES));
+                try (InputStream stream =
+                         (cl == null) ? ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)
+                                      : cl.getResourceAsStream(ROWSET_PROPERTIES)) {
+                    if (stream == null) {
+                        throw new SyncFactoryException(
+                            "Resource " + ROWSET_PROPERTIES + " not found");
+                    }
+                    properties.load(stream);
+                }
+
                 parseProperties(properties);
 
             // removed else, has properties should sum together
--- a/jdk/src/share/classes/javax/swing/JComponent.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/JComponent.java	Mon Mar 07 11:37:54 2011 -0800
@@ -4910,14 +4910,17 @@
      * Returns {@code true} if a paint triggered on a child component should cause
      * painting to originate from this Component, or one of its ancestors.
      * <p/>
-     * Calling {@link JComponent#repaint} on a Swing component will be delegated to
-     * the first ancestor which {@code isPaintingOrigin()} returns {@code true},
-     * if there are any.
+     * Calling {@link #repaint} or {@link #paintImmediately(int, int, int, int)}
+     * on a Swing component will result in calling
+     * the {@link JComponent#paintImmediately(int, int, int, int)} method of
+     * the first ancestor which {@code isPaintingOrigin()} returns {@code true}, if there are any.
      * <p/>
-     * {@code JComponent} subclasses that need to be repainted when any of their
+     * {@code JComponent} subclasses that need to be painted when any of their
      * children are repainted should override this method to return {@code true}.
      *
      * @return always returns {@code false}
+     *
+     * @see #paintImmediately(int, int, int, int)
      */
     protected boolean isPaintingOrigin() {
         return false;
@@ -4932,12 +4935,16 @@
      * and can collapse redundant requests into a single paint call.
      * This method is useful if one needs to update the display while
      * the current event is being dispatched.
+     * <p>
+     * This method is to be overridden when the dirty region needs to be changed
+     * for components that are painting origins.
      *
      * @param x  the x value of the region to be painted
      * @param y  the y value of the region to be painted
      * @param w  the width of the region to be painted
      * @param h  the height of the region to be painted
      * @see #repaint
+     * @see #isPaintingOrigin()
      */
     public void paintImmediately(int x,int y,int w, int h) {
         Component c = this;
@@ -4946,6 +4953,15 @@
         if(!isShowing()) {
             return;
         }
+
+        JComponent paintingOigin = SwingUtilities.getPaintingOrigin(this);
+        if (paintingOigin != null) {
+            Rectangle rectangle = SwingUtilities.convertRectangle(
+                    c, new Rectangle(x, y, w, h), paintingOigin);
+            paintingOigin.paintImmediately(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+            return;
+        }
+
         while(!c.isOpaque()) {
             parent = c.getParent();
             if(parent != null) {
--- a/jdk/src/share/classes/javax/swing/JLayer.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/JLayer.java	Mon Mar 07 11:37:54 2011 -0800
@@ -156,8 +156,9 @@
     // when layerUI is serializable
     private LayerUI<? super V> layerUI;
     private JPanel glassPane;
-    private boolean isPainting;
     private long eventMask;
+    private transient boolean isPainting;
+    private transient boolean isPaintingImmediately;
 
     private static final LayerEventController eventController =
             new LayerEventController();
@@ -393,17 +394,25 @@
     }
 
     /**
-     * Delegates repainting to {@link javax.swing.plaf.LayerUI#repaint} method.
+     * Delegates its functionality to the
+     * {@link javax.swing.plaf.LayerUI#paintImmediately(int, int, int, int, JLayer)} method,
+     * if {@code LayerUI} is set.
      *
-     * @param tm  this parameter is not used
-     * @param x  the x value of the dirty region
-     * @param y  the y value of the dirty region
-     * @param width  the width of the dirty region
-     * @param height  the height of the dirty region
+     * @param x  the x value of the region to be painted
+     * @param y  the y value of the region to be painted
+     * @param w  the width of the region to be painted
+     * @param h  the height of the region to be painted
      */
-    public void repaint(long tm, int x, int y, int width, int height) {
-        if (getUI() != null) {
-            getUI().repaint(tm, x, y, width, height, this);
+    public void paintImmediately(int x, int y, int w, int h) {
+        if (!isPaintingImmediately && getUI() != null) {
+            isPaintingImmediately = true;
+            try {
+                getUI().paintImmediately(x, y, w, h, this);
+            } finally {
+                isPaintingImmediately = false;
+            }
+        } else {
+            super.paintImmediately(x, y, w, h);
         }
     }
 
@@ -415,8 +424,11 @@
     public void paint(Graphics g) {
         if (!isPainting) {
             isPainting = true;
-            super.paintComponent(g);
-            isPainting = false;
+            try {
+                super.paintComponent(g);
+            } finally {
+                isPainting = false;
+            }
         } else {
             super.paint(g);
         }
--- a/jdk/src/share/classes/javax/swing/LookAndFeel.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/LookAndFeel.java	Mon Mar 07 11:37:54 2011 -0800
@@ -332,12 +332,13 @@
     {
         JTextComponent.KeyBinding[] rv = new JTextComponent.KeyBinding[keyBindingList.length / 2];
 
-        for(int i = 0; i < keyBindingList.length; i += 2) {
-            KeyStroke keystroke = (keyBindingList[i] instanceof KeyStroke)
-                ? (KeyStroke)keyBindingList[i]
-                : KeyStroke.getKeyStroke((String)keyBindingList[i]);
-            String action = (String)keyBindingList[i+1];
-            rv[i / 2] = new JTextComponent.KeyBinding(keystroke, action);
+        for(int i = 0; i < rv.length; i ++) {
+            Object o = keyBindingList[2 * i];
+            KeyStroke keystroke = (o instanceof KeyStroke)
+                ? (KeyStroke) o
+                : KeyStroke.getKeyStroke((String) o);
+            String action = (String) keyBindingList[2 * i + 1];
+            rv[i] = new JTextComponent.KeyBinding(keystroke, action);
         }
 
         return rv;
--- a/jdk/src/share/classes/javax/swing/RepaintManager.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/RepaintManager.java	Mon Mar 07 11:37:54 2011 -0800
@@ -438,7 +438,6 @@
      * @param y Y coordinate of the region to repaint
      * @param w Width of the region to repaint
      * @param h Height of the region to repaint
-     * @see JComponent#isPaintingOrigin()
      * @see JComponent#repaint
      */
     public void addDirtyRegion(JComponent c, int x, int y, int w, int h)
@@ -448,16 +447,6 @@
             delegate.addDirtyRegion(c, x, y, w, h);
             return;
         }
-        Container p = c;
-        while ((p = p.getParent()) instanceof JComponent) {
-            JComponent jp = (JComponent) p;
-            if (jp.isPaintingOrigin()) {
-                Rectangle rectangle = SwingUtilities.convertRectangle(
-                        c, new Rectangle(x, y, w, h), jp);
-                jp.repaint(0, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
-                return;
-            }
-        }
         addDirtyRegion0(c, x, y, w, h);
     }
 
--- a/jdk/src/share/classes/javax/swing/SwingUtilities.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/SwingUtilities.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1532,6 +1532,17 @@
         return applet;
     }
 
+    static JComponent getPaintingOrigin(JComponent c) {
+        Container p = c;
+        while ((p = p.getParent()) instanceof JComponent) {
+            JComponent jp = (JComponent) p;
+            if (jp.isPaintingOrigin()) {
+                return jp;
+            }
+        }
+        return null;
+    }
+
     /**
      * Process the key bindings for the <code>Component</code> associated with
      * <code>event</code>. This method is only useful if
--- a/jdk/src/share/classes/javax/swing/plaf/LayerUI.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/plaf/LayerUI.java	Mon Mar 07 11:37:54 2011 -0800
@@ -703,21 +703,19 @@
     }
 
     /**
-     * Adds the specified region to the dirty region list if the component
-     * is showing.  The component will be repainted after all of the
-     * currently pending events have been dispatched.
+     * Paints the specified region in the {@code JLayer} this {@code LayerUI} is set to, immediately.
      * <p/>
      * This method is to be overridden when the dirty region needs to be changed.
+     * The default implementation delegates its functionality to {@link JComponent#paintImmediately(int, int, int, int)}.
      *
-     * @param tm  this parameter is not used
-     * @param x  the x value of the dirty region
-     * @param y  the y value of the dirty region
-     * @param width  the width of the dirty region
-     * @param height  the height of the dirty region
-     * @see java.awt.Component#isShowing
-     * @see RepaintManager#addDirtyRegion
+     * @param x  the x value of the region to be painted
+     * @param y  the y value of the region to be painted
+     * @param w  the width of the region to be painted
+     * @param h  the height of the region to be painted
+     *
+     * @see JComponent#paintImmediately(int, int, int, int)
      */
-    public void repaint(long tm, int x, int y, int width, int height, JLayer<? extends V> l) {
-        RepaintManager.currentManager(l).addDirtyRegion(l, x, y, width, height);
+    public void paintImmediately(int x, int y, int width, int height, JLayer<? extends V> l) {
+        l.paintImmediately(x, y, width, height);
     }
 }
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1965,18 +1965,18 @@
     }
 
     /** Returns the preferred size to properly display the tree,
-      * this is a cover method for getPreferredSize(c, false).
+      * this is a cover method for getPreferredSize(c, true).
       */
     public Dimension getPreferredSize(JComponent c) {
         return getPreferredSize(c, true);
     }
 
     /** Returns the preferred size to represent the tree in
-      * <I>c</I>.  If <I>checkConsistancy</I> is true
-      * <b>checkConsistancy</b> is messaged first.
+      * <I>c</I>.  If <I>checkConsistency</I> is true
+      * <b>checkConsistency</b> is messaged first.
       */
     public Dimension getPreferredSize(JComponent c,
-                                      boolean checkConsistancy) {
+                                      boolean checkConsistency) {
         Dimension       pSize = this.getPreferredMinSize();
 
         if(!validCachedPreferredSize)
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java	Mon Mar 07 11:37:54 2011 -0800
@@ -510,7 +510,6 @@
         Font holdf = g.getFont();
         Color holdc = g.getColor();
 
-        paintBackground(g, lh);
         paintCheckIcon(g, lh, lr);
         paintIcon(g, lh, lr);
         paintText(g, lh, lr);
--- a/jdk/src/share/classes/sun/awt/image/ImageFetcher.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/image/ImageFetcher.java	Mon Mar 07 11:37:54 2011 -0800
@@ -61,8 +61,10 @@
     /**
       * Adds an ImageFetchable to the queue of items to fetch.  Instantiates
       * a new ImageFetcher if it's reasonable to do so.
+      * If there is no available fetcher to process an ImageFetchable, then
+      * reports failure to caller.
       */
-    public static void add(ImageFetchable src) {
+    public static boolean add(ImageFetchable src) {
         final FetcherInfo info = FetcherInfo.getFetcherInfo();
         synchronized(info.waitList) {
             if (!info.waitList.contains(src)) {
@@ -71,9 +73,23 @@
                             info.numFetchers < info.fetchers.length) {
                     createFetchers(info);
                 }
-                info.waitList.notify();
+                /* Creation of new fetcher may fail due to high vm load
+                 * or some other reason.
+                 * If there is already exist, but busy, fetcher, we leave
+                 * the src in queue (it will be handled by existing
+                 * fetcher later).
+                 * Otherwise, we report failure: there is no fetcher
+                 * to handle the src.
+                 */
+                if (info.numFetchers > 0) {
+                    info.waitList.notify();
+                } else {
+                    info.waitList.removeElement(src);
+                    return false;
+                }
             }
         }
+        return true;
     }
 
     /**
@@ -291,11 +307,15 @@
          public Object run() {
              for (int i = 0; i < info.fetchers.length; i++) {
                if (info.fetchers[i] == null) {
-                   info.fetchers[i] = new ImageFetcher(
+                   ImageFetcher f = new ImageFetcher(
                            fetcherGroup, i);
-                   info.fetchers[i].start();
-                   info.numFetchers++;
-                   break;
+                   try {
+                       f.start();
+                       info.fetchers[i] = f;
+                       info.numFetchers++;
+                       break;
+                   } catch (Error e) {
+                   }
                }
              }
           return null;
--- a/jdk/src/share/classes/sun/awt/image/InputStreamImageSource.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/image/InputStreamImageSource.java	Mon Mar 07 11:37:54 2011 -0800
@@ -164,8 +164,13 @@
 
     private synchronized void startProduction() {
         if (!awaitingFetch) {
-            ImageFetcher.add(this);
-            awaitingFetch = true;
+            if (ImageFetcher.add(this)) {
+                awaitingFetch = true;
+            } else {
+                ImageConsumerQueue cq = consumers;
+                consumers = null;
+                errorAllConsumers(cq, false);
+            }
         }
     }
 
--- a/jdk/src/share/classes/sun/dyn/AdapterMethodHandle.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/AdapterMethodHandle.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -478,37 +478,60 @@
         return new AdapterMethodHandle(target, newType, makeConv(raw ? OP_RETYPE_RAW : OP_RETYPE_ONLY));
     }
 
-    static MethodHandle makeTypeHandler(Access token,
-                MethodHandle target, MethodHandle typeHandler) {
+    static MethodHandle makeVarargsCollector(Access token,
+                MethodHandle target, Class<?> arrayType) {
         Access.check(token);
-        return new WithTypeHandler(target, typeHandler);
+        return new AsVarargsCollector(target, arrayType);
     }
 
-    static class WithTypeHandler extends AdapterMethodHandle {
-        final MethodHandle target, typeHandler;
-        WithTypeHandler(MethodHandle target, MethodHandle typeHandler) {
+    static class AsVarargsCollector extends AdapterMethodHandle {
+        final MethodHandle target;
+        final Class<?> arrayType;
+        MethodHandle cache;
+
+        AsVarargsCollector(MethodHandle target, Class<?> arrayType) {
             super(target, target.type(), makeConv(OP_RETYPE_ONLY));
             this.target = target;
-            this.typeHandler = typeHandler.asType(TYPE_HANDLER_TYPE);
+            this.arrayType = arrayType;
+            this.cache = target.asCollector(arrayType, 0);
+        }
+
+        @Override
+        public boolean isVarargsCollector() {
+            return true;
         }
 
+        @Override
         public MethodHandle asType(MethodType newType) {
-            if (this.type() == newType)
-                return this;
+            MethodType type = this.type();
+            int collectArg = type.parameterCount() - 1;
+            int newArity = newType.parameterCount();
+            if (newArity == collectArg+1 &&
+                type.parameterType(collectArg).isAssignableFrom(newType.parameterType(collectArg))) {
+                // if arity and trailing parameter are compatible, do normal thing
+                return super.asType(newType);
+            }
+            // check cache
+            if (cache.type().parameterCount() == newArity)
+                return cache.asType(newType);
+            // build and cache a collector
+            int arrayLength = newArity - collectArg;
+            MethodHandle collector;
             try {
-                MethodHandle retyped = (MethodHandle) typeHandler.invokeExact(target, newType);
-                // Contract:  Must return the desired type, or throw WMT
-                if (retyped.type() != newType)
-                    throw new WrongMethodTypeException(retyped.toString());
-                return retyped;
-            } catch (Throwable ex) {
-                if (ex instanceof Error)  throw (Error)ex;
-                if (ex instanceof RuntimeException)  throw (RuntimeException)ex;
-                throw new RuntimeException(ex);
+                collector = target.asCollector(arrayType, arrayLength);
+            } catch (IllegalArgumentException ex) {
+                throw new WrongMethodTypeException("cannot build collector");
             }
+            cache = collector;
+            return collector.asType(newType);
         }
-        private static final MethodType TYPE_HANDLER_TYPE
-            = MethodType.methodType(MethodHandle.class, MethodHandle.class, MethodType.class);
+
+        public MethodHandle asVarargsCollector(Class<?> arrayType) {
+            MethodType type = this.type();
+            if (type.parameterType(type.parameterCount()-1) == arrayType)
+                return this;
+            return super.asVarargsCollector(arrayType);
+        }
     }
 
     /** Can a checkcast adapter validly convert the target to newType?
@@ -939,7 +962,7 @@
 
     @Override
     public String toString() {
-        return nonAdapter((MethodHandle)vmtarget).toString();
+        return MethodHandleImpl.getNameString(IMPL_TOKEN, nonAdapter((MethodHandle)vmtarget), this);
     }
 
     private static MethodHandle nonAdapter(MethodHandle mh) {
--- a/jdk/src/share/classes/sun/dyn/CallSiteImpl.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/CallSiteImpl.java	Mon Mar 07 11:37:54 2011 -0800
@@ -37,17 +37,17 @@
     static CallSite makeSite(MethodHandle bootstrapMethod,
                              // Callee information:
                              String name, MethodType type,
-                             // Call-site attributes, if any:
+                             // Extra arguments for BSM, if any:
                              Object info,
                              // Caller information:
                              MemberName callerMethod, int callerBCI) {
         Class<?> callerClass = callerMethod.getDeclaringClass();
         Object caller;
-        if (bootstrapMethod.type().parameterType(0) == Class.class)
+        if (bootstrapMethod.type().parameterType(0) == Class.class && TRANSITIONAL_BEFORE_PFD)
             caller = callerClass;  // remove for PFD
         else
             caller = MethodHandleImpl.IMPL_LOOKUP.in(callerClass);
-        if (bootstrapMethod == null) {
+        if (bootstrapMethod == null && TRANSITIONAL_BEFORE_PFD) {
             // If there is no bootstrap method, throw IncompatibleClassChangeError.
             // This is a valid generic error type for resolution (JLS 12.3.3).
             throw new IncompatibleClassChangeError
@@ -56,30 +56,35 @@
         CallSite site;
         try {
             Object binding;
+            info = maybeReBox(info);
             if (info == null) {
-                if (false)  // switch when invokeGeneric works
-                    binding = bootstrapMethod.invokeGeneric(caller, name, type);
-                else
-                    binding = bootstrapMethod.invokeVarargs(new Object[]{ caller, name, type });
+                binding = bootstrapMethod.invokeGeneric(caller, name, type);
+            } else if (!info.getClass().isArray()) {
+                binding = bootstrapMethod.invokeGeneric(caller, name, type, info);
             } else {
-                info = maybeReBox(info);
-                if (false)  // switch when invokeGeneric works
-                    binding = bootstrapMethod.invokeGeneric(caller, name, type, info);
+                Object[] argv = (Object[]) info;
+                if (3 + argv.length > 255)
+                    new InvokeDynamicBootstrapError("too many bootstrap method arguments");
+                MethodType bsmType = bootstrapMethod.type();
+                if (bsmType.parameterCount() == 4 && bsmType.parameterType(3) == Object[].class)
+                    binding = bootstrapMethod.invokeGeneric(caller, name, type, argv);
                 else
-                    binding = bootstrapMethod.invokeVarargs(new Object[]{ caller, name, type, info });
+                    binding = MethodHandles.spreadInvoker(bsmType, 3)
+                        .invokeGeneric(bootstrapMethod, caller, name, type, argv);
             }
             //System.out.println("BSM for "+name+type+" => "+binding);
             if (binding instanceof CallSite) {
                 site = (CallSite) binding;
-            } else if (binding instanceof MethodHandle) {
+            } else if (binding instanceof MethodHandle && TRANSITIONAL_BEFORE_PFD) {
                 // Transitional!
                 MethodHandle target = (MethodHandle) binding;
                 site = new ConstantCallSite(target);
             } else {
-                throw new ClassCastException("bootstrap method failed to produce a MethodHandle or CallSite");
+                throw new ClassCastException("bootstrap method failed to produce a CallSite");
             }
-            PRIVATE_INITIALIZE_CALL_SITE.invokeExact(site, name, type,
-                                                     callerMethod, callerBCI);
+            if (TRANSITIONAL_BEFORE_PFD)
+                PRIVATE_INITIALIZE_CALL_SITE.invokeExact(site, name, type,
+                                                         callerMethod, callerBCI);
             assert(site.getTarget() != null);
             assert(site.getTarget().type().equals(type));
         } catch (Throwable ex) {
@@ -93,6 +98,8 @@
         return site;
     }
 
+    private static boolean TRANSITIONAL_BEFORE_PFD = true;  // FIXME: remove for PFD
+
     private static Object maybeReBox(Object x) {
         if (x instanceof Integer) {
             int xi = (int) x;
@@ -117,11 +124,12 @@
     static {
         try {
             PRIVATE_INITIALIZE_CALL_SITE =
+            !TRANSITIONAL_BEFORE_PFD ? null :
             MethodHandleImpl.IMPL_LOOKUP.findVirtual(CallSite.class, "initializeFromJVM",
                 MethodType.methodType(void.class,
                                       String.class, MethodType.class,
                                       MemberName.class, int.class));
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             throw uncaughtException(ex);
         }
     }
--- a/jdk/src/share/classes/sun/dyn/FilterGeneric.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/FilterGeneric.java	Mon Mar 07 11:37:54 2011 -0800
@@ -187,7 +187,7 @@
             MethodHandle entryPoint = null;
             try {
                 entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
             }
             if (entryPoint == null)  continue;
             Constructor<? extends Adapter> ctor = null;
--- a/jdk/src/share/classes/sun/dyn/FilterOneArgument.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/FilterOneArgument.java	Mon Mar 07 11:37:54 2011 -0800
@@ -56,7 +56,7 @@
             INVOKE =
                 MethodHandleImpl.IMPL_LOOKUP.findVirtual(FilterOneArgument.class, "invoke",
                                                          MethodType.genericMethodType(1));
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             throw uncaughtException(ex);
         }
     }
--- a/jdk/src/share/classes/sun/dyn/FromGeneric.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/FromGeneric.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -28,6 +28,7 @@
 import java.dyn.*;
 import java.lang.reflect.*;
 import sun.dyn.util.*;
+import static sun.dyn.MethodTypeImpl.invokers;
 
 /**
  * Adapters which mediate between incoming calls which are generic
@@ -128,7 +129,7 @@
             MethodType targetType, MethodType internalType) {
         // All the adapters we have here have reference-untyped internal calls.
         assert(internalType == internalType.erase());
-        MethodHandle invoker = MethodHandles.exactInvoker(targetType);
+        MethodHandle invoker = invokers(targetType).exactInvoker();
         // cast all narrow reference types, unbox all primitive arguments:
         MethodType fixArgsType = internalType.changeReturnType(targetType.returnType());
         MethodHandle fixArgs = AdapterMethodHandle.convertArguments(Access.TOKEN,
@@ -203,7 +204,7 @@
             MethodHandle entryPoint = null;
             try {
                 entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
             }
             if (entryPoint == null)  continue;
             Constructor<? extends Adapter> ctor = null;
--- a/jdk/src/share/classes/sun/dyn/InvokeGeneric.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/InvokeGeneric.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -28,6 +28,7 @@
 import java.dyn.*;
 import java.lang.reflect.*;
 import sun.dyn.util.*;
+import static sun.dyn.MethodTypeImpl.invokers;
 
 /**
  * Adapters which manage MethodHanndle.invokeGeneric calls.
@@ -43,7 +44,7 @@
     /** Compute and cache information for this adapter, so that it can
      *  call out to targets of the erasure-family of the given erased type.
      */
-    private InvokeGeneric(MethodType erasedCallerType) throws NoAccessException {
+    private InvokeGeneric(MethodType erasedCallerType) throws ReflectiveOperationException {
         this.erasedCallerType = erasedCallerType;
         this.initialInvoker = makeInitialInvoker();
         assert initialInvoker.type().equals(erasedCallerType
@@ -63,14 +64,14 @@
             try {
                 InvokeGeneric gen = new InvokeGeneric(form.erasedType());
                 form.genericInvoker = genericInvoker = gen.initialInvoker;
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 throw new RuntimeException(ex);
             }
         }
         return genericInvoker;
     }
 
-    private MethodHandle makeInitialInvoker() throws NoAccessException {
+    private MethodHandle makeInitialInvoker() throws ReflectiveOperationException {
         // postDispatch = #(MH'; MT, MH; A...){MH'(MT, MH; A)}
         MethodHandle postDispatch = makePostDispatchInvoker();
         MethodHandle invoker;
@@ -87,14 +88,14 @@
     private MethodHandle makePostDispatchInvoker() {
         // Take (MH'; MT, MH; A...) and run MH'(MT, MH; A...).
         MethodType invokerType = erasedCallerType.insertParameterTypes(0, EXTRA_ARGS);
-        return MethodHandles.exactInvoker(invokerType);
+        return invokers(invokerType).exactInvoker();
     }
     private MethodHandle dropDispatchArguments(MethodHandle targetInvoker) {
         assert(targetInvoker.type().parameterType(0) == MethodHandle.class);
         return MethodHandles.dropArguments(targetInvoker, 1, EXTRA_ARGS);
     }
 
-    private MethodHandle dispatcher(String dispatchName) throws NoAccessException {
+    private MethodHandle dispatcher(String dispatchName) throws ReflectiveOperationException {
         return lookup().bind(this, dispatchName,
                              MethodType.methodType(MethodHandle.class,
                                                    MethodType.class, MethodHandle.class));
@@ -108,7 +109,7 @@
      */
     private MethodHandle dispatch(MethodType callerType, MethodHandle target) {
         MethodType targetType = target.type();
-        if (USE_AS_TYPE_PATH || target instanceof AdapterMethodHandle.WithTypeHandler) {
+        if (USE_AS_TYPE_PATH || target.isVarargsCollector()) {
             MethodHandle newTarget = target.asType(callerType);
             targetType = callerType;
             Invokers invokers = MethodTypeImpl.invokers(Access.TOKEN, targetType);
--- a/jdk/src/share/classes/sun/dyn/Invokers.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/Invokers.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -47,7 +47,7 @@
     private /*lazy*/ MethodHandle genericInvoker;
 
     // generic (untyped) invoker for the outgoing call; accepts a single Object[]
-    private final /*lazy*/ MethodHandle[] varargsInvokers;
+    private final /*lazy*/ MethodHandle[] spreadInvokers;
 
     // invoker for an unbound callsite
     private /*lazy*/ MethodHandle uninitializedCallSite;
@@ -55,10 +55,9 @@
     /** Compute and cache information common to all collecting adapters
      *  that implement members of the erasure-family of the given erased type.
      */
-    public Invokers(Access token, MethodType targetType) {
-        Access.check(token);
+    /*non-public*/ Invokers(MethodType targetType) {
         this.targetType = targetType;
-        this.varargsInvokers = new MethodHandle[targetType.parameterCount()+1];
+        this.spreadInvokers = new MethodHandle[targetType.parameterCount()+1];
     }
 
     public static MethodType invokerType(MethodType targetType) {
@@ -69,8 +68,8 @@
         MethodHandle invoker = exactInvoker;
         if (invoker != null)  return invoker;
         try {
-            invoker = MethodHandleImpl.IMPL_LOOKUP.findVirtual(MethodHandle.class, "invoke", targetType);
-        } catch (NoAccessException ex) {
+            invoker = MethodHandleImpl.IMPL_LOOKUP.findVirtual(MethodHandle.class, "invokeExact", targetType);
+        } catch (ReflectiveOperationException ex) {
             throw new InternalError("JVM cannot find invoker for "+targetType);
         }
         assert(invokerType(targetType) == invoker.type());
@@ -101,13 +100,12 @@
         return invoker;
     }
 
-    public MethodHandle varargsInvoker(int objectArgCount) {
-        MethodHandle vaInvoker = varargsInvokers[objectArgCount];
+    public MethodHandle spreadInvoker(int objectArgCount) {
+        MethodHandle vaInvoker = spreadInvokers[objectArgCount];
         if (vaInvoker != null)  return vaInvoker;
         MethodHandle gInvoker = genericInvoker();
-        MethodType vaType = MethodType.genericMethodType(objectArgCount, true);
-        vaInvoker = MethodHandles.spreadArguments(gInvoker, invokerType(vaType));
-        varargsInvokers[objectArgCount] = vaInvoker;
+        vaInvoker = gInvoker.asSpreader(Object[].class, targetType.parameterCount() - objectArgCount);
+        spreadInvokers[objectArgCount] = vaInvoker;
         return vaInvoker;
     }
 
@@ -118,7 +116,7 @@
         if (invoker != null)  return invoker;
         if (targetType.parameterCount() > 0) {
             MethodType type0 = targetType.dropParameterTypes(0, targetType.parameterCount());
-            Invokers invokers0 = MethodTypeImpl.invokers(Access.TOKEN, type0);
+            Invokers invokers0 = MethodTypeImpl.invokers(type0);
             invoker = MethodHandles.dropArguments(invokers0.uninitializedCallSite(),
                                                   0, targetType.parameterList());
             assert(invoker.type().equals(targetType));
@@ -130,7 +128,7 @@
                 THROW_UCS = MethodHandleImpl.IMPL_LOOKUP
                     .findStatic(CallSite.class, "uninitializedCallSite",
                                 MethodType.methodType(Empty.class));
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 throw new RuntimeException(ex);
             }
         }
--- a/jdk/src/share/classes/sun/dyn/MemberName.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/MemberName.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -451,8 +451,6 @@
             return type.toString();  // class java.lang.String
         // else it is a field, method, or constructor
         StringBuilder buf = new StringBuilder();
-        if (!isResolved())
-            buf.append("*.");
         if (getDeclaringClass() != null) {
             buf.append(getName(clazz));
             buf.append('.');
@@ -512,14 +510,24 @@
     public static RuntimeException newIllegalArgumentException(String message) {
         return new IllegalArgumentException(message);
     }
-    public static NoAccessException newNoAccessException(MemberName name, Class<?> lookupClass) {
-        return newNoAccessException("cannot access", name, lookupClass);
+    public static IllegalAccessException newNoAccessException(MemberName name, Object from) {
+        return newNoAccessException("cannot access", name, from);
+    }
+    public static IllegalAccessException newNoAccessException(String message,
+            MemberName name, Object from) {
+        message += ": " + name;
+        if (from != null)  message += ", from " + from;
+        return new IllegalAccessException(message);
     }
-    public static NoAccessException newNoAccessException(String message,
-            MemberName name, Class<?> lookupClass) {
-        message += ": " + name;
-        if (lookupClass != null)  message += ", from " + lookupClass.getName();
-        return new NoAccessException(message);
+    public static ReflectiveOperationException newNoAccessException(MemberName name) {
+        if (name.isResolved())
+            return new IllegalAccessException(name.toString());
+        else if (name.isConstructor())
+            return new NoSuchMethodException(name.toString());
+        else if (name.isMethod())
+            return new NoSuchMethodException(name.toString());
+        else
+            return new NoSuchFieldException(name.toString());
     }
     public static Error uncaughtException(Exception ex) {
         Error err = new InternalError("uncaught exception");
@@ -643,14 +651,20 @@
         /** Produce a resolved version of the given member.
          *  Super types are searched (for inherited members) if {@code searchSupers} is true.
          *  Access checking is performed on behalf of the given {@code lookupClass}.
-         *  If lookup fails or access is not permitted, a {@linkplain NoAccessException} is thrown.
+         *  If lookup fails or access is not permitted, a {@linkplain ReflectiveOperationException} is thrown.
          *  Otherwise a fresh copy of the given member is returned, with modifier bits filled in.
          */
-        public MemberName resolveOrFail(MemberName m, boolean searchSupers, Class<?> lookupClass) throws NoAccessException {
+        public
+        <NoSuchMemberException extends ReflectiveOperationException>
+        MemberName resolveOrFail(MemberName m, boolean searchSupers, Class<?> lookupClass,
+                                 Class<NoSuchMemberException> nsmClass)
+                throws IllegalAccessException, NoSuchMemberException {
             MemberName result = resolveOrNull(m, searchSupers, lookupClass);
             if (result != null)
                 return result;
-            throw newNoAccessException(m, lookupClass);
+            ReflectiveOperationException ex = newNoAccessException(m);
+            if (ex instanceof IllegalAccessException)  throw (IllegalAccessException) ex;
+            throw nsmClass.cast(ex);
         }
         /** Return a list of all methods defined by the given class.
          *  Super types are searched (for inherited members) if {@code searchSupers} is true.
--- a/jdk/src/share/classes/sun/dyn/MethodHandleImpl.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/MethodHandleImpl.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -30,7 +30,6 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import sun.dyn.util.VerifyType;
-import java.dyn.NoAccessException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -136,6 +135,8 @@
     }
 
     static {
+        if (!MethodHandleNatives.JVM_SUPPORT)  // force init of native API
+            throw new InternalError("No JVM support for JSR 292");
         // Force initialization of Lookup, so it calls us back as initLookup:
         MethodHandles.publicLookup();
         if (IMPL_LOOKUP_INIT == null)
@@ -167,11 +168,11 @@
      * @param doDispatch whether the method handle will test the receiver type
      * @param lookupClass access-check relative to this class
      * @return a direct handle to the matching method
-     * @throws NoAccessException if the given method cannot be accessed by the lookup class
+     * @throws IllegalAccessException if the given method cannot be accessed by the lookup class
      */
     public static
     MethodHandle findMethod(Access token, MemberName method,
-            boolean doDispatch, Class<?> lookupClass) throws NoAccessException {
+                            boolean doDispatch, Class<?> lookupClass) throws IllegalAccessException {
         Access.check(token);  // only trusted calls
         MethodType mtype = method.getMethodType();
         if (!method.isStatic()) {
@@ -184,7 +185,10 @@
         if (!mh.isValid())
             throw newNoAccessException(method, lookupClass);
         assert(mh.type() == mtype);
-        return mh;
+        if (!method.isVarargs())
+            return mh;
+        else
+            return mh.asVarargsCollector(mtype.parameterType(mtype.parameterCount()-1));
     }
 
     public static
@@ -302,7 +306,7 @@
                 MethodHandle invoke = null;
                 try {
                     invoke = lookup.findVirtual(AllocateObject.class, name, MethodType.genericMethodType(nargs));
-                } catch (NoAccessException ex) {
+                } catch (ReflectiveOperationException ex) {
                 }
                 if (invoke == null)  break;
                 invokes.add(invoke);
@@ -317,7 +321,7 @@
         static {
             try {
                 VARARGS_INVOKE = IMPL_LOOKUP.findVirtual(AllocateObject.class, "invoke_V", MethodType.genericMethodType(0, true));
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 throw uncaughtException(ex);
             }
         }
@@ -469,7 +473,7 @@
             MethodHandle mh;
             try {
                 mh = IMPL_LOOKUP.findVirtual(FieldAccessor.class, name, type);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 throw uncaughtException(ex);
             }
             if (evclass != vclass || (!isStatic && ecclass != cclass)) {
@@ -537,7 +541,7 @@
             MethodHandle mh;
             try {
                 mh = IMPL_LOOKUP.findStatic(FieldAccessor.class, name, type);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 throw uncaughtException(ex);
             }
             if (caclass != null) {
@@ -1009,7 +1013,7 @@
                 MethodHandle invoke = null;
                 try {
                     invoke = lookup.findVirtual(GuardWithTest.class, name, MethodType.genericMethodType(nargs));
-                } catch (NoAccessException ex) {
+                } catch (ReflectiveOperationException ex) {
                 }
                 if (invoke == null)  break;
                 invokes.add(invoke);
@@ -1024,7 +1028,7 @@
         static {
             try {
                 VARARGS_INVOKE = IMPL_LOOKUP.findVirtual(GuardWithTest.class, "invoke_V", MethodType.genericMethodType(0, true));
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 throw uncaughtException(ex);
             }
         }
@@ -1145,7 +1149,7 @@
                 MethodHandle invoke = null;
                 try {
                     invoke = lookup.findVirtual(GuardWithCatch.class, name, MethodType.genericMethodType(nargs));
-                } catch (NoAccessException ex) {
+                } catch (ReflectiveOperationException ex) {
                 }
                 if (invoke == null)  break;
                 invokes.add(invoke);
@@ -1160,7 +1164,7 @@
         static {
             try {
                 VARARGS_INVOKE = IMPL_LOOKUP.findVirtual(GuardWithCatch.class, "invoke_V", MethodType.genericMethodType(0, true));
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 throw uncaughtException(ex);
             }
         }
@@ -1207,20 +1211,30 @@
             THROW_EXCEPTION
             = IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "throwException",
                     MethodType.methodType(Empty.class, Throwable.class));
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             throw new RuntimeException(ex);
         }
     }
     static <T extends Throwable> Empty throwException(T t) throws T { throw t; }
 
-    public static String getNameString(Access token, MethodHandle target) {
+    public static String getNameString(Access token, MethodHandle target, Object type) {
         Access.check(token);
+        if (!(type instanceof MethodType)) {
+            if (type == null)
+                type = target.type();
+            else if (type instanceof MethodHandle)
+                type = ((MethodHandle)type).type();
+        }
         MemberName name = null;
         if (target != null)
             name = MethodHandleNatives.getMethodName(target);
         if (name == null)
-            return "invoke" + target.type();
-        return name.getName() + target.type();
+            return "invoke" + type;
+        return name.getName() + type;
+    }
+
+    public static String getNameString(Access token, MethodHandle target) {
+        return getNameString(token, target, null);
     }
 
     static String addTypeString(Object obj, MethodHandle target) {
@@ -1263,8 +1277,8 @@
         return MethodHandleNatives.getBootstrap(callerClass);
     }
 
-    public static MethodHandle withTypeHandler(Access token, MethodHandle target, MethodHandle typeHandler) {
+    public static MethodHandle asVarargsCollector(Access token, MethodHandle target, Class<?> arrayType) {
         Access.check(token);
-        return AdapterMethodHandle.makeTypeHandler(token, target, typeHandler);
+        return AdapterMethodHandle.makeVarargsCollector(token, target, arrayType);
     }
 }
--- a/jdk/src/share/classes/sun/dyn/MethodHandleNatives.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/MethodHandleNatives.java	Mon Mar 07 11:37:54 2011 -0800
@@ -350,7 +350,7 @@
             case REF_invokeInterface:   return lookup.findVirtual(      defc, name, (MethodType) type );
             }
             throw new IllegalArgumentException("bad MethodHandle constant "+name+" : "+type);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             Error err = new IncompatibleClassChangeError();
             err.initCause(ex);
             throw err;
--- a/jdk/src/share/classes/sun/dyn/MethodTypeImpl.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/MethodTypeImpl.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -498,9 +498,12 @@
 
     public static Invokers invokers(Access token, MethodType type) {
         Access.check(token);
+        return invokers(type);
+    }
+    /*non-public*/ static Invokers invokers(MethodType type) {
         Invokers inv = METHOD_TYPE_FRIEND.getInvokers(type);
         if (inv != null)  return inv;
-        inv = new Invokers(token, type);
+        inv = new Invokers(type);
         METHOD_TYPE_FRIEND.setInvokers(type, inv);
         return inv;
     }
--- a/jdk/src/share/classes/sun/dyn/SpreadGeneric.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/SpreadGeneric.java	Mon Mar 07 11:37:54 2011 -0800
@@ -167,7 +167,7 @@
             MethodHandle entryPoint = null;
             try {
                 entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
             }
             if (entryPoint == null)  continue;
             Constructor<? extends Adapter> ctor = null;
--- a/jdk/src/share/classes/sun/dyn/ToGeneric.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/ToGeneric.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -31,6 +31,7 @@
 import sun.dyn.util.ValueConversions;
 import sun.dyn.util.Wrapper;
 import static sun.dyn.MemberName.newIllegalArgumentException;
+import static sun.dyn.MethodTypeImpl.invokers;
 
 /**
  * Adapters which mediate between incoming calls which are not generic
@@ -72,7 +73,7 @@
         assert(entryType.erase() == entryType); // for now
         // incoming call will first "forget" all reference types except Object
         this.entryType = entryType;
-        MethodHandle invoker0 = MethodHandles.exactInvoker(entryType.generic());
+        MethodHandle invoker0 = invokers(entryType.generic()).exactInvoker();
         MethodType rawEntryTypeInit;
         Adapter ad = findAdapter(rawEntryTypeInit = entryType);
         if (ad != null) {
@@ -284,7 +285,7 @@
                 try {
                     entryPoint = MethodHandleImpl.IMPL_LOOKUP.
                                     findSpecial(acls, iname, entryPointType, acls);
-                } catch (NoAccessException ex) {
+                } catch (ReflectiveOperationException ex) {
                 }
                 if (entryPoint == null)  continue;
                 Constructor<? extends Adapter> ctor = null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/dyn/WrapperInstance.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.dyn;
+
+import java.dyn.MethodHandle;
+
+/**
+ * Private API used inside of java.dyn.MethodHandles.
+ * Interface implemented by every object which is produced by
+ * {@link java.dyn.MethodHandles#asInstance MethodHandles.asInstance}.
+ * The methods of this interface allow a caller to recover the parameters
+ * to {@code asInstance}.
+ * This allows applications to repeatedly convert between method handles
+ * and SAM objects, without the risk of creating unbounded delegation chains.
+ */
+public interface WrapperInstance {
+    /** Produce or recover a target method handle which is behaviorally
+     *  equivalent to the SAM method of this object.
+     */
+    public MethodHandle getWrapperInstanceTarget();
+    /** Recover the SAM type for which this object was created.
+     */
+    public Class<?> getWrapperInstanceType();
+}
+
--- a/jdk/src/share/classes/sun/dyn/util/ValueConversions.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/util/ValueConversions.java	Mon Mar 07 11:37:54 2011 -0800
@@ -153,7 +153,7 @@
             try {
                 // actually, type is wrong; the Java method takes Object
                 mh = IMPL_LOOKUP.findStatic(ValueConversions.class, name, type.erase());
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 mh = null;
             }
         } else {
@@ -289,7 +289,7 @@
         if (exact) {
             try {
                 mh = IMPL_LOOKUP.findStatic(ValueConversions.class, name, type);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 mh = null;
             }
         } else {
@@ -408,7 +408,7 @@
         if (exact) {
             try {
                 mh = IMPL_LOOKUP.findStatic(ValueConversions.class, name, type);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
                 mh = null;
             }
         } else {
@@ -492,7 +492,7 @@
             case INT: case LONG: case FLOAT: case DOUBLE:
                 try {
                     mh = IMPL_LOOKUP.findStatic(ValueConversions.class, "zero"+wrap.simpleName(), type);
-                } catch (NoAccessException ex) {
+                } catch (ReflectiveOperationException ex) {
                     mh = null;
                 }
                 break;
@@ -654,7 +654,7 @@
             type = type.appendParameterTypes(wrap.primitiveType());
         try {
             mh = IMPL_LOOKUP.findStatic(ValueConversions.class, "identity", type);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             mh = null;
         }
         if (mh == null && wrap == Wrapper.VOID) {
@@ -723,7 +723,7 @@
             MethodHandle array = null;
             try {
                 array = lookup.findStatic(ValueConversions.class, name, type);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
             }
             if (array == null)  break;
             arrays.add(array);
@@ -784,7 +784,7 @@
             MethodHandle array = null;
             try {
                 array = lookup.findStatic(ValueConversions.class, name, type);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
             }
             if (array == null)  break;
             arrays.add(array);
--- a/jdk/src/share/classes/sun/dyn/util/VerifyAccess.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/dyn/util/VerifyAccess.java	Mon Mar 07 11:37:54 2011 -0800
@@ -25,7 +25,6 @@
 
 package sun.dyn.util;
 
-import java.dyn.NoAccessException;
 import java.lang.reflect.Modifier;
 import sun.dyn.MemberName;
 import sun.dyn.MethodHandleImpl;
@@ -139,6 +138,8 @@
      * <li>C is public.
      * <li>C and D are members of the same runtime package.
      * </ul>
+     * @param refc the symbolic reference class to which access is being checked (C)
+     * @param lookupClass the class performing the lookup (D)
      */
     public static boolean isClassAccessible(Class<?> refc, Class<?> lookupClass) {
         int mods = refc.getModifiers();
--- a/jdk/src/share/classes/sun/font/FontUtilities.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/font/FontUtilities.java	Mon Mar 07 11:37:54 2011 -0800
@@ -30,6 +30,8 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
+import java.lang.ref.SoftReference;
+import java.util.concurrent.ConcurrentHashMap;
 import java.security.AccessController;
 
 import java.security.PrivilegedAction;
@@ -383,6 +385,10 @@
      * }
      * return fuir;
      */
+    private static volatile
+        SoftReference<ConcurrentHashMap<PhysicalFont, CompositeFont>>
+        compMapRef = new SoftReference(null);
+
     public static FontUIResource getCompositeFontUIResource(Font font) {
 
         FontUIResource fuir = new FontUIResource(font);
@@ -402,12 +408,22 @@
 
         FontManager fm = FontManagerFactory.getInstance();
         CompositeFont dialog2D =
-          (CompositeFont) fm.findFont2D("dialog", font.getStyle(), FontManager.NO_FALLBACK);
+          (CompositeFont) fm.findFont2D("dialog", font.getStyle(),
+                                        FontManager.NO_FALLBACK);
         if (dialog2D == null) { /* shouldn't happen */
             return fuir;
         }
         PhysicalFont physicalFont = (PhysicalFont)font2D;
-        CompositeFont compFont = new CompositeFont(physicalFont, dialog2D);
+        ConcurrentHashMap<PhysicalFont, CompositeFont> compMap = compMapRef.get();
+        if (compMap == null) { // Its been collected.
+            compMap = new ConcurrentHashMap<PhysicalFont, CompositeFont>();
+            compMapRef = new SoftReference(compMap);
+        }
+        CompositeFont compFont = compMap.get(physicalFont);
+        if (compFont == null) {
+            compFont = new CompositeFont(physicalFont, dialog2D);
+            compMap.put(physicalFont, compFont);
+        }
         FontAccess.getFontAccess().setFont2D(fuir, compFont.handle);
         /* marking this as a created font is needed as only created fonts
          * copy their creator's handles.
--- a/jdk/src/share/classes/sun/misc/JarIndex.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/misc/JarIndex.java	Mon Mar 07 11:37:54 2011 -0800
@@ -106,6 +106,19 @@
     /**
      * Returns the jar index, or <code>null</code> if none.
      *
+     * This single parameter version of the method is retained
+     * for binary compatibility with earlier releases.
+     *
+     * @param jar the JAR file to get the index from.
+     * @exception IOException if an I/O error has occurred.
+     */
+    public static JarIndex getJarIndex(JarFile jar) throws IOException {
+        return getJarIndex(jar, null);
+    }
+
+    /**
+     * Returns the jar index, or <code>null</code> if none.
+     *
      * @param jar the JAR file to get the index from.
      * @exception IOException if an I/O error has occurred.
      */
--- a/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,19 @@
 package sun.misc;
 
 import java.io.IOException;
+import java.net.URL;
+import java.security.CodeSource;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
 public interface JavaUtilJarAccess {
     public boolean jarFileHasClassPathAttribute(JarFile jar) throws IOException;
+    public CodeSource[] getCodeSources(JarFile jar, URL url);
+    public CodeSource getCodeSource(JarFile jar, URL url, String name);
+    public Enumeration<String> entryNames(JarFile jar, CodeSource[] cs);
+    public Enumeration<JarEntry> entries2(JarFile jar);
+    public void setEagerValidation(JarFile jar, boolean eager);
+    public List getManifestDigests(JarFile jar);
 }
--- a/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java	Mon Mar 07 11:37:54 2011 -0800
@@ -27,6 +27,9 @@
 
 import java.io.*;
 import java.net.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
 import java.util.*;
 import java.util.jar.*;
 import java.util.zip.ZipFile;
@@ -208,38 +211,23 @@
             JarFile result = null;
 
             /* get the stream before asserting privileges */
-            final InputStream in =  url.openConnection().getInputStream();
-
-            try {
+            try (final InputStream in = url.openConnection().getInputStream()) {
                 result = AccessController.doPrivileged(
                     new PrivilegedExceptionAction<JarFile>() {
                         public JarFile run() throws IOException {
-                            OutputStream out = null;
-                            File tmpFile = null;
+                            Path tmpFile = Files.createTempFile("jar_cache", null);
                             try {
-                                tmpFile = File.createTempFile("jar_cache", null);
-                                tmpFile.deleteOnExit();
-                                out  = new FileOutputStream(tmpFile);
-                                int read = 0;
-                                byte[] buf = new byte[BUF_SIZE];
-                                while ((read = in.read(buf)) != -1) {
-                                    out.write(buf, 0, read);
+                                Files.copy(in, tmpFile, StandardCopyOption.REPLACE_EXISTING);
+                                JarFile jarFile = new URLJarFile(tmpFile.toFile(), closeController);
+                                tmpFile.toFile().deleteOnExit();
+                                return jarFile;
+                            } catch (Throwable thr) {
+                                try {
+                                    Files.delete(tmpFile);
+                                } catch (IOException ioe) {
+                                    thr.addSuppressed(ioe);
                                 }
-                                out.close();
-                                out = null;
-                                return new URLJarFile(tmpFile, closeController);
-                            } catch (IOException e) {
-                                if (tmpFile != null) {
-                                    tmpFile.delete();
-                                }
-                                throw e;
-                            } finally {
-                                if (in != null) {
-                                    in.close();
-                                }
-                                if (out != null) {
-                                    out.close();
-                                }
+                                throw thr;
                             }
                         }
                     });
--- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java	Mon Mar 07 11:37:54 2011 -0800
@@ -51,6 +51,7 @@
     // File access mode (immutable)
     private final boolean writable;
     private final boolean readable;
+    private final boolean append;
 
     // Required to prevent finalization of creating stream (immutable)
     private final Object parent;
@@ -67,6 +68,7 @@
         this.fd = fd;
         this.readable = readable;
         this.writable = writable;
+        this.append = append;
         this.parent = parent;
         this.nd = new FileDispatcherImpl(append);
     }
@@ -242,7 +244,8 @@
                 if (!isOpen())
                     return 0;
                 do {
-                    p = position0(fd, -1);
+                    // in append-mode then position is advanced to end before writing
+                    p = (append) ? nd.size(fd) : position0(fd, -1);
                 } while ((p == IOStatus.INTERRUPTED) && isOpen());
                 return IOStatus.normalize(p);
             } finally {
--- a/jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java	Mon Mar 07 11:37:54 2011 -0800
@@ -87,6 +87,7 @@
                                 gssLibs = new String[]{
                                     "libgssapi.so",
                                     "libgssapi_krb5.so",
+                                    "libgssapi_krb5.so.2",
                                 };
                             }
                         } else {
--- a/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Mon Mar 07 11:37:54 2011 -0800
@@ -231,13 +231,6 @@
         AdaptableX509CertSelector issuerSelector =
                         new AdaptableX509CertSelector();
 
-        // check trusted certificate's key usage
-        boolean[] usages = trustedCert.getKeyUsage();
-        if (usages != null) {
-            usages[5] = true;    // keyCertSign
-            issuerSelector.setKeyUsage(usages);
-        }
-
         // check trusted certificate's subject
         issuerSelector.setSubject(firstCert.getIssuerX500Principal());
 
--- a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -181,7 +181,8 @@
      *
      *
      */
-    public void process(Hashtable<String, CodeSigner[]> signers)
+    public void process(Hashtable<String, CodeSigner[]> signers,
+            List manifestDigests)
         throws IOException, SignatureException, NoSuchAlgorithmException,
             JarException, CertificateException
     {
@@ -190,14 +191,15 @@
         Object obj = null;
         try {
             obj = Providers.startJarVerification();
-            processImpl(signers);
+            processImpl(signers, manifestDigests);
         } finally {
             Providers.stopJarVerification(obj);
         }
 
     }
 
-    private void processImpl(Hashtable<String, CodeSigner[]> signers)
+    private void processImpl(Hashtable<String, CodeSigner[]> signers,
+            List manifestDigests)
         throws IOException, SignatureException, NoSuchAlgorithmException,
             JarException, CertificateException
     {
@@ -232,7 +234,7 @@
                                 sf.getEntries().entrySet().iterator();
 
         // see if we can verify the whole manifest first
-        boolean manifestSigned = verifyManifestHash(sf, md, decoder);
+        boolean manifestSigned = verifyManifestHash(sf, md, decoder, manifestDigests);
 
         // verify manifest main attributes
         if (!manifestSigned && !verifyManifestMainAttrs(sf, md, decoder)) {
@@ -275,7 +277,8 @@
      */
     private boolean verifyManifestHash(Manifest sf,
                                        ManifestDigester md,
-                                       BASE64Decoder decoder)
+                                       BASE64Decoder decoder,
+                                       List manifestDigests)
          throws IOException
     {
         Attributes mattr = sf.getMainAttributes();
@@ -290,6 +293,8 @@
                 // 16 is length of "-Digest-Manifest"
                 String algorithm = key.substring(0, key.length()-16);
 
+                manifestDigests.add(key);
+                manifestDigests.add(se.getValue());
                 MessageDigest digest = getDigest(algorithm);
                 if (digest != null) {
                     byte[] computedHash = md.manifestDigest(digest);
--- a/jdk/src/share/classes/sun/tools/jps/Jps.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/tools/jps/Jps.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -77,9 +77,52 @@
                 MonitoredVm vm = null;
                 String vmidString = "//" + lvmid + "?mode=r";
 
+                String errorString = null;
+
                 try {
+                    // Note: The VM associated with the current VM id may
+                    // no longer be running so these queries may fail. We
+                    // already added the VM id to the output stream above.
+                    // If one of the queries fails, then we try to add a
+                    // reasonable message to indicate that the requested
+                    // info is not available.
+
+                    errorString = " -- process information unavailable";
                     VmIdentifier id = new VmIdentifier(vmidString);
                     vm = monitoredHost.getMonitoredVm(id, 0);
+
+                    errorString = " -- main class information unavailable";
+                    output.append(" " + MonitoredVmUtil.mainClass(vm,
+                            arguments.showLongPaths()));
+
+                    if (arguments.showMainArgs()) {
+                        errorString = " -- main args information unavailable";
+                        String mainArgs = MonitoredVmUtil.mainArgs(vm);
+                        if (mainArgs != null && mainArgs.length() > 0) {
+                            output.append(" " + mainArgs);
+                        }
+                    }
+                    if (arguments.showVmArgs()) {
+                        errorString = " -- jvm args information unavailable";
+                        String jvmArgs = MonitoredVmUtil.jvmArgs(vm);
+                        if (jvmArgs != null && jvmArgs.length() > 0) {
+                          output.append(" " + jvmArgs);
+                        }
+                    }
+                    if (arguments.showVmFlags()) {
+                        errorString = " -- jvm flags information unavailable";
+                        String jvmFlags = MonitoredVmUtil.jvmFlags(vm);
+                        if (jvmFlags != null && jvmFlags.length() > 0) {
+                            output.append(" " + jvmFlags);
+                        }
+                    }
+
+                    errorString = " -- detach failed";
+                    monitoredHost.detach(vm);
+
+                    System.out.println(output);
+
+                    errorString = null;
                 } catch (URISyntaxException e) {
                     // unexpected as vmidString is based on a validated hostid
                     lastError = e;
@@ -87,7 +130,7 @@
                 } catch (Exception e) {
                     lastError = e;
                 } finally {
-                    if (vm == null) {
+                    if (errorString != null) {
                         /*
                          * we ignore most exceptions, as there are race
                          * conditions where a JVM in 'jvms' may terminate
@@ -95,7 +138,7 @@
                          * Other errors, such as access and I/O exceptions
                          * should stop us from iterating over the complete set.
                          */
-                        output.append(" -- process information unavailable");
+                        output.append(errorString);
                         if (arguments.isDebug()) {
                             if ((lastError != null)
                                     && (lastError.getMessage() != null)) {
@@ -110,33 +153,6 @@
                         continue;
                     }
                 }
-
-                output.append(" ");
-                output.append(MonitoredVmUtil.mainClass(vm,
-                        arguments.showLongPaths()));
-
-                if (arguments.showMainArgs()) {
-                    String mainArgs = MonitoredVmUtil.mainArgs(vm);
-                    if (mainArgs != null && mainArgs.length() > 0) {
-                        output.append(" ").append(mainArgs);
-                    }
-                }
-                if (arguments.showVmArgs()) {
-                    String jvmArgs = MonitoredVmUtil.jvmArgs(vm);
-                    if (jvmArgs != null && jvmArgs.length() > 0) {
-                      output.append(" ").append(jvmArgs);
-                    }
-                }
-                if (arguments.showVmFlags()) {
-                    String jvmFlags = MonitoredVmUtil.jvmFlags(vm);
-                    if (jvmFlags != null && jvmFlags.length() > 0) {
-                        output.append(" ").append(jvmFlags);
-                    }
-                }
-
-                System.out.println(output);
-
-                monitoredHost.detach(vm);
             }
         } catch (MonitorException e) {
             if (e.getMessage() != null) {
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
         {"America/Nipigon", EST},
         {"America/Nome", AKST},
         {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
         {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
         {"America/Panama", EST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Mon Mar 07 11:37:54 2011 -0800
@@ -405,6 +405,7 @@
             {"America/Nipigon", EST},
             {"America/Nome", AKST},
             {"America/Noronha", NORONHA},
+            {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
             {"America/Ojinaga", MST},
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Mon Mar 07 11:37:54 2011 -0800
@@ -42,6 +42,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.zip.ZipError;
 import java.util.concurrent.ExecutorService;
 
 /*
@@ -78,39 +79,60 @@
         }
     }
 
+    private boolean ensureFile(Path path) {
+        try {
+            BasicFileAttributes attrs =
+                Files.readAttributes(path, BasicFileAttributes.class);
+            if (!attrs.isRegularFile())
+                throw new UnsupportedOperationException();
+            return true;
+        } catch (IOException ioe) {
+            return false;
+        }
+    }
+
     @Override
     public FileSystem newFileSystem(URI uri, Map<String, ?> env)
         throws IOException
     {
-        return newFileSystem(uriToPath(uri), env, true);
+        Path path = uriToPath(uri);
+        synchronized(filesystems) {
+            Path realPath = null;
+            if (ensureFile(path)) {
+                realPath = path.toRealPath(true);
+                if (filesystems.containsKey(realPath))
+                    throw new FileSystemAlreadyExistsException();
+            }
+            ZipFileSystem zipfs = null;
+            try {
+                zipfs = new ZipFileSystem(this, path, env);
+            } catch (ZipError ze) {
+                String pname = path.toString();
+                if (pname.endsWith(".zip") || pname.endsWith(".jar"))
+                    throw ze;
+                // assume NOT a zip/jar file
+                throw new UnsupportedOperationException();
+            }
+            filesystems.put(realPath, zipfs);
+            return zipfs;
+        }
     }
 
     @Override
     public FileSystem newFileSystem(Path path, Map<String, ?> env)
         throws IOException
     {
-        if (!path.toUri().getScheme().equalsIgnoreCase("file")) {
+        if (path.getFileSystem() != FileSystems.getDefault()) {
             throw new UnsupportedOperationException();
         }
-        return newFileSystem(path, env, false);
-    }
-
-    private FileSystem newFileSystem(Path path, Map<String, ?> env, boolean checkIfFSExists)
-        throws IOException
-    {
-        synchronized(filesystems) {
-            Path realPath = null;
-            if (checkIfFSExists && Files.exists(path)) {
-                realPath = path.toRealPath(true);
-                if (filesystems.containsKey(realPath))
-                    throw new FileSystemAlreadyExistsException();
-            }
-            ZipFileSystem zipfs = new ZipFileSystem(this, path, env);
-            if (realPath == null)
-                realPath = path.toRealPath(true);
-            if (!filesystems.containsKey(realPath))
-                filesystems.put(realPath, zipfs);
-            return zipfs;
+        ensureFile(path);
+        try {
+            return new ZipFileSystem(this, path, env);
+        } catch (ZipError ze) {
+            String pname = path.toString();
+            if (pname.endsWith(".zip") || pname.endsWith(".jar"))
+                throw ze;
+            throw new UnsupportedOperationException();
         }
     }
 
--- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Mon Mar 07 11:37:54 2011 -0800
@@ -109,8 +109,8 @@
     jobject stream;            // ImageInputStream or ImageOutputStream
     jbyteArray hstreamBuffer;  // Handle to a Java buffer for the stream
     JOCTET *buf;               // Pinned buffer pointer */
-    int bufferOffset;          // holds offset between unpin and the next pin
-    int bufferLength;          // Allocated, nut just used
+    size_t bufferOffset;          // holds offset between unpin and the next pin
+    size_t bufferLength;          // Allocated, nut just used
     int suspendable;           // Set to true to suspend input
     long remaining_skip;       // Used only on input
 } streamBuffer, *streamBufferPtr;
@@ -129,7 +129,7 @@
  * Used to signal that no data need be restored from an unpin to a pin.
  * I.e. the buffer is empty.
  */
-#define NO_DATA -1
+#define NO_DATA ((size_t)-1)
 
 // Forward reference
 static void resetStreamBuffer(JNIEnv *env, streamBufferPtr sb);
@@ -389,7 +389,6 @@
 static imageIODataPtr initImageioData (JNIEnv *env,
                                        j_common_ptr cinfo,
                                        jobject obj) {
-    int i, j;
 
     imageIODataPtr data = (imageIODataPtr) malloc (sizeof(imageIOData));
     if (data == NULL) {
@@ -982,7 +981,7 @@
     streamBufferPtr sb = &data->streamBuf;
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
     jint ret;
-    int offset, buflen;
+    size_t offset, buflen;
 
     /*
      * The original (jpegdecoder.c) had code here that called
@@ -1520,7 +1519,7 @@
         imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
-    return (jlong) ret;
+    return ptr_to_jlong(ret);
 }
 
 /*
@@ -1535,7 +1534,7 @@
      jlong ptr,
      jobject source) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_common_ptr cinfo;
 
     if (data == NULL) {
@@ -1574,7 +1573,7 @@
     int h_samp0, h_samp1, h_samp2;
     int v_samp0, v_samp1, v_samp2;
     jboolean retval = JNI_FALSE;
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_decompress_ptr cinfo;
     struct jpeg_source_mgr *src;
     sun_jpeg_error_ptr jerr;
@@ -1772,7 +1771,7 @@
      jlong ptr,
      jint code) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_decompress_ptr cinfo;
 
     if (data == NULL) {
@@ -1814,7 +1813,7 @@
     struct jpeg_source_mgr *src;
     JSAMPROW scanLinePtr = NULL;
     jint bands[MAX_BANDS];
-    int i, j;
+    int i;
     jint *body;
     int scanlineLimit;
     int pixelStride;
@@ -1824,14 +1823,12 @@
     pixelBufferPtr pb;
     sun_jpeg_error_ptr jerr;
     boolean done;
-    jint *bandSize;
-    int maxBandValue, halfMaxBandValue;
     boolean mustScale = FALSE;
     boolean progressive = FALSE;
     boolean orderedBands = TRUE;
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_decompress_ptr cinfo;
-    unsigned int numBytes;
+    size_t numBytes;
 
     /* verify the inputs */
 
@@ -1849,7 +1846,7 @@
 
     cinfo = (j_decompress_ptr) data->jpegObj;
 
-    if ((numBands < 1) ||
+    if ((numBands < 1) || (numBands > MAX_BANDS) ||
         (sourceXStart < 0) || (sourceXStart >= (jint)cinfo->image_width) ||
         (sourceYStart < 0) || (sourceYStart >= (jint)cinfo->image_height) ||
         (sourceWidth < 1) || (sourceWidth > (jint)cinfo->image_width) ||
@@ -1863,10 +1860,10 @@
         return JNI_FALSE;
     }
 
-    if (stepX > cinfo->image_width) {
+    if (stepX > (jint)cinfo->image_width) {
         stepX = cinfo->image_width;
     }
-    if (stepY > cinfo->image_height) {
+    if (stepY > (jint)cinfo->image_height) {
         stepY = cinfo->image_height;
     }
 
@@ -2119,7 +2116,7 @@
      jobject this,
      jlong ptr) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
 
     if (data == NULL) {
         JNU_ThrowByName(env,
@@ -2137,7 +2134,7 @@
     (JNIEnv *env,
      jobject this,
      jlong ptr) {
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_decompress_ptr cinfo;
 
     if (data == NULL) {
@@ -2159,7 +2156,7 @@
      jobject this,
      jlong ptr) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_decompress_ptr cinfo;
     sun_jpeg_error_ptr jerr;
 
@@ -2232,7 +2229,7 @@
      jclass reader,
      jlong ptr) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_common_ptr info = destroyImageioData(env, data);
 
     imageio_dispose(info);
@@ -2317,8 +2314,8 @@
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
     /* find out how much needs to be written */
-    jint datacount = sb->bufferLength - dest->free_in_buffer;
-
+    /* this conversion from size_t to jint is safe, because the lenght of the buffer is limited by jint */
+    jint datacount = (jint)(sb->bufferLength - dest->free_in_buffer);
     if (datacount != 0) {
         RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
 
@@ -2485,7 +2482,7 @@
         imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
-    return (jlong) ret;
+    return ptr_to_jlong(ret);
 }
 
 JNIEXPORT void JNICALL
@@ -2495,7 +2492,7 @@
      jlong ptr,
      jobject destination) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_compress_ptr cinfo;
 
     if (data == NULL) {
@@ -2526,7 +2523,7 @@
 
     struct jpeg_destination_mgr *dest;
     sun_jpeg_error_ptr jerr;
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_compress_ptr cinfo;
 
     if (data == NULL) {
@@ -2625,10 +2622,11 @@
     jint *scanData;
     jint *bandSize;
     int maxBandValue, halfMaxBandValue;
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_compress_ptr cinfo;
     UINT8** scale = NULL;
 
+
     /* verify the inputs */
 
     if (data == NULL) {
@@ -2740,6 +2738,16 @@
                                           buffer);
             JNU_ThrowByName(env, "javax/imageio/IIOException", buffer);
         }
+
+        if (scale != NULL) {
+            for (i = 0; i < numBands; i++) {
+                if (scale[i] != NULL) {
+                    free(scale[i]);
+                }
+            }
+            free(scale);
+        }
+
         free(scanLinePtr);
         return data->abortFlag;
     }
@@ -2953,7 +2961,7 @@
      jobject this,
      jlong ptr) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
 
     if (data == NULL) {
         JNU_ThrowByName(env,
@@ -2970,7 +2978,7 @@
     (JNIEnv *env,
      jobject this,
      jlong ptr) {
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_compress_ptr cinfo;
 
     if (data == NULL) {
@@ -3002,7 +3010,7 @@
      jclass writer,
      jlong ptr) {
 
-    imageIODataPtr data = (imageIODataPtr) ptr;
+    imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_common_ptr info = destroyImageioData(env, data);
 
     imageio_dispose(info);
--- a/jdk/src/share/native/sun/awt/image/jpeg/jdmarker.c	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/native/sun/awt/image/jpeg/jdmarker.c	Mon Mar 07 11:37:54 2011 -0800
@@ -1325,14 +1325,14 @@
                    unsigned int length_limit)
 {
   my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
-  long maxlength;
+  size_t maxlength;
   jpeg_marker_parser_method processor;
 
   /* Length limit mustn't be larger than what we can allocate
    * (should only be a concern in a 16-bit environment).
    */
   maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct);
-  if (((long) length_limit) > maxlength)
+  if (length_limit > maxlength)
     length_limit = (unsigned int) maxlength;
 
   /* Choose processor routine to use.
--- a/jdk/src/share/native/sun/awt/image/jpeg/jmemmgr.c	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/native/sun/awt/image/jpeg/jmemmgr.c	Mon Mar 07 11:37:54 2011 -0800
@@ -133,7 +133,7 @@
   jvirt_barray_ptr virt_barray_list;
 
   /* This counts total space obtained from jpeg_get_small/large */
-  long total_space_allocated;
+  size_t total_space_allocated;
 
   /* alloc_sarray and alloc_barray set this value for use by virtual
    * array routines.
@@ -588,8 +588,8 @@
 /* Allocate the in-memory buffers for any unrealized virtual arrays */
 {
   my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
-  long space_per_minheight, maximum_space, avail_mem;
-  long minheights, max_minheights;
+  size_t space_per_minheight, maximum_space, avail_mem;
+  size_t minheights, max_minheights;
   jvirt_sarray_ptr sptr;
   jvirt_barray_ptr bptr;
 
@@ -1032,7 +1032,7 @@
 jinit_memory_mgr (j_common_ptr cinfo)
 {
   my_mem_ptr mem;
-  long max_to_use;
+  size_t max_to_use;
   int pool;
   size_t test_mac;
 
@@ -1109,8 +1109,10 @@
 
     if ((memenv = getenv("JPEGMEM")) != NULL) {
       char ch = 'x';
+      unsigned int mem_max = 0u;
 
-      if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) {
+      if (sscanf(memenv, "%u%c", &mem_max, &ch) > 0) {
+        max_to_use = (size_t)mem_max;
         if (ch == 'm' || ch == 'M')
           max_to_use *= 1000L;
         mem->pub.max_memory_to_use = max_to_use * 1000L;
--- a/jdk/src/share/native/sun/awt/image/jpeg/jmemnobs.c	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/native/sun/awt/image/jpeg/jmemnobs.c	Mon Mar 07 11:37:54 2011 -0800
@@ -73,9 +73,9 @@
  * Here we always say, "we got all you want bud!"
  */
 
-GLOBAL(long)
-jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
-                    long max_bytes_needed, long already_allocated)
+GLOBAL(size_t)
+jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,
+                    size_t max_bytes_needed, size_t already_allocated)
 {
   return max_bytes_needed;
 }
@@ -100,7 +100,7 @@
  * cleanup required.  Here, there isn't any.
  */
 
-GLOBAL(long)
+GLOBAL(size_t)
 jpeg_mem_init (j_common_ptr cinfo)
 {
   return 0;                     /* just set max_memory_to_use to 0 */
--- a/jdk/src/share/native/sun/awt/image/jpeg/jmemsys.h	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/native/sun/awt/image/jpeg/jmemsys.h	Mon Mar 07 11:37:54 2011 -0800
@@ -104,10 +104,10 @@
  * Conversely, zero may be returned to always use the minimum amount of memory.
  */
 
-EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo,
-                                     long min_bytes_needed,
-                                     long max_bytes_needed,
-                                     long already_allocated));
+EXTERN(size_t) jpeg_mem_available JPP((j_common_ptr cinfo,
+                                     size_t min_bytes_needed,
+                                     size_t max_bytes_needed,
+                                     size_t already_allocated));
 
 
 /*
@@ -198,5 +198,5 @@
  * all opened backing-store objects have been closed.
  */
 
-EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo));
+EXTERN(size_t) jpeg_mem_init JPP((j_common_ptr cinfo));
 EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo));
--- a/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c	Mon Mar 07 11:37:54 2011 -0800
@@ -328,7 +328,7 @@
     if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) {
         cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
     }
-    if (ret <= src->remaining_skip) {
+    if (ret < 0 || (unsigned int)ret <= src->remaining_skip) {
         return;
     }
     if (src->remaining_skip) {
@@ -397,7 +397,7 @@
     }
     num_bytes += src->remaining_skip;
     src->remaining_skip = 0;
-    ret = src->pub.bytes_in_buffer;
+    ret = (int)src->pub.bytes_in_buffer; /* this conversion is safe, because capacity of the buffer is limited by jnit */
     if (ret >= num_bytes) {
         src->pub.next_input_byte += num_bytes;
         src->pub.bytes_in_buffer -= num_bytes;
--- a/jdk/src/share/native/sun/awt/image/jpeg/jpeglib.h	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/share/native/sun/awt/image/jpeg/jpeglib.h	Mon Mar 07 11:37:54 2011 -0800
@@ -800,10 +800,10 @@
    * used for virtual-array buffers.)  May be changed by outer application
    * after creating the JPEG object.
    */
-  long max_memory_to_use;
+  size_t max_memory_to_use;
 
   /* Maximum allocation request accepted by alloc_large. */
-  long max_alloc_chunk;
+  size_t max_alloc_chunk;
 };
 
 
--- a/jdk/src/solaris/classes/sun/awt/X11/XDesktopPeer.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDesktopPeer.java	Mon Mar 07 11:37:54 2011 -0800
@@ -44,11 +44,27 @@
 public class XDesktopPeer implements DesktopPeer {
 
     private static boolean nativeLibraryLoaded = false;
-    static {
-        nativeLibraryLoaded = init();
+    private static boolean initExecuted = false;
+
+    private static void initWithLock(){
+        XToolkit.awtLock();
+        try {
+            if (!initExecuted) {
+                nativeLibraryLoaded = init();
+            }
+        } finally {
+            initExecuted = true;
+            XToolkit.awtUnlock();
+        }
+    }
+
+    //package-private
+    XDesktopPeer(){
+        initWithLock();
     }
 
     static boolean isDesktopSupported() {
+        initWithLock();
         return nativeLibraryLoaded;
     }
 
@@ -83,12 +99,17 @@
     }
 
     private void launch(URI uri) throws IOException {
-        if (!nativeLibraryLoaded) {
-            throw new IOException("Failed to load native libraries.");
+        byte[] uriByteArray = ( uri.toString() + '\0' ).getBytes();
+        boolean result = false;
+        XToolkit.awtLock();
+        try {
+            if (!nativeLibraryLoaded) {
+                throw new IOException("Failed to load native libraries.");
+            }
+            result = gnome_url_show(uriByteArray);
+        } finally {
+            XToolkit.awtUnlock();
         }
-
-        byte[] uriByteArray = ( uri.toString() + '\0' ).getBytes();
-        boolean result = gnome_url_show(uriByteArray);
         if (!result) {
             throw new IOException("Failed to show URI:" + uri);
         }
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	Mon Mar 07 11:37:54 2011 -0800
@@ -479,8 +479,7 @@
         if (xrpipe == null) {
             try {
                 SunToolkit.awtLock();
-                xgc = renderQueue.createGC(xid); // TODO: GC leak? where to
-                // clean up?
+                xgc = XCreateGC(getNativeOps());
 
                 xrpipe = new XRRenderer(maskBuffer.getMaskBuffer());
                 xrtxpipe = new PixelToShapeConverter(xrpipe);
--- a/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java	Mon Mar 07 11:37:54 2011 -0800
@@ -136,7 +136,7 @@
             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 
         FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
-        return FileChannelImpl.open(fdObj, flags.read, flags.write, null);
+        return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);
     }
 
     /**
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Mon Mar 07 11:37:54 2011 -0800
@@ -595,15 +595,16 @@
 }
 
 XImage* X11SD_GetSharedImage(X11SDOps *xsdo, jint width, jint height,
-                             jboolean readBits)
+                             jint maxWidth, jint maxHeight, jboolean readBits)
 {
     XImage * retImage = NULL;
     if (cachedXImage != NULL &&
-        X11SD_CachedXImageFits(width, height, xsdo->depth, readBits)) {
-            /* sync so previous data gets flushed */
-            XSync(awt_display, False);
-            retImage = cachedXImage;
-            cachedXImage = (XImage *)NULL;
+        X11SD_CachedXImageFits(width, height, maxWidth, maxHeight,
+                               xsdo->depth, readBits)) {
+        /* sync so previous data gets flushed */
+        XSync(awt_display, False);
+        retImage = cachedXImage;
+        cachedXImage = (XImage *)NULL;
     } else if (width * height * xsdo->depth > 0x10000) {
         retImage = X11SD_CreateSharedImage(xsdo, width, height);
     }
@@ -728,8 +729,8 @@
  * it must be close enough to avoid excessive reading from the screen;
  * otherwise it should just be at least the size requested.
  */
-jboolean X11SD_CachedXImageFits(jint width, jint height, jint depth,
-                                jboolean readBits)
+jboolean X11SD_CachedXImageFits(jint width, jint height, jint maxWidth,
+                                jint maxHeight, jint depth, jboolean readBits)
 {
     /* we assume here that the cached image exists */
     jint imgWidth = cachedXImage->width;
@@ -747,10 +748,14 @@
         return JNI_TRUE;
     }
 
-    if ((imgWidth < width + 64) && (imgHeight < height + 64)) {
+    if ((imgWidth < width + 64) && (imgHeight < height + 64)
+         && imgWidth <= maxWidth && imgHeight <= maxHeight)
+    {
         /* Cached image's width/height shouldn't be more than 64 pixels
          * larger than requested, because the region in XShmGetImage
          * can't be specified and we don't want to read too much.
+         * Furthermore it has to be smaller than maxWidth/Height
+         * so drawables are not read out of bounds.
          */
         return JNI_TRUE;
     }
@@ -1295,7 +1300,7 @@
                                SurfaceDataBounds *bounds,
                                jint lockFlags)
 {
-    int x, y, w, h;
+    int x, y, w, h, maxWidth, maxHeight;
     int scan;
     XImage * img = NULL;
     Drawable drawable;
@@ -1311,10 +1316,31 @@
 
 #ifdef MITSHM
     if (useMitShmExt == CAN_USE_MITSHM) {
-        if (xsdo->isPixmap && readBits) {
-            X11SD_PuntPixmap(xsdo, w, h);
+        if (xsdo->isPixmap) {
+            if (readBits) {
+                X11SD_PuntPixmap(xsdo, w, h);
+            }
+            maxWidth = xsdo->pmWidth;
+            maxHeight = xsdo->pmHeight;
+        } else {
+            XWindowAttributes winAttr;
+            if (XGetWindowAttributes(awt_display,
+                                     (Window) xsdo->drawable, &winAttr) != 0) {
+                maxWidth = winAttr.width;
+                maxHeight = winAttr.height;
+           } else {
+                /* XGWA failed which isn't a good thing. Defaulting to using
+                 * x,y means that after the subtraction of these we will use
+                 * w=0, h=0 which is a reasonable default on such a failure.
+                 */
+                maxWidth = x;
+                maxHeight = y;
+           }
         }
-        img = X11SD_GetSharedImage(xsdo, w, h, readBits);
+        maxWidth -= x;
+        maxHeight -= y;
+
+        img = X11SD_GetSharedImage(xsdo, w, h, maxWidth, maxHeight, readBits);
     }
 #endif /* MITSHM */
     drawable = xsdo->drawable;
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h	Mon Mar 07 11:37:54 2011 -0800
@@ -125,15 +125,21 @@
 #define X11SD_LOCK_BY_SHMEM     4       /* surface locked by ShMemExt */
 
 #ifdef MITSHM
-XImage * X11SD_GetSharedImage       (X11SDOps *xsdo, jint width, jint height, jboolean readBits);
+XImage * X11SD_GetSharedImage       (X11SDOps *xsdo,
+                                     jint width, jint height,
+                                     jint maxWidth, jint maxHeight,
+                                     jboolean readBits);
 XImage * X11SD_CreateSharedImage    (X11SDOps *xsdo, jint width, jint height);
 Drawable X11SD_CreateSharedPixmap   (X11SDOps *xsdo);
 void     X11SD_DropSharedSegment    (XShmSegmentInfo *shminfo);
 void     X11SD_PuntPixmap           (X11SDOps *xsdo, jint width, jint height);
 void     X11SD_UnPuntPixmap         (X11SDOps *xsdo);
-jboolean X11SD_CachedXImageFits     (jint width, jint height, jint depth, jboolean readBits);
+jboolean X11SD_CachedXImageFits     (jint width, jint height,
+                                     jint maxWidth, jint maxHeight,
+                                     jint depth, jboolean readBits);
 XImage * X11SD_GetCachedXImage      (jint width, jint height, jboolean readBits);
 #endif /* MITSHM */
+jint     X11SD_InitWindow(JNIEnv *env, X11SDOps *xsdo);
 void     X11SD_DisposeOrCacheXImage (XImage * image);
 void     X11SD_DisposeXImage(XImage * image);
 void     X11SD_DirectRenderNotify(JNIEnv *env, X11SDOps *xsdo);
--- a/jdk/src/solaris/native/sun/xawt/awt_Desktop.c	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/solaris/native/sun/xawt/awt_Desktop.c	Mon Mar 07 11:37:54 2011 -0800
@@ -48,9 +48,15 @@
     }
     dlerror(); /* Clear errors */
     gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
+    if (gnome_vfs_init == NULL){
+#ifdef INTERNAL_BUILD
+        fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
+#endif
+        return 0;
+    }
     if ((errmsg = dlerror()) != NULL) {
 #ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not find symble gnome_vfs_init\n");
+        fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
 #endif
         return 0;
     }
--- a/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java	Mon Mar 07 11:37:54 2011 -0800
@@ -51,9 +51,12 @@
 import java.awt.image.DataBuffer;
 import java.awt.image.IndexColorModel;
 import java.awt.image.WritableRaster;
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.SampleModel;
+
 import sun.awt.image.ByteComponentRaster;
 import sun.awt.image.BytePackedRaster;
-
 import java.awt.print.PageFormat;
 import java.awt.print.Printable;
 import java.awt.print.PrinterException;
@@ -1272,6 +1275,25 @@
                         return false;
                     }
 
+                    int bitsPerPixel = 24;
+                    SampleModel sm = deepImage.getSampleModel();
+                    if (sm instanceof ComponentSampleModel) {
+                        ComponentSampleModel csm = (ComponentSampleModel)sm;
+                        bitsPerPixel = csm.getPixelStride() * 8;
+                    } else if (sm instanceof MultiPixelPackedSampleModel) {
+                        MultiPixelPackedSampleModel mppsm =
+                            (MultiPixelPackedSampleModel)sm;
+                        bitsPerPixel = mppsm.getPixelBitStride();
+                    } else {
+                        if (icm != null) {
+                            int diw = deepImage.getWidth();
+                            int dih = deepImage.getHeight();
+                            if (diw > 0 && dih > 0) {
+                                bitsPerPixel = data.length*8/diw/dih;
+                            }
+                        }
+                    }
+
                     /* Because the caller's image has been rotated
                      * and sheared into our BufferedImage and because
                      * we will be handing that BufferedImage directly to
@@ -1289,7 +1311,7 @@
                          (float)Math.rint(scaledBounds.height+0.5),
                          0f, 0f,
                          deepImage.getWidth(), deepImage.getHeight(),
-                         icm);
+                         bitsPerPixel, icm);
 
                     setClip(holdClip);
                 }
--- a/jdk/src/windows/classes/sun/awt/windows/WPrinterJob.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/windows/classes/sun/awt/windows/WPrinterJob.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1212,13 +1212,14 @@
                                 float destWidth, float destHeight,
                                 float srcX, float srcY,
                                 float srcWidth, float srcHeight,
+                                int sampleBitsPerPixel,
                                 IndexColorModel icm) {
         int bitCount = 24;
         byte[] bmiColors = null;
 
         if (icm != null) {
-            bitCount = icm.getPixelSize();
-            bmiColors = new byte[(1<<bitCount)*4];
+            bitCount = sampleBitsPerPixel;
+            bmiColors = new byte[(1<<icm.getPixelSize())*4];
             for (int i=0;i<icm.getMapSize(); i++) {
                 bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff);
                 bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff);
--- a/jdk/src/windows/classes/sun/print/Win32PrintService.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java	Mon Mar 07 11:37:54 2011 -0800
@@ -31,6 +31,7 @@
 import java.net.URL;
 
 import java.util.Vector;
+import java.util.HashMap;
 
 import javax.print.DocFlavor;
 import javax.print.DocPrintJob;
@@ -205,6 +206,7 @@
     private MediaPrintableArea[] mediaPrintables;
     private MediaTray[] mediaTrays;
     private PrinterResolution[] printRes;
+    private HashMap mpaMap;
     private int nCopies;
     private int prnCaps;
     private int[] defaultSettings;
@@ -212,6 +214,7 @@
     private boolean gotTrays;
     private boolean gotCopies;
     private boolean mediaInitialized;
+    private boolean mpaListInitialized;
 
     private ArrayList idList;
     private MediaSize[] mediaSizes;
@@ -270,6 +273,20 @@
                 return DMPAPER_B6_JIS;
             }
         }
+
+        // If not found in predefined Windows ID, then we search through
+        // the returned IDs of the driver because they can define their own
+        // unique IDs.
+        initMedia();
+
+        if ((idList != null) && (mediaSizes != null) &&
+            (idList.size() == mediaSizes.length)) {
+            for (int i=0; i< idList.size(); i++) {
+                if (mediaSizes[i].getMediaSizeName() == msn) {
+                    return ((Integer)idList.get(i)).intValue();
+                }
+            }
+        }
         return 0;
     }
 
@@ -380,43 +397,115 @@
             // Add mediaName to the msnList
             if (mediaName != null) {
                 added = addToUniqueList(msnList, mediaName);
-
-                // get MediaPrintableArea only for supported MediaSizeName ?
-                if (added && !queryFailure) {
-                    prnArea=getMediaPrintableArea(printer,
-                                                  ((Integer)idList.get(i)).intValue());
-                    if (prnArea != null) {
-                        try {
-                            MediaPrintableArea mpa =
-                                new MediaPrintableArea(prnArea[0],
-                                                       prnArea[1],
-                                                       prnArea[2],
-                                                       prnArea[3],
-                                                       MediaPrintableArea.INCH);
-                            printableList.add(mpa);
-                        } catch (IllegalArgumentException iae) {
-                        }
-                    } else {
-                        // Calling getMediaPrintableArea causes
-                        // much overhead so if first attempt failed, we should
-                        // just bail out.
-                        if (i==0) {
-                            queryFailure = true;
-                        }
-                    }
-                }
             }
         }
 
         // init mediaSizeNames
         mediaSizeNames = new MediaSizeName[msnList.size()];
         msnList.toArray(mediaSizeNames);
+    }
 
-        // init mediaPrintables
-        mediaPrintables = new MediaPrintableArea[printableList.size()];
-        printableList.toArray(mediaPrintables);
+
+    /*
+     * Gets a list of MediaPrintableAreas using a call to native function.
+     *  msn is MediaSizeName used to get a specific printable area.  If null,
+     *  it will get all the supported MediPrintableAreas.
+     */
+    private synchronized MediaPrintableArea[] getMediaPrintables(MediaSizeName msn)
+    {
+        if (msn == null)  {
+            if (mpaListInitialized == true) {
+                return mediaPrintables;
+            }
+        } else {
+            // get from cached mapping of MPAs
+            if (mpaMap != null && (mpaMap.get(msn) != null)) {
+                MediaPrintableArea[] mpaArr = new MediaPrintableArea[1];
+                mpaArr[0] = (MediaPrintableArea)mpaMap.get(msn);
+                return mpaArr;
+            }
+        }
+
+        initMedia();
+
+        if ((mediaSizeNames == null) && (mediaSizeNames.length == 0)) {
+            return null;
+        }
+
+        MediaSizeName[] loopNames;
+        if (msn != null) {
+            loopNames = new MediaSizeName[1];
+            loopNames[0] = msn;
+        } else {
+            loopNames = mediaSizeNames;
+        }
+
+        if (mpaMap == null) {
+            mpaMap = new HashMap();
+        }
+
+        for (int i=0; i < loopNames.length; i++) {
+            MediaSizeName mediaName = loopNames[i];
+
+            if (mpaMap.get(mediaName) != null) {
+                continue;
+             }
+
+            if (mediaName != null) {
+                int defPaper = findPaperID(mediaName);
+                float[] prnArea = (defPaper != 0) ? getMediaPrintableArea(printer, defPaper) : null;
+                MediaPrintableArea printableArea = null;
+                if (prnArea != null) {
+                    try {
+                        printableArea = new MediaPrintableArea(prnArea[0],
+                                                               prnArea[1],
+                                                               prnArea[2],
+                                                               prnArea[3],
+                                                 MediaPrintableArea.INCH);
+
+                        mpaMap.put(mediaName, printableArea);
+                    }
+                    catch (IllegalArgumentException e) {
+                    }
+                } else {
+                    // if getting  MPA failed, we use MediaSize
+                    MediaSize ms =
+                        MediaSize.getMediaSizeForName((MediaSizeName)mediaName);
+
+                    if (ms != null) {
+                        try {
+                            printableArea = new MediaPrintableArea(0, 0,
+                                                     ms.getX(MediaSize.INCH),
+                                                     ms.getY(MediaSize.INCH),
+                                                     MediaPrintableArea.INCH);
+                            mpaMap.put(mediaName, printableArea);
+                        } catch (IllegalArgumentException e) {
+                        }
+                    }
+                }
+            } //mediaName != null
+        }
+
+       if (mpaMap.size() == 0) {
+           return null;
+       }
+
+       if (msn != null) {
+           if (mpaMap.get(msn) == null) {
+               return null;
+           }
+           MediaPrintableArea[] mpaArr = new MediaPrintableArea[1];
+           // by this time, we've already gotten the desired MPA
+           mpaArr[0] = (MediaPrintableArea)mpaMap.get(msn);
+           return mpaArr;
+       } else {
+           mediaPrintables = (MediaPrintableArea[])mpaMap.values().toArray(new MediaPrintableArea[0]);
+           mpaListInitialized = true;
+           return mediaPrintables;
+       }
     }
 
+
     private synchronized MediaTray[] getMediaTrays() {
         if (gotTrays == true && mediaTrays != null) {
             return mediaTrays;
@@ -626,7 +715,7 @@
 
     private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) {
 
-        initMedia();
+        getMediaPrintables(null);
 
         if (mediaPrintables != null) {
             for (int i=0; i<mediaPrintables.length; i++) {
@@ -1250,57 +1339,32 @@
             }
             if (trays != null) {
                 System.arraycopy(trays, 0, arr,
-                                 mediaSizeNames.length, trays.length);
+                                 len - trays.length, trays.length);
             }
             return arr;
         } else if (category == MediaPrintableArea.class) {
-            initMedia();
-
-            if (mediaPrintables == null) {
-                return null;
-            }
-
             // if getting printable area for a specific media size
-            Media mediaName;
+            Media mediaName = null;
             if ((attributes != null) &&
                 ((mediaName =
                   (Media)attributes.get(Media.class)) != null)) {
 
-                if (mediaName instanceof MediaSizeName) {
-                    MediaPrintableArea []arr = new MediaPrintableArea[1];
-
-                    if (mediaSizeNames.length == mediaPrintables.length) {
-
-                        for (int j=0; j < mediaSizeNames.length; j++) {
-
-                            if (mediaName.equals(mediaSizeNames[j])) {
-                                arr[0] = mediaPrintables[j];
-                                return arr;
-                            }
-                        }
-                    }
-
-                    MediaSize ms =
-                      MediaSize.getMediaSizeForName((MediaSizeName)mediaName);
-
-                    if (ms != null) {
-                        arr[0] = new MediaPrintableArea(0, 0,
-                                                        ms.getX(MediaSize.INCH),
-                                                        ms.getY(MediaSize.INCH),
-                                                        MediaPrintableArea.INCH);
-                        return arr;
-                    } else {
-                        return null;
-                    }
+                if (!(mediaName instanceof MediaSizeName)) {
+                    // if an instance of MediaTray, fall thru returning
+                    // all MediaPrintableAreas
+                    mediaName = null;
                 }
-                // else an instance of MediaTray, fall thru returning
-                // all MediaPrintableAreas
             }
 
-            MediaPrintableArea []arr =
-                new MediaPrintableArea[mediaPrintables.length];
-            System.arraycopy(mediaPrintables, 0, arr, 0, mediaPrintables.length);
-            return arr;
+            MediaPrintableArea[] mpas =
+                                  getMediaPrintables((MediaSizeName)mediaName);
+            if (mpas != null) {
+                MediaPrintableArea[] arr = new MediaPrintableArea[mpas.length];
+                System.arraycopy(mpas, 0, arr, 0, mpas.length);
+                return arr;
+            } else {
+                return null;
+            }
         } else if (category == SunAlternateMedia.class) {
             return new SunAlternateMedia(
                               (Media)getDefaultAttributeValue(Media.class));
--- a/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp	Mon Mar 07 11:37:54 2011 -0800
@@ -107,8 +107,16 @@
         // could retain their own DIB info and we would not need to
         // recreate it every time.
 
+        // GetRasInfo implicitly calls GetPrimitiveArrayCritical
+        // and since GetDC uses JNI it needs to be called first.
+        HDC hDC = dstOps->GetDC(env, dstOps, 0, NULL, clip, NULL, 0);
+        if (hDC == NULL) {
+            SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
+            return;
+        }
         srcOps->GetRasInfo(env, srcOps, &srcInfo);
         if (srcInfo.rasBase == NULL) {
+            dstOps->ReleaseDC(env, dstOps, hDC);
             SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
             return;
         }
@@ -174,13 +182,6 @@
             bmi.colors.dwMasks[2] = bmask;
         }
 
-        HDC hDC = dstOps->GetDC(env, dstOps, 0, NULL, clip, NULL, 0);
-        if (hDC == NULL) {
-            SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
-            SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
-            return;
-        }
-
         if (fastBlt) {
             // Window could go away at any time, leaving bits on the screen
             // from this GDI call, so make sure window still exists
--- a/jdk/test/ProblemList.txt	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/ProblemList.txt	Mon Mar 07 11:37:54 2011 -0800
@@ -41,14 +41,14 @@
 #
 # Shell tests are othervm by default.
 #
-# List items  are testnames followed by labels, all MUST BE commented 
+# List items  are testnames followed by labels, all MUST BE commented
 #   as to why they are here and use a label:
 #     generic-all	Problems on all platforms
 #     generic-ARCH	Where ARCH is one of: sparc, sparcv9, x64, i586, etc.
 #     OSNAME-all	Where OSNAME is one of: solaris, linux, windows
 #     OSNAME-ARCH	Specific on to one OSNAME and ARCH, e.g. solaris-x64
 #     OSNAME-REV	Specific on to one OSNAME and REV, e.g. solaris-5.8
-#	 
+#
 # More than one label is allowed but must be on the same line.
 #
 #############################################################################
@@ -234,7 +234,7 @@
 # Linux 32bit Fedora 9, IllegalStateException
 javax/management/monitor/RuntimeExceptionTest.java		generic-all
 
-# Problems with rmi connection, othervm  
+# Problems with rmi connection, othervm
 javax/management/remote/mandatory/subjectDelegation/SubjectDelegation2Test.java generic-all
 
 # Fails with port already in use
@@ -411,7 +411,7 @@
 com/sun/nio/sctp/SctpChannel/Send.java				generic-all
 com/sun/nio/sctp/SctpChannel/Shutdown.java			generic-all
 
-# Fails on OpenSolaris, IllegalStateException: Cannot add or remove addresses 
+# Fails on OpenSolaris, IllegalStateException: Cannot add or remove addresses
 #    from a channel that is bound to the wildcard address
 com/sun/nio/sctp/SctpChannel/Bind.java				generic-all
 
@@ -456,10 +456,10 @@
 java/rmi/server/RemoteServer/AddrInUse.java			generic-all
 
 # Connection error on Windows i586 -server
-#  Also connection errors in othervm on Solaris 10 sparc, same port??? 
+#  Also connection errors in othervm on Solaris 10 sparc, same port???
 sun/rmi/transport/tcp/DeadCachedConnection.java 	 	generic-all
 
-# Connection errors in othervm on Solaris 10 sparc, same port??? 
+# Connection errors in othervm on Solaris 10 sparc, same port???
 java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java generic-all
 java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java generic-all
 java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java generic-all
@@ -532,7 +532,7 @@
 java/security/Security/SynchronizedAccess.java			generic-all
 
 # Failing on Solaris X64 (-d64 -server) with:
-#  GSSException: Failure unspecified at GSS-API level 
+#  GSSException: Failure unspecified at GSS-API level
 #    (Mechanism level: Specified version of key is not available (44))
 sun/security/krb5/auto/BasicKrb5Test.java			generic-all
 
@@ -546,14 +546,14 @@
 sun/security/krb5/auto/HttpNegotiateServer.java			generic-all
 
 # Fails on almost all platforms
-#   java.lang.UnsupportedClassVersionError: SerialTest : 
+#   java.lang.UnsupportedClassVersionError: SerialTest :
 #      Unsupported major.minor version 51.0
 #    at java.lang.ClassLoader.defineClass1(Native Method)
 sun/security/util/Oid/S11N.sh					generic-all
 
 # Fails on Fedora 9 32bit
-#  GSSException: Failure unspecified at GSS-API level (Mechanism level: 
-#    Invalid argument (400) - Cannot find key of appropriate type to decrypt 
+#  GSSException: Failure unspecified at GSS-API level (Mechanism level:
+#    Invalid argument (400) - Cannot find key of appropriate type to decrypt
 #    AP REP - DES CBC mode with MD5)
 #  at sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:778)
 sun/security/krb5/auto/NonMutualSpnego.java			generic-all
@@ -673,7 +673,7 @@
 # Timeout on solaris-sparc and i586 and x64, -client and -server
 sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/InterruptedIO.java solaris-all
 
-# Do not seem to run on windows machines? dll missing? 
+# Do not seem to run on windows machines? dll missing?
 sun/security/tools/jarsigner/emptymanifest.sh		 	windows-all
 
 # Files does not exist or no encoding? solaris-sparcv9
@@ -734,8 +734,5 @@
 # Problems on windows, jmap.exe hangs? (these run jmap), fails on Solaris 10 x86
 java/util/concurrent/locks/Lock/TimedAcquireLeak.java		generic-all
 
-# Fails on solaris-sparc -server (Set not equal to copy. 1)
-java/util/EnumSet/EnumSetBash.java			 	solaris-sparc
-
 ############################################################################
 
--- a/jdk/test/demo/zipfs/ZipFSTester.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/demo/zipfs/ZipFSTester.java	Mon Mar 07 11:37:54 2011 -0800
@@ -105,6 +105,18 @@
             os.write(bits);
             os.close();
 
+            try {
+                provider.newFileSystem(new File(System.getProperty("test.src", ".")).toPath(),
+                                       new HashMap<String, Object>());
+                throw new RuntimeException("newFileSystem() opens a directory as zipfs");
+            } catch (UnsupportedOperationException uoe) {}
+
+            try {
+                provider.newFileSystem(src, new HashMap<String, Object>());
+                throw new RuntimeException("newFileSystem() opens a non-zip file as zipfs");
+            } catch (UnsupportedOperationException uoe) {}
+
+
             // copyin
             Path dst = getPathWithParents(fs, tmpName);
             Files.copy(src, dst);
--- a/jdk/test/demo/zipfs/basic.sh	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/demo/zipfs/basic.sh	Mon Mar 07 11:37:54 2011 -0800
@@ -21,7 +21,7 @@
 # questions.
 #
 # @test
-# @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840
+# @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
 # @summary Test ZipFileSystem demo
 # @build Basic PathOps ZipFSTester
 # @run shell basic.sh
--- a/jdk/test/java/awt/PrintJob/Text/StringWidth.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/awt/PrintJob/Text/StringWidth.java	Mon Mar 07 11:37:54 2011 -0800
@@ -63,7 +63,8 @@
   }
 
   public static void main(String[] args) {
-    new StringWidth();
+    StringWidth sw = new StringWidth();
+    sw.dispose();
   }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/font/StyledMetrics/BoldSpace.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6686365 7017637
+  @summary Confirm that styling does not affect metrics of zero advance glyphs
+*/
+
+import java.awt.*;
+import java.awt.image.*;
+
+public class BoldSpace {
+    public static void main(String[] s) {
+        BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+
+        String errMsg = "ZWJ Space char should have 0 advance\n";
+
+        Graphics g = bi.getGraphics();
+
+        // It turns out that some fonts inexplicably treat this as
+        // a standard character. In this 14 pt font, if we see an advance
+        // that's clearly bigger than we'd have introduced in bolding we'll
+        // not error out this test, presuming that its a consequence of
+        // the actual font data. A Linux font 'TLwg Type Bold' is the case
+        // in point.
+        int errorMargin = 4;
+        g.setFont(new Font("monospaced", Font.BOLD, 14));
+        //g.setFont(new Font("Lucida Sans Regular", Font.BOLD, 14));
+        FontMetrics fm = g.getFontMetrics();
+        System.out.println("Bold: " + fm.charWidth('\u200b'));
+        int cwid = fm.charWidth('\u200b');
+        if (cwid > 0 && cwid < errorMargin) {
+            throw new RuntimeException(errMsg);
+        }
+
+        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                                 RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+        fm = g.getFontMetrics();
+        System.out.println("Bold + LCD: "+fm.charWidth('\u200b'));
+        cwid = fm.charWidth('\u200b');
+        if (cwid > 0 && cwid < errorMargin) {
+            throw new RuntimeException(errMsg);
+        }
+
+
+        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                                 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        fm = g.getFontMetrics();
+        System.out.println("Bold FM OFF + AA: " + fm.charWidth('\u200b'));
+        cwid = fm.charWidth('\u200b');
+        if (cwid > 0 && cwid < errorMargin) {
+            throw new RuntimeException(errMsg);
+        }
+
+        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                                 RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
+        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                                 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        fm = g.getFontMetrics();
+        System.out.println("Bold FM ON + AA: " + fm.charWidth('\u200b'));
+        cwid = fm.charWidth('\u200b');
+        if (cwid > 0 && cwid < errorMargin) {
+            throw new RuntimeException(errMsg);
+        }
+
+        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                                 RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
+        fm = g.getFontMetrics();
+        System.out.println("Bold FM ON + nonAA: " + fm.charWidth('\u200b'));
+        cwid = fm.charWidth('\u200b');
+        if (cwid > 0 && cwid < errorMargin) {
+            throw new RuntimeException(errMsg);
+        }
+
+        System.out.println("All printed values should be 0 to PASS");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/ImagePrinting/ImageTypes.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ *
+ * @test
+ * @bug 4521945 7006865
+ * @summary Test printing images of different types.
+ * @author prr
+ * @run main/manual=yesno/timeout=900 ImageTypes
+ */
+
+import java.io.*;
+import static java.awt.Color.*;
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import java.awt.image.*;
+import static java.awt.image.BufferedImage.*;
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class ImageTypes extends Frame implements ActionListener {
+
+    private ImageCanvas c;
+
+    public static void main(String args[]) {
+
+        ImageTypes f = new ImageTypes();
+        f.show();
+    }
+
+    public ImageTypes () {
+        super("Image Types Printing Test");
+        c = new ImageCanvas();
+        add("Center", c);
+
+        Button printThisButton = new Button("Print");
+        printThisButton.addActionListener(this);
+        Panel p = new Panel();
+        p.add(printThisButton);
+        add("South", p);
+        add("North", getInstructions());
+        addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    System.exit(0);
+                }
+            });
+
+        pack();
+    }
+
+    private TextArea getInstructions() {
+        TextArea ta = new TextArea(10, 60);
+        ta.setFont(new Font("Dialog", Font.PLAIN, 11));
+        ta.setText
+            ("This is a manual test as it requires that you compare "+
+             "the on-screen rendering with the printed output.\n"+
+             "Select the 'Print' button to print out the test.\n"+
+             "For each image compare the printed one to the on-screen one.\n"+
+             "The test PASSES if the onscreen and printed rendering match.");
+        return ta;
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        PrinterJob pj = PrinterJob.getPrinterJob();
+
+        PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
+        if (pj != null && pj.printDialog(attrs)) {
+            pj.setPrintable(c);
+            try {
+                pj.print(attrs);
+            } catch (PrinterException pe) {
+                pe.printStackTrace();
+                throw new RuntimeException("Exception whilst printing.");
+            } finally {
+                System.out.println("PRINT RETURNED OK.");
+            }
+        }
+    }
+}
+
+class ImageCanvas extends Component implements Printable {
+
+    IndexColorModel icm2 = null;
+    IndexColorModel icm4 = null;
+    BufferedImage opaqueImg = null;
+    BufferedImage transImg = null;
+    int sw=99, sh=99;
+
+    void paintImage(BufferedImage bi, Color c1, Color c2) {
+
+        GradientPaint tp= new GradientPaint(0.0f, 0.0f, c1, 10f, 8f, c2, true);
+        Graphics2D g2d = (Graphics2D)bi.getGraphics();
+        g2d.setPaint(tp);
+        g2d.fillRect(0, 0, sw, sh);
+        g2d.setColor(gray);
+        int cnt=0;
+        Font font = new Font("Serif", Font.PLAIN, 11);
+        g2d.setFont(font);
+        FontMetrics fm = g2d.getFontMetrics();
+        for (int y=12;y<sh;y+=12) {
+            int x = 0;
+            while (x < sw) {
+                String s = (new Integer(++cnt)).toString();
+                g2d.drawString(s, x, y);
+                x+= fm.stringWidth(s);
+            }
+        }
+    }
+
+    ImageCanvas() {
+
+        opaqueImg = new BufferedImage(sw, sh, TYPE_INT_RGB);
+        Color o1 = new Color(0, 0, 0);
+        Color o2 = new Color(255, 255, 255);
+        paintImage(opaqueImg, o1, o2);
+
+        transImg = new BufferedImage(sw, sh, TYPE_INT_ARGB);
+        Color t1 = new Color(255, 255, 255, 220);
+        Color t2 = new Color(255, 200, 0, 220);
+        paintImage(transImg, t1, t2);
+
+        /* greyscale 2bpp */
+        byte[] arr2bpp =  {(byte)0, (byte)0x55, (byte)0xaa, (byte)0xff};
+        icm2 = new IndexColorModel(2, 4, arr2bpp, arr2bpp, arr2bpp);
+
+        /* color 4bpp */
+        int[] cmap = new int[16];
+        cmap[0] = black.getRGB();
+        cmap[1] = white.getRGB();
+        cmap[2] = gray.getRGB();
+        cmap[3] = lightGray.getRGB();
+        cmap[4] = red.getRGB();
+        cmap[5] = green.getRGB();
+        cmap[6] = blue.getRGB();
+        cmap[7] = yellow.getRGB();
+        cmap[8] = cyan.getRGB();
+        cmap[9] = magenta.getRGB();
+        cmap[10] = orange.getRGB();
+        cmap[11] = pink.getRGB();
+        cmap[12] = darkGray.getRGB();
+        cmap[13] = 192 << 16 ; // dark red.
+        cmap[14] = 192 << 8; // dark green
+        cmap[15] = 192; // dark blue
+
+        icm4 = new IndexColorModel(4, 16, cmap, 0, false, -1,
+                                   DataBuffer.TYPE_BYTE);
+
+    }
+
+
+    public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
+
+        if (pgIndex > 0) {
+            return Printable.NO_SUCH_PAGE;
+        }
+        Graphics2D g2d = (Graphics2D)g;
+        g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
+        paint(g2d);
+        return Printable.PAGE_EXISTS;
+    }
+
+    private void drawImage(Graphics g, int biType, IndexColorModel icm) {
+
+        BufferedImage bi;
+        if (icm != null) {
+            bi = new BufferedImage(sw, sh, biType, icm);
+        } else {
+            bi = new BufferedImage(sw, sh, biType);
+        }
+
+        Graphics big = bi.getGraphics();
+        if (bi.getColorModel().getPixelSize() <=2) {
+            big.drawImage(opaqueImg, 0, 0, null);
+        } else {
+            big.drawImage(transImg, 0, 0, null);
+        }
+        g.drawImage(bi, 0, 0, null);
+    }
+
+    public void paint(Graphics g) {
+
+        int incX = sw+10, incY = sh+10;
+
+        g.translate(10, 10);
+
+        drawImage(g, TYPE_INT_RGB, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_INT_BGR, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_INT_ARGB, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_INT_ARGB_PRE, null);
+        g.translate(-3*incX, incY);
+
+        drawImage(g, TYPE_3BYTE_BGR, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_4BYTE_ABGR, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_4BYTE_ABGR_PRE, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_USHORT_555_RGB, null);
+        g.translate(-3*incX, incY);
+
+        drawImage(g, TYPE_USHORT_555_RGB, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_USHORT_GRAY, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_BYTE_GRAY, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_BYTE_INDEXED, null);
+        g.translate(-3*incX, incY);
+
+        drawImage(g, TYPE_BYTE_BINARY, null);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_BYTE_BINARY, icm2);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_BYTE_BINARY, icm4);
+        g.translate(incX, 0);
+
+        drawImage(g, TYPE_BYTE_INDEXED, icm2);
+        g.translate(-3*incX, incY);
+
+        drawImage(g, TYPE_BYTE_INDEXED, icm4);
+        g.translate(incX, 0);
+    }
+
+
+
+     /* Size is chosen to match default imageable width of a NA letter
+      * page. This means there will be clipping, what is clipped will
+      * depend on PageFormat orientation.
+      */
+     public Dimension getPreferredSize() {
+        return new Dimension(468, 600);
+    }
+
+}
--- a/jdk/test/java/dyn/InvokeDynamicPrintArgs.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/dyn/InvokeDynamicPrintArgs.java	Mon Mar 07 11:37:54 2011 -0800
@@ -23,15 +23,19 @@
 
 /* @test
  * @summary smoke test for invokedynamic instructions
- * @library indify
+ * @build indify.Indify
  * @compile InvokeDynamicPrintArgs.java
  * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic
  *      indify.Indify
  *      --verify-specifier-count=3 --transitionalJSR292=false
  *      --expand-properties --classpath ${test.classes}
- *      --java InvokeDynamicPrintArgs --check-output
+ *      --java test.java.dyn.InvokeDynamicPrintArgs --check-output
  */
 
+package test.java.dyn;
+
+import org.junit.Test;
+
 import java.util.*;
 import java.io.*;
 
@@ -53,6 +57,20 @@
         closeBuf();
     }
 
+    @Test
+    public void testInvokeDynamicPrintArgs() throws IOException {
+        System.err.println(System.getProperties());
+        String testClassPath = System.getProperty("build.test.classes.dir");
+        if (testClassPath == null)  throw new RuntimeException();
+        String[] args = new String[]{
+            "--verify-specifier-count=3", "--transitionalJSR292=false",
+            "--expand-properties", "--classpath", testClassPath,
+            "--java", "test.java.dyn.InvokeDynamicPrintArgs", "--check-output"
+        };
+        System.err.println("Indify: "+Arrays.toString(args));
+        indify.Indify.main(args);
+    }
+
     private static PrintStream oldOut;
     private static ByteArrayOutputStream buf;
     private static void openBuf() {
@@ -79,11 +97,11 @@
     }
     private static final String[] EXPECT_OUTPUT = {
         "Printing some argument lists, starting with a empty one:",
-        "[InvokeDynamicPrintArgs, nothing, ()void][]",
-        "[InvokeDynamicPrintArgs, bar, (java.lang.String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar arg, 1]",
-        "[InvokeDynamicPrintArgs, bar2, (java.lang.String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar2 arg, 222]",
-        "[InvokeDynamicPrintArgs, baz, (java.lang.String,int,double)void, 1234.5][baz arg, 2, 3.14]",
-        "[InvokeDynamicPrintArgs, foo, (java.lang.String)void][foo arg]",
+        "[test.java.dyn.InvokeDynamicPrintArgs, nothing, ()void][]",
+        "[test.java.dyn.InvokeDynamicPrintArgs, bar, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar arg, 1]",
+        "[test.java.dyn.InvokeDynamicPrintArgs, bar2, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar2 arg, 222]",
+        "[test.java.dyn.InvokeDynamicPrintArgs, baz, (String,int,double)void, 1234.5][baz arg, 2, 3.14]",
+        "[test.java.dyn.InvokeDynamicPrintArgs, foo, (String)void][foo arg]",
         "Done printing argument lists."
     };
 
@@ -110,18 +128,15 @@
         return lookup().findStatic(lookup().lookupClass(), "bsm", MT_bsm());
     }
 
-    private static CallSite bsm2(Lookup caller, String name, MethodType type, Object arg) throws ReflectiveOperationException {
+    private static CallSite bsm2(Lookup caller, String name, MethodType type, Object... arg) throws ReflectiveOperationException {
         // ignore caller and name, but match the type:
         List<Object> bsmInfo = new ArrayList<>(Arrays.asList(caller, name, type));
-        if (arg instanceof Object[])
-            bsmInfo.addAll(Arrays.asList((Object[])arg));
-        else
-            bsmInfo.add(arg);
+        bsmInfo.addAll(Arrays.asList((Object[])arg));
         return new ConstantCallSite(MH_printArgs().bindTo(bsmInfo).asCollector(Object[].class, type.parameterCount()).asType(type));
     }
     private static MethodType MT_bsm2() {
         shouldNotCallThis();
-        return methodType(CallSite.class, Lookup.class, String.class, MethodType.class, Object.class);
+        return methodType(CallSite.class, Lookup.class, String.class, MethodType.class, Object[].class);
     }
     private static MethodHandle MH_bsm2() throws ReflectiveOperationException {
         shouldNotCallThis();
--- a/jdk/test/java/dyn/InvokeGenericTest.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/dyn/InvokeGenericTest.java	Mon Mar 07 11:37:54 2011 -0800
@@ -320,7 +320,7 @@
     MethodHandle callable(List<Class<?>> params) {
         MethodHandle mh = CALLABLES.get(params);
         if (mh == null) {
-            mh = collectArguments(collector_MH, methodType(Object.class, params));
+            mh = collector_MH.asType(methodType(Object.class, params));
             CALLABLES.put(params, mh);
         }
         return mh;
@@ -338,7 +338,7 @@
                 = LOOKUP.findStatic(LOOKUP.lookupClass(),
                                     "collector",
                                     methodType(Object.class, Object[].class));
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             throw new RuntimeException(ex);
         }
     }
--- a/jdk/test/java/dyn/JavaDocExamplesTest.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/dyn/JavaDocExamplesTest.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -74,7 +74,7 @@
 // static final private MethodHandle HASHCODE_1 = LOOKUP.findVirtual(Object.class,
 //     "hashCode", methodType(int.class));
 
-// form required if NoAccessException is intercepted:
+// form required if ReflectiveOperationException is intercepted:
 static final private MethodHandle CONCAT_2, HASHCODE_2;
 static {
   try {
@@ -82,7 +82,7 @@
       "concat", methodType(String.class, String.class));
     HASHCODE_2 = LOOKUP.findVirtual(Object.class,
       "hashCode", methodType(int.class));
-   } catch (NoAccessException ex) {
+   } catch (ReflectiveOperationException ex) {
      throw new RuntimeException(ex);
    }
 }
@@ -142,37 +142,79 @@
         Assert.assertEquals(exp, act);
     }
 
-static MethodHandle asList;
-    @Test public void testWithTypeHandler() throws Throwable {
+    @Test public void testMethodHandlesSummary() throws Throwable {
         {{
 {} /// JAVADOC
-MethodHandle makeEmptyList = MethodHandles.constant(List.class, Arrays.asList());
-MethodHandle asList = lookup()
-  .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class));
-
-JavaDocExamplesTest.asList = asList;
-/*
-static MethodHandle collectingTypeHandler(MethodHandle base, MethodType newType) {
-  return asList.asCollector(Object[].class, newType.parameterCount()).asType(newType);
-}
-*/
-
-MethodHandle collectingTypeHandler = lookup()
-  .findStatic(lookup().lookupClass(), "collectingTypeHandler",
-     methodType(MethodHandle.class, MethodHandle.class, MethodType.class));
-MethodHandle makeAnyList = makeEmptyList.withTypeHandler(collectingTypeHandler);
-
-assertEquals("[]", makeAnyList.invokeGeneric().toString());
-assertEquals("[1]", makeAnyList.invokeGeneric(1).toString());
-assertEquals("[two, too]", makeAnyList.invokeGeneric("two", "too").toString());
+Object x, y; String s; int i;
+MethodType mt; MethodHandle mh;
+MethodHandles.Lookup lookup = MethodHandles.lookup();
+// mt is (char,char)String
+mt = MethodType.methodType(String.class, char.class, char.class);
+mh = lookup.findVirtual(String.class, "replace", mt);
+s = (String) mh.invokeExact("daddy",'d','n');
+// invokeExact(Ljava/lang/String;CC)Ljava/lang/String;
+assert(s.equals("nanny"));
+// weakly typed invocation (using MHs.invoke)
+s = (String) mh.invokeWithArguments("sappy", 'p', 'v');
+assert(s.equals("savvy"));
+// mt is (Object[])List
+mt = MethodType.methodType(java.util.List.class, Object[].class);
+mh = lookup.findStatic(java.util.Arrays.class, "asList", mt);
+assert(mh.isVarargsCollector());
+x = mh.invokeGeneric("one", "two");
+// invokeGeneric(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;
+assert(x.equals(java.util.Arrays.asList("one","two")));
+// mt is (Object,Object,Object)Object
+mt = MethodType.genericMethodType(3);
+mh = mh.asType(mt);
+x = mh.invokeExact((Object)1, (Object)2, (Object)3);
+// invokeExact(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
+assert(x.equals(java.util.Arrays.asList(1,2,3)));
+// mt is { =&gt; int}
+mt = MethodType.methodType(int.class);
+mh = lookup.findVirtual(java.util.List.class, "size", mt);
+i = (int) mh.invokeExact(java.util.Arrays.asList(1,2,3));
+// invokeExact(Ljava/util/List;)I
+assert(i == 3);
+mt = MethodType.methodType(void.class, String.class);
+mh = lookup.findVirtual(java.io.PrintStream.class, "println", mt);
+mh.invokeExact(System.out, "Hello, world.");
+// invokeExact(Ljava/io/PrintStream;Ljava/lang/String;)V
+{}
             }}
     }
 
-static MethodHandle collectingTypeHandler(MethodHandle base, MethodType newType) {
-    //System.out.println("Converting "+asList+" to "+newType);
-    MethodHandle conv = asList.asCollector(Object[].class, newType.parameterCount()).asType(newType);
-    //System.out.println(" =>"+conv);
-    return conv;
+    @Test public void testAsVarargsCollector() throws Throwable {
+        {{
+{} /// JAVADOC
+MethodHandle asList = publicLookup()
+  .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class))
+  .asVarargsCollector(Object[].class);
+assertEquals("[]", asList.invokeGeneric().toString());
+assertEquals("[1]", asList.invokeGeneric(1).toString());
+assertEquals("[two, too]", asList.invokeGeneric("two", "too").toString());
+Object[] argv = { "three", "thee", "tee" };
+assertEquals("[three, thee, tee]", asList.invokeGeneric(argv).toString());
+List ls = (List) asList.invokeGeneric((Object)argv);
+assertEquals(1, ls.size());
+assertEquals("[three, thee, tee]", Arrays.toString((Object[])ls.get(0)));
+            }}
+    }
+
+    @Test public void testVarargsCollectorSuppression() throws Throwable {
+        {{
+{} /// JAVADOC
+MethodHandle vamh = publicLookup()
+  .findStatic(Arrays.class, "asList", methodType(List.class, Object[].class))
+  .asVarargsCollector(Object[].class);
+MethodHandle mh = MethodHandles.exactInvoker(vamh.type()).bindTo(vamh);
+assert(vamh.type().equals(mh.type()));
+assertEquals("[1, 2, 3]", vamh.invokeGeneric(1,2,3).toString());
+boolean failed = false;
+try { mh.invokeGeneric(1,2,3); }
+catch (WrongMethodTypeException ex) { failed = true; }
+assert(failed);
+{}
+            }}
+    }
 }
-
-}
--- a/jdk/test/java/dyn/MethodHandlesTest.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/dyn/MethodHandlesTest.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -323,6 +323,44 @@
         return x.getClass().getSimpleName();
     }
 
+    /** Return lambda(arg...[arity]) { new Object[]{ arg... } } */
+    static MethodHandle varargsList(int arity) {
+        return ValueConversions.varargsList(arity);
+    }
+    /** Return lambda(arg...[arity]) { Arrays.asList(arg...) } */
+    static MethodHandle varargsArray(int arity) {
+        return ValueConversions.varargsArray(arity);
+    }
+    /** Variation of varargsList, but with the given rtype. */
+    static MethodHandle varargsList(int arity, Class<?> rtype) {
+        MethodHandle list = varargsList(arity);
+        MethodType listType = list.type().changeReturnType(rtype);
+        if (List.class.isAssignableFrom(rtype) || rtype == void.class || rtype == Object.class) {
+            // OK
+        } else if (rtype.isAssignableFrom(String.class)) {
+            if (LIST_TO_STRING == null)
+                try {
+                    LIST_TO_STRING = PRIVATE.findStatic(PRIVATE.lookupClass(), "listToString",
+                                                        MethodType.methodType(String.class, List.class));
+                } catch (Exception ex) { throw new RuntimeException(ex); }
+            list = MethodHandles.filterReturnValue(list, LIST_TO_STRING);
+        } else if (rtype.isPrimitive()) {
+            if (LIST_TO_INT == null)
+                try {
+                    LIST_TO_INT = PRIVATE.findStatic(PRIVATE.lookupClass(), "listToInt",
+                                                     MethodType.methodType(int.class, List.class));
+                } catch (Exception ex) { throw new RuntimeException(ex); }
+            list = MethodHandles.filterReturnValue(list, LIST_TO_INT);
+            list = MethodHandles.explicitCastArguments(list, listType);
+        } else {
+            throw new RuntimeException("varargsList: "+rtype);
+        }
+        return list.asType(listType);
+    }
+    private static MethodHandle LIST_TO_STRING, LIST_TO_INT;
+    private static String listToString(List x) { return x.toString(); }
+    private static int listToInt(List x) { return x.toString().hashCode(); }
+
     static MethodHandle changeArgTypes(MethodHandle target, Class<?> argType) {
         return changeArgTypes(target, 0, 999, argType);
     }
@@ -458,8 +496,12 @@
         try {
             if (verbosity >= 4)  System.out.println("lookup via "+lookup+" of "+defc+" "+name+type);
             target = lookup.in(defc).findStatic(defc, name, type);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             noAccess = ex;
+            if (name.contains("bogus"))
+                assertTrue(noAccess instanceof NoSuchMethodException);
+            else
+                assertTrue(noAccess instanceof IllegalAccessException);
         }
         if (verbosity >= 3)
             System.out.println("findStatic "+lookup+": "+defc.getName()+"."+name+"/"+type+" => "+target
@@ -528,8 +570,12 @@
         try {
             if (verbosity >= 4)  System.out.println("lookup via "+lookup+" of "+defc+" "+name+type);
             target = lookup.in(defc).findVirtual(defc, methodName, type);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             noAccess = ex;
+            if (name.contains("bogus"))
+                assertTrue(noAccess instanceof NoSuchMethodException);
+            else
+                assertTrue(noAccess instanceof IllegalAccessException);
         }
         if (verbosity >= 3)
             System.out.println("findVirtual "+lookup+": "+defc.getName()+"."+name+"/"+type+" => "+target
@@ -558,11 +604,12 @@
         testFindSpecial(SubExample.class, Example.class, void.class, "v0");
         testFindSpecial(SubExample.class, Example.class, void.class, "pkg_v0");
         // Do some negative testing:
+        testFindSpecial(false, EXAMPLE, SubExample.class, Example.class, void.class, "bogus");
+        testFindSpecial(false, PRIVATE, SubExample.class, Example.class, void.class, "bogus");
         for (Lookup lookup : new Lookup[]{ PRIVATE, EXAMPLE, PACKAGE, PUBLIC }) {
             testFindSpecial(false, lookup, Object.class, Example.class, void.class, "v0");
             testFindSpecial(false, lookup, SubExample.class, Example.class, void.class, "<init>", int.class);
             testFindSpecial(false, lookup, SubExample.class, Example.class, void.class, "s0");
-            testFindSpecial(false, lookup, SubExample.class, Example.class, void.class, "bogus");
         }
     }
 
@@ -583,8 +630,12 @@
             if (verbosity >= 4)  System.out.println("lookup via "+lookup+" of "+defc+" "+name+type);
             if (verbosity >= 5)  System.out.println("  lookup => "+lookup.in(specialCaller));
             target = lookup.in(specialCaller).findSpecial(defc, name, type, specialCaller);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             noAccess = ex;
+            if (name.contains("bogus"))
+                assertTrue(noAccess instanceof NoSuchMethodException);
+            else
+                assertTrue(noAccess instanceof IllegalAccessException);
         }
         if (verbosity >= 3)
             System.out.println("findSpecial from "+specialCaller.getName()+" to "+defc.getName()+"."+name+"/"+type+" => "+target
@@ -639,8 +690,12 @@
         try {
             if (verbosity >= 4)  System.out.println("lookup via "+lookup+" of "+defc+" "+name+type);
             target = lookup.in(defc).bind(receiver, methodName, type);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             noAccess = ex;
+            if (name.contains("bogus"))
+                assertTrue(noAccess instanceof NoSuchMethodException);
+            else
+                assertTrue(noAccess instanceof IllegalAccessException);
         }
         if (verbosity >= 3)
             System.out.println("bind "+receiver+"."+name+"/"+type+" => "+target
@@ -698,14 +753,9 @@
                                    Class<?> defc, Class<?> rcvc, Class<?> ret, String name, Class<?>... params) throws Throwable {
         countTest(positive);
         MethodType type = MethodType.methodType(ret, params);
-        Method rmethod = null;
+        Method rmethod = defc.getDeclaredMethod(name, params);
         MethodHandle target = null;
         Exception noAccess = null;
-        try {
-            rmethod = defc.getDeclaredMethod(name, params);
-        } catch (NoSuchMethodException ex) {
-            throw new NoAccessException(ex);
-        }
         boolean isStatic = (rcvc == null);
         boolean isSpecial = (specialCaller != null);
         try {
@@ -714,8 +764,12 @@
                 target = lookup.in(specialCaller).unreflectSpecial(rmethod, specialCaller);
             else
                 target = lookup.in(defc).unreflect(rmethod);
-        } catch (NoAccessException ex) {
+        } catch (ReflectiveOperationException ex) {
             noAccess = ex;
+            if (name.contains("bogus"))
+                assertTrue(noAccess instanceof NoSuchMethodException);
+            else
+                assertTrue(noAccess instanceof IllegalAccessException);
         }
         if (verbosity >= 3)
             System.out.println("unreflect"+(isSpecial?"Special":"")+" "+defc.getName()+"."+name+"/"+type
@@ -824,25 +878,28 @@
                     if (type == float.class) {
                         float v = 'F';
                         if (isStatic)  v++;
-                        assert(value.equals(v));
+                        assertTrue(value.equals(v));
                     }
-                    assert(name.equals(field.getName()));
-                    assert(type.equals(field.getType()));
-                    assert(isStatic == (Modifier.isStatic(field.getModifiers())));
+                    assertTrue(name.equals(field.getName()));
+                    assertTrue(type.equals(field.getType()));
+                    assertTrue(isStatic == (Modifier.isStatic(field.getModifiers())));
                     cases.add(new Object[]{ field, value });
                 }
             }
+            cases.add(new Object[]{ new Object[]{ false, HasFields.class, "bogus_fD", double.class }, Error.class });
+            cases.add(new Object[]{ new Object[]{ true,  HasFields.class, "bogus_sL", Object.class }, Error.class });
             CASES = cases.toArray(new Object[0][]);
         }
     }
 
-    static final int TEST_UNREFLECT = 1, TEST_FIND_FIELD = 2, TEST_FIND_STATIC_FIELD = 3;
+    static final int TEST_UNREFLECT = 1, TEST_FIND_FIELD = 2, TEST_FIND_STATIC = 3, TEST_SETTER = 0x10;
     static boolean testModeMatches(int testMode, boolean isStatic) {
         switch (testMode) {
-        case TEST_FIND_STATIC_FIELD:    return isStatic;
+        case TEST_FIND_STATIC:          return isStatic;
         case TEST_FIND_FIELD:           return !isStatic;
-        default:                        return true;  // unreflect matches both
+        case TEST_UNREFLECT:            return true;  // unreflect matches both
         }
+        throw new InternalError("testMode="+testMode);
     }
 
     @Test
@@ -858,54 +915,161 @@
     @Test
     public void testFindStaticGetter() throws Throwable {
         startTest("findStaticGetter");
-        testGetter(TEST_FIND_STATIC_FIELD);
+        testGetter(TEST_FIND_STATIC);
     }
     public void testGetter(int testMode) throws Throwable {
         Lookup lookup = PRIVATE;  // FIXME: test more lookups than this one
         for (Object[] c : HasFields.CASES) {
-            Field f = (Field)c[0];
-            Object value = c[1];
-            Class<?> type = f.getType();
-            testGetter(lookup, f, type, value, testMode);
+            boolean positive = (c[1] != Error.class);
+            testGetter(positive, lookup, c[0], c[1], testMode);
+        }
+        testGetter(true, lookup,
+                   new Object[]{ true,  System.class, "out", java.io.PrintStream.class },
+                   System.out, testMode);
+        for (int isStaticN = 0; isStaticN <= 1; isStaticN++) {
+            testGetter(false, lookup,
+                       new Object[]{ (isStaticN != 0), System.class, "bogus", char.class },
+                       null, testMode);
         }
     }
-    public void testGetter(MethodHandles.Lookup lookup,
-            Field f, Class<?> type, Object value, int testMode) throws Throwable {
-        boolean isStatic = Modifier.isStatic(f.getModifiers());
-        Class<?> fclass = f.getDeclaringClass();
-        String   fname  = f.getName();
-        Class<?> ftype  = f.getType();
+    public void testGetter(boolean positive, MethodHandles.Lookup lookup,
+                           Object fieldRef, Object value, int testMode) throws Throwable {
+        testAccessor(positive, lookup, fieldRef, value, testMode);
+    }
+
+    public void testAccessor(boolean positive, MethodHandles.Lookup lookup,
+                             Object fieldRef, Object value, int testMode0) throws Throwable {
+        boolean isGetter = ((testMode0 & TEST_SETTER) == 0);
+        int testMode = testMode0 & ~TEST_SETTER;
+        boolean isStatic;
+        Class<?> fclass;
+        String   fname;
+        Class<?> ftype;
+        Field f = (fieldRef instanceof Field ? (Field)fieldRef : null);
+        if (f != null) {
+            isStatic = Modifier.isStatic(f.getModifiers());
+            fclass   = f.getDeclaringClass();
+            fname    = f.getName();
+            ftype    = f.getType();
+        } else {
+            Object[] scnt = (Object[]) fieldRef;
+            isStatic = (Boolean)  scnt[0];
+            fclass   = (Class<?>) scnt[1];
+            fname    = (String)   scnt[2];
+            ftype    = (Class<?>) scnt[3];
+            try {
+                f = fclass.getDeclaredField(fname);
+            } catch (ReflectiveOperationException ex) {
+                f = null;
+            }
+        }
         if (!testModeMatches(testMode, isStatic))  return;
-        countTest(true);
-        MethodType expType = MethodType.methodType(type, HasFields.class);
+        if (f == null && testMode == TEST_UNREFLECT)  return;
+        countTest(positive);
+        MethodType expType;
+        if (isGetter)
+            expType = MethodType.methodType(ftype, HasFields.class);
+        else
+            expType = MethodType.methodType(void.class, HasFields.class, ftype);
         if (isStatic)  expType = expType.dropParameterTypes(0, 1);
-        MethodHandle mh = lookup.unreflectGetter(f);
+        Exception noAccess = null;
+        MethodHandle mh;
+        try {
+            switch (testMode0) {
+            case TEST_UNREFLECT:   mh = lookup.unreflectGetter(f);                      break;
+            case TEST_FIND_FIELD:  mh = lookup.findGetter(fclass, fname, ftype);        break;
+            case TEST_FIND_STATIC: mh = lookup.findStaticGetter(fclass, fname, ftype);  break;
+            case TEST_SETTER|
+                 TEST_UNREFLECT:   mh = lookup.unreflectSetter(f);                      break;
+            case TEST_SETTER|
+                 TEST_FIND_FIELD:  mh = lookup.findSetter(fclass, fname, ftype);        break;
+            case TEST_SETTER|
+                 TEST_FIND_STATIC: mh = lookup.findStaticSetter(fclass, fname, ftype);  break;
+            default:
+                throw new InternalError("testMode="+testMode);
+            }
+        } catch (ReflectiveOperationException ex) {
+            mh = null;
+            noAccess = ex;
+            if (fname.contains("bogus"))
+                assertTrue(noAccess instanceof NoSuchFieldException);
+            else
+                assertTrue(noAccess instanceof IllegalAccessException);
+        }
+        if (verbosity >= 3)
+            System.out.println("find"+(isStatic?"Static":"")+(isGetter?"Getter":"Setter")+" "+fclass.getName()+"."+fname+"/"+ftype
+                               +" => "+mh
+                               +(noAccess == null ? "" : " !! "+noAccess));
+        if (positive && noAccess != null)  throw new RuntimeException(noAccess);
+        assertEquals(positive ? "positive test" : "negative test erroneously passed", positive, mh != null);
+        if (!positive)  return; // negative test failed as expected
+        assertEquals((isStatic ? 0 : 1)+(isGetter ? 0 : 1), mh.type().parameterCount());
+
+
         assertSame(mh.type(), expType);
         assertNameStringContains(mh, fname);
         HasFields fields = new HasFields();
         Object sawValue;
-        Class<?> rtype = type;
-        if (type != int.class)  rtype = Object.class;
-        mh = MethodHandles.convertArguments(mh, mh.type().generic().changeReturnType(rtype));
-        Object expValue = value;
-        for (int i = 0; i <= 1; i++) {
-            if (isStatic) {
-                if (type == int.class)
-                    sawValue = (int) mh.invokeExact();  // do these exactly
-                else
-                    sawValue = mh.invokeExact();
-            } else {
-                if (type == int.class)
-                    sawValue = (int) mh.invokeExact((Object) fields);
-                else
-                    sawValue = mh.invokeExact((Object) fields);
+        Class<?> vtype = ftype;
+        if (ftype != int.class)  vtype = Object.class;
+        if (isGetter) {
+            mh = MethodHandles.convertArguments(mh, mh.type().generic()
+                                                .changeReturnType(vtype));
+        } else {
+            int last = mh.type().parameterCount() - 1;
+            mh = MethodHandles.convertArguments(mh, mh.type().generic()
+                                                .changeReturnType(void.class)
+                                                .changeParameterType(last, vtype));
+        }
+        if (f != null && f.getDeclaringClass() == HasFields.class) {
+            assertEquals(f.get(fields), value);  // clean to start with
+        }
+        if (isGetter) {
+            Object expValue = value;
+            for (int i = 0; i <= 1; i++) {
+                if (isStatic) {
+                    if (ftype == int.class)
+                        sawValue = (int) mh.invokeExact();  // do these exactly
+                    else
+                        sawValue = mh.invokeExact();
+                } else {
+                    if (ftype == int.class)
+                        sawValue = (int) mh.invokeExact((Object) fields);
+                    else
+                        sawValue = mh.invokeExact((Object) fields);
+                }
+                assertEquals(sawValue, expValue);
+                if (f != null && f.getDeclaringClass() == HasFields.class
+                    && !Modifier.isFinal(f.getModifiers())) {
+                    Object random = randomArg(ftype);
+                    f.set(fields, random);
+                    expValue = random;
+                } else {
+                    break;
+                }
             }
-            assertEquals(sawValue, expValue);
-            Object random = randomArg(type);
-            f.set(fields, random);
-            expValue = random;
+        } else {
+            for (int i = 0; i <= 1; i++) {
+                Object putValue = randomArg(ftype);
+                if (isStatic) {
+                    if (ftype == int.class)
+                        mh.invokeExact((int)putValue);  // do these exactly
+                    else
+                        mh.invokeExact(putValue);
+                } else {
+                    if (ftype == int.class)
+                        mh.invokeExact((Object) fields, (int)putValue);
+                    else
+                        mh.invokeExact((Object) fields, putValue);
+                }
+                if (f != null && f.getDeclaringClass() == HasFields.class) {
+                    assertEquals(f.get(fields), putValue);
+                }
+            }
         }
-        f.set(fields, value);  // put it back
+        if (f != null && f.getDeclaringClass() == HasFields.class) {
+            f.set(fields, value);  // put it back
+        }
     }
 
 
@@ -922,61 +1086,24 @@
     @Test
     public void testFindStaticSetter() throws Throwable {
         startTest("findStaticSetter");
-        testSetter(TEST_FIND_STATIC_FIELD);
+        testSetter(TEST_FIND_STATIC);
     }
     public void testSetter(int testMode) throws Throwable {
         Lookup lookup = PRIVATE;  // FIXME: test more lookups than this one
         startTest("unreflectSetter");
         for (Object[] c : HasFields.CASES) {
-            Field f = (Field)c[0];
-            Object value = c[1];
-            Class<?> type = f.getType();
-            testSetter(lookup, f, type, value, testMode);
+            boolean positive = (c[1] != Error.class);
+            testSetter(positive, lookup, c[0], c[1], testMode);
+        }
+        for (int isStaticN = 0; isStaticN <= 1; isStaticN++) {
+            testSetter(false, lookup,
+                       new Object[]{ (isStaticN != 0), System.class, "bogus", char.class },
+                       null, testMode);
         }
     }
-    public void testSetter(MethodHandles.Lookup lookup,
-            Field f, Class<?> type, Object value, int testMode) throws Throwable {
-        boolean isStatic = Modifier.isStatic(f.getModifiers());
-        Class<?> fclass = f.getDeclaringClass();
-        String   fname  = f.getName();
-        Class<?> ftype  = f.getType();
-        if (!testModeMatches(testMode, isStatic))  return;
-        countTest(true);
-        MethodType expType = MethodType.methodType(void.class, HasFields.class, type);
-        if (isStatic)  expType = expType.dropParameterTypes(0, 1);
-        MethodHandle mh;
-        if (testMode == TEST_UNREFLECT)
-            mh = lookup.unreflectSetter(f);
-        else if (testMode == TEST_FIND_FIELD)
-            mh = lookup.findSetter(fclass, fname, ftype);
-        else if (testMode == TEST_FIND_STATIC_FIELD)
-            mh = lookup.findStaticSetter(fclass, fname, ftype);
-        else  throw new InternalError();
-        assertSame(mh.type(), expType);
-        assertNameStringContains(mh, fname);
-        HasFields fields = new HasFields();
-        Object sawValue;
-        Class<?> vtype = type;
-        if (type != int.class)  vtype = Object.class;
-        int last = mh.type().parameterCount() - 1;
-        mh = MethodHandles.convertArguments(mh, mh.type().generic().changeReturnType(void.class).changeParameterType(last, vtype));
-        assertEquals(f.get(fields), value);  // clean to start with
-        for (int i = 0; i <= 1; i++) {
-            Object putValue = randomArg(type);
-            if (isStatic) {
-                if (type == int.class)
-                    mh.invokeExact((int)putValue);  // do these exactly
-                else
-                    mh.invokeExact(putValue);
-            } else {
-                if (type == int.class)
-                    mh.invokeExact((Object) fields, (int)putValue);
-                else
-                    mh.invokeExact((Object) fields, putValue);
-            }
-            assertEquals(f.get(fields), putValue);
-        }
-        f.set(fields, value);  // put it back
+    public void testSetter(boolean positive, MethodHandles.Lookup lookup,
+                           Object fieldRef, Object value, int testMode) throws Throwable {
+        testAccessor(positive, lookup, fieldRef, value, testMode | TEST_SETTER);
     }
 
     @Test
@@ -1108,18 +1235,6 @@
         }
     }
 
-    static MethodHandle typeHandler2(MethodHandle target, MethodType newType) {
-        MethodType oldType = target.type();
-        int oldArity = oldType.parameterCount();
-        int newArity = newType.parameterCount();
-        if (newArity < oldArity)
-            return MethodHandles.insertArguments(target, oldArity, "OPTIONAL");
-        else if (newArity > oldArity)
-            return MethodHandles.dropArguments(target, oldArity-1, newType.parameterType(oldArity-1));
-        else
-            return target;  // attempt no further conversions
-    }
-
     @Test
     public void testConvertArguments() throws Throwable {
         if (CAN_SKIP_WORKING)  return;
@@ -1137,23 +1252,6 @@
         testConvert(true, true,  id, rtype, name, params);
     }
 
-    @Test
-    public void testTypeHandler() throws Throwable {
-        MethodHandle id = Callee.ofType(1);
-        MethodHandle th2 = PRIVATE.findStatic(MethodHandlesTest.class, "typeHandler2",
-                               MethodType.methodType(MethodHandle.class, MethodHandle.class, MethodType.class));
-        MethodHandle id2 = id.withTypeHandler(th2);
-        testConvert(true,  false, id2, null, "id", Object.class);
-        testConvert(true,  true,  id2, null, "id", Object.class);
-        if (true)  return;  //FIXME
-        testConvert(true,  false, id2, null, "id", String.class);  // FIXME: throws WMT
-        testConvert(false, true,  id2, null, "id", String.class);  // FIXME: should not succeed
-        testConvert(false, false, id2, null, "id", Object.class, String.class); //FIXME: array[1] line 1164
-        testConvert(true,  true,  id2, null, "id", Object.class, String.class);
-        testConvert(false, false, id2, null, "id");
-        testConvert(true,  true,  id2, null, "id");
-    }
-
     void testConvert(boolean positive, boolean useAsType,
                      MethodHandle id, Class<?> rtype, String name, Class<?>... params) throws Throwable {
         countTest(positive);
@@ -1183,9 +1281,9 @@
         RuntimeException error = null;
         try {
             if (useAsType)
-                target = MethodHandles.convertArguments(id, newType);
+                target = id.asType(newType);
             else
-                target = id.asType(newType);
+                target = MethodHandles.convertArguments(id, newType);
         } catch (RuntimeException ex) {
             error = ex;
         }
@@ -1205,6 +1303,20 @@
     }
 
     @Test
+    public void testVarargsCollector() throws Throwable {
+        MethodHandle vac0 = PRIVATE.findStatic(MethodHandlesTest.class, "called",
+                               MethodType.methodType(Object.class, String.class, Object[].class));
+        vac0 = vac0.bindTo("vac");
+        MethodHandle vac = vac0.asVarargsCollector(Object[].class);
+        testConvert(true,  true,  vac.asType(MethodType.genericMethodType(0)), null, "vac");
+        testConvert(true,  true,  vac.asType(MethodType.genericMethodType(0)), null, "vac");
+        for (Class<?> at : new Class[] { Object.class, String.class, Integer.class }) {
+            testConvert(true,  true,  vac.asType(MethodType.genericMethodType(1)), null, "vac", at);
+            testConvert(true,  true,  vac.asType(MethodType.genericMethodType(2)), null, "vac", at, at);
+        }
+    }
+
+    @Test
     public void testPermuteArguments() throws Throwable {
         if (CAN_SKIP_WORKING)  return;
         startTest("permuteArguments");
@@ -1300,7 +1412,7 @@
                 types[i] = args[i].getClass();
         }
         int inargs = args.length, outargs = reorder.length;
-        assert(inargs == types.length);
+        assertTrue(inargs == types.length);
         if (verbosity >= 3)
             System.out.println("permuteArguments "+Arrays.toString(reorder));
         Object[] permArgs = new Object[outargs];
@@ -1317,7 +1429,7 @@
         }
         MethodType inType  = MethodType.methodType(Object.class, types);
         MethodType outType = MethodType.methodType(Object.class, permTypes);
-        MethodHandle target = MethodHandles.convertArguments(ValueConversions.varargsList(outargs), outType);
+        MethodHandle target = MethodHandles.convertArguments(varargsList(outargs), outType);
         MethodHandle newTarget = MethodHandles.permuteArguments(target, inType, reorder);
         Object result = newTarget.invokeWithArguments(args);
         Object expected = Arrays.asList(permArgs);
@@ -1344,7 +1456,7 @@
     }
     public void testSpreadArguments(Class<?> argType, int pos, int nargs) throws Throwable {
         countTest();
-        MethodHandle target = ValueConversions.varargsArray(nargs);
+        MethodHandle target = varargsArray(nargs);
         MethodHandle target2 = changeArgTypes(target, argType);
         if (verbosity >= 3)
             System.out.println("spread into "+target2+" ["+pos+".."+nargs+"]");
@@ -1374,7 +1486,7 @@
             spreadParams.clear(); spreadParams.add(Object[].class);
         }
         MethodType newType = MethodType.methodType(Object.class, newParams);
-        MethodHandle result = MethodHandles.spreadArguments(target2, newType);
+        MethodHandle result = target2.asSpreader(Object[].class, nargs-pos).asType(newType);
         Object[] returnValue;
         if (pos == 0) {
             // In the following line, the first cast implies
@@ -1408,7 +1520,7 @@
     public void testCollectArguments(Class<?> argType, int pos, int nargs) throws Throwable {
         countTest();
         // fake up a MH with the same type as the desired adapter:
-        MethodHandle fake = ValueConversions.varargsArray(nargs);
+        MethodHandle fake = varargsArray(nargs);
         fake = changeArgTypes(fake, argType);
         MethodType newType = fake.type();
         Object[] args = randomArgs(newType.parameterArray());
@@ -1416,12 +1528,12 @@
         Object[] collectedArgs = Arrays.copyOfRange(args, 0, pos+1);
         collectedArgs[pos] = Arrays.copyOfRange(args, pos, args.length);
         // here is the MH which will witness the collected argument tail:
-        MethodHandle target = ValueConversions.varargsArray(pos+1);
+        MethodHandle target = varargsArray(pos+1);
         target = changeArgTypes(target, 0, pos, argType);
         target = changeArgTypes(target, pos, pos+1, Object[].class);
         if (verbosity >= 3)
             System.out.println("collect from "+Arrays.asList(args)+" ["+pos+".."+nargs+"]");
-        MethodHandle result = MethodHandles.collectArguments(target, newType);
+        MethodHandle result = target.asCollector(Object[].class, nargs-pos).asType(newType);
         Object[] returnValue = (Object[]) result.invokeWithArguments(args);
 //        assertTrue(returnValue.length == pos+1 && returnValue[pos] instanceof Object[]);
 //        returnValue[pos] = Arrays.asList((Object[]) returnValue[pos]);
@@ -1445,7 +1557,7 @@
 
     void testInsertArguments(int nargs, int pos, int ins) throws Throwable {
         countTest();
-        MethodHandle target = ValueConversions.varargsArray(nargs + ins);
+        MethodHandle target = varargsArray(nargs + ins);
         Object[] args = randomArgs(target.type().parameterArray());
         List<Object> resList = Arrays.asList(args);
         List<Object> argsToPass = new ArrayList<Object>(resList);
@@ -1465,6 +1577,55 @@
     }
 
     @Test
+    public void testFilterReturnValue() throws Throwable {
+        if (CAN_SKIP_WORKING)  return;
+        startTest("filterReturnValue");
+        Class<?> classOfVCList = varargsList(1).invokeWithArguments(0).getClass();
+        assertTrue(List.class.isAssignableFrom(classOfVCList));
+        for (int nargs = 0; nargs <= 3; nargs++) {
+            for (Class<?> rtype : new Class[] { Object.class,
+                                                List.class,
+                                                int.class,
+                                                //byte.class, //FIXME: add this
+                                                //long.class, //FIXME: add this
+                                                CharSequence.class,
+                                                String.class }) {
+                testFilterReturnValue(nargs, rtype);
+            }
+        }
+    }
+
+    void testFilterReturnValue(int nargs, Class<?> rtype) throws Throwable {
+        countTest();
+        MethodHandle target = varargsList(nargs, rtype);
+        MethodHandle filter;
+        if (List.class.isAssignableFrom(rtype) || rtype.isAssignableFrom(List.class))
+            filter = varargsList(1);  // add another layer of list-ness
+        else
+            filter = MethodHandles.identity(rtype);
+        filter = filter.asType(MethodType.methodType(target.type().returnType(), rtype));
+        Object[] argsToPass = randomArgs(nargs, Object.class);
+        if (verbosity >= 3)
+            System.out.println("filter "+target+" to "+rtype.getSimpleName()+" with "+filter);
+        MethodHandle target2 = MethodHandles.filterReturnValue(target, filter);
+        if (verbosity >= 4)
+            System.out.println("filtered target: "+target2);
+        // Simulate expected effect of filter on return value:
+        Object unfiltered = target.invokeWithArguments(argsToPass);
+        Object expected = filter.invokeWithArguments(unfiltered);
+        if (verbosity >= 4)
+            System.out.println("unfiltered: "+unfiltered+" : "+unfiltered.getClass().getSimpleName());
+        if (verbosity >= 4)
+            System.out.println("expected: "+expected+" : "+expected.getClass().getSimpleName());
+        Object result = target2.invokeWithArguments(argsToPass);
+        if (verbosity >= 3)
+            System.out.println("result: "+result+" : "+result.getClass().getSimpleName());
+        if (!expected.equals(result))
+            System.out.println("*** fail at n/rt = "+nargs+"/"+rtype.getSimpleName()+": "+Arrays.asList(argsToPass)+" => "+result+" != "+expected);
+        assertEquals(expected, result);
+    }
+
+    @Test
     public void testFilterArguments() throws Throwable {
         if (CAN_SKIP_WORKING)  return;
         startTest("filterArguments");
@@ -1477,8 +1638,8 @@
 
     void testFilterArguments(int nargs, int pos) throws Throwable {
         countTest();
-        MethodHandle target = ValueConversions.varargsList(nargs);
-        MethodHandle filter = ValueConversions.varargsList(1);
+        MethodHandle target = varargsList(nargs);
+        MethodHandle filter = varargsList(1);
         filter = MethodHandles.convertArguments(filter, filter.type().generic());
         Object[] argsToPass = randomArgs(nargs, Object.class);
         if (verbosity >= 3)
@@ -1492,7 +1653,7 @@
         if (verbosity >= 3)
             System.out.println("result: "+result);
         if (!expected.equals(result))
-            System.out.println("*** fail at n/p = "+nargs+"/"+pos+": "+argsToPass+" => "+result);
+            System.out.println("*** fail at n/p = "+nargs+"/"+pos+": "+Arrays.asList(argsToPass)+" => "+result+" != "+expected);
         assertEquals(expected, result);
     }
 
@@ -1512,8 +1673,8 @@
     void testFoldArguments(int nargs, int pos, int fold) throws Throwable {
         if (pos != 0)  return;  // can fold only at pos=0 for now
         countTest();
-        MethodHandle target = ValueConversions.varargsList(1 + nargs);
-        MethodHandle combine = ValueConversions.varargsList(fold).asType(MethodType.genericMethodType(fold));
+        MethodHandle target = varargsList(1 + nargs);
+        MethodHandle combine = varargsList(fold).asType(MethodType.genericMethodType(fold));
         List<Object> argsToPass = Arrays.asList(randomArgs(nargs, Object.class));
         if (verbosity >= 3)
             System.out.println("fold "+target+" with "+combine);
@@ -1529,7 +1690,7 @@
         if (verbosity >= 3)
             System.out.println("result: "+result);
         if (!expected.equals(result))
-            System.out.println("*** fail at n/p/f = "+nargs+"/"+pos+"/"+fold+": "+argsToPass+" => "+result);
+            System.out.println("*** fail at n/p/f = "+nargs+"/"+pos+"/"+fold+": "+argsToPass+" => "+result+" != "+expected);
         assertEquals(expected, result);
     }
 
@@ -1548,7 +1709,7 @@
 
     void testDropArguments(int nargs, int pos, int drop) throws Throwable {
         countTest();
-        MethodHandle target = ValueConversions.varargsArray(nargs);
+        MethodHandle target = varargsArray(nargs);
         Object[] args = randomArgs(target.type().parameterArray());
         MethodHandle target2 = MethodHandles.dropArguments(target, pos,
                 Collections.nCopies(drop, Object.class).toArray(new Class[0]));
@@ -1599,7 +1760,8 @@
         boolean testRetCode = type.returnType() != void.class;
         MethodHandle target = PRIVATE.findStatic(MethodHandlesTest.class, "invokee",
                                 MethodType.genericMethodType(0, true));
-        target = MethodHandles.collectArguments(target, type);
+        assertTrue(target.isVarargsCollector());
+        target = target.asType(type);
         Object[] args = randomArgs(type.parameterArray());
         List<Object> targetPlusArgs = new ArrayList<Object>(Arrays.asList(args));
         targetPlusArgs.add(0, target);
@@ -1644,14 +1806,14 @@
         assertCalled("invokee", args);
         // varargs invoker #0
         calledLog.clear();
-        inv = MethodHandles.varargsInvoker(type, 0);
+        inv = MethodHandles.spreadInvoker(type, 0);
         result = inv.invokeExact(target, args);
         if (testRetCode)  assertEquals(code, result);
         assertCalled("invokee", args);
         if (nargs >= 1) {
             // varargs invoker #1
             calledLog.clear();
-            inv = MethodHandles.varargsInvoker(type, 1);
+            inv = MethodHandles.spreadInvoker(type, 1);
             result = inv.invokeExact(target, args[0], Arrays.copyOfRange(args, 1, nargs));
             if (testRetCode)  assertEquals(code, result);
             assertCalled("invokee", args);
@@ -1659,7 +1821,7 @@
         if (nargs >= 2) {
             // varargs invoker #2
             calledLog.clear();
-            inv = MethodHandles.varargsInvoker(type, 2);
+            inv = MethodHandles.spreadInvoker(type, 2);
             result = inv.invokeExact(target, args[0], args[1], Arrays.copyOfRange(args, 2, nargs));
             if (testRetCode)  assertEquals(code, result);
             assertCalled("invokee", args);
@@ -1667,7 +1829,7 @@
         if (nargs >= 3) {
             // varargs invoker #3
             calledLog.clear();
-            inv = MethodHandles.varargsInvoker(type, 3);
+            inv = MethodHandles.spreadInvoker(type, 3);
             result = inv.invokeExact(target, args[0], args[1], args[2], Arrays.copyOfRange(args, 3, nargs));
             if (testRetCode)  assertEquals(code, result);
             assertCalled("invokee", args);
@@ -1676,7 +1838,7 @@
             // varargs invoker #0..N
             countTest();
             calledLog.clear();
-            inv = MethodHandles.varargsInvoker(type, k);
+            inv = MethodHandles.spreadInvoker(type, k);
             List<Object> targetPlusVarArgs = new ArrayList<Object>(targetPlusArgs);
             List<Object> tailList = targetPlusVarArgs.subList(1+k, 1+nargs);
             Object[] tail = tailList.toArray();
@@ -1823,7 +1985,7 @@
         MethodHandle thrower = throwOrReturn.asType(MethodType.genericMethodType(2));
         while (thrower.type().parameterCount() < nargs)
             thrower = MethodHandles.dropArguments(thrower, thrower.type().parameterCount(), Object.class);
-        MethodHandle catcher = ValueConversions.varargsList(1+nargs).asType(MethodType.genericMethodType(1+nargs));
+        MethodHandle catcher = varargsList(1+nargs).asType(MethodType.genericMethodType(1+nargs));
         MethodHandle target = MethodHandles.catchException(thrower,
                 thrown.getClass(), catcher);
         assertEquals(thrower.type(), target.type());
@@ -2089,25 +2251,12 @@
             }
         }
         // Test error checking:
-        MethodHandle genericMH = ValueConversions.varargsArray(0);
-        genericMH = MethodHandles.convertArguments(genericMH, genericMH.type().generic());
-        for (Class<?> sam : new Class[] { Runnable.class,
-                                          Fooable.class,
-                                          Iterable.class }) {
-            try {
-                // Must throw, because none of these guys has generic type.
-                MethodHandles.asInstance(genericMH, sam);
-                System.out.println("Failed to throw");
-                assertTrue(false);
-            } catch (IllegalArgumentException ex) {
-            }
-        }
         for (Class<?> nonSAM : new Class[] { Object.class,
                                              String.class,
                                              CharSequence.class,
                                              Example.class }) {
             try {
-                MethodHandles.asInstance(ValueConversions.varargsArray(0), nonSAM);
+                MethodHandles.asInstance(varargsArray(0), nonSAM);
                 System.out.println("Failed to throw");
                 assertTrue(false);
             } catch (IllegalArgumentException ex) {
@@ -2159,12 +2308,13 @@
             MethodHandle array = null;
             try {
                 array = lookup.findStatic(ValueConversions.class, name, type);
-            } catch (NoAccessException ex) {
+            } catch (ReflectiveOperationException ex) {
+                // break from loop!
             }
             if (array == null)  break;
             arrays.add(array);
         }
-        assert(arrays.size() == 11);  // current number of methods
+        assertTrue(arrays.size() == 11);  // current number of methods
         return arrays.toArray(new MethodHandle[0]);
     }
     static final MethodHandle[] ARRAYS = makeArrays();
@@ -2211,22 +2361,23 @@
                                      Object a8, Object a9)
                 { return makeList(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
     static MethodHandle[] makeLists() {
-        ArrayList<MethodHandle> arrays = new ArrayList<MethodHandle>();
+        ArrayList<MethodHandle> lists = new ArrayList<MethodHandle>();
         MethodHandles.Lookup lookup = IMPL_LOOKUP;
         for (;;) {
-            int nargs = arrays.size();
+            int nargs = lists.size();
             MethodType type = MethodType.genericMethodType(nargs).changeReturnType(List.class);
             String name = "list";
-            MethodHandle array = null;
+            MethodHandle list = null;
             try {
-                array = lookup.findStatic(ValueConversions.class, name, type);
-            } catch (NoAccessException ex) {
+                list = lookup.findStatic(ValueConversions.class, name, type);
+            } catch (ReflectiveOperationException ex) {
+                // break from loop!
             }
-            if (array == null)  break;
-            arrays.add(array);
+            if (list == null)  break;
+            lists.add(list);
         }
-        assert(arrays.size() == 11);  // current number of methods
-        return arrays.toArray(new MethodHandle[0]);
+        assertTrue(lists.size() == 11);  // current number of methods
+        return lists.toArray(new MethodHandle[0]);
     }
     static final MethodHandle[] LISTS = makeLists();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/dyn/MethodTypeTest.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,542 @@
+/*
+ * Copyright 2008, 2011 Sun Microsystems, Inc.  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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @summary unit tests for java.dyn.MethodType
+ * @compile MethodTypeTest.java
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.MethodTypeTest
+ */
+
+package test.java.dyn;
+
+import sun.dyn.MemberName;
+import java.dyn.MethodType;
+import java.lang.reflect.Method;
+
+import java.util.*;
+import org.junit.*;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author jrose
+ */
+public class MethodTypeTest {
+
+    private Class<?> rtype;
+    private Class<?>[] ptypes;
+    private MethodType mt_viS, mt_OO, mt_OO2, mt_vv, mt_Vv, mt_Ov;
+    private MethodType mt_iSI, mt_ISi, mt_ISI, mt_iSi;
+    private MethodType mt_viO, mt_iO2, mt_OOi, mt_iOi;
+    private MethodType mt_VIO, mt_IO2, mt_OOI, mt_IOI, mt_VIS;
+    private MethodType mt_vOiSzA, mt_OO99;
+    private MethodType[] GALLERY;
+    private Method compareTo;
+
+    @Before
+    public void setUp() throws Exception {
+        rtype = void.class;
+        ptypes = new Class<?>[] { int.class, String.class };
+
+        mt_viS = MethodType.methodType(void.class, int.class, String.class);
+        mt_OO = MethodType.methodType(Object.class, Object.class);
+        mt_OO2 = MethodType.methodType(Object.class, Object.class, Object.class);
+        mt_vv = MethodType.methodType(void.class);
+        mt_Vv = MethodType.methodType(Void.class);
+        mt_Ov = MethodType.methodType(Object.class);
+        mt_iSI = MethodType.methodType(int.class, String.class, Integer.class);
+        mt_ISi = MethodType.methodType(Integer.class, String.class, int.class);
+        mt_ISI = MethodType.methodType(Integer.class, String.class, Integer.class);
+        mt_iSi = MethodType.methodType(int.class, String.class, int.class);
+
+        compareTo = String.class.getDeclaredMethod("compareTo", String.class);
+
+        mt_viO = MethodType.methodType(void.class, int.class, Object.class);
+        mt_iO2 = MethodType.methodType(int.class, Object.class, Object.class);
+        mt_OOi = MethodType.methodType(Object.class, Object.class, int.class);
+        mt_iOi = MethodType.methodType(int.class, Object.class, int.class);
+
+        mt_VIO = MethodType.methodType(Void.class, Integer.class, Object.class);
+        mt_IO2 = MethodType.methodType(Integer.class, Object.class, Object.class);
+        mt_OOI = MethodType.methodType(Object.class, Object.class, Integer.class);
+        mt_IOI = MethodType.methodType(Integer.class, Object.class, Integer.class);
+        mt_VIS = MethodType.methodType(Void.class, Integer.class, String.class);
+
+        mt_vOiSzA = MethodType.methodType(void.class, Object.class, int.class, String.class, boolean.class, Object[].class);
+        mt_OO99 = MethodType.genericMethodType(99);
+
+        GALLERY = new MethodType[] {
+            mt_viS, mt_OO, mt_OO2, mt_vv, mt_Vv, mt_Ov,
+            mt_iSI, mt_ISi, mt_ISI, mt_iSi,
+            mt_viO, mt_iO2, mt_OOi, mt_iOi,
+            mt_VIO, mt_IO2, mt_OOI, mt_IOI,
+            mt_VIS, mt_vOiSzA, mt_OO99
+        };
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    /** Make sure the method types are all distinct. */
+    @Test
+    public void testDistinct() {
+        List<MethodType> gallery2 = new ArrayList<>();
+        for (MethodType mt : GALLERY) {
+            assertFalse(mt.toString(), gallery2.contains(mt));
+            gallery2.add(mt);
+        }
+        // check self-equality also:
+        assertEquals(Arrays.asList(GALLERY), gallery2);
+    }
+
+    /**
+     * Test of make method, of class MethodType.
+     */
+    @Test
+    public void testMake_Class_ClassArr() {
+        System.out.println("make (from type array)");
+        MethodType result = MethodType.methodType(rtype, ptypes);
+        assertSame(mt_viS, result);
+    }
+
+    /**
+     * Test of make method, of class MethodType.
+     */
+    @Test
+    public void testMake_Class_List() {
+        System.out.println("make (from type list)");
+        MethodType result = MethodType.methodType(rtype, Arrays.asList(ptypes));
+        assertSame(mt_viS, result);
+    }
+
+    /**
+     * Test of make method, of class MethodType.
+     */
+    @Test
+    public void testMake_3args() {
+        System.out.println("make (from type with varargs)");
+        MethodType result = MethodType.methodType(rtype, ptypes[0], ptypes[1]);
+        assertSame(mt_viS, result);
+    }
+
+    /**
+     * Test of make method, of class MethodType.
+     */
+    @Test
+    public void testMake_Class() {
+        System.out.println("make (from single type)");
+        Class<?> rt = Integer.class;
+        MethodType expResult = MethodType.methodType(rt, new Class<?>[0]);
+        MethodType result = MethodType.methodType(rt);
+        assertSame(expResult, result);
+    }
+
+    @Test
+    public void testMakeGeneric() {
+        System.out.println("makeGeneric");
+        int objectArgCount = 2;
+        MethodType expResult = mt_OO2;
+        MethodType result = MethodType.genericMethodType(objectArgCount);
+        assertSame(expResult, result);
+    }
+
+    /**
+     * Test of make method, of class MethodType.
+     */
+    @Test
+    public void testMake_Method() {
+        System.out.println("make (via MemberName.getMethodType)");
+        MethodType expResult = MethodType.methodType(int.class, String.class);
+        MemberName name = new MemberName(compareTo);
+        MethodType result = name.getMethodType();
+        assertSame(expResult, result);
+    }
+
+    /**
+     * Test of make method, of class MethodType.
+     */
+    @Test
+    public void testMake_MethodType() {
+        System.out.println("make (from rtype, MethodType)");
+        MethodType expResult = mt_iO2;
+        MethodType result = MethodType.methodType(int.class, mt_IO2);
+        assertSame(expResult, result);
+    }
+
+    /**
+     * Test of make method, of class MethodType.
+     */
+    @Test
+    public void testMake_String_ClassLoader() {
+        System.out.println("make (from bytecode signature)");
+        ClassLoader loader = null;
+        MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        String obj = "Ljava/lang/Object;";
+        assertEquals(obj, concat(Object.class));
+        String[] expResults = {
+            "(ILjava/lang/String;)V",
+            concat("(", obj, 2, ")", Object.class),
+            "()V", "()"+obj,
+            concat("(", String.class, Integer.class, ")I"),
+            concat("(", String.class, "I)", Integer.class),
+            concat("(", String.class, Integer.class, ")", Integer.class),
+            concat("(", String.class, "I)I")
+        };
+        for (int i = 0; i < instances.length; i++) {
+            MethodType instance = instances[i];
+            String result = instance.toMethodDescriptorString();
+            assertEquals("#"+i, expResults[i], result);
+            MethodType parsed = MethodType.fromMethodDescriptorString(result, loader);
+            assertSame("--#"+i, instance, parsed);
+        }
+    }
+    private static String concat(Object... parts) {
+        StringBuilder sb = new StringBuilder();
+        Object prevPart = "";
+        for (Object part : parts) {
+            if (part instanceof Class) {
+                part = "L"+((Class)part).getName()+";";
+            }
+            if (part instanceof Integer) {
+                for (int n = (Integer) part; n > 1; n--)
+                    sb.append(prevPart);
+                part = "";
+            }
+            sb.append(part);
+            prevPart = part;
+        }
+        return sb.toString().replace('.', '/');
+    }
+
+    @Test
+    public void testHasPrimitives() {
+        System.out.println("hasPrimitives");
+        MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        boolean[] expResults =   {true,   false,  true,  false, true,   true,   false,  true};
+        for (int i = 0; i < instances.length; i++) {
+            boolean result = instances[i].hasPrimitives();
+            assertEquals("#"+i, expResults[i], result);
+        }
+    }
+
+    @Test
+    public void testHasWrappers() {
+        System.out.println("hasWrappers");
+        MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        boolean[] expResults =   {false,  false,  false, false, true,   true,   true,   false};
+        for (int i = 0; i < instances.length; i++) {
+            System.out.println("  hasWrappers "+instances[i]);
+            boolean result = instances[i].hasWrappers();
+            assertEquals("#"+i, expResults[i], result);
+        }
+    }
+
+    @Test
+    public void testErase() {
+        System.out.println("erase");
+        MethodType[] instances  = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        MethodType[] expResults = {mt_viO, mt_OO2, mt_vv, mt_Ov, mt_iO2, mt_OOi, mt_OO2, mt_iOi};
+        for (int i = 0; i < instances.length; i++) {
+            MethodType result = instances[i].erase();
+            assertSame("#"+i, expResults[i], result);
+        }
+    }
+
+    @Test
+    public void testGeneric() {
+        System.out.println("generic");
+        MethodType[] instances =  {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        MethodType[] expResults = {mt_OO2, mt_OO2, mt_Ov, mt_Ov, mt_OO2, mt_OO2, mt_OO2, mt_OO2};
+        for (int i = 0; i < instances.length; i++) {
+            MethodType result = instances[i].generic();
+            assertSame("#"+i, expResults[i], result);
+        }
+    }
+
+    @Test
+    public void testWrap() {
+        System.out.println("wrap");
+        MethodType[] instances =  {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        MethodType[] expResults = {mt_VIS, mt_OO2, mt_Vv, mt_Ov, mt_ISI, mt_ISI, mt_ISI, mt_ISI};
+        for (int i = 0; i < instances.length; i++) {
+            MethodType result = instances[i].wrap();
+            assertSame("#"+i, expResults[i], result);
+        }
+    }
+
+    @Test
+    public void testUnwrap() {
+        System.out.println("unwrap");
+        MethodType[] instances =  {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        MethodType[] expResults = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSi, mt_iSi, mt_iSi, mt_iSi};
+        for (int i = 0; i < instances.length; i++) {
+            MethodType result = instances[i].unwrap();
+            assertSame("#"+i, expResults[i], result);
+        }
+    }
+
+    /**
+     * Test of parameterType method, of class MethodType.
+     */
+    @Test
+    public void testParameterType() {
+        System.out.println("parameterType");
+        for (int num = 0; num < ptypes.length; num++) {
+            MethodType instance = mt_viS;
+            Class<?> expResult = ptypes[num];
+            Class<?> result = instance.parameterType(num);
+            assertSame(expResult, result);
+        }
+    }
+
+    /**
+     * Test of parameterCount method, of class MethodType.
+     */
+    @Test
+    public void testParameterCount() {
+        System.out.println("parameterCount");
+        MethodType instance = mt_viS;
+        int expResult = 2;
+        int result = instance.parameterCount();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of returnType method, of class MethodType.
+     */
+    @Test
+    public void testReturnType() {
+        System.out.println("returnType");
+        MethodType instance = mt_viS;
+        Class<?> expResult = void.class;
+        Class<?> result = instance.returnType();
+        assertSame(expResult, result);
+    }
+
+    /**
+     * Test of parameterList method, of class MethodType.
+     */
+    @Test
+    public void testParameterList() {
+        System.out.println("parameterList");
+        MethodType instance = mt_viS;
+        List<Class<?>> expResult = Arrays.asList(ptypes);
+        List<Class<?>> result = instance.parameterList();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of parameterArray method, of class MethodType.
+     */
+    @Test
+    public void testParameterArray() {
+        System.out.println("parameterArray");
+        MethodType instance = mt_viS;
+        Class<?>[] expResult = ptypes;
+        Class<?>[] result = instance.parameterArray();
+        assertEquals(Arrays.asList(expResult), Arrays.asList(result));
+    }
+
+    /**
+     * Test of equals method, of class MethodType.
+     */
+    @Test
+    public void testEquals_Object() {
+        System.out.println("equals");
+        Object x = null;
+        MethodType instance = mt_viS;
+        boolean expResult = false;
+        boolean result = instance.equals(x);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of equals method, of class MethodType.
+     */
+    @Test
+    public void testEquals_MethodType() {
+        System.out.println("equals");
+        MethodType that = mt_viS;
+        MethodType instance = mt_viS;
+        boolean expResult = true;
+        boolean result = instance.equals(that);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of hashCode method, of class MethodType.
+     */
+    @Test
+    public void testHashCode() {
+        System.out.println("hashCode");
+        MethodType instance = mt_viS;
+        ArrayList<Class<?>> types = new ArrayList<Class<?>>();
+        types.add(instance.returnType());
+        types.addAll(instance.parameterList());
+        int expResult = types.hashCode();
+        int result = instance.hashCode();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of toString method, of class MethodType.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+        MethodType[] instances = {mt_viS, mt_OO2, mt_vv, mt_Ov, mt_iSI, mt_ISi, mt_ISI, mt_iSi};
+        //String expResult = "void[int, class java.lang.String]";
+        String[] expResults = {
+            "(int,String)void",
+            "(Object,Object)Object",
+            "()void",
+            "()Object",
+            "(String,Integer)int",
+            "(String,int)Integer",
+            "(String,Integer)Integer",
+            "(String,int)int"
+        };
+        for (int i = 0; i < instances.length; i++) {
+            MethodType instance = instances[i];
+            String result = instance.toString();
+            System.out.println("#"+i+":"+result);
+            assertEquals("#"+i, expResults[i], result);
+        }
+    }
+
+    private static byte[] writeSerial(Object x) throws java.io.IOException {
+        try (java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
+             java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(bout)
+             ) {
+            out.writeObject(x);
+            out.flush();
+            return bout.toByteArray();
+        }
+    }
+    private static Object readSerial(byte[] wire) throws java.io.IOException, ClassNotFoundException {
+        try (java.io.ByteArrayInputStream bin = new java.io.ByteArrayInputStream(wire);
+             java.io.ObjectInputStream in = new java.io.ObjectInputStream(bin)) {
+            return in.readObject();
+        }
+    }
+    private static void testSerializedEquality(Object x) throws java.io.IOException, ClassNotFoundException {
+        if (x instanceof Object[])
+            x = Arrays.asList((Object[]) x);  // has proper equals method
+        byte[] wire = writeSerial(x);
+        Object y = readSerial(wire);
+        assertEquals(x, y);
+    }
+
+    /** Test (de-)serialization. */
+    @Test
+    public void testSerialization() throws Throwable {
+        System.out.println("serialization");
+        for (MethodType mt : GALLERY) {
+            testSerializedEquality(mt);
+        }
+        testSerializedEquality(GALLERY);
+
+        // Make a list of mixed objects:
+        List<Object> stuff = new ArrayList<>();
+        Collections.addAll(stuff, GALLERY);  // copy #1
+        Object[] triples = Arrays.copyOfRange(GALLERY, 0, GALLERY.length/2);
+        Collections.addAll(stuff, triples);  // copy #3 (partial)
+        for (MethodType mt : GALLERY) {
+            Collections.addAll(stuff, mt.parameterArray());
+        }
+        Collections.shuffle(stuff, new Random(292));
+        Collections.addAll(stuff, GALLERY);  // copy #2
+        testSerializedEquality(stuff);
+    }
+
+    /** Test serialization formats. */
+    @Test
+    public void testPortableSerialFormat() throws Throwable {
+        System.out.println("portable serial format");
+        Object[][] cases = {
+            { mt_vv, new byte[] {  // ()void
+                    (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13,
+                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x64, (byte)0x79, (byte)0x6e,
+                    (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54,
+                    (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
+                    (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x04, (byte)0x76, (byte)0x6f, (byte)0x69, (byte)0x64,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x75, (byte)0x72, (byte)0x00,
+                    (byte)0x12, (byte)0x5b, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e,
+                    (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x43, (byte)0x6c, (byte)0x61,
+                    (byte)0x73, (byte)0x73, (byte)0x3b, (byte)0xab, (byte)0x16, (byte)0xd7, (byte)0xae, (byte)0xcb,
+                    (byte)0xcd, (byte)0x5a, (byte)0x99, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78,
+                } },
+            { mt_OO, new byte[] {  // (Object)Object
+                    (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13,
+                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x64, (byte)0x79, (byte)0x6e,
+                    (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54,
+                    (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
+                    (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x10, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61,
+                    (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x4f, (byte)0x62,
+                    (byte)0x6a, (byte)0x65, (byte)0x63, (byte)0x74, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78,
+                    (byte)0x70, (byte)0x75, (byte)0x72, (byte)0x00, (byte)0x12, (byte)0x5b, (byte)0x4c, (byte)0x6a,
+                    (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67,
+                    (byte)0x2e, (byte)0x43, (byte)0x6c, (byte)0x61, (byte)0x73, (byte)0x73, (byte)0x3b, (byte)0xab,
+                    (byte)0x16, (byte)0xd7, (byte)0xae, (byte)0xcb, (byte)0xcd, (byte)0x5a, (byte)0x99, (byte)0x02,
+                    (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01,
+                    (byte)0x71, (byte)0x00, (byte)0x7e, (byte)0x00, (byte)0x03, (byte)0x78,
+                } },
+        };
+        boolean generateData = false;
+        //generateData = true;
+        for (Object[] c : cases) {
+            MethodType mt = (MethodType) c[0];
+            System.out.println("deserialize "+mt);
+            byte[] wire = (byte[]) c[1];
+            if (generateData) {
+                wire = writeSerial(mt);
+                final String INDENT = "                ";
+                System.out.print("{  // "+mt);
+                for (int i = 0; i < wire.length; i++) {
+                    if (i % 8 == 0) { System.out.println(); System.out.print(INDENT+"   "); }
+                    String hex = Integer.toHexString(wire[i] & 0xFF);
+                    if (hex.length() == 1)  hex = "0"+hex;
+                    System.out.print(" (byte)0x"+hex+",");
+                }
+                System.out.println();
+                System.out.println(INDENT+"}");
+                System.out.flush();
+            }
+            Object decode;
+            try {
+                decode = readSerial(wire);
+            } catch (Exception ex) {
+                decode = ex;  // oops!
+            }
+            assertEquals(mt, decode);
+        }
+    }
+}
--- a/jdk/test/java/dyn/indify/Indify.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/dyn/indify/Indify.java	Mon Mar 07 11:37:54 2011 -0800
@@ -98,8 +98,9 @@
 (same output as above)
  * </pre></blockquote>
  * <p>
- * Until the format of {@code CONSTANT_InvokeDynamic} entries is finalized,
- * the {@code --transitionalJSR292} switch is recommended (and turned on by default).
+ * Before OpenJDK build b123, the format of {@code CONSTANT_InvokeDynamic} is in transition,
+ * and the switch {@code --transitionalJSR292=yes} is recommended.
+ * It is turned <em>off</em> by default, but users of earlier builds may need to turn it on.
  * <p>
  * A version of this transformation built on top of <a href="http://asm.ow2.org/">http://asm.ow2.org/</a> would be welcome.
  * @author John Rose
@@ -116,7 +117,7 @@
     public boolean overwrite = false;
     public boolean quiet = false;
     public boolean verbose = false;
-    public boolean transitionalJSR292 = true;  // default to false later
+    public boolean transitionalJSR292 = false;  // final version is distributed
     public boolean all = false;
     public int verifySpecifierCount = -1;
 
@@ -158,6 +159,7 @@
         av = avl.toArray(new String[0]);
         Class<?> mainClass = Class.forName(mainClassName, true, makeClassLoader());
         java.lang.reflect.Method main = mainClass.getMethod("main", String[].class);
+        try { main.setAccessible(true); } catch (SecurityException ex) { }
         main.invoke(null, (Object) av);
     }
 
@@ -223,8 +225,8 @@
     private boolean booleanOption(String s) {
         if (s == null)  return true;
         switch (s) {
-        case "true":  case "yes": case "1": return true;
-        case "false": case "no":  case "0": return false;
+        case "true":  case "yes": case "on":  case "1": return true;
+        case "false": case "no":  case "off": case "0": return false;
         }
         throw new IllegalArgumentException("unrecognized boolean flag="+s);
     }
@@ -284,7 +286,7 @@
     }
 
     File classPathFile(File pathDir, String className) {
-        String qualname = className+".class";
+        String qualname = className.replace('.','/')+".class";
         qualname = qualname.replace('/', File.separatorChar);
         return new File(pathDir, qualname);
     }
@@ -339,6 +341,7 @@
         private File findClassInPath(String name) {
             for (String s : classpath) {
                 File f = classPathFile(new File(s), name);
+                //System.out.println("Checking for "+f);
                 if (f.exists() && f.canRead()) {
                     return f;
                 }
@@ -353,11 +356,11 @@
             }
         }
         private Class<?> transformAndLoadClass(File f) throws ClassNotFoundException, IOException {
-            if (verbose)  System.out.println("Loading class from "+f);
+            if (verbose)  System.err.println("Loading class from "+f);
             ClassFile cf = new ClassFile(f);
             Logic logic = new Logic(cf);
             boolean changed = logic.transform();
-            if (verbose && !changed)  System.out.println("(no change)");
+            if (verbose && !changed)  System.err.println("(no change)");
             logic.reportPatternMethods(!verbose, keepgoing);
             byte[] bytes = cf.toByteArray();
             return defineClass(null, bytes, 0, bytes.length);
@@ -525,6 +528,7 @@
                     throw new IllegalArgumentException("BootstrapMethods length is "+specsLen+" but should be "+verifySpecifierCount);
                 }
             }
+            if (!quiet)  System.err.flush();
         }
 
         // mark constant pool entries according to participation in patterns
@@ -696,6 +700,18 @@
                     args.clear();
                     break;
 
+                case opc_new:
+                {
+                    String type = pool.getString(CONSTANT_Class, (short)i.u2At(1));
+                    //System.out.println("new "+type);
+                    switch (type) {
+                    case "java/lang/StringBuilder":
+                        jvm.push("StringBuilder");
+                        continue decode;  // go to next instruction
+                    }
+                    break decode;  // bail out
+                }
+
                 case opc_getstatic:
                 {
                     // int.class compiles to getstatic Integer.TYPE
@@ -732,8 +748,9 @@
 
                 case opc_invokestatic:
                 case opc_invokevirtual:
+                case opc_invokespecial:
                 {
-                    boolean hasRecv = (bc == opc_invokevirtual);
+                    boolean hasRecv = (bc != opc_invokestatic);
                     int methi = i.u2At(1);
                     char mark = poolMarks[methi];
                     Short[] ref = pool.getMemberRef((short)methi);
@@ -770,6 +787,7 @@
                     if (mark == 'T' || mark == 'H' || mark == 'I') {
                         ownMethod = findMember(cf.methods, ref[1], ref[2]);
                     }
+                    //if (intrinsic != null)  System.out.println("intrinsic = "+intrinsic);
                     switch (intrinsic == null ? "" : intrinsic) {
                     case "fromMethodDescriptorString":
                         con = makeMethodTypeCon(args.get(0));
@@ -860,6 +878,15 @@
                             }
                         }
                         break decode;
+                    case "StringBuilder.append":
+                        // allow calls like ("value = "+x)
+                        removeEmptyJVMSlots(args);
+                        args.subList(1, args.size()).clear();
+                        continue;
+                    case "StringBuilder.toString":
+                        args.clear();
+                        args.add(intrinsic);
+                        continue;
                     }
                     if (!hasRecv && ownMethod != null && patternMark != 0) {
                         con = constants.get(ownMethod);
@@ -1506,6 +1533,7 @@
                 out.write(bytes);
             } else {
                 trueSize = flatten(out);
+                //if (!(item instanceof Code))  System.err.println("wrote complex attr name="+(int)(char)name+" size="+trueSize+" data="+Arrays.toString(flatten()));
             }
             if (trueSize != size && size >= 0)
                 System.err.println("warning: attribute size changed "+size+" to "+trueSize);
@@ -1525,7 +1553,7 @@
         }
         public List<Attr> attrs() { return null; }  // Code overrides this
         public byte[] flatten() {
-            ByteArrayOutputStream buf = new ByteArrayOutputStream(size);
+            ByteArrayOutputStream buf = new ByteArrayOutputStream(Math.max(20, size));
             flatten(buf);
             return buf.toByteArray();
         }
@@ -1642,6 +1670,7 @@
         opc_invokestatic           = 184,
         opc_invokeinterface        = 185,
         opc_invokedynamic          = 186,
+        opc_new                    = 187,
         opc_anewarray              = 189,
         opc_checkcast              = 192,
         opc_ifnull                 = 198,
--- a/jdk/test/java/lang/Thread/StopBeforeStart.java	Mon Mar 07 14:31:50 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +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.
- *
- * 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     4519200
- * @summary Confirm a Thread.stop before start complies with the spec
- * @author  Pete Soper
- *
- * Confirm that a thread that had its stop method invoked before start
- * does properly terminate with expected exception behavior. NOTE that
- * arbitrary application threads could return from their run methods faster
- * than the VM can throw an async exception.
- */
-public class StopBeforeStart {
-
-    private static final int JOIN_TIMEOUT=10000;
-
-    private class MyThrowable extends Throwable {
-    }
-
-    private class Catcher implements Thread.UncaughtExceptionHandler {
-        private boolean nullaryStop;
-        private Throwable theThrowable;
-        private Throwable expectedThrowable;
-        private boolean exceptionThrown;
-
-        Catcher(boolean nullaryStop) {
-            this.nullaryStop = nullaryStop;
-            if (!nullaryStop) {
-                expectedThrowable = new MyThrowable();
-            }
-        }
-
-        public void uncaughtException(Thread t, Throwable th) {
-            exceptionThrown = true;
-            theThrowable = th;
-        }
-
-        void check(String label) throws Throwable {
-            if (!exceptionThrown) {
-                throw new RuntimeException(label +
-                        " test:" + " missing uncaught exception");
-            }
-
-            if (nullaryStop) {
-                if (! (theThrowable instanceof ThreadDeath)) {
-                    throw new RuntimeException(label +
-                        " test:" + " expected ThreadDeath in uncaught handler");
-                }
-            } else if (theThrowable != expectedThrowable) {
-                throw new RuntimeException(label +
-                        " test:" + " wrong Throwable in uncaught handler");
-            }
-        }
-    }
-
-    private class MyRunnable implements Runnable {
-        public void run() {
-            while(true)
-                ;
-        }
-    }
-
-    private class MyThread extends Thread {
-        public void run() {
-            while(true)
-                ;
-        }
-    }
-
-
-    public static void main(String args[]) throws Throwable {
-        (new StopBeforeStart()).doit();
-        System.out.println("Test passed");
-    }
-
-    private void doit() throws Throwable {
-
-        runit(false, new Thread(new MyRunnable()),"Thread");
-        runit(true, new Thread(new MyRunnable()),"Thread");
-        runit(false, new MyThread(),"Runnable");
-        runit(true, new MyThread(),"Runnable");
-    }
-
-    private void runit(boolean nullaryStop, Thread thread,
-                        String type) throws Throwable {
-
-        Catcher c = new Catcher(nullaryStop);
-        thread.setUncaughtExceptionHandler(c);
-
-        if (nullaryStop) {
-            thread.stop();
-        } else {
-            thread.stop(c.expectedThrowable);
-        }
-
-        thread.start();
-        thread.join(JOIN_TIMEOUT);
-
-        if (thread.getState() != Thread.State.TERMINATED) {
-
-            thread.stop();
-
-            // Under high load this could be a false positive
-            throw new RuntimeException(type +
-                        " test:" + " app thread did not terminate");
-        }
-
-        c.check(type);
-    }
-}
--- a/jdk/test/java/nio/channels/FileChannel/Position.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/nio/channels/FileChannel/Position.java	Mon Mar 07 11:37:54 2011 -0800
@@ -22,13 +22,16 @@
  */
 
 /* @test
+ * @bug 4429043 6526860
  * @summary Test position method of FileChannel
  */
 
 import java.io.*;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.*;
+import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
+import java.nio.file.*;
+import static java.nio.file.StandardOpenOption.*;
+import java.nio.charset.Charset;
 import java.util.Random;
 
 
@@ -38,32 +41,42 @@
 
 public class Position {
 
-    private static PrintStream err = System.err;
-
-    private static Random generator = new Random();
+    private static final Charset ISO8859_1 = Charset.forName("8859_1");
 
-    private static int CHARS_PER_LINE = File.separatorChar == '/' ? 5 : 6;
-
-    private static File blah;
+    private static final Random generator = new Random();
 
     public static void main(String[] args) throws Exception {
-        blah = File.createTempFile("blah", null);
-        blah.deleteOnExit();
+        Path blah = Files.createTempFile("blah", null);
+        blah.toFile().deleteOnExit();
         initTestFile(blah);
 
-        FileInputStream fis = new FileInputStream(blah);
-        FileChannel c = fis.getChannel();
-
-        for(int i=0; i<100; i++) {
-            long newPos = generator.nextInt(1000);
-            c.position(newPos);
-            if (c.position() != newPos)
-                throw new RuntimeException("Position failed");
+        for (int i=0; i<10; i++) {
+            try (FileChannel fc = (generator.nextBoolean()) ?
+                    FileChannel.open(blah, READ) :
+                    new FileInputStream(blah.toFile()).getChannel()) {
+                for (int j=0; j<100; j++) {
+                    long newPos = generator.nextInt(1000);
+                    fc.position(newPos);
+                    if (fc.position() != newPos)
+                        throw new RuntimeException("Position failed");
+                }
+            }
         }
 
-        c.close();
-        fis.close();
-        blah.delete();
+        for (int i=0; i<10; i++) {
+            try (FileChannel fc = (generator.nextBoolean()) ?
+                     FileChannel.open(blah, APPEND) :
+                     new FileOutputStream(blah.toFile(), true).getChannel()) {
+                for (int j=0; j<10; j++) {
+                    if (fc.position() != fc.size())
+                        throw new RuntimeException("Position expected to be size");
+                    byte[] buf = new byte[generator.nextInt(100)];
+                    fc.write(ByteBuffer.wrap(buf));
+                }
+            }
+        }
+
+        Files.delete(blah);
     }
 
     /**
@@ -78,19 +91,15 @@
      * 3999
      *
      */
-    private static void initTestFile(File blah) throws Exception {
-        FileOutputStream fos = new FileOutputStream(blah);
-        BufferedWriter awriter
-            = new BufferedWriter(new OutputStreamWriter(fos, "8859_1"));
-
-        for(int i=0; i<4000; i++) {
-            String number = new Integer(i).toString();
-            for (int h=0; h<4-number.length(); h++)
-                awriter.write("0");
-            awriter.write(""+i);
-            awriter.newLine();
+    private static void initTestFile(Path blah) throws IOException {
+        try (BufferedWriter awriter = Files.newBufferedWriter(blah, ISO8859_1)) {
+            for(int i=0; i<4000; i++) {
+                String number = new Integer(i).toString();
+                for (int h=0; h<4-number.length(); h++)
+                    awriter.write("0");
+                awriter.write(""+i);
+                awriter.newLine();
+            }
         }
-       awriter.flush();
-       awriter.close();
     }
 }
--- a/jdk/test/java/nio/file/Files/walkFileTree/PrintFileTree.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/nio/file/Files/walkFileTree/PrintFileTree.java	Mon Mar 07 11:37:54 2011 -0800
@@ -54,6 +54,7 @@
         if (followLinks)
             options.add(FileVisitOption.FOLLOW_LINKS);
 
+        final boolean follow = followLinks;
         final boolean reportCycles = printCycles;
         Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor<Path>() {
             @Override
@@ -63,8 +64,7 @@
             }
             @Override
             public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
-                if (!attrs.isDirectory() || reportCycles)
-                    System.out.println(file);
+                System.out.println(file);
                 return FileVisitResult.CONTINUE;
             }
             @Override
@@ -79,11 +79,13 @@
             public FileVisitResult visitFileFailed(Path file, IOException exc)
                 throws IOException
             {
-                if (reportCycles && (exc instanceof FileSystemLoopException)) {
-                    System.out.println(file);
+                if (follow && (exc instanceof FileSystemLoopException)) {
+                    if (reportCycles)
+                        System.out.println(file);
                     return FileVisitResult.CONTINUE;
+                } else {
+                    throw exc;
                 }
-                throw exc;
             }
         });
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Hashtable/SerializationDeadlock.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ * -------------------------------------------
+ *
+ * Portions Copyright (c) 2010, 2011 IBM Corporation
+ */
+
+/*
+ * @test
+ * @bug 6927486
+ * @summary Serializing Hashtable objects which refer to each other should not be able to deadlock.
+ * @author Neil Richards <neil.richards@ngmr.net>, <neil_richards@uk.ibm.com>
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.concurrent.CyclicBarrier;
+
+public class SerializationDeadlock {
+    public static void main(final String[] args) throws Exception {
+        // Test for Hashtable serialization deadlock
+        final Hashtable<Object, Object> h1 = new Hashtable<>();
+        final Hashtable<Object, Object> h2 = new Hashtable<>();
+        final TestBarrier testStart = new TestBarrier(3);
+
+        // Populate the hashtables so that they refer to each other
+        h1.put(testStart, h2);
+        h2.put(testStart, h1);
+
+        final CyclicBarrier testEnd = new CyclicBarrier(3);
+        final TestThread t1 = new TestThread(h1, testEnd);
+        final TestThread t2 = new TestThread(h2, testEnd);
+
+        t1.start();
+        t2.start();
+
+        // Wait for both test threads to have initiated serialization
+        // of the 'testStart' object (and hence of both 'h1' and 'h2')
+        testStart.await();
+
+        // Wait for both test threads to successfully finish serialization
+        // of 'h1' and 'h2'.
+        System.out.println("Waiting for Hashtable serialization to complete ...");
+        System.out.println("(This test will hang if serialization deadlocks)");
+        testEnd.await();
+        System.out.println("Test PASSED: serialization completed successfully");
+
+        TestThread.handleExceptions();
+    }
+
+    static final class TestBarrier extends CyclicBarrier
+            implements Serializable {
+        public TestBarrier(final int count) {
+            super(count);
+        }
+
+        private void writeObject(final ObjectOutputStream oos)
+                throws IOException {
+            oos.defaultWriteObject();
+            // Wait until all test threads have started serializing data
+            try {
+                await();
+            } catch (final Exception e) {
+                throw new IOException("Test ERROR: Unexpected exception caught", e);
+            }
+        }
+    }
+
+    static final class TestThread extends Thread {
+        private static final List<Exception> exceptions = new ArrayList<>();
+
+        private final Hashtable<Object, Object> hashtable;
+        private final CyclicBarrier testEnd;
+
+        public TestThread(final Hashtable<Object, Object> hashtable,
+                final CyclicBarrier testEnd) {
+            this.hashtable = hashtable;
+            this.testEnd = testEnd;
+            setDaemon(true);
+        }
+
+        public void run() {
+            try {
+                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                final ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+                oos.writeObject(hashtable);
+                oos.close();
+            } catch (final IOException ioe) {
+                addException(ioe);
+            } finally {
+                try {
+                    testEnd.await();
+                } catch (Exception e) {
+                    addException(e);
+                }
+            }
+        }
+
+        private static synchronized void addException(final Exception exception) {
+            exceptions.add(exception);
+        }
+
+        public static synchronized void handleExceptions() {
+            if (false == exceptions.isEmpty()) {
+                throw new RuntimeException(getErrorText(exceptions));
+            }
+        }
+
+        private static String getErrorText(final List<Exception> exceptions) {
+            final StringWriter sw = new StringWriter();
+            final PrintWriter pw = new PrintWriter(sw);
+
+            pw.println("Test ERROR: Unexpected exceptions thrown on test threads:");
+            for (Exception exception : exceptions) {
+                pw.print("\t");
+                pw.println(exception);
+                for (StackTraceElement element : exception.getStackTrace()) {
+                    pw.print("\t\tat ");
+                    pw.println(element);
+                }
+            }
+
+            pw.close();
+            return sw.toString();
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Hashtable/SimpleSerialization.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ * -------------------------------------------
+ *
+ * Portions Copyright (c) 2010, 2011 IBM Corporation
+ */
+
+/*
+ * @test
+ * @bug 6927486
+ * @summary A serialized Hashtable can be de-serialized properly.
+ * @author Neil Richards <neil.richards@ngmr.net>, <neil_richards@uk.ibm.com>
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Hashtable;
+
+public class SimpleSerialization {
+    public static void main(final String[] args) throws Exception {
+        Hashtable<String, String> h1 = new Hashtable<>();
+
+        h1.put("key", "value");
+
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+        oos.writeObject(h1);
+        oos.close();
+
+        final byte[] data = baos.toByteArray();
+        final ByteArrayInputStream bais = new ByteArrayInputStream(data);
+        final ObjectInputStream ois = new ObjectInputStream(bais);
+
+        final Object deserializedObject = ois.readObject();
+        ois.close();
+
+        if (false == h1.equals(deserializedObject)) {
+            throw new RuntimeException(getFailureText(h1, deserializedObject));
+        }
+    }
+
+    private static String getFailureText(final Object orig, final Object copy) {
+        final StringWriter sw = new StringWriter();
+        final PrintWriter pw = new PrintWriter(sw);
+
+        pw.println("Test FAILED: Deserialized object is not equal to the original object");
+        pw.print("\tOriginal: ");
+        printObject(pw, orig).println();
+        pw.print("\tCopy:     ");
+        printObject(pw, copy).println();
+
+        pw.close();
+        return sw.toString();
+    }
+
+    private static PrintWriter printObject(final PrintWriter pw, final Object o) {
+        pw.printf("%s@%08x", o.getClass().getName(), System.identityHashCode(o));
+        return pw;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimeZone/DaylightTimeTest.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 6936350
+ * @summary Test case for TimeZone.observesDaylightTime()
+ */
+
+import java.util.*;
+import static java.util.GregorianCalendar.*;
+
+public class DaylightTimeTest {
+    private static final int ONE_HOUR = 60 * 60 * 1000; // one hour
+    private static final int INTERVAL = 24 * ONE_HOUR;  // one day
+    private static final String[] ZONES = TimeZone.getAvailableIDs();
+    private static int errors = 0;
+
+    public static void main(String[] args) {
+
+        // Test default TimeZone
+        for (String id : ZONES) {
+            TimeZone tz = TimeZone.getTimeZone(id);
+            long now = System.currentTimeMillis();
+            boolean observes = tz.observesDaylightTime();
+            boolean found = findDSTTransition(tz, now);
+            if (observes != found) {
+                // There's a critical section. If DST ends after the
+                // System.currentTimeMills() call, there should be
+                // inconsistency in the determination. Try the same
+                // thing again to see the inconsistency was due to the
+                // critical section.
+                now = System.currentTimeMillis();
+                observes = tz.observesDaylightTime();
+                found = findDSTTransition(tz, now);
+                if (observes != found) {
+                    System.err.printf("%s: observesDaylightTime() should return %s at %d%n",
+                                      tz.getID(), found, now);
+                    errors++;
+                }
+            }
+        }
+
+        // Test SimpleTimeZone in which observesDaylightTime() is
+        // equivalent to useDaylightTime().
+        testSimpleTimeZone(new SimpleTimeZone(-8*ONE_HOUR, "X",
+                                              APRIL, 1, -SUNDAY, 2*ONE_HOUR,
+                                              OCTOBER, -1, SUNDAY, 2*ONE_HOUR,
+                                              1*ONE_HOUR));
+        testSimpleTimeZone(new SimpleTimeZone(-8*ONE_HOUR, "Y"));
+
+        if (errors > 0) {
+            throw new RuntimeException("DaylightTimeTest: failed");
+        }
+    }
+
+    /**
+     * Returns true if it's `now' in DST or there's any
+     * standard-to-daylight transition within 50 years after `now'.
+     */
+    private static boolean findDSTTransition(TimeZone tz, long now) {
+        GregorianCalendar cal = new GregorianCalendar(tz, Locale.US);
+        cal.setTimeInMillis(now);
+        cal.add(YEAR, 50);
+        long end = cal.getTimeInMillis();
+
+        for (long t = now; t < end; t += INTERVAL) {
+            cal.setTimeInMillis(t);
+            if (cal.get(DST_OFFSET) > 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static void testSimpleTimeZone(SimpleTimeZone stz) {
+        if (stz.useDaylightTime() != stz.observesDaylightTime()) {
+            System.err.printf("Failed: useDaylightTime=%b, observesDaylightTime()=%b%n\t%s%n",
+                              stz.useDaylightTime(),stz.observesDaylightTime(), stz);
+            errors++;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Vector/SerializationDeadlock.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Portions Copyright (c) 2010, 2011 IBM Corporation
+ */
+
+/*
+ * @test
+ * @bug 6934356
+ * @summary Serializing Vector objects which refer to each other should not be able to deadlock.
+ * @author Neil Richards <neil.richards@ngmr.net>, <neil_richards@uk.ibm.com>
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+import java.util.concurrent.CyclicBarrier;
+
+public class SerializationDeadlock {
+    public static void main(final String[] args) throws Exception {
+        // Test for Vector serialization deadlock
+        final Vector<Object> v1 = new Vector<>();
+        final Vector<Object> v2 = new Vector<>();
+        final TestBarrier testStart = new TestBarrier(3);
+
+        // Populate the vectors so that they refer to each other
+        v1.add(testStart);
+        v1.add(v2);
+        v2.add(testStart);
+        v2.add(v1);
+
+        final CyclicBarrier testEnd = new CyclicBarrier(3);
+        final TestThread t1 = new TestThread(v1, testEnd);
+        final TestThread t2 = new TestThread(v2, testEnd);
+
+        t1.start();
+        t2.start();
+
+        // Wait for both test threads to have initiated serialization
+        // of the 'testStart' object (and hence of both 'v1' and 'v2')
+        testStart.await();
+
+        // Wait for both test threads to successfully finish serialization
+        // of 'v1' and 'v2'.
+        System.out.println("Waiting for Vector serialization to complete ...");
+        System.out.println("(This test will hang if serialization deadlocks)");
+        testEnd.await();
+        System.out.println("Test PASSED: serialization completed successfully");
+
+        TestThread.handleExceptions();
+    }
+
+    static final class TestBarrier extends CyclicBarrier
+            implements Serializable {
+        public TestBarrier(final int count) {
+            super(count);
+        }
+
+        private void writeObject(final ObjectOutputStream oos)
+                throws IOException {
+            oos.defaultWriteObject();
+            // Wait until all test threads have started serializing data
+            try {
+                await();
+            } catch (final Exception e) {
+                throw new IOException("Test ERROR: Unexpected exception caught", e);
+            }
+        }
+    }
+
+    static final class TestThread extends Thread {
+        private static final List<Exception> exceptions = new ArrayList<>();
+
+        private final Vector vector;
+        private final CyclicBarrier testEnd;
+
+        public TestThread(final Vector vector, final CyclicBarrier testEnd) {
+            this.vector = vector;
+            this.testEnd = testEnd;
+            setDaemon(true);
+        }
+
+        public void run() {
+            try {
+                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                final ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+                oos.writeObject(vector);
+                oos.close();
+            } catch (final IOException ioe) {
+                addException(ioe);
+            } finally {
+                try {
+                    testEnd.await();
+                } catch (Exception e) {
+                    addException(e);
+                }
+            }
+        }
+
+        private static synchronized void addException(final Exception exception) {
+            exceptions.add(exception);
+        }
+
+        public static synchronized void handleExceptions() {
+            if (false == exceptions.isEmpty()) {
+                throw new RuntimeException(getErrorText(exceptions));
+            }
+        }
+
+        private static String getErrorText(final List<Exception> exceptions) {
+            final StringWriter sw = new StringWriter();
+            final PrintWriter pw = new PrintWriter(sw);
+
+            pw.println("Test ERROR: Unexpected exceptions thrown on test threads:");
+            for (Exception exception : exceptions) {
+                pw.print("\t");
+                pw.println(exception);
+                for (StackTraceElement element : exception.getStackTrace()) {
+                    pw.print("\t\tat ");
+                    pw.println(element);
+                }
+            }
+
+            pw.close();
+            return sw.toString();
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Vector/SimpleSerialization.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Portions Copyright (c) 2010, 2011 IBM Corporation
+ */
+
+/*
+ * @test
+ * @bug 6934356
+ * @summary A serialized Vector can be successfully de-serialized.
+ * @author Neil Richards <neil.richards@ngmr.net>, <neil_richards@uk.ibm.com>
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Vector;
+
+public class SimpleSerialization {
+    public static void main(final String[] args) throws Exception {
+        final Vector<String> v1 = new Vector<>();
+
+        v1.add("entry1");
+        v1.add("entry2");
+
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+        oos.writeObject(v1);
+        oos.close();
+
+        final byte[] data = baos.toByteArray();
+        final ByteArrayInputStream bais = new ByteArrayInputStream(data);
+        final ObjectInputStream ois = new ObjectInputStream(bais);
+
+        final Object deserializedObject = ois.readObject();
+        ois.close();
+
+        if (false == v1.equals(deserializedObject)) {
+            throw new RuntimeException(getFailureText(v1, deserializedObject));
+        }
+    }
+
+    private static String getFailureText(final Object orig, final Object copy) {
+        final StringWriter sw = new StringWriter();
+        final PrintWriter pw = new PrintWriter(sw);
+
+        pw.println("Test FAILED: Deserialized object is not equal to the original object");
+        pw.print("\tOriginal: ");
+        printObject(pw, orig).println();
+        pw.print("\tCopy:     ");
+        printObject(pw, copy).println();
+
+        pw.close();
+        return sw.toString();
+    }
+
+    private static PrintWriter printObject(final PrintWriter pw, final Object o) {
+        pw.printf("%s@%08x", o.getClass().getName(), System.identityHashCode(o));
+        return pw;
+    }
+}
--- a/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java	Mon Mar 07 11:37:54 2011 -0800
@@ -124,11 +124,11 @@
         oneRun(new ArrayBlockingQueue<Integer>(CAPACITY), pairs, iters);
         oneRun(new LinkedBlockingQueue<Integer>(CAPACITY), pairs, iters);
         oneRun(new LinkedBlockingDeque<Integer>(CAPACITY), pairs, iters);
-        oneRun(new LinkedTransferQueue<Integer>(), pairs, iters);
         oneRun(new SynchronousQueue<Integer>(), pairs, iters / 8);
 
-        /* PriorityBlockingQueue is unbounded
+        /* unbounded queue implementations are prone to OOME
         oneRun(new PriorityBlockingQueue<Integer>(iters / 2 * pairs), pairs, iters / 4);
+        oneRun(new LinkedTransferQueue<Integer>(), pairs, iters);
         */
     }
 
--- a/jdk/test/javax/print/attribute/ServiceDialogTest.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/javax/print/attribute/ServiceDialogTest.java	Mon Mar 07 11:37:54 2011 -0800
@@ -71,7 +71,7 @@
                         if (factories.length > 0) {
                                 services[0] = factories[0].getPrintService(fos);
                         } else {
-                                throw new RuntimeException("No StreamPrintService available which would support "+flavor");
+                                throw new RuntimeException("No StreamPrintService available which would support "+flavor);
                         }
 
                         services[2] = new TestPrintService("Test Printer");
--- a/jdk/test/javax/swing/JComponent/6989617/bug6989617.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/javax/swing/JComponent/6989617/bug6989617.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,76 +28,107 @@
    @run main bug6989617
 */
 
+import sun.awt.SunToolkit;
+
 import javax.swing.*;
 import java.awt.*;
 
 public class bug6989617 {
-
-    private boolean isPaintingOrigin;
-    private boolean innerPanelRepainted, outerPanelRepainted;
-
-    public bug6989617() {
+    private static MyPanel panel;
+    private static JButton button;
 
-        final JButton button = new JButton("button");
+    public static void main(String... args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                JFrame frame = new JFrame();
+                frame. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                panel = new MyPanel();
 
-        JPanel innerPanel = new JPanel() {
-            protected boolean isPaintingOrigin() {
-                return isPaintingOrigin;
-            }
+                button = new JButton("Hello");
+                panel.add(button);
+                frame.add(panel);
 
-            public void repaint(long tm, int x, int y, int width, int height) {
-                if (button.getParent() != null) {
-                    innerPanelRepainted = true;
-                    if (!button.getSize().equals(new Dimension(width, height))) {
-                        throw new RuntimeException("Wrong size of the dirty area");
-                    }
-                    if (!button.getLocation().equals(new Point(x, y))) {
-                        throw new RuntimeException("Wrong location of the dirty area");
-                    }
+                frame.setSize(200, 300);
+                frame.setVisible(true);
+            }
+        });
+        // Testing the panel as a painting origin,
+        // the panel.paintImmediately() must be triggered
+        // when button.repaint() is called
+        toolkit.realSync();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                if (panel.getPaintRectangle() != null) {
+                    throw new RuntimeException("paint rectangle is not null");
                 }
-                super.repaint(tm, x, y, width, height);
+                button.repaint();
             }
-        };
-
-        JPanel outerPanel = new JPanel() {
-            protected boolean isPaintingOrigin() {
-                return isPaintingOrigin;
+        });
+        toolkit.realSync();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                Rectangle pr = panel.getPaintRectangle();
+                if (!pr.getSize().equals(button.getSize())) {
+                    throw new RuntimeException("wrong size of the dirty area");
+                }
+                if (!pr.getLocation().equals(button.getLocation())) {
+                    throw new RuntimeException("wrong location of the dirty area");
+                }
             }
-
-            public void repaint(long tm, int x, int y, int width, int height) {
-                if (button.getParent() != null) {
-                    outerPanelRepainted = true;
-                    if (!button.getSize().equals(new Dimension(width, height))) {
-                        throw new RuntimeException("Wrong size of the dirty area");
-                    }
+        });
+        // Testing the panel as NOT a painting origin
+        // the panel.paintImmediately() must NOT be triggered
+        // when button.repaint() is called
+        toolkit.realSync();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                panel.resetPaintRectangle();
+                panel.setPaintingOrigin(false);
+                if (panel.getPaintRectangle() != null) {
+                    throw new RuntimeException("paint rectangle is not null");
                 }
-                super.repaint(tm, x, y, width, height);
+                button.repaint();
             }
-        };
-
-
-        outerPanel.add(innerPanel);
-        innerPanel.add(button);
+        });
+        toolkit.realSync();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                if(panel.getPaintRectangle() != null) {
+                    throw new RuntimeException("paint rectangle is not null");
+                }
+                System.out.println("Test passed...");
+            }
+        });
+    }
 
-        outerPanel.setSize(100, 100);
-        innerPanel.setBounds(10, 10, 50, 50);
-        button.setBounds(10, 10, 20, 20);
+    static class MyPanel extends JPanel {
+        private boolean isPaintingOrigin = true;
+        private Rectangle paintRectangle;
 
-        if (innerPanelRepainted || outerPanelRepainted) {
-            throw new RuntimeException("Repainted flag is unexpectedly on");
+        {
+            setLayout(new GridBagLayout());
+        }
+
+        public boolean isPaintingOrigin() {
+            return isPaintingOrigin;
         }
-        button.repaint();
-        if (innerPanelRepainted || outerPanelRepainted) {
-            throw new RuntimeException("Repainted flag is unexpectedly on");
+
+        public void setPaintingOrigin(boolean paintingOrigin) {
+            isPaintingOrigin = paintingOrigin;
         }
-        isPaintingOrigin = true;
-        button.repaint();
-        if (!innerPanelRepainted || !outerPanelRepainted) {
-            throw new RuntimeException("Repainted flag is unexpectedly off");
+
+        public void paintImmediately(int x, int y, int w, int h) {
+            super.paintImmediately(x, y, w, h);
+            paintRectangle = new Rectangle(x, y, w, h);
+        }
+
+        public Rectangle getPaintRectangle() {
+            return paintRectangle == null? null: new Rectangle(paintRectangle);
+        }
+
+        public void resetPaintRectangle() {
+            this.paintRectangle = null;
         }
     }
-
-    public static void main(String... args) throws Exception {
-        new bug6989617();
-    }
 }
--- a/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html	Mon Mar 07 11:37:54 2011 -0800
@@ -1,6 +1,8 @@
 <html>
 <body>
 <applet  code="bug6798062.class" width=400 height=300></applet>
+The test is suitable only for Windows
+
 1. Create a link
 2. Copy path to the link into TextField
 3. Run the Windows Task Manager. Select the Processes tab and find the java process
--- a/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java	Mon Mar 07 11:37:54 2011 -0800
@@ -28,6 +28,7 @@
    @run applet/manual=done bug6798062.html
 */
 
+import sun.awt.OSInfo;
 import sun.awt.shell.ShellFolder;
 
 import javax.swing.*;
@@ -68,13 +69,23 @@
         add(initialize());
     }
 
-    private JPanel initialize() {
-        File file = new File("c:/");
+    private JComponent initialize() {
+        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+            return new JLabel("The test is suitable only for Windows");
+        }
+
+        String tempDir = System.getProperty("java.io.tmpdir");
+
+        if (tempDir.length() == 0) { // 'java.io.tmpdir' isn't guaranteed to be defined
+            tempDir = System.getProperty("user.home");
+        }
+
+        System.out.println("Temp directory: " + tempDir);
 
         try {
-            folder = ShellFolder.getShellFolder(file);
+            folder = ShellFolder.getShellFolder(new File(tempDir));
         } catch (FileNotFoundException e) {
-            fail("Directory " + file.getPath() + " not found");
+            fail("Directory " + tempDir + " not found");
         }
 
         slider.setMajorTickSpacing(10);
--- a/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java	Mon Mar 07 11:37:54 2011 -0800
@@ -69,8 +69,6 @@
 
                 frame.setSize(200, 100);
                 frame.setVisible(true);
-
-                thumbBounds[0] = new Rectangle(ui.getThumbBounds());
             }
         });
 
@@ -78,6 +76,8 @@
 
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
+                thumbBounds[0] = new Rectangle(ui.getThumbBounds());
+
                 Point l = sb.getLocationOnScreen();
 
                 robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/LookAndFeel/6474153/bug6474153.java	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 6474153
+ * @summary LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size
+ * @author Alexander Potochkin
+ */
+
+import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
+import javax.swing.text.DefaultEditorKit;
+import javax.swing.text.JTextComponent;
+
+public class bug6474153 {
+
+    public static void main(String... args) throws Exception {
+        checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction} ));
+        checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction, "PAGE_UP"} ));
+    }
+
+    private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) {
+        if (keyActionArray.length != 1) {
+            throw new RuntimeException("Wrong array lenght!");
+        }
+        if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) {
+            throw new RuntimeException("Wrong action name!");
+        }
+        if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) {
+            throw new RuntimeException("Wrong keystroke!");
+        }
+    }
+}
--- a/jdk/test/sun/java2d/pipe/RegionOps.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/java2d/pipe/RegionOps.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 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.
+ *
+ * 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 %W% %E%
  * @bug 6504874
--- a/jdk/test/sun/security/krb5/auto/BadKdc1.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/BadKdc1.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 6843127
- * @run main/timeout=300 BadKdc1
+ * @run main/othervm/timeout=300 BadKdc1
  * @summary krb5 should not try to access unavailable kdc too often
  */
 
--- a/jdk/test/sun/security/krb5/auto/BadKdc2.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/BadKdc2.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 6843127
- * @run main/timeout=300 BadKdc2
+ * @run main/othervm/timeout=300 BadKdc2
  * @summary krb5 should not try to access unavailable kdc too often
  */
 
--- a/jdk/test/sun/security/krb5/auto/BadKdc3.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/BadKdc3.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 6843127
- * @run main/timeout=300 BadKdc3
+ * @run main/othervm/timeout=300 BadKdc3
  * @summary krb5 should not try to access unavailable kdc too often
  */
 
--- a/jdk/test/sun/security/krb5/auto/BadKdc4.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/BadKdc4.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 6843127
- * @run main/timeout=300 BadKdc4
+ * @run main/othervm/timeout=300 BadKdc4
  * @summary krb5 should not try to access unavailable kdc too often
  */
 
--- a/jdk/test/sun/security/krb5/auto/CleanState.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/CleanState.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6716534
+ * @run main/othervm CleanState
  * @summary Krb5LoginModule has not cleaned temp info between authentication attempts
  */
 import com.sun.security.auth.module.Krb5LoginModule;
--- a/jdk/test/sun/security/krb5/auto/CrossRealm.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/CrossRealm.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6706974
+ * @run main/othervm CrossRealm
  * @summary Add krb5 test infrastructure
  */
 import java.io.File;
--- a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6578647 6829283
+ * @run main/othervm HttpNegotiateServer
  * @summary Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
  * @summary HTTP/Negotiate: Authenticator triggered again when user cancels the first one
  */
--- a/jdk/test/sun/security/krb5/auto/IgnoreChannelBinding.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/IgnoreChannelBinding.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6851973
+ * @run main/othervm IgnoreChannelBinding
  * @summary ignore incoming channel binding if acceptor does not set one
  */
 
--- a/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 4641821
+ * @run main/othervm KerberosHashEqualsTest
  * @summary hashCode() and equals() for KerberosKey and KerberosTicket
  */
 
--- a/jdk/test/sun/security/krb5/auto/LifeTimeInSeconds.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/LifeTimeInSeconds.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6857802
+ * @run main/othervm LifeTimeInSeconds
  * @summary GSS getRemainingInitLifetime method returns milliseconds not seconds
  */
 import org.ietf.jgss.GSSCredential;
--- a/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6765491
+ * @run main/othervm LoginModuleOptions
  * @summary Krb5LoginModule a little too restrictive, and the doc is not clear.
  */
 import com.sun.security.auth.module.Krb5LoginModule;
--- a/jdk/test/sun/security/krb5/auto/MaxRetries.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/MaxRetries.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 6844193
- * @run main/timeout=300 MaxRetries
+ * @run main/othervm/timeout=300 MaxRetries
  * @summary support max_retries in krb5.conf
  */
 
--- a/jdk/test/sun/security/krb5/auto/MoreKvno.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/MoreKvno.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -25,6 +25,7 @@
  * @test
  * @bug 6893158
  * @bug 6907425
+ * @run main/othervm MoreKvno
  * @summary AP_REQ check should use key version number
  */
 
--- a/jdk/test/sun/security/krb5/auto/NewSalt.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/NewSalt.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 6960894
  * @summary Better AS-REQ creation and processing
- * @run main NewSalt
+ * @run main/othervm NewSalt
  * @run main/othervm -Dnopreauth NewSalt
  * @run main/othervm -Donlyonepreauth NewSalt
  */
--- a/jdk/test/sun/security/krb5/auto/NonMutualSpnego.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/NonMutualSpnego.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6733095
+ * @run main/othervm NonMutualSpnego
  * @summary Failure when SPNEGO request non-Mutual
  */
 
--- a/jdk/test/sun/security/krb5/auto/SSL.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/SSL.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -25,16 +25,16 @@
  * @test
  * @bug 6894643 6913636
  * @summary Test JSSE Kerberos ciphersuite
- * @run main SSL TLS_KRB5_WITH_RC4_128_SHA
- * @run main SSL TLS_KRB5_WITH_RC4_128_MD5
- * @run main SSL TLS_KRB5_WITH_3DES_EDE_CBC_SHA
- * @run main SSL TLS_KRB5_WITH_3DES_EDE_CBC_MD5
- * @run main SSL TLS_KRB5_WITH_DES_CBC_SHA
- * @run main SSL TLS_KRB5_WITH_DES_CBC_MD5
- * @run main SSL TLS_KRB5_EXPORT_WITH_RC4_40_SHA
- * @run main SSL TLS_KRB5_EXPORT_WITH_RC4_40_MD5
- * @run main SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA
- * @run main SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5
+ * @run main/othervm SSL TLS_KRB5_WITH_RC4_128_SHA
+ * @run main/othervm SSL TLS_KRB5_WITH_RC4_128_MD5
+ * @run main/othervm SSL TLS_KRB5_WITH_3DES_EDE_CBC_SHA
+ * @run main/othervm SSL TLS_KRB5_WITH_3DES_EDE_CBC_MD5
+ * @run main/othervm SSL TLS_KRB5_WITH_DES_CBC_SHA
+ * @run main/othervm SSL TLS_KRB5_WITH_DES_CBC_MD5
+ * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_RC4_40_SHA
+ * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_RC4_40_MD5
+ * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA
+ * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5
  */
 import java.io.*;
 import java.net.InetAddress;
--- a/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6815182
+ * @run main/othervm SpnegoReqFlags
  * @summary GSSAPI/SPNEGO does not work with server using MIT Kerberos library
  */
 
--- a/jdk/test/sun/security/krb5/auto/Test5653.java	Mon Mar 07 14:31:50 2011 +0000
+++ b/jdk/test/sun/security/krb5/auto/Test5653.java	Mon Mar 07 11:37:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6895424
+ * @run main/othervm Test5653
  * @summary RFC 5653
  */
 
--- a/langtools/.hgtags	Mon Mar 07 14:31:50 2011 +0000
+++ b/langtools/.hgtags	Mon Mar 07 11:37:54 2011 -0800
@@ -105,3 +105,5 @@
 d7225b476a5d1aebffb8827e7c72ba2e1651f4e7 jdk7-b128
 1383d1ee8b5db13d5df9523d1760df17b9d228d4 jdk7-b129
 7a98db8cbfce77a619057aa4fdde69d2a06d4101 jdk7-b130
+67221b8643b478c4fceacc89240db876455aae76 jdk7-b131
+e3d011d59a33acef79eff7523bef069557e91002 jdk7-b132
--- a/langtools/LICENSE	Mon Mar 07 14:31:50 2011 +0000
+++ b/langtools/LICENSE	Mon Mar 07 11:37:54 2011 -0800
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Sun Microsystems, Inc.  are subject to
-the following clarification and special exception to the GPL, but only where
-Sun has expressly included in the particular source file's header the words
-"Sun designates this particular file as subject to the "Classpath" exception
-as provided by Sun in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/make/Defs-internal.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/Defs-internal.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -28,21 +28,63 @@
 # not contain rules.
 #
 
-# Indicate that we are visiting a separate repo or component 
+# The build times report is turned off by setting REPORT_BUILD_TIMES to nothing.
+# This is necessary for the target clobber/clean which will erase the
+# directories where the buildtimes are stored.
+REPORT_BUILD_TIMES=1
+# Store the build times in this directory.
+BUILDTIMESDIR=$(ABS_OUTPUTDIR)/tmp/buildtimes
+
+# Record starting time for build of a sub repository.
+define RecordStartTime
+$(MKDIR) -p $(BUILDTIMESDIR)
+$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$1
+$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$1_human_readable
+endef
+
+# Indicate that we started to build a sub repository and record starting time. 
 define MakeStart
-$(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n" \
+$(call RecordStartTime,$1)
+$(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n\n" \
 "########################################################################" \
 "########################################################################" \
-"Entering $1 for target $2" \
+"Entering $1 for target(s) $2" \
 "########################################################################"
 endef
 
-define MakeFinish
-$(PRINTF) "%s\n##### %-60.60s #####\n%s\n%s\n\n" \
+# Record ending time and calculate the difference and store it in a
+# easy to read format. Handles builds that cross midnight. Expects
+# that a build will never take 24 hours or more. 
+define RecordEndTime
+$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$1
+$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$1_human_readable
+$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$1` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$1` $1 | \
+  $(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \
+             M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \
+  > $(BUILDTIMESDIR)/build_time_diff_$1
+endef
+
+# Indicate that we are done.
+# Record ending time and print out the total time it took to build.
+define MakeFinish 
+$(if $(REPORT_BUILD_TIMES),$(call RecordEndTime,$1),) 
+$(PRINTF) "%s\n##### %-60.60s #####\n%s\n##### %-60.60s #####\n%s\n\n" \
 "########################################################################" \
-"Leaving $1 for target $2" \
+"Leaving $1 for target(s) $2" \
 "########################################################################" \
-"########################################################################"
+$(if $(REPORT_BUILD_TIMES),"Build time `$(CAT) $(BUILDTIMESDIR)/build_time_diff_$1` for target(s) $2","") \
+"########################################################################" 
+endef
+
+# Find all build_time_* files and print their contents in a list sorted
+# on the name of the sub repository.
+define ReportBuildTimes
+$(PRINTF) "-- Build times ----------\nTarget %s\nStart %s\nEnd   %s\n%s\n%s\n-------------------------\n" \
+$1 \
+"`$(CAT) $(BUILDTIMESDIR)/build_time_start_TOTAL_human_readable`" \
+"`$(CAT) $(BUILDTIMESDIR)/build_time_end_TOTAL_human_readable`" \
+"`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | $(XARGS) $(CAT) | $(SORT) -k 2`" \
+"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`"
 endef
 
 ifdef OPENJDK
--- a/make/corba-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/corba-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -40,17 +40,17 @@
 corba: corba-build
 corba-build:
 	$(MKDIR) -p $(CORBA_OUTPUTDIR)
-	@$(call MakeStart, corba, all)
+	@$(call MakeStart,corba,all)
 	($(CD) $(CORBA_TOPDIR)/make && \
 	 $(MAKE) $(CORBA_BUILD_ARGUMENTS) all)
-	@$(call MakeFinish, corba, all)
+	@$(call MakeFinish,corba,all)
 
 corba-clobber::
 	$(MKDIR) -p $(CORBA_OUTPUTDIR)
-	@$(call MakeStart, corba, clobber)
+	@$(call MakeStart,corba,clobber)
 	($(CD) $(CORBA_TOPDIR)/make &&  \
 	 $(MAKE) $(CORBA_BUILD_ARGUMENTS) clobber)
-	@$(call MakeFinish, corba, clobber)
+	@$(call MakeFinish,corba,clobber)
 
 .PHONY: corba corba-build corba-clobber 
 
--- a/make/deploy-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/deploy-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -64,19 +64,17 @@
     endif
   endif
 endif
-  
-ifneq ($(KERNEL), off)
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    ifeq ($(PLATFORM), windows)
-      # Only set up to use UPX compression if it is available
-      UP_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/upx ] ; then \
-        $(ECHO) true ; \
-      else \
-        $(ECHO) false ; \
-      fi )
-      ifeq ($(UP_TMP), true)
-        DEPLOY_BUILD_TARGETS += cmd-comp-all
-      endif
+
+ifeq ($(ARCH_DATA_MODEL), 32)
+  ifeq ($(PLATFORM), windows)
+    # Only set up to use UPX compression if it is available
+    UP_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/upx ] ; then \
+      $(ECHO) true ; \
+    else \
+      $(ECHO) false ; \
+    fi )
+    ifeq ($(UP_TMP), true)
+      DEPLOY_BUILD_TARGETS += cmd-comp-all
     endif
   endif
 endif
@@ -118,18 +116,18 @@
 
 deploy-build:
 ifeq ($(BUILD_DEPLOY), true)
-	@$(call MakeStart, deploy, $(DEPLOY_BUILD_TARGETS))
+	@$(call MakeStart,deploy,$(DEPLOY_BUILD_TARGETS))
 	($(CD) $(DEPLOY_TOPDIR)/make && \
 	  $(MAKE) $(DEPLOY_BUILD_TARGETS) $(DEPLOY_BUILD_ARGUMENTS))
-	@$(call MakeFinish, deploy, $(DEPLOY_BUILD_TARGETS))
+	@$(call MakeFinish,deploy,$(DEPLOY_BUILD_TARGETS))
 endif
 
 deploy-clobber::
 ifeq ($(BUILD_DEPLOY), true)
-	@$(call MakeStart, deploy, clobber)
+	@$(call MakeStart,deploy,clobber)
 	($(CD) $(DEPLOY_TOPDIR)/make && \
 	  $(MAKE) clobber $(DEPLOY_BUILD_ARGUMENTS))
-	@$(call MakeFinish, deploy, clobber)
+	@$(call MakeFinish,deploy,clobber)
 endif 
 
 deploy-sanity::
--- a/make/hotspot-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/hotspot-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -96,10 +96,10 @@
 hotspot-build::
 	$(MKDIR) -p $(HOTSPOT_OUTPUTDIR)
 	$(MKDIR) -p $(HOTSPOT_EXPORT_PATH)
-	@$(call MakeStart, hotspot, $(HOTSPOT_TARGET))
+	@$(call MakeStart,hotspot,$(HOTSPOT_TARGET))
 	$(CD) $(HOTSPOT_TOPDIR)/make && \
 	    $(MAKE) $(HOTSPOT_BUILD_ARGUMENTS) $(HOTSPOT_TARGET)
-	@$(call MakeFinish, hotspot, $(HOTSPOT_TARGET))
+	@$(call MakeFinish,hotspot,$(HOTSPOT_TARGET))
 
 #####################
 # .PHONY
--- a/make/install-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/install-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -57,39 +57,39 @@
 
 install-build:
 ifeq ($(BUILD_INSTALL), true)
-	@$(call MakeStart, install, $(INSTALL_BUILD_TARGETS))
+	@$(call MakeStart,install,$(INSTALL_BUILD_TARGETS))
 	($(CD) $(INSTALL_TOPDIR)/make && \
 	  $(MAKE) $(INSTALL_BUILD_TARGETS) $(INSTALL_BUILD_ARGUMENTS))
-	@$(call MakeFinish, install, $(INSTALL_BUILD_TARGETS))
+	@$(call MakeFinish,install,$(INSTALL_BUILD_TARGETS))
 endif
 
 update-patcher:
 ifeq ($(BUILD_INSTALL), true)
 	if [ -r $(INSTALL_TOPDIR)/make/update/Makefile ]; then \
-	  $(call MakeStart, install update, all); \
+	  $(call MakeStart,install_update,all); \
 	  ( $(CD) $(INSTALL_TOPDIR)/make/update && \
 	    $(MAKE) all $(INSTALL_BUILD_ARGUMENTS) ); \
-	  $(call MakeFinish, install, all); \
+	  $(call MakeFinish,install_update,all); \
 	fi
 endif
 
 update-patchgen:
 ifeq ($(BUILD_INSTALL), true)
 	if [ -r $(INSTALL_TOPDIR)/make/update/Makefile ]; then \
-	  $(call MakeStart, install update, patchgen); \
+	  $(call MakeStart,install_update,patchgen); \
 	  ( $(CD) $(INSTALL_TOPDIR)/make/update && \
 	    $(MAKE) patchgen $(INSTALL_BUILD_ARGUMENTS) ); \
-	  $(call MakeFinish, install, patchgen); \
+	  $(call MakeFinish,install_update,patchgen); \
 	fi
 endif
 
 installer:
 ifeq ($(BUILD_INSTALL), true)
 	if [ -r $(INSTALL_TOPDIR)/make/installer/Makefile ]; then \
-	  $(call MakeStart, install installer, all); \
+	  $(call MakeStart,install_installer,all); \
 	  ( $(CD) $(INSTALL_TOPDIR)/make/installer && \
 	    $(MAKE) all $(INSTALL_BUILD_ARGUMENTS) ); \
-	  $(call MakeFinish, install, all); \
+	  $(call MakeFinish,install_installer,all); \
 	fi
 endif
 
@@ -99,10 +99,10 @@
 
 install-clobber:
 ifeq ($(BUILD_INSTALL), true)
-	@$(call MakeStart, install, clobber)
+	@$(call MakeStart,install,clobber)
 	($(CD) $(INSTALL_TOPDIR)/make && \
 	  $(MAKE) clobber $(INSTALL_BUILD_ARGUMENTS))
-	@$(call MakeFinish, install, clobber)
+	@$(call MakeFinish,install,clobber)
 endif
 
 install-sanity:: 
--- a/make/jaxp-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/jaxp-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -40,17 +40,17 @@
 jaxp: jaxp-build
 jaxp-build:
 	$(MKDIR) -p $(JAXP_OUTPUTDIR)
-	@$(call MakeStart, jaxp, all)
+	@$(call MakeStart,jaxp,all)
 	($(CD) $(JAXP_TOPDIR)/make && \
 	 $(MAKE) $(JAXP_BUILD_ARGUMENTS) all)
-	@$(call MakeFinish, jaxp, all)
+	@$(call MakeFinish,jaxp,all)
 
 jaxp-clobber::
 	$(MKDIR) -p $(JAXP_OUTPUTDIR)
-	@$(call MakeStart, jaxp, clobber)
+	@$(call MakeStart,jaxp,clobber)
 	($(CD) $(JAXP_TOPDIR)/make &&  \
 	 $(MAKE) $(JAXP_BUILD_ARGUMENTS) clobber)
-	@$(call MakeFinish, jaxp, clobber)
+	@$(call MakeFinish,jaxp,clobber)
 
 .PHONY: jaxp jaxp-build jaxp-clobber
 
--- a/make/jaxws-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/jaxws-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -40,17 +40,17 @@
 jaxws: jaxws-build
 jaxws-build:
 	$(MKDIR) -p $(JAXWS_OUTPUTDIR)
-	@$(call MakeStart, jaxws, all)
+	@$(call MakeStart,jaxws,all)
 	($(CD) $(JAXWS_TOPDIR)/make && \
 	 $(MAKE) $(JAXWS_BUILD_ARGUMENTS) all)
-	@$(call MakeFinish, jaxws, all)
+	@$(call MakeFinish,jaxws,all)
 
 jaxws-clobber::
 	$(MKDIR) -p $(JAXWS_OUTPUTDIR)
-	@$(call MakeStart, jaxws, clobber)
+	@$(call MakeStart,jaxws,clobber)
 	($(CD) $(JAXWS_TOPDIR)/make &&  \
 	 $(MAKE) $(JAXWS_BUILD_ARGUMENTS) clobber)
-	@$(call MakeFinish, jaxws, clobber)
+	@$(call MakeFinish,jaxws,clobber)
 
 .PHONY: jaxws jaxws-build jaxws-clobber
 
--- a/make/jdk-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/jdk-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -75,16 +75,16 @@
 
 jdk: jdk-build
 jdk-build:
-	@$(call MakeStart, jdk, $(JDK_BUILD_TARGETS))
+	@$(call MakeStart,jdk,$(JDK_BUILD_TARGETS))
 	( $(CD) $(JDK_TOPDIR)/make && \
 	  $(MAKE) $(JDK_BUILD_TARGETS) $(JDK_BUILD_ARGUMENTS) ; )
-	@$(call MakeFinish, jdk, $(JDK_BUILD_TARGETS))
+	@$(call MakeFinish,jdk,$(JDK_BUILD_TARGETS))
 
 jdk-clobber::
-	@$(call MakeStart, jdk, $(JDK_CLOBBER_TARGETS))
+	@$(call MakeStart,jdk,$(JDK_CLOBBER_TARGETS))
 	( $(CD) $(JDK_TOPDIR)/make && \
 	  $(MAKE) $(JDK_CLOBBER_TARGETS) $(JDK_BUILD_ARGUMENTS) ; )
-	@$(call MakeFinish, jdk, $(JDK_CLOBBER_TARGETS))
+	@$(call MakeFinish,jdk,$(JDK_CLOBBER_TARGETS))
 
 jdk-sanity::
 	( $(CD) $(JDK_TOPDIR)/make && \
@@ -92,17 +92,17 @@
 
 compare-images: compare-image
 compare-image:
-	@$(call MakeStart, jdk, compare-image)
+	@$(call MakeStart,jdk,compare-image)
 	( $(CD) $(JDK_TOPDIR)/make && \
 	  $(MAKE) ALT_OUTPUTDIR=$(ABS_OUTPUTDIR) compare-image )
-	@$(call MakeFinish, jdk, compare-image)
+	@$(call MakeFinish,jdk,compare-image)
 
 compare-images-clobber: compare-image-clobber
 compare-image-clobber:
-	@$(call MakeStart, jdk, compare-image-clobber)
+	@$(call MakeStart,jdk,compare-image-clobber)
 	( $(CD) $(JDK_TOPDIR)/make && \
 	  $(MAKE) ALT_OUTPUTDIR=$(ABS_OUTPUTDIR) compare-image-clobber )
-	@$(call MakeFinish, jdk, compare-image-clobber)
+	@$(call MakeFinish,jdk,compare-image-clobber)
 
 .PHONY: jdk jdk-build jdk-clobber jdk-sanity 
 
--- a/make/langtools-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/langtools-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -35,17 +35,17 @@
 langtools: langtools-build
 langtools-build:
 	$(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)
-	@$(call MakeStart, langtools, all)
+	@$(call MakeStart,langtools,all)
 	($(CD) $(LANGTOOLS_TOPDIR)/make && \
 	  $(MAKE) $(LANGTOOLS_BUILD_ARGUMENTS) all)
-	@$(call MakeFinish, langtools, all)
+	@$(call MakeFinish,langtools,all)
 
 langtools-clobber::
 	$(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)
-	@$(call MakeStart, langtools, clobber)
+	@$(call MakeStart,langtools,clobber)
 	($(CD) $(LANGTOOLS_TOPDIR)/make &&  \
 	  $(MAKE) $(LANGTOOLS_BUILD_ARGUMENTS) clobber)
-	@$(call MakeFinish, langtools, clobber)
+	@$(call MakeFinish,langtools,clobber)
 
 .PHONY: langtools langtools-build langtools-clobber
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/scripts/webrev.ksh	Mon Mar 07 11:37:54 2011 -0800
@@ -0,0 +1,3182 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Use is subject to license terms.
+#
+# This script takes a file list and a workspace and builds a set of html files
+# suitable for doing a code review of source changes via a web page.
+# Documentation is available via 'webrev -h'.
+#
+
+WEBREV_UPDATED=23.18-hg
+
+HTML='<?xml version="1.0"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
+
+FRAMEHTML='<?xml version="1.0"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
+
+STDHEAD='<meta http-equiv="cache-control" content="no-cache" />
+<meta http-equiv="Pragma" content="no-cache" />
+<meta http-equiv="Expires" content="-1" />
+<!--
+   Note to customizers: the body of the webrev is IDed as SUNWwebrev
+   to allow easy overriding by users of webrev via the userContent.css
+   mechanism available in some browsers.
+
+   For example, to have all "removed" information be red instead of
+   brown, set a rule in your userContent.css file like:
+
+       body#SUNWwebrev span.removed { color: red ! important; }
+-->
+<style type="text/css" media="screen">
+body {
+    background-color: #eeeeee;
+}
+hr {
+    border: none 0;
+    border-top: 1px solid #aaa;
+    height: 1px;
+}
+div.summary {
+    font-size: .8em;
+    border-bottom: 1px solid #aaa;
+    padding-left: 1em;
+    padding-right: 1em;
+}
+div.summary h2 {
+    margin-bottom: 0.3em;
+}
+div.summary table th {
+    text-align: right;
+    vertical-align: top;
+    white-space: nowrap;
+}
+span.lineschanged {
+    font-size: 0.7em;
+}
+span.oldmarker {
+    color: red;
+    font-size: large;
+    font-weight: bold;
+}
+span.newmarker {
+    color: green;
+    font-size: large;
+    font-weight: bold;
+}
+span.removed {
+    color: brown;
+}
+span.changed {
+    color: blue;
+}
+span.new {
+    color: blue;
+    font-weight: bold;
+}
+a.print { font-size: x-small; }
+
+</style>
+
+<style type="text/css" media="print">
+pre { font-size: 0.8em; font-family: courier, monospace; }
+span.removed { color: #444; font-style: italic }
+span.changed { font-weight: bold; }
+span.new { font-weight: bold; }
+span.newmarker { font-size: 1.2em; font-weight: bold; }
+span.oldmarker { font-size: 1.2em; font-weight: bold; }
+a.print {display: none}
+hr { border: none 0; border-top: 1px solid #aaa; height: 1px; }
+</style>
+'
+
+#
+# UDiffs need a slightly different CSS rule for 'new' items (we don't
+# want them to be bolded as we do in cdiffs or sdiffs).
+#
+UDIFFCSS='
+<style type="text/css" media="screen">
+span.new {
+    color: blue;
+    font-weight: normal;
+}
+</style>
+'
+
+#
+# input_cmd | html_quote | output_cmd
+# or
+# html_quote filename | output_cmd
+#
+# Make a piece of source code safe for display in an HTML <pre> block.
+#
+html_quote()
+{
+	sed -e "s/&/\&amp;/g" -e "s/</\&lt;/g" -e "s/>/\&gt;/g" "$@" | expand
+}
+
+#
+# input_cmd | bug2url | output_cmd
+#
+# Scan for bugids and insert <a> links to the relevent bug database.
+#
+bug2url()
+{
+	sed -e 's|[0-9]\{5,\}|<a href=\"'$BUGURL'&\">&</a>|g'
+}
+
+#
+# input_cmd | sac2url | output_cmd
+#
+# Scan for ARC cases and insert <a> links to the relevent SAC database.
+# This is slightly complicated because inside the SWAN, SAC cases are
+# grouped by ARC: PSARC/2006/123.  But on OpenSolaris.org, they are
+# referenced as 2006/123 (without labelling the ARC).
+#
+sac2url()
+{
+	if [[ -z $Oflag ]]; then
+	    sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'\1/\2/\3\">\1 \2/\3</a>|g'
+	else
+	    sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'/\2/\3\">\1 \2/\3</a>|g'
+	fi
+}
+
+#
+# strip_unchanged <infile> | output_cmd
+#
+# Removes chunks of sdiff documents that have not changed. This makes it
+# easier for a code reviewer to find the bits that have changed.
+#
+# Deleted lines of text are replaced by a horizontal rule. Some
+# identical lines are retained before and after the changed lines to
+# provide some context.  The number of these lines is controlled by the
+# variable C in the $AWK script below.
+#
+# The script detects changed lines as any line that has a "<span class="
+# string embedded (unchanged lines have no particular class and are not
+# part of a <span>).  Blank lines (without a sequence number) are also
+# detected since they flag lines that have been inserted or deleted.
+#
+strip_unchanged()
+{
+	$AWK '
+	BEGIN	{ C = c = 20 }
+	NF == 0 || /span class=/ {
+		if (c > C) {
+			c -= C
+			inx = 0
+			if (c > C) {
+				print "\n</pre><hr></hr><pre>"
+				inx = c % C
+				c = C
+			}
+
+			for (i = 0; i < c; i++)
+				print ln[(inx + i) % C]
+		}
+		c = 0;
+		print
+		next
+	}
+	{	if (c >= C) {
+			ln[c % C] = $0
+			c++;
+			next;
+		}
+		c++;
+		print
+	}
+	END	{ if (c > (C * 2)) print "\n</pre><hr></hr>" }
+
+	' $1
+}
+
+#
+# sdiff_to_html
+#
+# This function takes two files as arguments, obtains their diff, and
+# processes the diff output to present the files as an HTML document with
+# the files displayed side-by-side, differences shown in color.  It also
+# takes a delta comment, rendered as an HTML snippet, as the third
+# argument.  The function takes two files as arguments, then the name of
+# file, the path, and the comment.  The HTML will be delivered on stdout,
+# e.g.
+#
+#   $ sdiff_to_html old/usr/src/tools/scripts/webrev.sh \
+#         new/usr/src/tools/scripts/webrev.sh \
+#         webrev.sh usr/src/tools/scripts \
+#         '<a href="http://monaco.sfbay.sun.com/detail.jsp?cr=1234567">
+#          1234567</a> my bugid' > <file>.html
+#
+# framed_sdiff() is then called which creates $2.frames.html
+# in the webrev tree.
+#
+# FYI: This function is rather unusual in its use of awk.  The initial
+# diff run produces conventional diff output showing changed lines mixed
+# with editing codes.  The changed lines are ignored - we're interested in
+# the editing codes, e.g.
+#
+#      8c8
+#      57a61
+#      63c66,76
+#      68,93d80
+#      106d90
+#      108,110d91
+#
+#  These editing codes are parsed by the awk script and used to generate
+#  another awk script that generates HTML, e.g the above lines would turn
+#  into something like this:
+#
+#      BEGIN { printf "<pre>\n" }
+#      function sp(n) {for (i=0;i<n;i++)printf "\n"}
+#      function wl(n) {printf "<font color=%s>%4d %s </font>\n", n, NR, $0}
+#      NR==8           {wl("#7A7ADD");next}
+#      NR==54          {wl("#7A7ADD");sp(3);next}
+#      NR==56          {wl("#7A7ADD");next}
+#      NR==57          {wl("black");printf "\n"; next}
+#        :               :
+#
+#  This script is then run on the original source file to generate the
+#  HTML that corresponds to the source file.
+#
+#  The two HTML files are then combined into a single piece of HTML that
+#  uses an HTML table construct to present the files side by side.  You'll
+#  notice that the changes are color-coded:
+#
+#   black     - unchanged lines
+#   blue      - changed lines
+#   bold blue - new lines
+#   brown     - deleted lines
+#
+#  Blank lines are inserted in each file to keep unchanged lines in sync
+#  (side-by-side).  This format is familiar to users of sdiff(1) or
+#  Teamware's filemerge tool.
+#
+sdiff_to_html()
+{
+	diff -b $1 $2 > /tmp/$$.diffs
+
+	TNAME=$3
+	TPATH=$4
+	COMMENT=$5
+
+	#
+	#  Now we have the diffs, generate the HTML for the old file.
+	#
+	$AWK '
+	BEGIN	{
+		printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
+		printf "function removed() "
+		printf "{printf \"<span class=\\\"removed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
+		printf "function changed() "
+		printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
+		printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
+}
+	/^</	{next}
+	/^>/	{next}
+	/^---/	{next}
+
+	{
+	split($1, a, /[cad]/) ;
+	if (index($1, "a")) {
+		if (a[1] == 0) {
+			n = split(a[2], r, /,/);
+			if (n == 1)
+				printf "BEGIN\t\t{sp(1)}\n"
+			else
+				printf "BEGIN\t\t{sp(%d)}\n",\
+				(r[2] - r[1]) + 1
+			next
+		}
+
+		printf "NR==%s\t\t{", a[1]
+		n = split(a[2], r, /,/);
+		s = r[1];
+		if (n == 1)
+			printf "bl();printf \"\\n\"; next}\n"
+		else {
+			n = r[2] - r[1]
+			printf "bl();sp(%d);next}\n",\
+			(r[2] - r[1]) + 1
+		}
+		next
+	}
+	if (index($1, "d")) {
+		n = split(a[1], r, /,/);
+		n1 = r[1]
+		n2 = r[2]
+		if (n == 1)
+			printf "NR==%s\t\t{removed(); next}\n" , n1
+		else
+			printf "NR==%s,NR==%s\t{removed(); next}\n" , n1, n2
+		next
+	}
+	if (index($1, "c")) {
+		n = split(a[1], r, /,/);
+		n1 = r[1]
+		n2 = r[2]
+		final = n2
+		d1 = 0
+		if (n == 1)
+			printf "NR==%s\t\t{changed();" , n1
+		else {
+			d1 = n2 - n1
+			printf "NR==%s,NR==%s\t{changed();" , n1, n2
+		}
+		m = split(a[2], r, /,/);
+		n1 = r[1]
+		n2 = r[2]
+		if (m > 1) {
+			d2  = n2 - n1
+			if (d2 > d1) {
+				if (n > 1) printf "if (NR==%d)", final
+				printf "sp(%d);", d2 - d1
+			}
+		}
+		printf "next}\n" ;
+
+		next
+	}
+	}
+
+	END	{ printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
+	' /tmp/$$.diffs > /tmp/$$.file1
+
+	#
+	#  Now generate the HTML for the new file
+	#
+	$AWK '
+	BEGIN	{
+		printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
+		printf "function new() "
+		printf "{printf \"<span class=\\\"new\\\">%%4d %%s</span>\\n\", NR, $0}\n"
+		printf "function changed() "
+		printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
+		printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
+	}
+
+	/^</	{next}
+	/^>/	{next}
+	/^---/	{next}
+
+	{
+	split($1, a, /[cad]/) ;
+	if (index($1, "d")) {
+		if (a[2] == 0) {
+			n = split(a[1], r, /,/);
+			if (n == 1)
+				printf "BEGIN\t\t{sp(1)}\n"
+			else
+				printf "BEGIN\t\t{sp(%d)}\n",\
+				(r[2] - r[1]) + 1
+			next
+		}
+
+		printf "NR==%s\t\t{", a[2]
+		n = split(a[1], r, /,/);
+		s = r[1];
+		if (n == 1)
+			printf "bl();printf \"\\n\"; next}\n"
+		else {
+			n = r[2] - r[1]
+			printf "bl();sp(%d);next}\n",\
+			(r[2] - r[1]) + 1
+		}
+		next
+	}
+	if (index($1, "a")) {
+		n = split(a[2], r, /,/);
+		n1 = r[1]
+		n2 = r[2]
+		if (n == 1)
+			printf "NR==%s\t\t{new() ; next}\n" , n1
+		else
+			printf "NR==%s,NR==%s\t{new() ; next}\n" , n1, n2
+		next
+	}
+	if (index($1, "c")) {
+		n = split(a[2], r, /,/);
+		n1 = r[1]
+		n2 = r[2]
+		final = n2
+		d2 = 0;
+		if (n == 1) {
+			final = n1
+			printf "NR==%s\t\t{changed();" , n1
+		} else {
+			d2 = n2 - n1
+			printf "NR==%s,NR==%s\t{changed();" , n1, n2
+		}
+		m = split(a[1], r, /,/);
+		n1 = r[1]
+		n2 = r[2]
+		if (m > 1) {
+			d1  = n2 - n1
+			if (d1 > d2) {
+				if (n > 1) printf "if (NR==%d)", final
+				printf "sp(%d);", d1 - d2
+			}
+		}
+		printf "next}\n" ;
+		next
+	}
+	}
+	END	{ printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
+	' /tmp/$$.diffs > /tmp/$$.file2
+
+	#
+	# Post-process the HTML files by running them back through $AWK
+	#
+	html_quote < $1 | $AWK -f /tmp/$$.file1 > /tmp/$$.file1.html
+
+	html_quote < $2 | $AWK -f /tmp/$$.file2 > /tmp/$$.file2.html
+
+	#
+	# Now combine into a valid HTML file and side-by-side into a table
+	#
+	print "$HTML<head>$STDHEAD"
+	print "<title>$WNAME Sdiff $TPATH </title>"
+	print "</head><body id=\"SUNWwebrev\">"
+	print "<h2>$TPATH/$TNAME</h2>"
+        print "<a class=\"print\" href=\"javascript:print()\">Print this page</a>"
+	print "<pre>$COMMENT</pre>\n"
+	print "<table><tr valign=\"top\">"
+	print "<td><pre>"
+
+	strip_unchanged /tmp/$$.file1.html
+
+	print "</pre></td><td><pre>"
+
+	strip_unchanged /tmp/$$.file2.html
+
+	print "</pre></td>"
+	print "</tr></table>"
+	print "</body></html>"
+
+	framed_sdiff $TNAME $TPATH /tmp/$$.file1.html /tmp/$$.file2.html \
+	    "$COMMENT"
+}
+
+
+#
+# framed_sdiff <filename> <filepath> <lhsfile> <rhsfile> <comment>
+#
+# Expects lefthand and righthand side html files created by sdiff_to_html.
+# We use insert_anchors() to augment those with HTML navigation anchors,
+# and then emit the main frame.  Content is placed into:
+#
+#    $WDIR/DIR/$TNAME.lhs.html
+#    $WDIR/DIR/$TNAME.rhs.html
+#    $WDIR/DIR/$TNAME.frames.html
+#
+# NOTE: We rely on standard usage of $WDIR and $DIR.
+#
+function framed_sdiff
+{
+	typeset TNAME=$1
+	typeset TPATH=$2
+	typeset lhsfile=$3
+	typeset rhsfile=$4
+	typeset comments=$5
+	typeset RTOP
+
+	# Enable html files to access WDIR via a relative path.
+	RTOP=$(relative_dir $TPATH $WDIR)
+
+	# Make the rhs/lhs files and output the frameset file.
+	print "$HTML<head>$STDHEAD" > $WDIR/$DIR/$TNAME.lhs.html
+
+	cat >> $WDIR/$DIR/$TNAME.lhs.html <<-EOF
+	    <script type="text/javascript" src="$RTOP/ancnav.js"></script>
+	    </head>
+	    <body id="SUNWwebrev" onkeypress="keypress(event);">
+	    <a name="0"></a>
+	    <pre>$comments</pre><hr></hr>
+	EOF
+
+	cp $WDIR/$DIR/$TNAME.lhs.html $WDIR/$DIR/$TNAME.rhs.html
+
+	insert_anchors $lhsfile >> $WDIR/$DIR/$TNAME.lhs.html
+	insert_anchors $rhsfile >> $WDIR/$DIR/$TNAME.rhs.html
+
+	close='</body></html>'
+
+	print $close >> $WDIR/$DIR/$TNAME.lhs.html
+	print $close >> $WDIR/$DIR/$TNAME.rhs.html
+
+	print "$FRAMEHTML<head>$STDHEAD" > $WDIR/$DIR/$TNAME.frames.html
+	print "<title>$WNAME Framed-Sdiff " \
+	    "$TPATH/$TNAME</title> </head>" >> $WDIR/$DIR/$TNAME.frames.html
+	cat >> $WDIR/$DIR/$TNAME.frames.html <<-EOF
+	  <frameset rows="*,60">
+	    <frameset cols="50%,50%">
+	      <frame src="$TNAME.lhs.html" scrolling="auto" name="lhs" />
+	      <frame src="$TNAME.rhs.html" scrolling="auto" name="rhs" />
+	    </frameset>
+	  <frame src="$RTOP/ancnav.html" scrolling="no" marginwidth="0"
+	   marginheight="0" name="nav" />
+	  <noframes>
+            <body id="SUNWwebrev">
+	      Alas 'frames' webrev requires that your browser supports frames
+	      and has the feature enabled.
+            </body>
+	  </noframes>
+	  </frameset>
+	</html>
+	EOF
+}
+
+
+#
+# fix_postscript
+#
+# Merge codereview output files to a single conforming postscript file, by:
+# 	- removing all extraneous headers/trailers
+#	- making the page numbers right
+#	- removing pages devoid of contents which confuse some
+#	  postscript readers.
+#
+# From Casper.
+#
+function fix_postscript
+{
+	infile=$1
+
+	cat > /tmp/$$.crmerge.pl << \EOF
+
+	print scalar(<>);		# %!PS-Adobe---
+	print "%%Orientation: Landscape\n";
+
+	$pno = 0;
+	$doprint = 1;
+
+	$page = "";
+
+	while (<>) {
+		next if (/^%%Pages:\s*\d+/);
+
+		if (/^%%Page:/) {
+			if ($pno == 0 || $page =~ /\)S/) {
+				# Header or single page containing text
+				print "%%Page: ? $pno\n" if ($pno > 0);
+				print $page;
+				$pno++;
+			} else {
+				# Empty page, skip it.
+			}
+			$page = "";
+			$doprint = 1;
+			next;
+		}
+
+		# Skip from %%Trailer of one document to Endprolog
+		# %%Page of the next
+		$doprint = 0 if (/^%%Trailer/);
+		$page .= $_ if ($doprint);
+	}
+
+	if ($page =~ /\)S/) {
+		print "%%Page: ? $pno\n";
+		print $page;
+	} else {
+		$pno--;
+	}
+	print "%%Trailer\n%%Pages: $pno\n";
+EOF
+
+	$PERL /tmp/$$.crmerge.pl < $infile
+}
+
+
+#
+# input_cmd | insert_anchors | output_cmd
+#
+# Flag blocks of difference with sequentially numbered invisible
+# anchors.  These are used to drive the frames version of the
+# sdiffs output.
+#
+# NOTE: Anchor zero flags the top of the file irrespective of changes,
+# an additional anchor is also appended to flag the bottom.
+#
+# The script detects changed lines as any line that has a "<span
+# class=" string embedded (unchanged lines have no class set and are
+# not part of a <span>.  Blank lines (without a sequence number)
+# are also detected since they flag lines that have been inserted or
+# deleted.
+#
+function insert_anchors
+{
+	$AWK '
+	function ia() {
+		# This should be able to be a singleton <a /> but that
+		# seems to trigger a bug in firefox a:hover rule processing
+		printf "<a name=\"%d\" id=\"anc%d\"></a>", anc, anc++;
+	}
+
+	BEGIN {
+		anc=1;
+		inblock=1;
+		printf "<pre>\n";
+	}
+	NF == 0 || /^<span class=/ {
+		if (inblock == 0) {
+			ia();
+			inblock=1;
+		}
+		print;
+		next;
+	}
+	{
+		inblock=0;
+		print;
+	}
+	END {
+		ia();
+
+		printf "<b style=\"font-size: large; color: red\">";
+		printf "--- EOF ---</b>"
+        	for(i=0;i<8;i++) printf "\n\n\n\n\n\n\n\n\n\n";
+		printf "</pre>"
+		printf "<form name=\"eof\">";
+		printf "<input name=\"value\" value=\"%d\" type=\"hidden\" />",
+		    anc - 1;
+		printf "</form>";
+	}
+	' $1
+}
+
+
+#
+# relative_dir
+#
+# Print a relative return path from $1 to $2.  For example if
+# $1=/tmp/myreview/raw_files/usr/src/tools/scripts and $2=/tmp/myreview,
+# this function would print "../../../../".
+#
+# In the event that $1 is not in $2 a warning is printed to stderr,
+# and $2 is returned-- the result of this is that the resulting webrev
+# is not relocatable.
+#
+function relative_dir
+{
+    d1=$1
+    d2=$2
+    if [[ "$d1" == "." ]]; then
+	print "."
+    else
+	typeset cur="${d1##$d2?(/)}"
+	typeset ret=""
+	if [[ $d2 == $cur ]]; then   # Should never happen.
+		# Should never happen.
+		print -u2 "\nWARNING: relative_dir: \"$1\" not relative "
+		print -u2 "to \"$2\".  Check input paths.  Framed webrev "
+		print -u2 "will not be relocatable!"
+		print $2
+		return
+	fi
+
+	while [[ -n ${cur} ]];
+	do
+		cur=${cur%%*(/)*([!/])}
+		if [[ -z $ret ]]; then
+			ret=".."
+		else
+			ret="../$ret"
+		fi
+	done
+	print $ret
+    fi
+}
+
+
+#
+# frame_nav_js
+#
+# Emit javascript for frame navigation
+#
+function frame_nav_js
+{
+cat << \EOF
+var myInt;
+var scrolling=0;
+var sfactor = 3;
+var scount=10;
+
+function scrollByPix() {
+	if (scount<=0) {
+		sfactor*=1.2;
+		scount=10;
+	}
+	parent.lhs.scrollBy(0,sfactor);
+	parent.rhs.scrollBy(0,sfactor);
+	scount--;
+}
+
+function scrollToAnc(num) {
+
+	// Update the value of the anchor in the form which we use as
+	// storage for this value.  setAncValue() will take care of
+	// correcting for overflow and underflow of the value and return
+	// us the new value.
+	num = setAncValue(num);
+
+	// Set location and scroll back a little to expose previous
+	// lines.
+	//
+	// Note that this could be improved: it is possible although
+	// complex to compute the x and y position of an anchor, and to
+	// scroll to that location directly.
+	//
+	parent.lhs.location.replace(parent.lhs.location.pathname + "#" + num);
+	parent.rhs.location.replace(parent.rhs.location.pathname + "#" + num);
+
+	parent.lhs.scrollBy(0,-30);
+	parent.rhs.scrollBy(0,-30);
+}
+
+function getAncValue()
+{
+	return (parseInt(parent.nav.document.diff.real.value));
+}
+
+function setAncValue(val)
+{
+	if (val <= 0) {
+		val = 0;
+		parent.nav.document.diff.real.value = val;
+		parent.nav.document.diff.display.value = "BOF";
+		return (val);
+	}
+
+	//
+	// The way we compute the max anchor value is to stash it
+	// inline in the left and right hand side pages-- it's the same
+	// on each side, so we pluck from the left.
+	//
+	maxval = parent.lhs.document.eof.value.value;
+	if (val < maxval) {
+		parent.nav.document.diff.real.value = val;
+		parent.nav.document.diff.display.value = val.toString();
+		return (val);
+	}
+
+	// this must be: val >= maxval
+	val = maxval;
+	parent.nav.document.diff.real.value = val;
+	parent.nav.document.diff.display.value = "EOF";
+	return (val);
+}
+
+function stopScroll() {
+	if (scrolling==1) {
+		clearInterval(myInt);
+		scrolling=0;
+	}
+}
+
+function startScroll() {
+	stopScroll();
+	scrolling=1;
+	myInt=setInterval("scrollByPix()",10);
+}
+
+function handlePress(b) {
+
+	switch (b) {
+	    case 1 :
+		scrollToAnc(-1);
+		break;
+	    case 2 :
+		scrollToAnc(getAncValue() - 1);
+		break;
+	    case 3 :
+		sfactor=-3;
+		startScroll();
+		break;
+	    case 4 :
+		sfactor=3;
+		startScroll();
+		break;
+	    case 5 :
+		scrollToAnc(getAncValue() + 1);
+		break;
+	    case 6 :
+		scrollToAnc(999999);
+		break;
+	}
+}
+
+function handleRelease(b) {
+	stopScroll();
+}
+
+function keypress(ev) {
+	var keynum;
+	var keychar;
+
+	if (window.event) { // IE
+		keynum = ev.keyCode;
+	} else if (ev.which) { // non-IE
+		keynum = ev.which;
+	}
+
+	keychar = String.fromCharCode(keynum);
+
+	if (keychar == "k") {
+		handlePress(2);
+		return (0);
+	} else if (keychar == "j" || keychar == " ") {
+		handlePress(5);
+		return (0);
+	}
+	return (1);
+}
+
+function ValidateDiffNum(){
+	val = parent.nav.document.diff.display.value;
+	if (val == "EOF") {
+		scrollToAnc(999999);
+		return;
+	}
+
+	if (val == "BOF") {
+		scrollToAnc(0);
+		return;
+	}
+
+        i=parseInt(val);
+        if (isNaN(i)) {
+                parent.nav.document.diff.display.value = getAncValue();
+        } else {
+                scrollToAnc(i);
+        }
+        return false;
+}
+
+EOF
+}
+
+#
+# frame_navigation
+#
+# Output anchor navigation file for framed sdiffs.
+#
+function frame_navigation
+{
+	print "$HTML<head>$STDHEAD"
+
+	cat << \EOF
+<title>Anchor Navigation</title>
+<meta http-equiv="Content-Script-Type" content="text/javascript" />
+<meta http-equiv="Content-Type" content="text/html" />
+
+<style type="text/css">
+    div.button td { padding-left: 5px; padding-right: 5px;
+		    background-color: #eee; text-align: center;
+		    border: 1px #444 outset; cursor: pointer; }
+    div.button a { font-weight: bold; color: black }
+    div.button td:hover { background: #ffcc99; }
+</style>
+EOF
+
+	print "<script type=\"text/javascript\" src=\"ancnav.js\"></script>"
+
+	cat << \EOF
+</head>
+<body id="SUNWwebrev" bgcolor="#eeeeee" onload="document.diff.real.focus();"
+	onkeypress="keypress(event);">
+    <noscript lang="javascript">
+      <center>
+	<p><big>Framed Navigation controls require Javascript</big><br />
+	Either this browser is incompatable or javascript is not enabled</p>
+      </center>
+    </noscript>
+    <table width="100%" border="0" align="center">
+	<tr>
+          <td valign="middle" width="25%">Diff navigation:
+          Use 'j' and 'k' for next and previous diffs; or use buttons
+          at right</td>
+	  <td align="center" valign="top" width="50%">
+	    <div class="button">
+	      <table border="0" align="center">
+                  <tr>
+		    <td>
+		      <a onMouseDown="handlePress(1);return true;"
+			 onMouseUp="handleRelease(1);return true;"
+			 onMouseOut="handleRelease(1);return true;"
+			 onClick="return false;"
+			 title="Go to Beginning Of file">BOF</a></td>
+		    <td>
+		      <a onMouseDown="handlePress(3);return true;"
+			 onMouseUp="handleRelease(3);return true;"
+			 onMouseOut="handleRelease(3);return true;"
+			 title="Scroll Up: Press and Hold to accelerate"
+			 onClick="return false;">Scroll Up</a></td>
+		    <td>
+		      <a onMouseDown="handlePress(2);return true;"
+			 onMouseUp="handleRelease(2);return true;"
+			 onMouseOut="handleRelease(2);return true;"
+			 title="Go to previous Diff"
+			 onClick="return false;">Prev Diff</a>
+		    </td></tr>
+
+		  <tr>
+		    <td>
+		      <a onMouseDown="handlePress(6);return true;"
+			 onMouseUp="handleRelease(6);return true;"
+			 onMouseOut="handleRelease(6);return true;"
+			 onClick="return false;"
+			 title="Go to End Of File">EOF</a></td>
+		    <td>
+		      <a onMouseDown="handlePress(4);return true;"
+			 onMouseUp="handleRelease(4);return true;"
+			 onMouseOut="handleRelease(4);return true;"
+			 title="Scroll Down: Press and Hold to accelerate"
+			 onClick="return false;">Scroll Down</a></td>
+		    <td>
+		      <a onMouseDown="handlePress(5);return true;"
+			 onMouseUp="handleRelease(5);return true;"
+			 onMouseOut="handleRelease(5);return true;"
+			 title="Go to next Diff"
+			 onClick="return false;">Next Diff</a></td>
+		  </tr>
+              </table>
+	    </div>
+	  </td>
+	  <th valign="middle" width="25%">
+	    <form action="" name="diff" onsubmit="return ValidateDiffNum();">
+		<input name="display" value="BOF" size="8" type="text" />
+		<input name="real" value="0" size="8" type="hidden" />
+	    </form>
+	  </th>
+	</tr>
+    </table>
+  </body>
+</html>
+EOF
+}
+
+
+
+#
+# diff_to_html <filename> <filepath> { U | C } <comment>
+#
+# Processes the output of diff to produce an HTML file representing either
+# context or unified diffs.
+#
+diff_to_html()
+{
+	TNAME=$1
+	TPATH=$2
+	DIFFTYPE=$3
+	COMMENT=$4
+
+	print "$HTML<head>$STDHEAD"
+	print "<title>$WNAME ${DIFFTYPE}diff $TPATH</title>"
+
+	if [[ $DIFFTYPE == "U" ]]; then
+		print "$UDIFFCSS"
+	fi
+
+	cat <<-EOF
+	</head>
+	<body id="SUNWwebrev">
+	<h2>$TPATH</h2>
+        <a class="print" href="javascript:print()">Print this page</a>
+	<pre>$COMMENT</pre>
+        <pre>
+EOF
+
+	html_quote | $AWK '
+	/^--- new/	{ next }
+	/^\+\+\+ new/	{ next }
+	/^--- old/	{ next }
+	/^\*\*\* old/	{ next }
+	/^\*\*\*\*/	{ next }
+	/^-------/	{ printf "<center><h1>%s</h1></center>\n", $0; next }
+	/^\@\@.*\@\@$/	{ printf "</pre><hr /><pre>\n";
+			  printf "<span class=\"newmarker\">%s</span>\n", $0;
+			  next}
+
+	/^\*\*\*/	{ printf "<hr /><span class=\"oldmarker\">%s</span>\n", $0;
+			  next}
+	/^---/		{ printf "<span class=\"newmarker\">%s</span>\n", $0;
+			  next}
+	/^\+/		{printf "<span class=\"new\">%s</span>\n", $0; next}
+	/^!/		{printf "<span class=\"changed\">%s</span>\n", $0; next}
+	/^-/		{printf "<span class=\"removed\">%s</span>\n", $0; next}
+			{printf "%s\n", $0; next}
+	'
+
+	print "</pre></body></html>\n"
+}
+
+
+#
+# source_to_html { new | old } <filename>
+#
+# Process a plain vanilla source file to transform it into an HTML file.
+#
+source_to_html()
+{
+	WHICH=$1
+	TNAME=$2
+
+	print "$HTML<head>$STDHEAD"
+	print "<title>$WHICH $TNAME</title>"
+	print "<body id=\"SUNWwebrev\">"
+	print "<pre>"
+	html_quote | $AWK '{line += 1 ; printf "%4d %s\n", line, $0 }'
+	print "</pre></body></html>"
+}
+
+#
+# teamwarecomments {text|html} parent-file child-file
+#
+# Find the first delta in the child that's not in the parent.  Get the
+# newest delta from the parent, get all deltas from the child starting
+# with that delta, and then get all info starting with the second oldest
+# delta in that list (the first delta unique to the child).
+#
+# This code adapted from Bill Shannon's "spc" script
+#
+comments_from_teamware()
+{
+	fmt=$1
+	pfile=$PWS/$2
+	cfile=$CWS/$3
+
+	psid=$($SCCS prs -d:I: $pfile 2>/dev/null)
+	if [[ -z "$psid" ]]; then
+	    psid=1.1
+	fi
+
+	set -A sids $($SCCS prs -l -r$psid -d:I: $cfile 2>/dev/null)
+	N=${#sids[@]}
+
+	nawkprg='
+		/^COMMENTS:/	{p=1; next}
+		/^D [0-9]+\.[0-9]+/ {printf "--- %s ---\n", $2; p=0; }
+		NF == 0u	{ next }
+		{if (p==0) next; print $0 }'
+
+	if [[ $N -ge 2 ]]; then
+		sid1=${sids[$((N-2))]}	# Gets 2nd to last sid
+
+		if [[ $fmt == "text" ]]; then
+			$SCCS prs -l -r$sid1 $cfile  2>/dev/null | \
+			    $AWK "$nawkprg"
+			return
+		fi
+
+		$SCCS prs -l -r$sid1 $cfile  2>/dev/null | \
+		    html_quote | bug2url | sac2url | $AWK "$nawkprg"
+	fi
+}
+
+#
+# wxcomments {text|html} filepath
+#
+# Given the pathname of a file, find its location in a "wx" active file
+# list and print the following sccs comment.  Output is either text or
+# HTML; if the latter, embedded bugids (sequence of 5 or more digits) are
+# turned into URLs.
+#
+comments_from_wx()
+{
+	typeset fmt=$1
+	typeset p=$2
+
+	comm=`$AWK '
+	$1 == "'$p'" {
+		do getline ; while (NF > 0)
+		getline
+		while (NF > 0) { print ; getline }
+		exit
+	}' < $wxfile`
+
+	if [[ $fmt == "text" ]]; then
+		print "$comm"
+		return
+	fi
+
+	print "$comm" | html_quote | bug2url | sac2url
+}
+
+comments_from_mercurial()
+{
+	fmt=$1
+	pfile=$PWS/$2
+	cfile=$CWS/$3
+
+        logdir=`dirname $cfile`
+        logf=`basename $cfile`
+        if [ -d $logdir ]; then
+            ( cd $logdir;
+	        active=`hg status $logf 2>/dev/null`
+                # If the output from 'hg status' is not empty, it means the file
+                # hasn't been committed, so don't fetch comments.
+	        if [[ -z $active ]] ; then
+                    if [[ -n $ALL_CREV ]]; then
+                        rev_opt=
+                        for rev in $ALL_CREV; do
+                            rev_opt="$rev_opt --rev $rev"
+                        done
+                        comm=`hg log $rev_opt --follow --template 'rev {rev} : {desc}\n' $logf`
+                    elif [[ -n $FIRST_CREV ]]; then
+		        comm=`hg log --rev $FIRST_CREV:tip --follow --template 'rev {rev} : {desc}\n' $logf`
+                    else
+		        comm=`hg log -l1 --follow --template 'rev {rev} : {desc}\n' $logf`
+                    fi
+	        else
+	            comm=""
+	        fi
+	        if [[ $fmt == "text" ]]; then
+	            print "$comm"
+	            return
+	        fi
+	  
+	        print "$comm" | html_quote | bug2url | sac2url
+                )
+        fi
+}
+
+
+#
+# getcomments {text|html} filepath parentpath
+#
+# Fetch the comments depending on what SCM mode we're in.
+#
+getcomments()
+{
+	typeset fmt=$1
+	typeset p=$2
+	typeset pp=$3
+
+	if [[ -n $wxfile ]]; then
+		comments_from_wx $fmt $p
+	else
+		if [[ $SCM_MODE == "teamware" ]]; then
+			comments_from_teamware $fmt $pp $p
+		elif [[ $SCM_MODE == "mercurial" ]]; then
+			comments_from_mercurial $fmt $pp $p
+		fi
+	fi
+}
+
+#
+# printCI <total-changed> <inserted> <deleted> <modified> <unchanged>
+#
+# Print out Code Inspection figures similar to sccs-prt(1) format.
+#
+function printCI
+{
+	integer tot=$1 ins=$2 del=$3 mod=$4 unc=$5
+	typeset str
+	if (( tot == 1 )); then
+		str="line"
+	else
+		str="lines"
+	fi
+	printf '%d %s changed: %d ins; %d del; %d mod; %d unchg' \
+	    $tot $str $ins $del $mod $unc
+}
+
+
+#
+# difflines <oldfile> <newfile>
+#
+# Calculate and emit number of added, removed, modified and unchanged lines,
+# and total lines changed, the sum of added + removed + modified.
+#
+function difflines
+{
+	integer tot mod del ins unc err
+	typeset filename
+
+	eval $( diff -e $1 $2 | $AWK '
+	# Change range of lines: N,Nc
+	/^[0-9]*,[0-9]*c$/ {
+		n=split(substr($1,1,length($1)-1), counts, ",");
+		if (n != 2) {
+		    error=2
+		    exit;
+		}
+		#
+		# 3,5c means lines 3 , 4 and 5 are changed, a total of 3 lines.
+		# following would be 5 - 3 = 2! Hence +1 for correction.
+		#
+		r=(counts[2]-counts[1])+1;
+
+		#
+		# Now count replacement lines: each represents a change instead
+		# of a delete, so increment c and decrement r.
+		#
+		while (getline != /^\.$/) {
+			c++;
+			r--;
+		}
+		#
+		# If there were more replacement lines than original lines,
+		# then r will be negative; in this case there are no deletions,
+		# but there are r changes that should be counted as adds, and
+		# since r is negative, subtract it from a and add it to c.
+		#
+		if (r < 0) {
+			a-=r;
+			c+=r;
+		}
+
+		#
+		# If there were more original lines than replacement lines, then
+		# r will be positive; in this case, increment d by that much.
+		#
+		if (r > 0) {
+			d+=r;
+		}
+		next;
+	}
+
+	# Change lines: Nc
+	/^[0-9].*c$/ {
+		# The first line is a replacement; any more are additions.
+		if (getline != /^\.$/) {
+			c++;
+			while (getline != /^\.$/) a++;
+		}
+		next;
+	}
+
+	# Add lines: both Na and N,Na
+	/^[0-9].*a$/ {
+		while (getline != /^\.$/) a++;
+		next;
+	}
+
+	# Delete range of lines: N,Nd
+	/^[0-9]*,[0-9]*d$/ {
+		n=split(substr($1,1,length($1)-1), counts, ",");
+		if (n != 2) {
+			error=2
+			exit;
+		}
+		#
+		# 3,5d means lines 3 , 4 and 5 are deleted, a total of 3 lines.
+		# following would be 5 - 3 = 2! Hence +1 for correction.
+		#
+		r=(counts[2]-counts[1])+1;
+		d+=r;
+		next;
+	}
+
+	# Delete line: Nd.   For example 10d says line 10 is deleted.
+	/^[0-9]*d$/ {d++; next}
+
+	# Should not get here!
+	{
+		error=1;
+		exit;
+	}
+
+	# Finish off - print results
+	END {
+		printf("tot=%d;mod=%d;del=%d;ins=%d;err=%d\n",
+		    (c+d+a), c, d, a, error);
+	}' )
+
+	# End of $AWK, Check to see if any trouble occurred.
+	if (( $? > 0 || err > 0 )); then
+		print "Unexpected Error occurred reading" \
+		    "\`diff -e $1 $2\`: \$?=$?, err=" $err
+		return
+	fi
+
+	# Accumulate totals
+	(( TOTL += tot ))
+	(( TMOD += mod ))
+	(( TDEL += del ))
+	(( TINS += ins ))
+	# Calculate unchanged lines
+	unc=`wc -l < $1`
+	if (( unc > 0 )); then
+		(( unc -= del + mod ))
+		(( TUNC += unc ))
+	fi
+	# print summary
+	print "<span class=\"lineschanged\">\c"
+	printCI $tot $ins $del $mod $unc
+	print "</span>"
+}
+
+
+#
+# flist_from_wx
+#
+# Sets up webrev to source its information from a wx-formatted file.
+# Sets the global 'wxfile' variable.
+#
+function flist_from_wx
+{
+	typeset argfile=$1
+	if [[ -n ${argfile%%/*} ]]; then
+		#
+		# If the wx file pathname is relative then make it absolute
+		# because the webrev does a "cd" later on.
+		#
+		wxfile=$PWD/$argfile
+	else
+		wxfile=$argfile
+	fi
+
+	$AWK '{ c = 1; print;
+	  while (getline) {
+		if (NF == 0) { c = -c; continue }
+		if (c > 0) print
+	  }
+	}' $wxfile > $FLIST
+
+	print " Done."
+}
+
+#
+# flist_from_teamware [ <args-to-putback-n> ]
+#
+# Generate the file list by extracting file names from a putback -n.  Some
+# names may come from the "update/create" messages and others from the
+# "currently checked out" warning.  Renames are detected here too.  Extract
+# values for CODEMGR_WS and CODEMGR_PARENT from the output of the putback
+# -n as well, but remove them if they are already defined.
+#
+function flist_from_teamware
+{
+	if [[ -n $codemgr_parent ]]; then
+		if [[ ! -d $codemgr_parent/Codemgr_wsdata ]]; then
+			print -u2 "parent $codemgr_parent doesn't look like a" \
+			    "valid teamware workspace"
+			exit 1
+		fi
+		parent_args="-p $codemgr_parent"
+	fi
+
+	print " File list from: 'putback -n $parent_args $*' ... \c"
+
+	putback -n $parent_args $* 2>&1 |
+	    $AWK '
+		/^update:|^create:/	{print $2}
+		/^Parent workspace:/	{printf("CODEMGR_PARENT=%s\n",$3)}
+		/^Child workspace:/	{printf("CODEMGR_WS=%s\n",$3)}
+		/^The following files are currently checked out/ {p = 1; next}
+		NF == 0			{p=0 ; next}
+		/^rename/		{old=$3}
+		$1 == "to:"		{print $2, old}
+		/^"/			{next}
+		p == 1			{print $1}' |
+	    sort -r -k 1,1 -u | sort > $FLIST
+
+	print " Done."
+}
+
+function outgoing_from_mercurial_forest
+{
+    hg foutgoing --template 'rev: {rev}\n' $OUTPWS | $FILTER | $AWK '
+        BEGIN           {ntree=0}
+        /^comparing/    {next}
+        /^no changes/   {next}
+        /^searching/    {next}
+	/^\[.*\]$/	{tree=substr($1,2,length($1)-2);
+                         trees[ntree++] = tree;
+                         revs[tree]=-1;
+                         next}
+        /^rev:/   {rev=$2+0;
+                   if (revs[tree] == -1 || rev < revs[tree])
+                        { revs[tree] = rev; };
+                  next;}
+        END       {for (tree in trees)
+                        { rev=revs[trees[tree]];
+                          if (rev > 0) 
+                                {printf("%s %d\n",trees[tree],rev-1)}
+                        }}' | while read LINE
+    do
+        set - $LINE
+        TREE=$1
+        REV=$2
+        A=`hg -R $CWS/$TREE log --rev $REV --template '{node}'`
+        FSTAT_OPT="--rev $A"
+        print "Revision: $A $REV" >> $FLIST
+        treestatus $TREE
+    done
+}
+
+function flist_from_mercurial_forest
+{
+    rm -f $FLIST
+    if [ -z "$Nflag" ]; then
+	print " File list from hg foutgoing $PWS ..."
+        outgoing_from_mercurial_forest
+        HG_LIST_FROM_COMMIT=1
+    fi
+    if [ ! -f $FLIST ]; then
+        # hg commit hasn't been run see what is lying around
+	print "\n No outgoing, perhaps you haven't commited."
+	print " File list from hg fstatus -mard ...\c"
+        FSTAT_OPT=
+        fstatus
+        HG_LIST_FROM_COMMIT=0
+    fi
+    print " Done."
+}
+
+#
+# Used when dealing with the result of 'hg foutgoing'
+# When now go down the tree and generate the change list
+#
+function treestatus
+{
+    TREE=$1
+    HGCMD="hg -R $CWS/$TREE status $FSTAT_OPT"
+    
+    $HGCMD -mdn 2>/dev/null | $FILTER | while read F
+    do
+        echo $TREE/$F
+    done >> $FLIST
+
+    # Then all the added files
+    # But some of these could have been "moved" or renamed ones
+    # so let's make sure we get the proper info
+    # hg status -aC will produce something like:
+    #	A subdir/File3
+    #	A subdir/File4
+    #	  File4
+    #	A subdir/File5
+    # The first and last are simple addition while the middle one
+    # is a move/rename
+
+    $HGCMD -aC | $FILTER | while read LINE; do
+	ldone=""
+	while [ -z "$ldone" ]; do
+	    ldone="1"
+	    set - $LINE
+	    if [ $# -eq 2 -a "$1" == "A" ]; then
+		AFILE=$2
+		if read LINE2; then
+		    set - $LINE2
+		    if [ $# -eq 1 ]; then
+			echo $TREE/$AFILE $TREE/$1 >>$FLIST
+		    elif [ $# -eq 2 ]; then
+			echo $TREE/$AFILE >>$FLIST
+			LINE=$LINE2
+			ldone=""
+		    fi
+		else
+		    echo $TREE/$AFILE >>$FLIST
+		fi
+	    fi
+	done
+    done
+    $HGCMD -rn | $FILTER | while read RFILE; do
+	grep "$TREE/$RFILE" $FLIST >/dev/null
+	if [ $? -eq 1 ]; then
+	    echo $TREE/$RFILE >>$FLIST
+	fi
+    done
+}
+
+function fstatus
+{
+    #
+    # forest extension is still being changed. For instance the output
+    # of fstatus used to no prepend the tree path to filenames, but
+    # this has changed recently. AWK code below does try to handle both
+    # cases
+    #
+    hg fstatus -mdn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
+	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
+	$1 != ""	{n=index($1,tree);
+			 if (n == 0)
+				{ printf("%s/%s\n",tree,$1)}
+			 else
+				{ printf("%s\n",$1)}}' >> $FLIST
+
+    #
+    # There is a bug in the output of fstatus -aC on recent versions: it
+    # inserts a space between the name of the tree and the filename of the
+    # old file. e.g.:
+    #
+    # $ hg fstatus -aC
+    # [.]
+    #
+    # [MyWS]
+    # A MyWS/subdir/File2
+    #  MyWS/ File2
+    #
+    # [MyWS2]
+    #
+
+    hg fstatus -aC $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
+	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
+	/^A .*/		{n=index($2,tree);
+			 if (n == 0)
+				{ printf("A %s/%s\n",tree,$2)}
+			 else
+				{ printf("A %s\n",$2)}; 
+			 next}
+	/^ /		{n=index($1,tree);
+			 if (n == 0)
+				{ printf("%s/%s\n",tree,$1)}
+			 else
+				{ if (NF == 2)
+					printf("%s/%s\n",tree,$2)
+				  else
+					printf("%s\n",$1)
+				};
+			 next}
+	' | while read LINE; do
+	ldone=""
+	while [ -z "$ldone" ]; do
+	    ldone="1"
+	    set - $LINE
+	    if [ $# -eq 2 -a "$1" == "A" ]; then
+		AFILE=$2
+		if read LINE2; then
+		    set - $LINE2
+		    if [ $# -eq 1 ]; then
+			echo $AFILE $1 >>$FLIST
+		    elif [ $# -eq 2 ]; then
+			echo $AFILE >>$FLIST
+			LINE=$LINE2
+			ldone=""
+		    fi
+		else
+		    echo $AFILE >>$FLIST
+		fi
+	    fi
+	done
+    done
+    hg fstatus -rn $FSTAT_OPT 2>/dev/null | $FILTER | $AWK '
+	/^\[.*\]$/	{tree=substr($1,2,length($1)-2); next}
+	$1 != ""	{n=index($1,tree);
+			 if (n == 0)
+				{ printf("%s/%s\n",tree,$1)}
+			 else
+				{ printf("%s\n",$1)}}' | while read RFILE; do
+	grep "$RFILE" $FLIST >/dev/null
+	if [ $? -eq 1 ]; then
+	    echo $RFILE >>$FLIST
+	fi
+    done
+}
+
+#
+# flist_from_mercurial $PWS
+#
+# Only local file based repositories are supported at present
+# since even though we can determine the list from the parent finding
+# the changes is harder.
+#
+# We first look for any outgoing files, this is for when the user has
+# run hg commit.  If we don't find any then we look with hg status.
+#
+# We need at least one of default-push or default paths set in .hg/hgrc
+# If neither are set we don't know who to compare with.
+
+function flist_from_mercurial 
+{
+#	if [ "${PWS##ssh://}" != "$PWS" -o \
+#	     "${PWS##http://}" != "$PWS" -o \
+#	     "${PWS##https://}" != "$PWS" ]; then
+#		print "Remote Mercurial repositories not currently supported."
+#		print "Set default and/or default-push to a local repository"
+#		exit
+#	fi
+    if [[ -n $forestflag ]]; then
+        HG_LIST_FROM_COMMIT=
+	flist_from_mercurial_forest
+    else
+        STATUS_REV=
+        if [[ -n $rflag ]]; then
+            STATUS_REV="--rev $PARENT_REV"
+        elif [[ -n $OUTREV ]]; then
+            STATUS_REV="--rev $OUTREV"
+        else
+            # hg commit hasn't been run see what is lying around
+            print "\n No outgoing, perhaps you haven't commited."
+        fi
+	# First let's list all the modified or deleted files
+
+	hg status $STATUS_REV -mdn | $FILTER > $FLIST
+
+	# Then all the added files
+	# But some of these could have been "moved" or renamed ones
+	# so let's make sure we get the proper info
+	# hg status -aC will produce something like:
+	#	A subdir/File3
+	#	A subdir/File4
+	#	  File4
+	#	A subdir/File5
+	# The first and last are simple addition while the middle one
+	# is a move/rename
+
+	hg status $STATUS_REV -aC | $FILTER >$FLIST.temp
+	while read LINE; do
+	    ldone=""
+	    while [ -z "$ldone" ]; do
+		ldone="1"
+		set - $LINE
+		if [ $# -eq 2 -a "$1" == "A" ]; then
+		    AFILE=$2
+		    if read LINE2; then
+			set - $LINE2
+			if [ $# -eq 1 ]; then
+			    echo $AFILE $1 >>$FLIST
+			elif [ $# -eq 2 ]; then
+			    echo $AFILE >>$FLIST
+			    LINE=$LINE2
+			    ldone=""
+			fi
+		    else
+			echo $AFILE >>$FLIST
+		    fi
+		fi
+	    done
+	done < $FLIST.temp
+	hg status $STATUS_REV -rn | $FILTER > $FLIST.temp
+	while read RFILE; do
+	    grep "$RFILE" $FLIST >/dev/null
+	    if [ $? -eq 1 ]; then
+		echo $RFILE >>$FLIST
+	    fi
+	done < $FLIST.temp
+	rm -f $FLIST.temp
+    fi
+}
+
+function env_from_flist
+{
+	[[ -r $FLIST ]] || return
+
+	#
+	# Use "eval" to set env variables that are listed in the file
+	# list.  Then copy those into our local versions of those
+	# variables if they have not been set already.
+	#
+	eval `sed -e "s/#.*$//" $FLIST | grep = `
+
+	[[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
+
+	#
+	# Check to see if CODEMGR_PARENT is set in the flist file.
+	#
+	[[ -z $codemgr_parent && -n $CODEMGR_PARENT ]] && \
+	    codemgr_parent=$CODEMGR_PARENT
+}
+
+#
+# detect_scm
+#
+# We dynamically test the SCM type; this allows future extensions to
+# new SCM types
+#
+function detect_scm
+{
+	#
+	# If CODEMGR_WS is specified in the flist file, we assume teamware.
+	#
+	if [[ -r $FLIST ]]; then
+		egrep '^CODEMGR_WS=' $FLIST > /dev/null 2>&1
+		if [[ $? -eq 0 ]]; then
+			print "teamware"
+			return
+		fi
+	fi
+
+	#
+	# The presence of $CODEMGR_WS and a Codemgr_wsdata directory
+	# is our clue that this is a teamware workspace.
+	# Same if true if current directory has a Codemgr_wsdata sub-dir
+	#
+	if [[ -z "$CODEMGR_WS" ]]; then
+	    CODEMGR_WS=`workspace name 2>/dev/null`
+	fi
+
+	if [[ -n $CODEMGR_WS && -d "$CODEMGR_WS/Codemgr_wsdata" ]]; then
+		print "teamware"
+	elif [[ -d $PWD/Codemgr_wsdata ]]; then
+		print "teamware"
+	elif hg root >/dev/null ; then
+		print "mercurial"
+	else
+		print "unknown"
+	fi
+}
+
+#
+# Extract the parent workspace from the Codemgr_wsdata/parent file
+#
+function parent_from_teamware
+{
+    if [[ -f "$1/Codemgr_wsdata/parent" ]]; then
+	tail -1 "$1/Codemgr_wsdata/parent"
+    fi
+}
+
+function look_for_prog
+{
+	typeset path
+	typeset ppath
+	typeset progname=$1
+
+	DEVTOOLS=
+	OS=`uname`
+	if [[ "$OS" == "SunOS" ]]; then
+	    DEVTOOLS="/java/devtools/`uname -p`/bin"
+	elif [[ "$OS" == "Linux" ]]; then
+	    DEVTOOLS="/java/devtools/linux/bin"
+	fi
+	    
+	ppath=$PATH
+	ppath=$ppath:/usr/sfw/bin:/usr/bin:/usr/sbin
+	ppath=$ppath:/opt/teamware/bin:/opt/onbld/bin
+	ppath=$ppath:/opt/onbld/bin/`uname -p`
+	ppath=$ppath:/java/devtools/share/bin:$DEVTOOLS
+
+	PATH=$ppath prog=`whence $progname`
+	if [[ -n $prog ]]; then
+		print $prog
+	fi
+}
+
+function build_old_new_teamware
+{
+	# If the child's version doesn't exist then
+	# get a readonly copy.
+
+	if [[ ! -f $F && -f SCCS/s.$F ]]; then
+		$SCCS get -s $F
+	fi
+
+	#
+	# Snag new version of file.
+	#
+	rm -f $newdir/$DIR/$F
+	cp $F $newdir/$DIR/$F
+
+	#
+	# Get the parent's version of the file. First see whether the
+	# child's version is checked out and get the parent's version
+	# with keywords expanded or unexpanded as appropriate.
+	#
+	if [ -f $PWS/$PDIR/SCCS/s.$PF -o \
+	    -f $PWS/$PDIR/SCCS/p.$PF ]; then
+		rm -f $olddir/$PDIR/$PF
+		if [ -f SCCS/p.$F ]; then
+			$SCCS get -s -p -k $PWS/$PDIR/$PF \
+			    > $olddir/$PDIR/$PF
+		else
+			$SCCS get -s -p    $PWS/$PDIR/$PF \
+			    > $olddir/$PDIR/$PF
+		fi
+	else
+		if [[ -f $PWS/$PDIR/$PF ]]; then
+			# Parent is not a real workspace, but just a raw
+			# directory tree - use the file that's there as
+			# the old file.
+
+			rm -f $olddir/$DIR/$F
+			cp $PWS/$PDIR/$PF $olddir/$DIR/$F
+		fi
+	fi
+}
+
+#
+# Find the parent for $1
+#
+function find_outrev
+{
+    crev=$1
+    prev=`hg log -r $crev --template '{parents}\n'`
+    if [[ -z "$prev" ]]
+    then
+	# No specific parent means previous changeset is parent
+	prev=`expr $crev - 1`
+    else
+	# Format is either of the following two:
+	# 546:7df6fcf1183b
+	# 548:16f1915bb5cd 547:ffaa4e775815
+	prev=`echo $prev | sed -e 's/\([0-9]*\):.*/\1/'`
+    fi
+    print $prev
+}
+
+function extract_ssh_infos
+{
+    CMD=$1
+    if expr "$CMD" : 'ssh://[^/]*@' >/dev/null; then
+	ssh_user=`echo $CMD | sed -e 's/ssh:\/\/\(.*\)@.*/\1/'`
+	ssh_host=`echo $CMD | sed -e 's/ssh:\/\/.*@\([^/]*\)\/.*/\1/'`
+	ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/.*@[^/]*\/\(.*\)/\1/'`
+    else
+	ssh_user=
+	ssh_host=`echo $CMD | sed -e 's/ssh:\/\/\([^/]*\)\/.*/\1/'`
+	ssh_dir=`echo $CMD | sed -e 's/ssh:\/\/[^/]*\/\(.*\)/\1/'`
+    fi
+    
+}
+
+function build_old_new_mercurial
+{
+	olddir=$1
+	newdir=$2
+	DIR=$3
+	F=$4
+	#
+	# new version of the file.
+	#
+	rm -rf $newdir/$DIR/$F
+	if [ -f $F ]; then
+	    cp $F  $newdir/$DIR/$F
+	fi
+
+	#
+	# Old version of the file.
+	#
+	rm -rf $olddir/$DIR/$F
+
+	if [ -n "$PWS" ]; then
+	    if expr "$PWS" : 'ssh://' >/dev/null
+	    then
+		extract_ssh_infos $PWS
+		if [ -n "$ssh_user" ]; then
+		    parent="ssh -l $ssh_user $ssh_host hg -R $ssh_dir --cwd $ssh_dir"
+		else
+		    parent="ssh $ssh_host hg -R $ssh_dir --cwd $ssh_dir"
+		fi
+	    else
+		parent="hg -R $PWS --cwd $PWS"
+	    fi
+	else
+	    parent=""
+	fi
+
+	if [ -z "$rename" ]; then
+	    if [ -n "$rflag" ]; then
+		parentrev=$PARENT_REV
+	    elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then
+                parentrev=$OUTREV
+	    else
+                if [[ -n $HG_BRANCH ]]; then
+                    parentrev=$HG_BRANCH
+                else
+		    parentrev="tip"
+                fi
+	    fi
+
+	    if [ -n "$parentrev" ]; then
+		if [ -z "$parent" ]; then
+		    hg cat --rev $parentrev --output $olddir/$DIR/$F $F 2>/dev/null
+		else
+		    # when specifying a workspace we have to provide
+		    # the full path
+		    $parent cat --rev $parentrev --output $olddir/$DIR/$F $DIR/$F 2>/dev/null
+		fi
+	    fi
+	else
+	    # It's a rename (or a move), so let's make sure we move
+	    # to the right directory first, then restore it once done
+	    current_dir=`pwd`
+	    cd $CWS/$PDIR
+	    if [ -n "$rflag" ]; then
+		parentrev=$PARENT_REV
+	    elif [ "$HG_LIST_FROM_COMMIT" -eq 1 ]; then
+                parentrev=$OUTREV
+	    fi
+	    if [ -z "$parentrev" ]; then
+		parentrev=`hg log -l1 $PF | $AWK -F: '/changeset/ {print $2}'`
+	    fi
+	    if [ -n "$parentrev" ]; then
+		mkdir -p $olddir/$PDIR
+		if [ -z "$parent" ]; then
+		    hg cat --rev $parentrev --output $olddir/$PDIR/$PF $PF 2>/dev/null
+		else
+		    $parent cat --rev $parentrev --output $olddir/$PDIR/$PF $PDIR/$PF 2>/dev/null
+		fi
+	    fi
+	    cd $current_dir
+	fi
+}
+
+function build_old_new
+{
+	if [[ $SCM_MODE == "teamware" ]]; then
+		build_old_new_teamware $@
+	fi
+
+	if [[ $SCM_MODE == "mercurial" ]]; then
+		build_old_new_mercurial $@
+	fi
+}
+
+
+#
+# Usage message.
+#
+function usage
+{
+	print "Usage:\twebrev [common-options]
+	webrev [common-options] ( <file> | - )
+	webrev [common-options] -w <wx file>
+	webrev [common-options] -l [arguments to 'putback']
+
+Options:
+	-v: Print the version of this tool.
+        -b: Do not ignore changes in the amount of white space.
+        -c <CR#>: Include link to CR (aka bugid) in the main page.
+	-O: Print bugids/arc cases suitable for OpenJDK.
+	-i <filename>: Include <filename> in the index.html file.
+	-o <outdir>: Output webrev to specified directory.
+	-p <compare-against>: Use specified parent wkspc or basis for comparison
+	-w <wxfile>: Use specified wx active file.
+        -u <username>: Use that username instead of 'guessing' one.
+	-m: Forces the use of Mercurial
+	-t: Forces the use of Teamware
+
+Mercurial only options:
+	-r rev: Compare against a specified revision
+	-N: Skip 'hg outgoing', use only 'hg status'
+	-f: Use the forest extension
+
+Environment:
+	WDIR: Control the output directory.
+	WEBREV_BUGURL: Control the URL prefix for bugids.
+	WEBREV_SACURL: Control the URL prefix for ARC cases.
+
+SCM Environment:
+	Teamware: CODEMGR_WS: Workspace location.
+	Teamware: CODEMGR_PARENT: Parent workspace location.
+
+"
+
+	exit 2
+}
+
+#
+#
+# Main program starts here
+#
+#
+LANG="C"
+LC_ALL="C"
+export LANG LC_ALL
+trap "rm -f /tmp/$$.* ; exit" 0 1 2 3 15
+
+set +o noclobber
+
+[[ -z $WDIFF ]] && WDIFF=`look_for_prog wdiff`
+[[ -z $WX ]] && WX=`look_for_prog wx`
+[[ -z $CODEREVIEW ]] && CODEREVIEW=`look_for_prog codereview`
+[[ -z $PS2PDF ]] && PS2PDF=`look_for_prog ps2pdf`
+[[ -z $PERL ]] && PERL=`look_for_prog perl`
+[[ -z $SCCS ]] && SCCS=`look_for_prog sccs`
+[[ -z $AWK ]] && AWK=`look_for_prog nawk`
+[[ -z $AWK ]] && AWK=`look_for_prog gawk`
+[[ -z $AWK ]] && AWK=`look_for_prog awk`
+[[ -z $WSPACE ]] && WSPACE=`look_for_prog workspace`
+[[ -z $JAR ]] && JAR=`look_for_prog jar`
+[[ -z $ZIP ]] && ZIP=`look_for_prog zip`
+[[ -z $GETENT ]] && GETENT=`look_for_prog getent`
+[[ -z $WGET ]] && WGET=`look_for_prog wget`
+
+if uname | grep CYGWIN >/dev/null
+then
+        ISWIN=1
+        # Under windows mercurial outputs '\' instead of '/'
+        FILTER="tr '\\\\' '/'"
+else
+        FILTER="cat"
+fi
+
+if [[ ! -x $PERL ]]; then
+	print -u2 "Error: No perl interpreter found.  Exiting."
+	exit 1
+fi
+
+#
+# These aren't fatal, but we want to note them to the user.
+# We don't warn on the absence of 'wx' until later when we've
+# determined that we actually need to try to invoke it.
+#
+# [[ ! -x $CODEREVIEW ]] && print -u2 "WARNING: codereview(1) not found."
+# [[ ! -x $PS2PDF ]] && print -u2 "WARNING: ps2pdf(1) not found."
+# [[ ! -x $WDIFF ]] && print -u2 "WARNING: wdiff not found."
+
+# Declare global total counters.
+integer TOTL TINS TDEL TMOD TUNC
+
+flist_mode=
+flist_file=
+bflag=
+iflag=
+oflag=
+pflag=
+uflag=
+lflag=
+wflag=
+Oflag=
+rflag=
+Nflag=
+forestflag=
+while getopts "c:i:o:p:r:u:lmtwONvfb" opt
+do
+	case $opt in
+        b)      bflag=1;;
+
+	i)	iflag=1
+		INCLUDE_FILE=$OPTARG;;
+
+	o)	oflag=1
+		WDIR=$OPTARG;;
+
+	p)	pflag=1
+		codemgr_parent=$OPTARG;;
+
+	u)      uflag=1
+		username=$OPTARG;;
+
+        c)      if [[ -z $CRID ]]; then
+                   CRID=$OPTARG
+                else
+                   CRID="$CRID $OPTARG"
+                fi;;
+
+	m)	SCM_MODE="mercurial";;
+
+	t)	SCM_MODE="teamware";;
+
+	#
+	# If -l has been specified, we need to abort further options
+	# processing, because subsequent arguments are going to be
+	# arguments to 'putback -n'.
+	#
+	l)	lflag=1
+		break;;
+
+	w)	wflag=1;;
+
+	O)	Oflag=1;;
+
+	N)	Nflag=1;;
+
+	f)	forestflag=1;;
+
+	r)	rflag=1
+		PARENT_REV=$OPTARG;;
+
+	v)	print "$0 version: $WEBREV_UPDATED";;
+		
+
+	?)	usage;;
+	esac
+done
+
+FLIST=/tmp/$$.flist
+
+if [[ -n $wflag && -n $lflag ]]; then
+	usage
+fi
+
+if [[ -n $forestflag && -n $rflag ]]; then
+    print "The -r <rev> flag is incompatible with the use of forests"
+    exit 2
+fi
+
+#
+# If this manually set as the parent, and it appears to be an earlier webrev,
+# then note that fact and set the parent to the raw_files/new subdirectory.
+#
+if [[ -n $pflag && -d $codemgr_parent/raw_files/new ]]; then
+	parent_webrev="$codemgr_parent"
+	codemgr_parent="$codemgr_parent/raw_files/new"
+fi
+
+if [[ -z $wflag && -z $lflag ]]; then
+	shift $(($OPTIND - 1))
+
+	if [[ $1 == "-" ]]; then
+		cat > $FLIST
+		flist_mode="stdin"
+		flist_done=1
+		shift
+	elif [[ -n $1 ]]; then
+		if [[ ! -r $1 ]]; then
+			print -u2 "$1: no such file or not readable"
+			usage
+		fi
+		cat $1 > $FLIST
+		flist_mode="file"
+		flist_file=$1
+		flist_done=1
+		shift
+	else
+		flist_mode="auto"
+	fi
+fi
+
+#
+# Before we go on to further consider -l and -w, work out which SCM we think
+# is in use.
+#
+if [[ -z $SCM_MODE ]]; then
+    SCM_MODE=`detect_scm $FLIST`
+fi
+if [[ $SCM_MODE == "unknown" ]]; then
+	print -u2 "Unable to determine SCM type currently in use."
+	print -u2 "For teamware: webrev looks for \$CODEMGR_WS either in"
+	print -u2 "              the environment or in the file list."
+	print -u2 "For mercurial: webrev runs 'hg root'."
+	exit 1
+fi
+
+print -u2 "   SCM detected: $SCM_MODE"
+
+
+if [[ $SCM_MODE == "mercurial" ]]; then
+    #
+    # determine Workspace and parent workspace paths
+    #
+    CWS=`hg root | $FILTER`
+    if [[ -n $pflag && -z "$PWS" ]]; then
+	OUTPWS=$codemgr_parent
+        # Let's try to expand it if it's an alias defined in [paths]
+        tmp=`hg path $OUTPWS 2>/dev/null | $FILTER`
+        if [[ -n $tmp ]]; then
+            OUTPWS="$tmp"
+        fi
+        if [[ -n $rflag ]]; then
+	    if expr "$codemgr_parent" : 'ssh://.*' >/dev/null; then
+	        PWS=$codemgr_parent
+	    else
+	        PWS=`hg -R "$codemgr_parent" root 2>/dev/null | $FILTER`
+	    fi
+        fi
+    fi
+    #
+    # OUTPWS is the parent repository to use when using 'hg outgoing'
+    #
+    if [[ -z $Nflag ]]; then
+        if [[ -n $forestflag ]]; then
+            #
+            # for forest we have to rely on properly set default and
+            # default-push because they can be different from the top one.
+            # unless of course it was explicitely speficied with -p
+            if [[ -z $pflag ]]; then
+                OUTPWS=
+            fi
+        else
+            #
+            # Unfortunately mercurial is bugged and doesn't handle
+            # aliases correctly in 'hg path default'
+            # So let's do it ourselves. Sigh...
+            if [[ -z "$OUTPWS" ]]; then
+                OUTPWS=`grep default-push $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER`
+            fi
+            # Still empty, means no default-push
+            if [[ -z "$OUTPWS" ]]; then
+                OUTPWS=`grep 'default =' $CWS/.hg/hgrc | $AWK '{print $3}' | $FILTER`
+            fi
+            # Let's try to expand it if it's an alias defined in [paths]
+            tmp=`hg path $OUTPWS 2>/dev/null | $FILTER`
+            if [[ -n $tmp ]]; then
+                OUTPWS="$tmp"
+            fi
+        fi
+    fi
+    #
+    # OUTPWS may contain username:password, let's make sure we remove the
+    # sensitive information before we print out anything in the HTML
+    #
+    OUTPWS2=$OUTPWS
+    if [[ -n $OUTPWS ]]; then
+	if [[ `expr "$OUTPWS" : '.*://[^/]*@.*'` -gt 0 ]]; then
+	    # Remove everything between '://' and '@'
+	    OUTPWS2=`echo $OUTPWS | sed -e 's/\(.*:\/\/\).*@\(.*\)/\1\2/'`
+	fi
+    fi
+
+    if [[ -z $HG_BRANCH ]]; then
+        HG_BRANCH=`hg branch`
+        if [ "$HG_BRANCH" == "default" ]; then
+            #
+            # 'default' means no particular branch, so let's cancel that
+            #
+            HG_BRANCH=
+        fi
+    fi
+
+    if [[ -z $forestflag ]]; then
+        if [[ -z $Nflag ]]; then
+            #
+            # If no "-N", always do "hg outgoing" against parent
+            # repository to determine list of outgoing revisions.
+            #
+            ALL_CREV=`hg outgoing -q --template '{rev}\n' $OUTPWS | sort -n`
+            if [[ -n $ALL_CREV ]]; then
+                FIRST_CREV=`echo "$ALL_CREV" | head -1`
+                #
+                # If no "-r", choose revision to compare against by
+                # finding the latest revision not in the outgoing list.
+                #
+                if [[ -z $rflag ]]; then
+                    OUTREV=`find_outrev "$FIRST_CREV"`
+                    if [[ -n $OUTREV ]]; then
+                        HG_LIST_FROM_COMMIT=1
+                    fi
+                fi
+            fi
+        elif [[ -n $rflag ]]; then
+            #
+            # If skipping "hg outgoing" but still comparing against a
+            # specific revision (not the tip), set revision for comment
+            # accumulation.
+            #
+            FIRST_CREV=`hg log --rev $PARENT_REV --template '{rev}'`
+            FIRST_CREV=`expr $FIRST_CREV + 1`
+        fi
+    fi
+    #Let's check if a merge is needed, if so, issue a warning
+    PREV=`hg parent | grep '^tag:.*tip$'`
+    if [[ -z $PREV ]]; then
+        print "WARNING: parent rev is not tip. Maybe an update or merge is needed"
+    fi
+fi
+
+if [[ -n $lflag ]]; then
+	#
+	# If the -l flag is given instead of the name of a file list,
+	# then generate the file list by extracting file names from a
+	# putback -n.
+	#
+	shift $(($OPTIND - 1))
+	if [[ $SCM_MODE == "teamware" ]]; then
+		flist_from_teamware "$*"
+	elif [[ $SCM_MODE == "mercurial" ]]; then
+		flist_from_mercurial
+	fi
+	flist_done=1
+	shift $#
+
+elif [[ -n $wflag ]]; then
+	#
+	# If the -w is given then assume the file list is in Bonwick's "wx"
+	# command format, i.e.  pathname lines alternating with SCCS comment
+	# lines with blank lines as separators.  Use the SCCS comments later
+	# in building the index.html file.
+	#
+	shift $(($OPTIND - 1))
+	wxfile=$1
+	if [[ -z $wxfile && -n $CODEMGR_WS ]]; then
+		if [[ -r $CODEMGR_WS/wx/active ]]; then
+			wxfile=$CODEMGR_WS/wx/active
+		fi
+	fi
+
+	[[ -z $wxfile ]] && print -u2 "wx file not specified, and could not " \
+	    "be auto-detected (check \$CODEMGR_WS)" && exit 1
+
+	print -u2 " File list from: wx 'active' file '$wxfile' ... \c"
+	flist_from_wx $wxfile
+	flist_done=1
+	if [[ -n "$*" ]]; then
+		shift
+	fi
+elif [[ $flist_mode == "stdin" ]]; then
+	print -u2 " File list from: standard input"
+elif [[ $flist_mode == "file" ]]; then
+	print -u2 " File list from: $flist_file"
+fi
+
+if [[ $# -gt 0 ]]; then
+	print -u2 "WARNING: unused arguments: $*"
+fi
+
+if [[ $SCM_MODE == "teamware" ]]; then
+	#
+	# Parent (internally $codemgr_parent) and workspace ($codemgr_ws) can
+	# be set in a number of ways, in decreasing precedence:
+	#
+	#      1) on the command line (only for the parent)
+	#      2) in the user environment
+	#      3) in the flist
+	#      4) automatically based on the workspace (only for the parent)
+	#
+
+	#
+	# Here is case (2): the user environment
+	#
+	[[ -z $codemgr_ws && -n $CODEMGR_WS ]] && codemgr_ws=$CODEMGR_WS
+	[[ -z $codemgr_ws && -n $WSPACE ]] && codemgr_ws=`$WSPACE name`
+	    
+	if [[ -n $codemgr_ws && ! -d $codemgr_ws ]]; then
+		print -u2 "$codemgr_ws: no such workspace"
+		exit 1
+	fi
+
+	[[ -z $codemgr_parent && -n $CODEMGR_PARENT ]] && \
+	    codemgr_parent=$CODEMGR_PARENT
+
+	if [[ -n $codemgr_parent && ! -d $codemgr_parent ]]; then
+		print -u2 "$codemgr_parent: no such directory"
+		exit 1
+	fi
+
+	#
+	# If we're in auto-detect mode and we haven't already gotten the file
+	# list, then see if we can get it by probing for wx.
+	#
+	if [[ -z $flist_done && $flist_mode == "auto" && -n $codemgr_ws ]]; then
+		if [[ ! -x $WX ]]; then
+			print -u2 "WARNING: wx not found!"
+		fi
+
+		#
+		# We need to use wx list -w so that we get renamed files, etc.
+		# but only if a wx active file exists-- otherwise wx will
+		# hang asking us to initialize our wx information.
+		#
+		if [[ -x $WX && -f $codemgr_ws/wx/active ]]; then
+			print -u2 " File list from: 'wx list -w' ... \c"
+			$WX list -w > $FLIST
+			$WX comments > /tmp/$$.wx_comments
+			wxfile=/tmp/$$.wx_comments
+			print -u2 "done"
+			flist_done=1
+		fi
+	fi
+
+	#
+	# If by hook or by crook we've gotten a file list by now (perhaps
+	# from the command line), eval it to extract environment variables from
+	# it: This is step (3).
+	#
+	env_from_flist
+
+	#
+	# Continuing step (3): If we still have no file list, we'll try to get
+	# it from teamware.
+	#
+	if [[ -z $flist_done ]]; then
+		flist_from_teamware
+		env_from_flist
+	fi
+
+	if [[ -z $codemgr_ws && -d $PWD/Codemgr_wsdata ]]; then
+	    codemgr_ws=$PWD
+	fi
+	#
+	# Observe true directory name of CODEMGR_WS, as used later in
+	# webrev title.
+	#
+	if [[ -n $codemgr_ws ]]; then
+	    codemgr_ws=$(cd $codemgr_ws;print $PWD)
+	fi
+
+	if [[ -n $codemgr_parent ]]; then
+	    codemgr_parent=$(cd $codemgr_parent;print $PWD)
+	fi
+
+	#
+	# (4) If we still don't have a value for codemgr_parent, get it
+	# from workspace.
+	#
+	[[ -z $codemgr_parent && -n $WSPACE ]] && codemgr_parent=`$WSPACE parent`
+	[[ -z $codemgr_parent ]] && codemgr_parent=`parent_from_teamware $codemgr_ws`
+
+	if [[ ! -d $codemgr_parent ]]; then
+	    print -u2 "$CODEMGR_PARENT: no such parent workspace"
+	    exit 1
+	fi
+
+	#
+	# Reset CODEMGR_WS to make sure teamware commands are happy.
+	#
+	CODEMGR_WS=$codemgr_ws
+	CWS=$codemgr_ws
+	PWS=$codemgr_parent
+elif [[ $SCM_MODE == "mercurial" ]]; then
+    if [[ -z $flist_done ]]; then
+	flist_from_mercurial $PWS
+    fi
+fi
+
+#
+# If the user didn't specify a -i option, check to see if there is a
+# webrev-info file in the workspace directory.
+#
+if [[ -z $iflag && -r "$CWS/webrev-info" ]]; then
+	iflag=1
+	INCLUDE_FILE="$CWS/webrev-info"
+fi
+
+if [[ -n $iflag ]]; then
+	if [[ ! -r $INCLUDE_FILE ]]; then
+		print -u2 "include file '$INCLUDE_FILE' does not exist or is" \
+		    "not readable."
+		exit 1
+	else
+		#
+		# $INCLUDE_FILE may be a relative path, and the script alters
+		# PWD, so we just stash a copy in /tmp.
+		#
+		cp $INCLUDE_FILE /tmp/$$.include
+	fi
+fi
+
+#
+# Output directory.
+#
+if [[ -z $WDIR ]]; then
+    WDIR=$CWS/webrev
+else
+    # If the output directory doesn't end with '/webrev' or '/webrev/'
+    # then add '/webrev'. This is for backward compatibility
+    if ! expr $WDIR : '.*/webrev/\?$' >/dev/null
+    then
+	WDIR=$WDIR/webrev
+    fi
+fi
+# WDIR=${WDIR:-$CWS/webrev}
+
+#
+# Name of the webrev, derived from the workspace name; in the
+# future this could potentially be an option.
+#
+# Let's keep what's after the last '/'
+WNAME=${CWS##*/}
+
+#
+# If WDIR doesn't start with '/' or 'x:' prepend the current dir
+#
+if [ ${WDIR%%/*} ]; then
+    if [[ -n $ISWIN ]]; then
+        if [ ${WDIR%%[A-Za-z]:*} ]; then
+	    WDIR=$PWD/$WDIR
+        fi
+    else
+	WDIR=$PWD/$WDIR
+    fi
+fi
+
+if [[ ! -d $WDIR ]]; then
+	mkdir -p $WDIR
+	[[ $? != 0 ]] && exit 1
+fi
+
+#
+# Summarize what we're going to do.
+#
+print "      Workspace: $CWS"
+if [[ -n $parent_webrev ]]; then
+    print "Compare against: webrev at $parent_webrev"
+elif [[ -n $OUTPWS2 ]]; then
+    print "Compare against: $OUTPWS2"
+fi
+if [[ -n $HG_BRANCH ]]; then
+    print "         Branch: $HG_BRANCH"
+fi
+if [[ -n $rflag ]]; then
+        print "Compare against version: $PARENT_REV"
+fi
+[[ -n $INCLUDE_FILE ]] && print "      Including: $INCLUDE_FILE"
+print "      Output to: $WDIR"
+
+#
+# Save the file list in the webrev dir
+#
+[[ ! $FLIST -ef $WDIR/file.list ]] && cp $FLIST $WDIR/file.list
+
+#
+#    Bug IDs will be replaced by a URL.  Order of precedence
+#    is: default location, $WEBREV_BUGURL, the -O flag.
+#
+BUGURL='http://monaco.sfbay.sun.com/detail.jsp?cr='
+[[ -n $WEBREV_BUGURL ]] && BUGURL="$WEBREV_BUGURL"
+[[ -n "$Oflag" ]] && \
+    BUGURL='http://bugs.sun.com/bugdatabase/view_bug.do?bug_id='
+
+#
+#    Likewise, ARC cases will be replaced by a URL.  Order of precedence
+#    is: default, $WEBREV_SACURL, the -O flag.
+#
+#    Note that -O also triggers different substitution behavior for
+#    SACURL.  See sac2url().
+#
+SACURL='http://sac.eng.sun.com'
+[[ -n $WEBREV_SACURL ]] && SACURL="$WEBREV_SACURL"
+[[ -n $Oflag ]] && \
+    SACURL='http://www.opensolaris.org/os/community/arc/caselog'
+
+rm -f $WDIR/$WNAME.patch
+rm -f $WDIR/$WNAME.ps
+rm -f $WDIR/$WNAME.pdf
+
+touch $WDIR/$WNAME.patch
+
+print "   Output Files:"
+
+#
+# Clean up the file list: Remove comments, blank lines and env variables.
+#
+sed -e "s/#.*$//" -e "/=/d" -e "/^[   ]*$/d" $FLIST > /tmp/$$.flist.clean
+FLIST=/tmp/$$.flist.clean
+
+#
+# Clean up residual raw files
+#
+if [ -d $WDIR/raw_files ]; then
+    rm -rf $WDIR/raw_files 2>/dev/null
+fi
+
+#
+# Should we ignore changes in white spaces when generating diffs?
+# 
+if [[ -n $bflag ]]; then
+    DIFFOPTS="-t"
+else
+    DIFFOPTS="-bt"
+fi
+#
+# First pass through the files: generate the per-file webrev HTML-files.
+#
+while read LINE
+do
+	set - $LINE
+	P=$1
+
+        if [[ $1 == "Revision:" ]]; then
+            OUTREV=$2
+            continue
+        fi
+	#
+	# Normally, each line in the file list is just a pathname of a
+	# file that has been modified or created in the child.  A file
+	# that is renamed in the child workspace has two names on the
+	# line: new name followed by the old name.
+	#
+	oldname=""
+	oldpath=""
+	rename=
+	if [[ $# -eq 2 ]]; then
+		PP=$2			# old filename
+		oldname=" (was $PP)"
+		oldpath="$PP"
+		rename=1
+        	PDIR=${PP%/*}
+        	if [[ $PDIR == $PP ]]; then
+			PDIR="."   # File at root of workspace
+		fi
+
+		PF=${PP##*/}
+
+	        DIR=${P%/*}
+	        if [[ $DIR == $P ]]; then
+			DIR="."   # File at root of workspace
+		fi
+
+		F=${P##*/}
+        else
+	        DIR=${P%/*}
+	        if [[ "$DIR" == "$P" ]]; then
+			DIR="."   # File at root of workspace
+		fi
+
+		F=${P##*/}
+
+		PP=$P
+		PDIR=$DIR
+		PF=$F
+	fi
+
+        # Make the webrev directory if necessary as it may have been
+        # removed because it was empty
+        if [ ! -d $CWS/$DIR ]; then
+	    mkdir -p $CWS/$DIR
+        fi
+
+	COMM=`getcomments html $P $PP`
+
+	print "\t$P$oldname\n\t\t\c"
+
+	# Make the webrev mirror directory if necessary
+	mkdir -p $WDIR/$DIR
+
+	# cd to the directory so the names are short
+	cd $CWS/$DIR
+
+	#
+	# If we're in OpenSolaris mode, we enforce a minor policy:
+	# help to make sure the reviewer doesn't accidentally publish
+	# source which is in usr/closed/*
+	#
+	if [[ -n $Oflag ]]; then
+		pclosed=${P##usr/closed/}
+		if [[ $pclosed != $P ]]; then
+			print "*** Omitting closed source for OpenSolaris" \
+			    "mode review"
+			continue
+		fi
+	fi
+
+	#
+	# We stash old and new files into parallel directories in /tmp
+	# and do our diffs there.  This makes it possible to generate
+	# clean looking diffs which don't have absolute paths present.
+	#
+	olddir=$WDIR/raw_files/old
+	newdir=$WDIR/raw_files/new
+	mkdir -p $olddir
+	mkdir -p $newdir
+	mkdir -p $olddir/$PDIR
+	mkdir -p $newdir/$DIR
+
+	build_old_new $olddir $newdir $DIR $F
+
+	if [[ ! -f $F && ! -f $olddir/$DIR/$F ]]; then
+		print "*** Error: file not in parent or child"
+		continue
+	fi
+
+	cd $WDIR/raw_files
+	ofile=old/$PDIR/$PF
+	nfile=new/$DIR/$F
+
+	mv_but_nodiff=
+	cmp $ofile $nfile > /dev/null 2>&1
+	if [[ $? == 0 && $rename == 1 ]]; then
+		mv_but_nodiff=1
+	fi
+
+        #
+        # Cleaning up
+        #
+        rm -f $WDIR/$DIR/$F.cdiff.html
+        rm -f $WDIR/$DIR/$F.udiff.html
+        rm -f $WDIR/$DIR/$F.wdiff.html
+        rm -f $WDIR/$DIR/$F.sdiff.html
+        rm -f $WDIR/$DIR/$F-.html
+        rm -f $WDIR/$DIR/$F.html
+
+	its_a_jar=
+	if expr $F : '.*\.jar' >/dev/null; then
+	    its_a_jar=1
+	    # It's a JAR file, let's do it differntly
+	    if [[ -z $JAR ]]; then
+		print "No access to jar, so can't produce diffs for jar files"
+	    else
+		if [ -f $ofile ]; then
+		    $JAR -tvf $ofile >"$ofile".lst
+		fi
+		if [ -f $nfile ]; then
+		    $JAR -tvf $nfile >"$nfile".lst
+		fi
+
+		if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
+
+		    ${CDIFFCMD:-diff -bt -C 5} $ofile.lst $nfile.lst > $WDIR/$DIR/$F.cdiff
+		    diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \
+			> $WDIR/$DIR/$F.cdiff.html
+		    print " cdiffs\c"
+
+		    ${UDIFFCMD:-diff -bt -U 5} $ofile.lst $nfile.lst > $WDIR/$DIR/$F.udiff
+		    diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \
+			> $WDIR/$DIR/$F.udiff.html
+
+		    print " udiffs\c"
+
+		    if [[ -x $WDIFF ]]; then
+			$WDIFF -c "$COMM" \
+			    -t "$WNAME Wdiff $DIR/$F" $ofile.lst $nfile.lst > \
+			    $WDIR/$DIR/$F.wdiff.html 2>/dev/null
+			if [[ $? -eq 0 ]]; then
+			    print " wdiffs\c"
+			else
+			    print " wdiffs[fail]\c"
+			fi
+		    fi
+
+		    sdiff_to_html $ofile $nfile $F $DIR "$COMM" \
+			> $WDIR/$DIR/$F.sdiff.html
+		    print " sdiffs\c"
+
+		    print " frames\c"
+
+		    rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff
+
+		    difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count
+
+		elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then
+		# renamed file: may also have differences
+		    difflines $ofile.lst $nfile.lst > $WDIR/$DIR/$F.count
+		elif [[ -f $nfile ]]; then
+		# new file: count added lines
+		    difflines /dev/null $nfile.lst > $WDIR/$DIR/$F.count
+		elif [[ -f $ofile ]]; then
+		# old file: count deleted lines
+		    difflines $ofile.lst /dev/null > $WDIR/$DIR/$F.count
+		fi
+	    fi
+	else
+	    
+	    #
+	    # If we have old and new versions of the file then run the
+	    # appropriate diffs.  This is complicated by a couple of factors:
+	    #
+	    #	- renames must be handled specially: we emit a 'remove'
+	    #	  diff and an 'add' diff
+	    #	- new files and deleted files must be handled specially
+	    #	- Solaris patch(1m) can't cope with file creation
+	    #	  (and hence renames) as of this writing.
+	    #   - To make matters worse, gnu patch doesn't interpret the
+	    #	  output of Solaris diff properly when it comes to
+	    #	  adds and deletes.  We need to do some "cleansing"
+	    #     transformations:
+	    # 	    [to add a file] @@ -1,0 +X,Y @@  -->  @@ -0,0 +X,Y @@
+	    #	    [to del a file] @@ -X,Y +1,0 @@  -->  @@ -X,Y +0,0 @@
+	    #
+	    cleanse_rmfile="sed 's/^\(@@ [0-9+,-]*\) [0-9+,-]* @@$/\1 +0,0 @@/'"
+	    cleanse_newfile="sed 's/^@@ [0-9+,-]* \([0-9+,-]* @@\)$/@@ -0,0 \1/'"
+
+	    rm -f $WDIR/$DIR/$F.patch
+	    if [[ -z $rename ]]; then
+		if [ ! -f $ofile ]; then
+		    diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
+			> $WDIR/$DIR/$F.patch
+		elif [ ! -f $nfile ]; then
+		    diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
+			> $WDIR/$DIR/$F.patch
+		else
+		    diff -u $ofile $nfile > $WDIR/$DIR/$F.patch
+		fi
+	    else
+		diff -u $ofile /dev/null | sh -c "$cleanse_rmfile" \
+		    > $WDIR/$DIR/$F.patch
+
+		diff -u /dev/null $nfile | sh -c "$cleanse_newfile" \
+		    >> $WDIR/$DIR/$F.patch
+
+	    fi
+
+
+	#
+	# Tack the patch we just made onto the accumulated patch for the
+	# whole wad.
+	#
+	    cat $WDIR/$DIR/$F.patch >> $WDIR/$WNAME.patch
+
+	    print " patch\c"
+
+	    if [[ -f $ofile && -f $nfile && -z $mv_but_nodiff ]]; then
+
+		${CDIFFCMD:-diff -bt -C 5} $ofile $nfile > $WDIR/$DIR/$F.cdiff
+		diff_to_html $F $DIR/$F "C" "$COMM" < $WDIR/$DIR/$F.cdiff \
+		    > $WDIR/$DIR/$F.cdiff.html
+		print " cdiffs\c"
+
+		${UDIFFCMD:-diff -bt -U 5} $ofile $nfile > $WDIR/$DIR/$F.udiff
+		diff_to_html $F $DIR/$F "U" "$COMM" < $WDIR/$DIR/$F.udiff \
+		    > $WDIR/$DIR/$F.udiff.html
+
+		print " udiffs\c"
+
+		if [[ -x $WDIFF ]]; then
+		    $WDIFF -c "$COMM" \
+			-t "$WNAME Wdiff $DIR/$F" $ofile $nfile > \
+			$WDIR/$DIR/$F.wdiff.html 2>/dev/null
+		    if [[ $? -eq 0 ]]; then
+			print " wdiffs\c"
+		    else
+			print " wdiffs[fail]\c"
+		    fi
+		fi
+
+		sdiff_to_html $ofile $nfile $F $DIR "$COMM" \
+		    > $WDIR/$DIR/$F.sdiff.html
+		print " sdiffs\c"
+
+		print " frames\c"
+
+		rm -f $WDIR/$DIR/$F.cdiff $WDIR/$DIR/$F.udiff
+
+		difflines $ofile $nfile > $WDIR/$DIR/$F.count
+
+	    elif [[ -f $ofile && -f $nfile && -n $mv_but_nodiff ]]; then
+		# renamed file: may also have differences
+		difflines $ofile $nfile > $WDIR/$DIR/$F.count
+	    elif [[ -f $nfile ]]; then
+		# new file: count added lines
+		difflines /dev/null $nfile > $WDIR/$DIR/$F.count
+	    elif [[ -f $ofile ]]; then
+		# old file: count deleted lines
+		difflines $ofile /dev/null > $WDIR/$DIR/$F.count
+	    fi
+	fi
+	#
+	# Now we generate the postscript for this file.  We generate diffs
+	# only in the event that there is delta, or the file is new (it seems
+	# tree-killing to print out the contents of deleted files).
+	#
+	if [[ -f $nfile ]]; then
+		ocr=$ofile
+		[[ ! -f $ofile ]] && ocr=/dev/null
+
+		if [[ -z $mv_but_nodiff ]]; then
+			textcomm=`getcomments text $P $PP`
+			if [[ -x $CODEREVIEW ]]; then
+				$CODEREVIEW -y "$textcomm" \
+				    -e $ocr $nfile \
+				    > /tmp/$$.psfile 2>/dev/null &&
+				    cat /tmp/$$.psfile >> $WDIR/$WNAME.ps
+				if [[ $? -eq 0 ]]; then
+					print " ps\c"
+				else
+					print " ps[fail]\c"
+				fi
+			fi
+		fi
+	fi
+
+	if [[ -f $ofile && -z $mv_but_nodiff ]]; then
+	    if [[ -n $its_a_jar ]]; then
+		source_to_html Old $P < $ofile.lst > $WDIR/$DIR/$F-.html
+	    else
+		source_to_html Old $P < $ofile > $WDIR/$DIR/$F-.html
+	    fi
+		print " old\c"
+	fi
+
+	if [[ -f $nfile ]]; then
+	    if [[ -n $its_a_jar ]]; then
+		source_to_html New $P < $nfile.lst > $WDIR/$DIR/$F.html
+	    else
+		source_to_html New $P < $nfile > $WDIR/$DIR/$F.html
+	    fi
+		print " new\c"
+	fi
+
+	print
+done < $FLIST
+
+frame_nav_js > $WDIR/ancnav.js
+frame_navigation > $WDIR/ancnav.html
+
+if [[ -f $WDIR/$WNAME.ps && -x $CODEREVIEW && -x $PS2PDF ]]; then
+	print " Generating PDF: \c"
+	fix_postscript $WDIR/$WNAME.ps | $PS2PDF - > $WDIR/$WNAME.pdf
+	print "Done."
+fi
+
+# Now build the index.html file that contains
+# links to the source files and their diffs.
+
+cd $CWS
+
+# Save total changed lines for Code Inspection.
+print "$TOTL" > $WDIR/TotalChangedLines
+
+print "     index.html: \c"
+INDEXFILE=$WDIR/index.html
+exec 3<&1			# duplicate stdout to FD3.
+exec 1<&-			# Close stdout.
+exec > $INDEXFILE		# Open stdout to index file.
+
+print "$HTML<head>"
+print "<meta name=\"scm\" content=\"$SCM_MODE\" />"
+print "$STDHEAD"
+print "<title>$WNAME</title>"
+print "</head>"
+print "<body id=\"SUNWwebrev\">"
+print "<div class=\"summary\">"
+print "<h2>Code Review for $WNAME</h2>"
+
+print "<table>"
+
+if [[ -z $uflag ]]
+then
+    if [[ $SCM_MODE == "mercurial" ]]
+    then
+        #
+        # Let's try to extract the user name from the .hgrc file
+        #
+	username=`grep '^username' $HOME/.hgrc | sed 's/^username[ ]*=[ ]*\(.*\)/\1/'`
+    fi
+
+    if [[ -z $username ]]
+    then
+        #
+        # Figure out the username and gcos name.  To maintain compatibility
+        # with passwd(4), we must support '&' substitutions.
+        #
+	username=`id | cut -d '(' -f 2 | cut -d ')' -f 1`
+	if [[ -x $GETENT ]]; then
+	    realname=`$GETENT passwd $username | cut -d':' -f 5 | cut -d ',' -f 1`
+	fi
+	userupper=`print "$username" | sed 's/\<./\u&/g'`
+	realname=`print $realname | sed s/\&/$userupper/`
+    fi
+fi
+
+date="on `date`"
+
+if [[ -n "$username" && -n "$realname" ]]; then
+	print "<tr><th>Prepared by:</th>"
+	print "<td>$realname ($username) $date</td></tr>"
+elif [[ -n "$username" ]]; then
+	print "<tr><th>Prepared by:</th><td>$username $date</td></tr>"
+fi
+
+print "<tr><th>Workspace:</th><td>$CWS</td></tr>"
+if [[ -n $parent_webrev ]]; then
+        print "<tr><th>Compare against:</th><td>"
+	print "webrev at $parent_webrev"
+else
+    if [[ -n $OUTPWS2 ]]; then
+        print "<tr><th>Compare against:</th><td>"
+	print "$OUTPWS2"
+    fi
+fi
+print "</td></tr>"
+if [[ -n $rflag ]]; then
+    print "<tr><th>Compare against version:</th><td>$PARENT_REV</td></tr>"
+elif [[ -n $OUTREV ]]; then
+    if [[ -z $forestflag ]]; then
+        print "<tr><th>Compare against version:</th><td>$OUTREV</td></tr>"
+    fi
+fi
+if [[ -n $HG_BRANCH ]]; then
+    print "<tr><th>Branch:</th><td>$HG_BRANCH</td></tr>"
+fi
+
+print "<tr><th>Summary of changes:</th><td>"
+printCI $TOTL $TINS $TDEL $TMOD $TUNC
+print "</td></tr>"
+
+if [[ -f $WDIR/$WNAME.patch ]]; then
+	print "<tr><th>Patch of changes:</th><td>"
+	print "<a href=\"$WNAME.patch\">$WNAME.patch</a></td></tr>"
+fi
+if [[ -f $WDIR/$WNAME.pdf ]]; then
+	print "<tr><th>Printable review:</th><td>"
+	print "<a href=\"$WNAME.pdf\">$WNAME.pdf</a></td></tr>"
+fi
+
+if [[ -n "$iflag" ]]; then
+	print "<tr><th>Author comments:</th><td><div>"
+	cat /tmp/$$.include
+	print "</div></td></tr>"
+fi
+# Add links to referenced CRs, if any
+# external URL has a <title> like:
+# <title>Bug ID: 6641309 Wrong Cookie separator used in HttpURLConnection</title>
+# while internal URL has <title> like:
+# <title>6641309: Wrong Cookie separator used in HttpURLConnection</title>
+#
+if [[ -n $CRID ]]; then
+    for id in $CRID
+    do
+        print "<tr><th>Bug id:</th><td>"
+        url="${BUGURL}${id}"
+        if [[ -n $WGET ]]; then
+            msg=`$WGET -q $url -O - | grep '<title>' | sed 's/<title>\(.*\)<\/title>/\1/' | sed 's/Bug ID://'`
+        fi
+        if [[ -n $msg ]]; then
+            print "<a href=\"$url\">$msg</a>"
+        else
+            print $id | bug2url
+        fi
+        
+        print "</td></tr>"
+    done
+fi
+print "<tr><th>Legend:</th><td>"
+print "<b>Modified file</b><br><font color=red><b>Deleted file</b></font><br><font color=green><b>New file</b></font></td></tr>"
+print "</table>"
+print "</div>"
+
+#
+# Second pass through the files: generate the rest of the index file
+#
+while read LINE
+do
+	set - $LINE
+        if [[ $1 == "Revision:" ]]; then
+            FIRST_CREV=`expr $3 + 1`
+            continue
+        fi
+	P=$1
+
+	if [[ $# == 2 ]]; then
+		PP=$2
+		oldname=" <i>(was $PP)</i>"
+
+	else
+		PP=$P
+		oldname=""
+	fi
+
+	DIR=${P%/*}
+	if [[ $DIR == $P ]]; then
+		DIR="."   # File at root of workspace
+	fi
+
+	# Avoid processing the same file twice.
+	# It's possible for renamed files to
+	# appear twice in the file list
+
+	F=$WDIR/$P
+
+	print "<p><code>"
+
+	# If there's a diffs file, make diffs links
+
+        NODIFFS=
+	if [[ -f $F.cdiff.html ]]; then
+		print "<a href=\"$P.cdiff.html\">Cdiffs</a>"
+		print "<a href=\"$P.udiff.html\">Udiffs</a>"
+
+		if [[ -f $F.wdiff.html && -x $WDIFF ]]; then
+			print "<a href=\"$P.wdiff.html\">Wdiffs</a>"
+		fi
+
+		print "<a href=\"$P.sdiff.html\">Sdiffs</a>"
+
+		print "<a href=\"$P.frames.html\">Frames</a>"
+	else
+                NODIFFS=1
+		print " ------ ------ ------"
+
+		if [[ -x $WDIFF ]]; then
+			print " ------"
+		fi
+
+		print " ------"
+	fi
+
+	# If there's an old file, make the link
+
+        NOOLD=
+	if [[ -f $F-.html ]]; then
+		print "<a href=\"$P-.html\">Old</a>"
+	else
+                NOOLD=1
+		print " ---"
+	fi
+
+	# If there's an new file, make the link
+
+        NONEW=
+	if [[ -f $F.html ]]; then
+		print "<a href=\"$P.html\">New</a>"
+	else
+                NONEW=1
+		print " ---"
+	fi
+
+	if [[ -f $F.patch ]]; then
+		print "<a href=\"$P.patch\">Patch</a>"
+	else
+		print " -----"
+	fi
+
+	if [[ -f $WDIR/raw_files/new/$P ]]; then
+		print "<a href=\"raw_files/new/$P\">Raw</a>"
+	else
+		print " ---"
+	fi
+        print "</code>"
+        if [[ -n $NODIFFS && -z $oldname ]]; then
+            if [[ -n $NOOLD ]]; then
+                print "<font color=green><b>$P</b></font>"
+            elif [[ -n $NONEW ]]; then
+                print "<font color=red><b>$P</b></font>"
+            fi
+        else
+	    print "<b>$P</b> $oldname"
+        fi
+
+	#
+	# Check for usr/closed
+	#
+	if [ ! -z "$Oflag" ]; then
+		if [[ $P == usr/closed/* ]]; then
+			print "&nbsp;&nbsp;<i>Closed source: omitted from" \
+			    "this review</i>"
+		fi
+	fi
+
+	print "</p><blockquote>\c"
+	# Insert delta comments if any
+	comments=`getcomments html $P $PP`
+	if [ -n "$comments" ]; then
+	    print "<pre>$comments</pre>"
+	fi
+
+	# Add additional comments comment
+
+	print "<!-- Add comments to explain changes in $P here -->"
+
+	# Add count of changes.
+
+	if [[ -f $F.count ]]; then
+	    cat $F.count
+	    rm $F.count
+	fi
+        print "</blockquote>"
+done < $FLIST
+
+print
+print
+print "<hr />"
+print "<p style=\"font-size: small\">"
+print "This code review page was prepared using <b>$0</b>"
+print "(vers $WEBREV_UPDATED)."
+print "</body>"
+print "</html>"
+
+if [[ -n $ZIP ]]; then
+    # Let's generate a zip file for convenience
+    cd $WDIR/..
+    if [ -f webrev.zip ]; then
+	rm webrev.zip
+    fi
+    $ZIP -r webrev webrev >/dev/null 2>&1
+fi
+
+exec 1<&-			# Close FD 1.
+exec 1<&3			# dup FD 3 to restore stdout.
+exec 3<&-			# close FD 3.
+
+print "Done."
+print "Output to: $WDIR"
+
--- a/make/sponsors-rules.gmk	Mon Mar 07 14:31:50 2011 +0000
+++ b/make/sponsors-rules.gmk	Mon Mar 07 11:37:54 2011 -0800
@@ -59,10 +59,10 @@
 sponsors-build:
 ifeq ($(ARCH_DATA_MODEL), 32)
   ifeq ($(BUILD_SPONSORS), true)
-	@$(call MakeStart, sponsors, $(SPONSORS_BUILD_TARGETS))
+	@$(call MakeStart,sponsors,$(SPONSORS_BUILD_TARGETS))
 	($(CD) $(SPONSORS_TOPDIR)/make && \
 	  $(MAKE) $(SPONSORS_BUILD_TARGETS) $(SPONSORS_BUILD_ARGUMENTS))
-	@$(call MakeFinish, sponsors, $(SPONSORS_BUILD_TARGETS))
+	@$(call MakeFinish,sponsors,$(SPONSORS_BUILD_TARGETS))
   endif
 endif