changeset 3007:24a29daacd09

Merge
author jgodinez
date Thu, 14 May 2009 09:53:35 -0700
parents 8201b60ec5eb c33e7d38c921
children e6248b598ca5
files hotspot/make/jprt.config jaxp/src/share/classes/com/sun/org/apache/xalan/internal/client/XSLTProcessorApplet.java jaxp/src/share/classes/com/sun/org/apache/xalan/internal/client/package.html
diffstat 180 files changed, 14234 insertions(+), 2076 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed May 06 14:14:54 2009 -0700
+++ b/.hgtags	Thu May 14 09:53:35 2009 -0700
@@ -31,3 +31,5 @@
 15096652c4d48dfb9fc0b2cb135304db94c65ba0 jdk7-b54
 c8b275d62d6b0a980c510e839b70292245863e85 jdk7-b55
 a8134c4ee2cf451cf9b5e1609f39d83ecd53acc5 jdk7-b56
+b44f05654c26fcd1f995e712992f9b07ffd7c0c6 jdk7-b57
+d60a9ce3c3eabf28f5d50ae839d18be04a551bc2 jdk7-b58
--- a/.hgtags-top-repo	Wed May 06 14:14:54 2009 -0700
+++ b/.hgtags-top-repo	Thu May 14 09:53:35 2009 -0700
@@ -31,3 +31,5 @@
 2ef382b1bbd58a68e668391c6145a4b2066c5b96 jdk7-b54
 aea0ace7a1e43619800931d42bbf69c579361c2d jdk7-b55
 ba12117a5e6c918578d6b2a8c693232a33289024 jdk7-b56
+ffd09e767dfa6d21466183a400f72cf62d53297f jdk7-b57
+59b497130f82ec809c245ffb5e521e3a5fabf8af jdk7-b58
--- a/corba/.hgtags	Wed May 06 14:14:54 2009 -0700
+++ b/corba/.hgtags	Thu May 14 09:53:35 2009 -0700
@@ -31,3 +31,5 @@
 8130ac858d6789d5853d23044ba4a992afda574a jdk7-b54
 7a869f16ba83060c34b77620406cfa89d1cd7084 jdk7-b55
 553a664b807bb3a3c93f3b5a3c20ff0a90e08371 jdk7-b56
+972c6157fae57850694675da82fd58a17930db0a jdk7-b57
+2e3b8edab3ef55406494d3dd562e06882e6fc15e jdk7-b58
--- a/corba/make/com/sun/corba/se/sources/Makefile	Wed May 06 14:14:54 2009 -0700
+++ b/corba/make/com/sun/corba/se/sources/Makefile	Thu May 14 09:53:35 2009 -0700
@@ -46,6 +46,8 @@
 include $(CORBA_JMK_DIRECTORY)com_sun_corba_se_PortableActivationIDL.jmk
 include $(CORBA_JMK_DIRECTORY)com_sun_corba_se_impl_logging.jmk
 
+FILES_java += com/sun/corba/se/org/omg/CORBA/ORB.java
+
 #
 # Dirs
 #
--- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -202,6 +202,10 @@
     private IDLNameTranslatorImpl(Class[] interfaces)
     {
 
+        SecurityManager s = System.getSecurityManager();
+        if (s != null) {
+            s.checkPermission(new DynamicAccessPermission("access"));
+        }
         try {
             IDLTypesUtil idlTypesUtil = new IDLTypesUtil();
             for (int ctr=0; ctr<interfaces.length; ctr++)
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/first.set	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/first.set	Thu May 14 09:53:35 2009 -0700
@@ -1,11 +1,35 @@
+/*
+ * Copyright 1999 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.
+ */
+
 /*
  *    COMPONENT_NAME:  idl.parser
- *                                                 
+ *
  *    ORIGINS: 27
  *
- *    THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM                        
  *    5639-D57, (C) COPYRIGHT International Business Machines Corp., 1997, 1998
- *                                        
+ *
  */
 
 CORBA IDL
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/follow.set	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/follow.set	Thu May 14 09:53:35 2009 -0700
@@ -1,11 +1,35 @@
+/*
+ * Copyright 1999 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.
+ */
+
 /*
  *    COMPONENT_NAME:  idl.parser
- *                                                 
+ *
  *    ORIGINS: 27
  *
- *    THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM                        
  *    5639-D57, (C) COPYRIGHT International Business Machines Corp., 1997, 1998
- *                                        
+ *
  */
 
 CORBA IDL
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar.idl	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar.idl	Thu May 14 09:53:35 2009 -0700
@@ -1,14 +1,38 @@
+/*
+ * Copyright 1999 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.
+ */
+
 /*
  *    COMPONENT_NAME:  idl.parser
- *                                                 
+ *
  *    ORIGINS: 27
  *
- *    THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM                        
  *    5639-D57, (C) COPYRIGHT International Business Machines Corp., 1997, 1998
- *                                        
+ *
  */
 
-CORBA 2.3 IDL 
+CORBA 2.3 IDL
 ---------------
 
 (1) <specification>	<definition><specification'>
@@ -83,7 +107,7 @@
 
 (16) <vad>		e
 			<export> <vad>
-		
+
 (17) <value_dcl>	<value_header> "{" <value_element> <ve> "}"
 
 (17) <ve>		e
@@ -91,9 +115,9 @@
 
 (18) <value_header>	"custom" "valuetype" <id> <value_inheritance_spec>
 			"valuetype" <id> <value_inheritance_spec>
-			"custom" "valuetype" <id> 
-			"valuetype" <id> 
-			
+			"custom" "valuetype" <id>
+			"valuetype" <id>
+
 (19) <value_inheritance_spec>	<opt_inherits> <opt_supports>
 
 (19) <opt_inherits>	e
@@ -107,7 +131,7 @@
 			"supports" <interface_name> <interface_name_list>
 
 (19) <interface_name_list>  e
-			"," <interface_name> <interface_name_list> 
+			"," <interface_name> <interface_name_list>
 
 (20) <value_name>	<scoped_name>
 
@@ -121,7 +145,7 @@
 (23) <init_dcl>		"factory" <id> "(" ")"
 			"factory" <id> "(" <init_param_dcls> ")"
 
-(24) <init_param_dcls>	<init_param_decl> 
+(24) <init_param_dcls>	<init_param_decl>
 			<init_param_decl> "," <init_param_dcls>
 
 (25) <init_param_dcl>	<init_param_attribute> <param_type_spec> <simple_declarator>
@@ -349,7 +373,7 @@
 
 (87) <op_dcl''>		e
 			<context_expr>
-			<raises_expr> 
+			<raises_expr>
 			<raises_expr> <context_expr>
 
 (88) <op_attribute>	"oneway"
@@ -386,7 +410,7 @@
 			<wide_string_type>
 			<scoped_name>
 
-(96) <fixed_pt_type>	"fixed" "<" <positive_int_const> "," <positive_int_const> ">" 
+(96) <fixed_pt_type>	"fixed" "<" <positive_int_const> "," <positive_int_const> ">"
 
 (97) <fixed_pt_const_type> "fixed"
 
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar3.idl	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar3.idl	Thu May 14 09:53:35 2009 -0700
@@ -1,11 +1,35 @@
+/*
+ * Copyright 1999 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.
+ */
+
 /*
  *    COMPONENT_NAME:  idl.parser
- *                                                 
+ *
  *    ORIGINS: 27
  *
- *    THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM                        
  *    5639-D57, (C) COPYRIGHT International Business Machines Corp., 1997, 1998
- *                                        
+ *
  */
 
 (1) <specification>	<imports> <definition> <specification'> // CORBA3
@@ -98,7 +122,7 @@
 
 (16) <vad>		e
 			<export> <vad>
-		
+
 (17) <value_dcl>	<value_header> "{" <value_element> <ve> "}"
 
 (17) <ve>		e
@@ -106,9 +130,9 @@
 
 (18) <value_header>	"custom" "valuetype" <id> <value_inheritance_spec>
 			"valuetype" <id> <value_inheritance_spec>
-			"custom" "valuetype" <id> 
-			"valuetype" <id> 
-			
+			"custom" "valuetype" <id>
+			"valuetype" <id>
+
 (19) <value_inheritance_spec>	<opt_inherits> <opt_supports>
 
 (19) <opt_inherits>	e
@@ -122,7 +146,7 @@
 			"supports" <interface_name> <interface_name_list>
 
 (19) <interface_name_list>  e
-			"," <interface_name> <interface_name_list> 
+			"," <interface_name> <interface_name_list>
 
 (20) <value_name>	<scoped_name>
 
@@ -136,7 +160,7 @@
 (23) <init_dcl>		"factory" <id> "(" ")"
 			"factory" <id> "(" <init_param_dcls> ")"
 
-(24) <init_param_dcls>	<init_param_dcl> 
+(24) <init_param_dcls>	<init_param_dcl>
 			<init_param_dcl> "," <init_param_dcls>
 
 (25) <init_param_dcl>	<init_param_attribute> <param_type_spec> <simple_declarator>
@@ -351,7 +375,7 @@
 (85) <readonly_attr_spec>   <readonly_attr_header> <readonly_attr_declarator>	// CORBA3
 
 (85) <readonly_attr_header> "readonly" "attribute" <param_type_spec>	// CORBA3
-			
+
 (85) <readonly_attr_declarator> <simple_declarator> <get_excep_expr>	// CORBA3
 			<simple_declarator> <sds>   // CORBA3
 
@@ -389,7 +413,7 @@
 
 (87) <op_dcl''>		e
 			<context_expr>
-			<raises_expr> 
+			<raises_expr>
 			<raises_expr> <context_expr>
 
 (88) <op_attribute>	"oneway"
@@ -426,7 +450,7 @@
 			<wide_string_type>
 			<scoped_name>
 
-(96) <fixed_pt_type>	"fixed" "<" <positive_int_const> "," <positive_int_const> ">" 
+(96) <fixed_pt_type>	"fixed" "<" <positive_int_const> "," <positive_int_const> ">"
 
 (97) <fixed_pt_const_type> "fixed"
 
@@ -450,7 +474,7 @@
 
 (204) <snames>		e
 			"," <scoped_name> <snames>
-			
+
 (205) <component_inheritance_spec> ":" <scoped_name>
 
 (206) <component_body>	<component_export> <ces>
@@ -458,8 +482,8 @@
 (206) <ces>		e
 			<component_export> <ces>
 
-(207) <component_export>    <provides_dcl> ";" 
-			<uses_dcl> ";" 
+(207) <component_export>    <provides_dcl> ";"
+			<uses_dcl> ";"
 			<emits_dcl> ";"
 			<publishes_dcl> ";"
 			<consumes_dcl> ";"
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl.prp	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl.prp	Thu May 14 09:53:35 2009 -0700
@@ -1,3 +1,28 @@
+#
+# Copyright 1999-2004 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.
+#
+
 #
 # COMPONENT_NAME:  idl.parser
 #
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp	Thu May 14 09:53:35 2009 -0700
@@ -1,3 +1,28 @@
+#
+# Copyright 1999-2005 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.
+#
+
 #
 # COMPONENT_NAME:  idl.parser
 #
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp	Thu May 14 09:53:35 2009 -0700
@@ -1,3 +1,28 @@
+#
+# Copyright 2005 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.
+#
+
 #
 # COMPONENT_NAME:  idl.parser
 #
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable.prp	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable.prp	Thu May 14 09:53:35 2009 -0700
@@ -1,3 +1,28 @@
+#
+# Copyright 1999-2004 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.
+#
+
 #
 # COMPONENT_NAME: idl.toJava
 #
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp	Thu May 14 09:53:35 2009 -0700
@@ -1,3 +1,28 @@
+#
+# Copyright 2001-2005 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.
+#
+
 #
 # COMPONENT_NAME: idl.toJava
 #
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp	Wed May 06 14:14:54 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp	Thu May 14 09:53:35 2009 -0700
@@ -1,3 +1,28 @@
+#
+# Copyright 2005 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.
+#
+
 #
 # COMPONENT_NAME: idl.toJava
 #
--- a/hotspot/.hgtags	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/.hgtags	Thu May 14 09:53:35 2009 -0700
@@ -31,3 +31,5 @@
 fafab5d5349c7c066d677538db67a1ee0fb33bd2 jdk7-b54
 f8e839c086152da70d6ec5913ba6f9f509282e8d jdk7-b55
 a3fd9e40ff2e854f6169eb6d09d491a28634d04f jdk7-b56
+f4cbf78110c726919f46b59a3b054c54c7e889b4 jdk7-b57
+53d9bf689e80fcc76b221bbe6c5d58e08b80cbc6 jdk7-b58
--- a/hotspot/agent/src/os/linux/Makefile	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/agent/src/os/linux/Makefile	Thu May 14 09:53:35 2009 -0700
@@ -60,6 +60,14 @@
   LFLAGS_LIBSA = -Xlinker --version-script=mapfile
 endif
 
+# If this is a --hash-style=gnu system, use --hash-style=both
+#   The gnu .hash section won't work on some Linux systems like SuSE 10.
+_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
+ifneq ($(_HAS_HASH_STYLE_GNU),)
+  LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
+endif
+LFLAGS_LIBSA += $(LDFLAGS_HASH_STYLE)
+
 $(LIBSA): $(OBJS) mapfile
 	if [ ! -d $(ARCH) ] ; then mkdir $(ARCH) ; fi
 	$(GCC) -shared $(LFLAGS_LIBSA) -o $(LIBSA) $(OBJS) $(LIBS)
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java	Thu May 14 09:53:35 2009 -0700
@@ -306,8 +306,6 @@
 
       entryAddr = entryAddr.addOffsetTo(intConstantEntryArrayStride);
     } while (nameAddr != null);
-      String symbol = "heapOopSize"; // global int constant and value is initialized at runtime.
-      addIntConstant(symbol, (int)lookupInProcess(symbol).getCIntegerAt(0, 4, false));
   }
 
   private void readVMLongConstants() {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Thu May 14 09:53:35 2009 -0700
@@ -318,11 +318,17 @@
     logMinObjAlignmentInBytes = db.lookupIntConstant("LogMinObjAlignmentInBytes").intValue();
     heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
     oopSize  = db.lookupIntConstant("oopSize").intValue();
-    heapOopSize  = db.lookupIntConstant("heapOopSize").intValue();
 
     intxType = db.lookupType("intx");
     uintxType = db.lookupType("uintx");
     boolType = (CIntegerType) db.lookupType("bool");
+
+    if (isCompressedOopsEnabled()) {
+      // Size info for oops within java objects is fixed
+      heapOopSize = (int)getIntSize();
+    } else {
+      heapOopSize = (int)getOopSize();
+    }
   }
 
   /** This could be used by a reflective runtime system */
@@ -343,13 +349,12 @@
     }
     soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
 
-    debugger.putHeapConst(soleInstance.getHeapOopSize(), Universe.getNarrowOopBase(),
-                          Universe.getNarrowOopShift());
-
     for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
       ((Observer) iter.next()).update(null, null);
     }
 
+    debugger.putHeapConst(soleInstance.getHeapOopSize(), Universe.getNarrowOopBase(),
+                          Universe.getNarrowOopShift());
   }
 
   /** This is used by the debugging system */
--- a/hotspot/make/hotspot_version	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/make/hotspot_version	Thu May 14 09:53:35 2009 -0700
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=16
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=02
+HS_BUILD_NUMBER=03
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=7
--- a/hotspot/make/jprt.config	Wed May 06 14:14:54 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,275 +0,0 @@
-#!echo "This is not a shell script"
-#
-# Copyright 2006-2008 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.
-#
-# 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.
-#  
-#
-
-#############################################################################
-# Error
-error() # message
-{
-  echo "ERROR: $1"
-  exit 6
-}
-# Directory must exist
-dirMustExist() # dir name
-{
-  if [ ! -d "$1" ] ; then
-    error "Directory for $2 does not exist: $1"
-  fi
-}
-# File must exist
-fileMustExist() # dir name
-{
-  if [ ! -f "$1" ] ; then
-    error "File for $2 does not exist: $1"
-  fi
-}
-#############################################################################
-
-# Should be set by JPRT as the 3 basic inputs
-bootdir="${ALT_BOOTDIR}"
-slashjava="${ALT_SLASH_JAVA}"
-jdk_import="${ALT_JDK_IMPORT_PATH}"
-
-# Check input
-dirMustExist "${bootdir}"    ALT_BOOTDIR
-dirMustExist "${slashjava}"  ALT_SLASH_JAVA
-dirMustExist "${jdk_import}" ALT_JDK_IMPORT_PATH
-
-# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
-osname=`uname -s`
-if [ "${osname}" = SunOS ] ; then
-   
-    # SOLARIS: Sparc or X86
-    osarch=`uname -p`
-    if [ "${osarch}" = sparc ] ; then
-	solaris_arch=sparc
-    else
-	solaris_arch=i386
-    fi
-
-    if [ "${JPRT_SOLARIS_COMPILER_NAME}" != "" ] ; then
-        compiler_name=${JPRT_SOLARIS_COMPILER_NAME}
-    else
-        if [ "${JPRT_JOB_PRODUCT_RELEASE}" = "jdk6"      -o \
-             "${JPRT_JOB_PRODUCT_RELEASE}" = "jdk6u10"   -o \
-             "${JPRT_JOB_PRODUCT_RELEASE}" = "jdk6u14"   -o \
-             "${JPRT_JOB_PRODUCT_RELEASE}" = "jdk6perf" ] ; then
-            # All jdk6 builds use SS11
-            compiler_name=SS11
-        else
-	    compiler_name=SS12
-        fi
-    fi
-    
-    # Get into path (make sure it matches ALT setting)
-    compiler_path=${slashjava}/devtools/${solaris_arch}/SUNWspro/${compiler_name}/bin
-    dirMustExist "${compiler_path}" COMPILER_PATH
-    path4sdk=${compiler_path}
-
-    # Add basic solaris system paths
-    path4sdk=${path4sdk}:/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
-
-    # Get the previous JDK to be used to bootstrap the build
-    path4sdk=${bootdir}/bin:${path4sdk}
-
-    # Find GNU make
-    make=/usr/sfw/bin/gmake
-    if [ ! -f ${make} ] ; then
-	make=/opt/sfw/bin/gmake
-	if [ ! -f ${make} ] ; then
-	    make=${slashjava}/devtools/${solaris_arch}/bin/gnumake
-        fi 
-    fi
-    fileMustExist "${make}" make
-
-    # File creation mask
-    umask 002
-
-elif [ "${osname}" = Linux ] ; then
-   
-    # LINUX: X86, AMD64
-    osarch=`uname -m`
-    if [ "${osarch}" = i686 ] ; then
-	linux_arch=i586
-    elif [ "${osarch}" = x86_64 ] ; then
-	linux_arch=amd64
-    fi
-
-    # Get the compilers into path (make sure it matches ALT setting)
-    compiler_path=/usr/bin
-    dirMustExist "${compiler_path}" COMPILER_PATH
-    path4sdk=${compiler_path}
-    
-    # Add basic paths
-    path4sdk=${path4sdk}:/usr/bin:/bin:/usr/sbin:/sbin
-
-    # Get the previous JDK to be used to bootstrap the build
-    path4sdk=${bootdir}/bin:${path4sdk}
-    
-    # Find GNU make
-    make=/usr/bin/make
-    fileMustExist "${make}" make
-
-    umask 002
-
-else
-
-    # Windows: Differs on CYGWIN vs. MKS, and the compiler available.
-    #   Also, blanks in pathnames gives GNU make headaches, so anything placed
-    #   in any ALT_* variable should be the short windows dosname.
-   
-    # WINDOWS: Install and use MKS or CYGWIN (should have already been done)
-    #   Assumption here is that you are in a shell window via MKS or cygwin.
-    #   MKS install should have defined the environment variable ROOTDIR.
-    #   We also need to figure out which one we have: X86, AMD64
-    if [ "`echo ${PROCESSOR_IDENTIFIER} | fgrep AMD64`" != "" ] ; then
-	windows_arch=amd64
-    else
-	windows_arch=i586
-    fi
-    
-    # We need to determine if we are running a CYGWIN shell or an MKS shell
-    #    (if uname isn't available, then it will be unix_toolset=unknown)
-    unix_toolset=unknown
-    if [ "`uname -a | fgrep Cygwin`" = "" -a -d "${ROOTDIR}" ] ; then
-        # We kind of assume ROOTDIR is where MKS is and it's ok
-        unix_toolset=MKS
-        mkshome=`dosname -s "${ROOTDIR}"`
-	# Utility to convert to short pathnames without spaces
-	dosname="${mkshome}/mksnt/dosname -s"
-        # Most unix utilities are in the mksnt directory of ROOTDIR
-        unixcommand_path="${mkshome}/mksnt"
-        path4sdk="${unixcommand_path}"
-        dirMustExist "${unixcommand_path}" UNIXCOMMAND_PATH
-	devtools_path="${slashjava}/devtools/win32/bin"
-	path4sdk="${devtools_path};${path4sdk}"
-        dirMustExist "${devtools_path}" DEVTOOLS_PATH
-        # Find GNU make
-        make="${devtools_path}/gnumake.exe"
-        fileMustExist "${make}" make
-    elif [ "`uname -a | fgrep Cygwin`" != "" -a -f /bin/cygpath ] ; then
-        # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
-        unix_toolset=CYGWIN
-	# Utility to convert to short pathnames without spaces
-	dosname="/usr/bin/cygpath -a -m -s"
-        # Most unix utilities are in the /usr/bin
-        unixcommand_path="/usr/bin"
-        path4sdk="${unixcommand_path}"
-        dirMustExist "${unixcommand_path}" UNIXCOMMAND_PATH
-        # Find GNU make
-        make="${unixcommand_path}/make.exe"
-        fileMustExist "${make}" make
-    else
-      echo "WARNING: Cannot figure out if this is MKS or CYGWIN"
-    fi
-
-    # WINDOWS: Compiler setup (nasty part)
-    #   NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE.
-    #   NOTE: CYGWIN has a link.exe too, make sure the compilers are first
-    if [ "${windows_arch}" = i586 ] ; then
-        # 32bit Windows compiler settings
-        # VisualStudio .NET 2003 VC++ 7.1 (VS71COMNTOOLS should be defined)
-        vs_root=`${dosname} "${VS71COMNTOOLS}/../.."`
-        # Fill in PATH, LIB, and INCLUDE (unset all others to make sure)
-        vc7_root="${vs_root}/Vc7"
-        compiler_path="${vc7_root}/bin"
-        platform_sdk="${vc7_root}/PlatformSDK"
-        # LIB and INCLUDE must use ; as a separator
-        include4sdk="${vc7_root}/atlmfc/include"
-        include4sdk="${include4sdk};${vc7_root}/include"
-        include4sdk="${include4sdk};${platform_sdk}/include/prerelease"
-        include4sdk="${include4sdk};${platform_sdk}/include"
-        include4sdk="${include4sdk};${vs_root}/SDK/v1.1/include"
-        lib4sdk="${vc7_root}/atlmfc/lib"
-        lib4sdk="${lib4sdk};${vc7_root}/lib"
-        lib4sdk="${lib4sdk};${platform_sdk}/lib/prerelease"
-        lib4sdk="${lib4sdk};${platform_sdk}/lib"
-        lib4sdk="${lib4sdk};${vs_root}/SDK/v1.1/lib"
-        # Search path and DLL locating path
-        #   WARNING: CYGWIN has a link.exe too, make sure compilers are first
-        path4sdk="${vs_root}/Common7/Tools/bin;${path4sdk}"
-	path4sdk="${vs_root}/SDK/v1.1/bin;${path4sdk}"
-        path4sdk="${vs_root}/Common7/Tools;${path4sdk}"
-	path4sdk="${vs_root}/Common7/Tools/bin/prerelease;${path4sdk}"
-        path4sdk="${vs_root}/Common7/IDE;${path4sdk}"
-	path4sdk="${compiler_path};${path4sdk}"
-    elif [ "${windows_arch}" = amd64 ] ; then
-        # AMD64 64bit Windows compiler settings
-	if [ "${MSSDK}" != "" ] ; then
-	    platform_sdk="${MSSDK}"
-	else
-	    platform_sdk=`${dosname} "C:/Program Files/Microsoft Platform SDK/"`
-	fi
-	compiler_path="${platform_sdk}/Bin/win64/x86/AMD64"
-        # LIB and INCLUDE must use ; as a separator
-        include4sdk="${platform_sdk}/Include"
-	include4sdk="${include4sdk};${platform_sdk}/Include/crt/sys"
-	include4sdk="${include4sdk};${platform_sdk}/Include/mfc"
-	include4sdk="${include4sdk};${platform_sdk}/Include/atl"
-	include4sdk="${include4sdk};${platform_sdk}/Include/crt"
-        lib4sdk="${platform_sdk}/Lib/AMD64"
-        lib4sdk="${lib4sdk};${platform_sdk}/Lib/AMD64/atlmfc"
-        # Search path and DLL locating path
-        #   WARNING: CYGWIN has a link.exe too, make sure compilers are first
-        path4sdk="${platform_sdk}/bin;${path4sdk}"
-        path4sdk="${compiler_path};${path4sdk}"
-    fi
-    # Export LIB and INCLUDE
-    unset lib
-    unset Lib
-    LIB="${lib4sdk}"
-    export LIB
-    unset include
-    unset Include
-    INCLUDE="${include4sdk}"
-    export INCLUDE
-    # Set the ALT variable
-    dirMustExist "${compiler_path}" COMPILER_PATH
-    
-    # WINDOWS: Get the previous JDK to be used to bootstrap the build
-    path4sdk="${bootdir}/bin;${path4sdk}"
-
-    # Turn all \\ into /, remove duplicates and trailing /
-    slash_path="`echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g'`"
-    
-    # For windows, it's hard to know where the system is, so we just add this
-    #    to PATH.
-    path4sdk="${slash_path};${PATH}"
-    
-    # Convert path4sdk to cygwin style
-    if [ "${unix_toolset}" = CYGWIN ] ; then
-	path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
-    fi
-
-fi
-
-# Export PATH setting
-PATH="${path4sdk}"
-export PATH
-
-# Unset certain vars
-unset LD_LIBRARY_PATH
-unset LD_LIBRARY_PATH_32
-unset LD_LIBRARY_PATH_64
-
--- a/hotspot/make/jprt.properties	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/make/jprt.properties	Thu May 14 09:53:35 2009 -0700
@@ -70,10 +70,33 @@
 jprt.my.solaris.x64.jdk6u14=solaris_x64_5.10
 jprt.my.solaris.x64=${jprt.my.solaris.x64.${jprt.tools.default.release}}
 
-jprt.my.linux.i586=linux_i586
-jprt.my.linux.x64=linux_x64
-jprt.my.windows.i586=windows_i586
-jprt.my.windows.x64=windows_x64
+jprt.my.linux.i586.jdk7=linux_i586_2.6
+jprt.my.linux.i586.jdk6=linux_i586_2.4
+jprt.my.linux.i586.jdk6perf=linux_i586_2.4
+jprt.my.linux.i586.jdk6u10=linux_i586_2.4
+jprt.my.linux.i586.jdk6u14=linux_i586_2.4
+jprt.my.linux.i586=${jprt.my.linux.i586.${jprt.tools.default.release}}
+
+jprt.my.linux.x64.jdk7=linux_x64_2.6
+jprt.my.linux.x64.jdk6=linux_x64_2.4
+jprt.my.linux.x64.jdk6perf=linux_x64_2.4
+jprt.my.linux.x64.jdk6u10=linux_x64_2.4
+jprt.my.linux.x64.jdk6u14=linux_x64_2.4
+jprt.my.linux.x64=${jprt.my.linux.x64.${jprt.tools.default.release}}
+
+jprt.my.windows.i586.jdk7=windows_i586_5.0
+jprt.my.windows.i586.jdk6=windows_i586_5.0
+jprt.my.windows.i586.jdk6perf=windows_i586_5.0
+jprt.my.windows.i586.jdk6u10=windows_i586_5.0
+jprt.my.windows.i586.jdk6u14=windows_i586_5.0
+jprt.my.windows.i586=${jprt.my.windows.i586.${jprt.tools.default.release}}
+
+jprt.my.windows.x64.jdk7=windows_x64_5.2
+jprt.my.windows.x64.jdk6=windows_x64_5.2
+jprt.my.windows.x64.jdk6perf=windows_x64_5.2
+jprt.my.windows.x64.jdk6u10=windows_x64_5.2
+jprt.my.windows.x64.jdk6u14=windows_x64_5.2
+jprt.my.windows.x64=${jprt.my.windows.x64.${jprt.tools.default.release}}
 
 # Standard list of jprt build targets for this source tree
 
--- a/hotspot/make/linux/makefiles/gcc.make	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/make/linux/makefiles/gcc.make	Thu May 14 09:53:35 2009 -0700
@@ -113,6 +113,11 @@
 
 OPT_CFLAGS/NOOPT=-O0
 
+# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. 
+ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
+OPT_CFLAGS/mulnode.o += -O0
+endif
+
 #------------------------------------------------------------------------
 # Linker flags
 
--- a/hotspot/make/linux/makefiles/jsig.make	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/make/linux/makefiles/jsig.make	Thu May 14 09:53:35 2009 -0700
@@ -39,7 +39,7 @@
 # cause problems with interposing. See CR: 6466665
 # LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
 
-LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT
+LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE)
 
 $(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
 	@echo Making signal interposition lib...
--- a/hotspot/make/linux/makefiles/saproc.make	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/make/linux/makefiles/saproc.make	Thu May 14 09:53:35 2009 -0700
@@ -51,7 +51,7 @@
 	   $(MAKE) -f vm.make $(LIBSAPROC); \
 	fi
 
-SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE))
+SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE)) $(LDFLAGS_HASH_STYLE)
 
 $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
 	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Thu May 14 09:53:35 2009 -0700
@@ -2314,7 +2314,8 @@
 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) { }
 
 void os::free_memory(char *addr, size_t bytes) {
-  uncommit_memory(addr, bytes);
+  ::mmap(addr, bytes, PROT_READ | PROT_WRITE,
+         MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
 }
 
 void os::numa_make_global(char *addr, size_t bytes) {
@@ -2361,6 +2362,19 @@
 extern "C" void numa_warn(int number, char *where, ...) { }
 extern "C" void numa_error(char *where) { }
 
+
+// If we are running with libnuma version > 2, then we should
+// be trying to use symbols with versions 1.1
+// If we are running with earlier version, which did not have symbol versions,
+// we should use the base version.
+void* os::Linux::libnuma_dlsym(void* handle, const char *name) {
+  void *f = dlvsym(handle, name, "libnuma_1.1");
+  if (f == NULL) {
+    f = dlsym(handle, name);
+  }
+  return f;
+}
+
 bool os::Linux::libnuma_init() {
   // sched_getcpu() should be in libc.
   set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
@@ -2370,19 +2384,19 @@
     void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
     if (handle != NULL) {
       set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t,
-                                           dlsym(handle, "numa_node_to_cpus")));
+                                           libnuma_dlsym(handle, "numa_node_to_cpus")));
       set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t,
-                                       dlsym(handle, "numa_max_node")));
+                                       libnuma_dlsym(handle, "numa_max_node")));
       set_numa_available(CAST_TO_FN_PTR(numa_available_func_t,
-                                        dlsym(handle, "numa_available")));
+                                        libnuma_dlsym(handle, "numa_available")));
       set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t,
-                                            dlsym(handle, "numa_tonode_memory")));
+                                            libnuma_dlsym(handle, "numa_tonode_memory")));
       set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
-                                            dlsym(handle, "numa_interleave_memory")));
+                                            libnuma_dlsym(handle, "numa_interleave_memory")));
 
 
       if (numa_available() != -1) {
-        set_numa_all_nodes((unsigned long*)dlsym(handle, "numa_all_nodes"));
+        set_numa_all_nodes((unsigned long*)libnuma_dlsym(handle, "numa_all_nodes"));
         // Create a cpu -> node mapping
         _cpu_to_node = new (ResourceObj::C_HEAP) GrowableArray<int>(0, true);
         rebuild_cpu_to_node_map();
--- a/hotspot/src/os/linux/vm/os_linux.hpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/os/linux/vm/os_linux.hpp	Thu May 14 09:53:35 2009 -0700
@@ -147,7 +147,7 @@
 
   static void libpthread_init();
   static bool libnuma_init();
-
+  static void* libnuma_dlsym(void* handle, const char* name);
   // Minimum stack size a thread can be created with (allowing
   // the VM to completely create the thread and enter user code)
   static size_t min_stack_allowed;
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp	Thu May 14 09:53:35 2009 -0700
@@ -53,7 +53,9 @@
     ResourceMark rm;
     HandleMark   hm;
 
-    if (TraceG1Refine) gclog_or_tty->print_cr("G1-Refine starting pass");
+    if (G1TraceConcurrentRefinement) {
+      gclog_or_tty->print_cr("G1-Refine starting pass");
+    }
     _sts.join();
     bool no_sleep = _cg1r->refine();
     _sts.leave();
@@ -207,9 +209,9 @@
 
 
 void ConcurrentG1RefineThread::yield() {
-  if (TraceG1Refine) gclog_or_tty->print_cr("G1-Refine-yield");
+  if (G1TraceConcurrentRefinement) gclog_or_tty->print_cr("G1-Refine-yield");
   _sts.yield("G1 refine");
-  if (TraceG1Refine) gclog_or_tty->print_cr("G1-Refine-yield-end");
+  if (G1TraceConcurrentRefinement) gclog_or_tty->print_cr("G1-Refine-yield-end");
 }
 
 void ConcurrentG1RefineThread::stop() {
@@ -230,7 +232,7 @@
       Terminator_lock->wait();
     }
   }
-  if (TraceG1Refine) gclog_or_tty->print_cr("G1-Refine-stop");
+  if (G1TraceConcurrentRefinement) gclog_or_tty->print_cr("G1-Refine-stop");
 }
 
 void ConcurrentG1RefineThread::print() {
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu May 14 09:53:35 2009 -0700
@@ -448,8 +448,8 @@
     gclog_or_tty->print_cr("[global] init, heap start = "PTR_FORMAT", "
                            "heap end = "PTR_FORMAT, _heap_start, _heap_end);
 
-  _markStack.allocate(G1CMStackSize);
-  _regionStack.allocate(G1CMRegionStackSize);
+  _markStack.allocate(G1MarkStackSize);
+  _regionStack.allocate(G1MarkRegionStackSize);
 
   // Create & start a ConcurrentMark thread.
   if (G1ConcMark) {
@@ -499,20 +499,21 @@
     _marking_task_overhead    = 1.0;
   } else {
     if (ParallelMarkingThreads > 0) {
-      // notice that ParallelMarkingThreads overwrites G1MarkingOverheadPerc
+      // notice that ParallelMarkingThreads overwrites G1MarkingOverheadPercent
       // if both are set
 
       _parallel_marking_threads = ParallelMarkingThreads;
       _sleep_factor             = 0.0;
       _marking_task_overhead    = 1.0;
-    } else if (G1MarkingOverheadPerc > 0) {
+    } else if (G1MarkingOverheadPercent > 0) {
       // we will calculate the number of parallel marking threads
       // based on a target overhead with respect to the soft real-time
       // goal
 
-      double marking_overhead = (double) G1MarkingOverheadPerc / 100.0;
+      double marking_overhead = (double) G1MarkingOverheadPercent / 100.0;
       double overall_cm_overhead =
-        (double) G1MaxPauseTimeMS * marking_overhead / (double) G1TimeSliceMS;
+        (double) MaxGCPauseMillis * marking_overhead /
+        (double) GCPauseIntervalMillis;
       double cpu_ratio = 1.0 / (double) os::processor_count();
       double marking_thread_num = ceil(overall_cm_overhead / cpu_ratio);
       double marking_task_overhead =
@@ -1747,7 +1748,7 @@
   g1h->increment_total_collections();
 
 #ifndef PRODUCT
-  if (G1VerifyConcMark) {
+  if (VerifyDuringGC) {
     G1CollectedHeap::heap()->prepare_for_verify();
     G1CollectedHeap::heap()->verify(true,false);
   }
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Thu May 14 09:53:35 2009 -0700
@@ -136,9 +136,6 @@
         iter++;
         if (!cm()->has_aborted()) {
           _cm->markFromRoots();
-        } else {
-          if (TraceConcurrentMark)
-            gclog_or_tty->print_cr("CM-skip-mark-from-roots");
         }
 
         double mark_end_time = os::elapsedVTime();
@@ -163,9 +160,6 @@
           sprintf(verbose_str, "GC remark");
           VM_CGC_Operation op(&final_cl, verbose_str);
           VMThread::execute(&op);
-        } else {
-          if (TraceConcurrentMark)
-            gclog_or_tty->print_cr("CM-skip-remark");
         }
         if (cm()->restart_for_overflow() &&
             G1TraceMarkStackOverflow) {
@@ -208,8 +202,6 @@
                                    count_end_sec - count_start_sec);
           }
         }
-      } else {
-        if (TraceConcurrentMark) gclog_or_tty->print_cr("CM-skip-end-game");
       }
       double end_time = os::elapsedVTime();
       _vtime_count_accum += (end_time - counting_start_time);
@@ -230,7 +222,6 @@
         VM_CGC_Operation op(&cl_cl, verbose_str);
         VMThread::execute(&op);
       } else {
-        if (TraceConcurrentMark) gclog_or_tty->print_cr("CM-skip-cleanup");
         G1CollectedHeap::heap()->set_marking_complete();
       }
 
@@ -287,9 +278,7 @@
 
 
 void ConcurrentMarkThread::yield() {
-  if (TraceConcurrentMark) gclog_or_tty->print_cr("CM-yield");
   _sts.yield("Concurrent Mark");
-  if (TraceConcurrentMark) gclog_or_tty->print_cr("CM-yield-end");
 }
 
 void ConcurrentMarkThread::stop() {
@@ -299,7 +288,6 @@
   while (!_has_terminated) {
     Terminator_lock->wait();
   }
-  if (TraceConcurrentMark) gclog_or_tty->print_cr("CM-stop");
 }
 
 void ConcurrentMarkThread::print() {
@@ -314,12 +302,10 @@
   // below while the world is otherwise stopped.
   MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
   while (!started()) {
-    if (TraceConcurrentMark) gclog_or_tty->print_cr("CM-sleeping");
     CGC_lock->wait(Mutex::_no_safepoint_check_flag);
   }
   set_in_progress();
   clear_started();
-  if (TraceConcurrentMark) gclog_or_tty->print_cr("CM-starting");
 }
 
 // Note: this method, although exported by the ConcurrentMarkSweepThread,
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu May 14 09:53:35 2009 -0700
@@ -528,7 +528,7 @@
            res->zero_fill_state() == HeapRegion::Allocated)),
          "Non-young alloc Regions must be zero filled (and non-H)");
 
-  if (G1TraceRegions) {
+  if (G1PrintRegions) {
     if (res != NULL) {
       gclog_or_tty->print_cr("new alloc region %d:["PTR_FORMAT", "PTR_FORMAT"], "
                              "top "PTR_FORMAT,
@@ -2282,13 +2282,13 @@
     // to that.
     g1_policy()->print_tracing_info();
   }
-  if (SummarizeG1RSStats) {
+  if (G1SummarizeRSetStats) {
     g1_rem_set()->print_summary_info();
   }
-  if (SummarizeG1ConcMark) {
+  if (G1SummarizeConcurrentMark) {
     concurrent_mark()->print_summary_info();
   }
-  if (SummarizeG1ZFStats) {
+  if (G1SummarizeZFStats) {
     ConcurrentZFThread::print_summary_info();
   }
   g1_policy()->print_yg_surv_rate_info();
@@ -3255,7 +3255,7 @@
   HeapRegion* r = heap_region_containing(old);
   if (!r->evacuation_failed()) {
     r->set_evacuation_failed(true);
-    if (G1TraceRegions) {
+    if (G1PrintRegions) {
       gclog_or_tty->print("evacuation failed in heap region "PTR_FORMAT" "
                           "["PTR_FORMAT","PTR_FORMAT")\n",
                           r, r->bottom(), r->end());
@@ -3466,7 +3466,7 @@
   }
 
   static size_t gclab_word_size() {
-    return ParallelGCG1AllocBufferSize / HeapWordSize;
+    return G1ParallelGCAllocBufferSize / HeapWordSize;
   }
 
   static size_t bitmap_size_in_bits() {
@@ -3616,7 +3616,7 @@
 
 public:
   G1ParGCAllocBuffer() :
-    ParGCAllocBuffer(ParallelGCG1AllocBufferSize / HeapWordSize),
+    ParGCAllocBuffer(G1ParallelGCAllocBufferSize / HeapWordSize),
     _during_marking(G1CollectedHeap::heap()->mark_in_progress()),
     _bitmap(G1CollectedHeap::heap()->reserved_region().start()),
     _retired(false)
@@ -3812,14 +3812,14 @@
 
     HeapWord* obj = NULL;
     if (word_sz * 100 <
-        (size_t)(ParallelGCG1AllocBufferSize / HeapWordSize) *
+        (size_t)(G1ParallelGCAllocBufferSize / HeapWordSize) *
                                                   ParallelGCBufferWastePct) {
       G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
       add_to_alloc_buffer_waste(alloc_buf->words_remaining());
       alloc_buf->retire(false, false);
 
       HeapWord* buf =
-        _g1h->par_allocate_during_gc(purpose, ParallelGCG1AllocBufferSize / HeapWordSize);
+        _g1h->par_allocate_during_gc(purpose, G1ParallelGCAllocBufferSize / HeapWordSize);
       if (buf == NULL) return NULL; // Let caller handle allocation failure.
       // Otherwise.
       alloc_buf->set_buf(buf);
@@ -4331,7 +4331,7 @@
       _g1h->g1_policy()->record_obj_copy_time(i, elapsed_ms-term_ms);
       _g1h->g1_policy()->record_termination_time(i, term_ms);
     }
-    if (G1UseSurvivorSpace) {
+    if (G1UseSurvivorSpaces) {
       _g1h->g1_policy()->record_thread_age_table(pss.age_table());
     }
     _g1h->update_surviving_young_words(pss.surviving_young_words()+1);
@@ -4435,28 +4435,6 @@
 
   // XXX What should this be doing in the parallel case?
   g1_policy()->record_collection_pause_end_CH_strong_roots();
-  if (G1VerifyRemSet) {
-    // :::: FIXME ::::
-    // The stupid remembered set doesn't know how to filter out dead
-    // objects, which the smart one does, and so when it is created
-    // and then compared the number of entries in each differs and
-    // the verification code fails.
-    guarantee(false, "verification code is broken, see note");
-
-    // Let's make sure that the current rem set agrees with the stupidest
-    // one possible!
-    bool refs_enabled = ref_processor()->discovery_enabled();
-    if (refs_enabled) ref_processor()->disable_discovery();
-    StupidG1RemSet stupid(this);
-    count_closure.n = 0;
-    stupid.oops_into_collection_set_do(&count_closure, worker_i);
-    int stupid_n = count_closure.n;
-    count_closure.n = 0;
-    g1_rem_set()->oops_into_collection_set_do(&count_closure, worker_i);
-    guarantee(count_closure.n == stupid_n, "Old and new rem sets differ.");
-    gclog_or_tty->print_cr("\nFound %d pointers in heap RS.", count_closure.n);
-    if (refs_enabled) ref_processor()->enable_discovery();
-  }
   if (scan_so != NULL) {
     scan_scan_only_set(scan_so, worker_i);
   }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp	Thu May 14 09:53:35 2009 -0700
@@ -37,8 +37,9 @@
 inline HeapRegion*
 G1CollectedHeap::heap_region_containing_raw(const void* addr) const {
   assert(_g1_reserved.contains(addr), "invariant");
-  size_t index = ((intptr_t) addr - (intptr_t) _g1_reserved.start())
-                                              >> HeapRegion::LogOfHRGrainBytes;
+  size_t index = pointer_delta(addr, _g1_reserved.start(), 1)
+                                        >> HeapRegion::LogOfHRGrainBytes;
+
   HeapRegion* res = _hrs->at(index);
   assert(res == _hrs->addr_to_region(addr), "sanity");
   return res;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu May 14 09:53:35 2009 -0700
@@ -136,7 +136,7 @@
   _scanned_cards_seq(new TruncatedSeq(TruncatedSeqLength)),
   _rs_lengths_seq(new TruncatedSeq(TruncatedSeqLength)),
 
-  _pause_time_target_ms((double) G1MaxPauseTimeMS),
+  _pause_time_target_ms((double) MaxGCPauseMillis),
 
   // </NEW PREDICTION>
 
@@ -220,7 +220,7 @@
   _par_last_termination_times_ms = new double[_parallel_gc_threads];
 
   // start conservatively
-  _expensive_region_limit_ms = 0.5 * (double) G1MaxPauseTimeMS;
+  _expensive_region_limit_ms = 0.5 * (double) MaxGCPauseMillis;
 
   // <NEW PREDICTION>
 
@@ -249,12 +249,12 @@
 
   // </NEW PREDICTION>
 
-  double time_slice  = (double) G1TimeSliceMS / 1000.0;
-  double max_gc_time = (double) G1MaxPauseTimeMS / 1000.0;
+  double time_slice  = (double) GCPauseIntervalMillis / 1000.0;
+  double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
   guarantee(max_gc_time < time_slice,
             "Max GC time should not be greater than the time slice");
   _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
-  _sigma = (double) G1ConfidencePerc / 100.0;
+  _sigma = (double) G1ConfidencePercent / 100.0;
 
   // start conservatively (around 50ms is about right)
   _concurrent_mark_init_times_ms->add(0.05);
@@ -262,7 +262,7 @@
   _concurrent_mark_cleanup_times_ms->add(0.20);
   _tenuring_threshold = MaxTenuringThreshold;
 
-  if (G1UseSurvivorSpace) {
+  if (G1UseSurvivorSpaces) {
     // if G1FixedSurvivorSpaceSize is 0 which means the size is not
     // fixed, then _max_survivor_regions will be calculated at
     // calculate_young_list_target_config during initialization
@@ -451,7 +451,7 @@
   guarantee( adaptive_young_list_length(), "pre-condition" );
 
   double start_time_sec = os::elapsedTime();
-  size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1MinReservePerc);
+  size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1MinReservePercent);
   min_reserve_perc = MIN2((size_t) 50, min_reserve_perc);
   size_t reserve_regions =
     (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0);
@@ -1109,7 +1109,7 @@
   _short_lived_surv_rate_group->record_scan_only_prefix(short_lived_so_length);
   tag_scan_only(short_lived_so_length);
 
-  if (G1UseSurvivorSpace) {
+  if (G1UseSurvivorSpaces) {
     _survivors_age_table.clear();
   }
 
@@ -1826,11 +1826,11 @@
     _rs_lengths_seq->add((double) _max_rs_lengths);
 
     double expensive_region_limit_ms =
-      (double) G1MaxPauseTimeMS - predict_constant_other_time_ms();
+      (double) MaxGCPauseMillis - predict_constant_other_time_ms();
     if (expensive_region_limit_ms < 0.0) {
       // this means that the other time was predicted to be longer than
       // than the max pause time
-      expensive_region_limit_ms = (double) G1MaxPauseTimeMS;
+      expensive_region_limit_ms = (double) MaxGCPauseMillis;
     }
     _expensive_region_limit_ms = expensive_region_limit_ms;
 
@@ -2093,24 +2093,24 @@
 }
 
 double G1CollectorPolicy::recent_avg_time_for_pauses_ms() {
-  if (_recent_pause_times_ms->num() == 0) return (double) G1MaxPauseTimeMS;
+  if (_recent_pause_times_ms->num() == 0) return (double) MaxGCPauseMillis;
   else return _recent_pause_times_ms->avg();
 }
 
 double G1CollectorPolicy::recent_avg_time_for_CH_strong_ms() {
   if (_recent_CH_strong_roots_times_ms->num() == 0)
-    return (double)G1MaxPauseTimeMS/3.0;
+    return (double)MaxGCPauseMillis/3.0;
   else return _recent_CH_strong_roots_times_ms->avg();
 }
 
 double G1CollectorPolicy::recent_avg_time_for_G1_strong_ms() {
   if (_recent_G1_strong_roots_times_ms->num() == 0)
-    return (double)G1MaxPauseTimeMS/3.0;
+    return (double)MaxGCPauseMillis/3.0;
   else return _recent_G1_strong_roots_times_ms->avg();
 }
 
 double G1CollectorPolicy::recent_avg_time_for_evac_ms() {
-  if (_recent_evac_times_ms->num() == 0) return (double)G1MaxPauseTimeMS/3.0;
+  if (_recent_evac_times_ms->num() == 0) return (double)MaxGCPauseMillis/3.0;
   else return _recent_evac_times_ms->avg();
 }
 
@@ -2197,17 +2197,18 @@
 }
 
 size_t G1CollectorPolicy::expansion_amount() {
-  if ((int)(recent_avg_pause_time_ratio() * 100.0) > G1GCPct) {
-    // We will double the existing space, or take G1ExpandByPctOfAvail % of
-    // the available expansion space, whichever is smaller, bounded below
-    // by a minimum expansion (unless that's all that's left.)
+  if ((int)(recent_avg_pause_time_ratio() * 100.0) > G1GCPercent) {
+    // We will double the existing space, or take
+    // G1ExpandByPercentOfAvailable % of the available expansion
+    // space, whichever is smaller, bounded below by a minimum
+    // expansion (unless that's all that's left.)
     const size_t min_expand_bytes = 1*M;
     size_t reserved_bytes = _g1->g1_reserved_obj_bytes();
     size_t committed_bytes = _g1->capacity();
     size_t uncommitted_bytes = reserved_bytes - committed_bytes;
     size_t expand_bytes;
     size_t expand_bytes_via_pct =
-      uncommitted_bytes * G1ExpandByPctOfAvail / 100;
+      uncommitted_bytes * G1ExpandByPercentOfAvailable / 100;
     expand_bytes = MIN2(expand_bytes_via_pct, committed_bytes);
     expand_bytes = MAX2(expand_bytes, min_expand_bytes);
     expand_bytes = MIN2(expand_bytes, uncommitted_bytes);
@@ -2591,7 +2592,7 @@
 // Calculates survivor space parameters.
 void G1CollectorPolicy::calculate_survivors_policy()
 {
-  if (!G1UseSurvivorSpace) {
+  if (!G1UseSurvivorSpaces) {
     return;
   }
   if (G1FixedSurvivorSpaceSize == 0) {
@@ -2851,7 +2852,7 @@
 // estimate of the number of live bytes.
 void G1CollectorPolicy::
 add_to_collection_set(HeapRegion* hr) {
-  if (G1TraceRegions) {
+  if (G1PrintRegions) {
     gclog_or_tty->print_cr("added region to cset %d:["PTR_FORMAT", "PTR_FORMAT"], "
                   "top "PTR_FORMAT", young %s",
                   hr->hrs_index(), hr->bottom(), hr->end(),
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Thu May 14 09:53:35 2009 -0700
@@ -57,7 +57,7 @@
 
   mark_sweep_phase1(marked_for_unloading, clear_all_softrefs);
 
-  if (G1VerifyConcMark) {
+  if (VerifyDuringGC) {
       G1CollectedHeap* g1h = G1CollectedHeap::heap();
       g1h->checkConcurrentMark();
   }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Thu May 14 09:53:35 2009 -0700
@@ -180,6 +180,7 @@
   CardTableModRefBS *_ct_bs;
   int _worker_i;
   bool _try_claimed;
+  size_t _min_skip_distance, _max_skip_distance;
 public:
   ScanRSClosure(OopsInHeapRegionClosure* oc, int worker_i) :
     _oc(oc),
@@ -191,6 +192,8 @@
     _g1h = G1CollectedHeap::heap();
     _bot_shared = _g1h->bot_shared();
     _ct_bs = (CardTableModRefBS*) (_g1h->barrier_set());
+    _min_skip_distance = 16;
+    _max_skip_distance = 2 * _g1h->n_par_threads() * _min_skip_distance;
   }
 
   void set_try_claimed() { _try_claimed = true; }
@@ -245,9 +248,13 @@
     HeapRegionRemSetIterator* iter = _g1h->rem_set_iterator(_worker_i);
     hrrs->init_iterator(iter);
     size_t card_index;
+    size_t skip_distance = 0, current_card = 0, jump_to_card = 0;
     while (iter->has_next(card_index)) {
+      if (current_card < jump_to_card) {
+        ++current_card;
+        continue;
+      }
       HeapWord* card_start = _g1h->bot_shared()->address_for_index(card_index);
-
 #if 0
       gclog_or_tty->print("Rem set iteration yielded card [" PTR_FORMAT ", " PTR_FORMAT ").\n",
                           card_start, card_start + CardTableModRefBS::card_size_in_words);
@@ -257,20 +264,28 @@
       assert(card_region != NULL, "Yielding cards not in the heap?");
       _cards++;
 
-      if (!card_region->in_collection_set()) {
-        // If the card is dirty, then we will scan it during updateRS.
-        if (!_ct_bs->is_card_claimed(card_index) &&
-            !_ct_bs->is_card_dirty(card_index)) {
-          assert(_ct_bs->is_card_clean(card_index) ||
-                 _ct_bs->is_card_claimed(card_index) ||
-                 _ct_bs->is_card_deferred(card_index),
-                 "Card is either clean, claimed or deferred");
-          if (_ct_bs->claim_card(card_index))
+       // If the card is dirty, then we will scan it during updateRS.
+      if (!card_region->in_collection_set() && !_ct_bs->is_card_dirty(card_index)) {
+          if (!_ct_bs->is_card_claimed(card_index) && _ct_bs->claim_card(card_index)) {
             scanCard(card_index, card_region);
-        }
+          } else if (_try_claimed) {
+            if (jump_to_card == 0 || jump_to_card != current_card) {
+              // We did some useful work in the previous iteration.
+              // Decrease the distance.
+              skip_distance = MAX2(skip_distance >> 1, _min_skip_distance);
+            } else {
+              // Previous iteration resulted in a claim failure.
+              // Increase the distance.
+              skip_distance = MIN2(skip_distance << 1, _max_skip_distance);
+            }
+            jump_to_card = current_card + skip_distance;
+          }
       }
+      ++current_card;
     }
-    hrrs->set_iter_complete();
+    if (!_try_claimed) {
+      hrrs->set_iter_complete();
+    }
     return false;
   }
   // Set all cards back to clean.
@@ -508,7 +523,7 @@
     // and they are causing failures. When we resolve said race
     // conditions, we'll revert back to parallel remembered set
     // updating and scanning. See CRs 6677707 and 6677708.
-    if (G1EnableParallelRSetUpdating || (worker_i == 0)) {
+    if (G1ParallelRSetUpdatingEnabled || (worker_i == 0)) {
       updateRS(worker_i);
       scanNewRefsRS(oc, worker_i);
     } else {
@@ -517,7 +532,7 @@
       _g1p->record_update_rs_time(worker_i, 0.0);
       _g1p->record_scan_new_refs_time(worker_i, 0.0);
     }
-    if (G1EnableParallelRSetScanning || (worker_i == 0)) {
+    if (G1ParallelRSetScanningEnabled || (worker_i == 0)) {
       scanRS(oc, worker_i);
     } else {
       _g1p->record_scan_rs_start_time(worker_i, os::elapsedTime());
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Thu May 14 09:53:35 2009 -0700
@@ -28,87 +28,65 @@
 
 #define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw) \
                                                                             \
-  product(intx, ParallelGCG1AllocBufferSize, 8*K,                           \
+  product(intx, G1ParallelGCAllocBufferSize, 8*K,                           \
           "Size of parallel G1 allocation buffers in to-space.")            \
                                                                             \
-  product(intx, G1TimeSliceMS, 500,                                         \
-          "Time slice for MMU specification")                               \
-                                                                            \
-  product(intx, G1MaxPauseTimeMS, 200,                                      \
-          "Max GC time per MMU time slice")                                 \
-                                                                            \
-  product(intx, G1ConfidencePerc, 50,                                       \
+  product(intx, G1ConfidencePercent, 50,                                    \
           "Confidence level for MMU/pause predictions")                     \
                                                                             \
-  product(intx, G1MarkingOverheadPerc, 0,                                   \
+  develop(intx, G1MarkingOverheadPercent, 0,                                   \
           "Overhead of concurrent marking")                                 \
                                                                             \
-  product(bool, G1AccountConcurrentOverhead, false,                         \
+  develop(bool, G1AccountConcurrentOverhead, false,                         \
           "Whether soft real-time compliance in G1 will take into account"  \
           "concurrent overhead")                                            \
                                                                             \
   product(intx, G1YoungGenSize, 0,                                          \
           "Size of the G1 young generation, 0 is the adaptive policy")      \
                                                                             \
-  product(bool, G1Gen, true,                                                \
+  develop(bool, G1Gen, true,                                                \
           "If true, it will enable the generational G1")                    \
                                                                             \
-  develop(intx, G1GCPct, 10,                                                \
+  develop(intx, G1GCPercent, 10,                                                \
           "The desired percent time spent on GC")                           \
                                                                             \
-  product(intx, G1PolicyVerbose, 0,                                         \
+  develop(intx, G1PolicyVerbose, 0,                                         \
           "The verbosity level on G1 policy decisions")                     \
                                                                             \
   develop(bool, G1UseHRIntoRS, true,                                        \
           "Determines whether the 'advanced' HR Into rem set is used.")     \
                                                                             \
-  product(bool, G1VerifyRemSet, false,                                      \
-          "If true, verify the rem set functioning at each GC")             \
-                                                                            \
-  product(bool, G1VerifyConcMark, false,                                    \
-          "If true, verify the conc marking code at full GC time")          \
-                                                                            \
   develop(intx, G1MarkingVerboseLevel, 0,                                   \
           "Level (0-4) of verboseness of the marking code")                 \
                                                                             \
-  develop(bool, G1VerifyConcMarkPrintReachable, true,                       \
+  develop(bool, G1VerifyConcMarkPrintReachable, false,                      \
           "If conc mark verification fails, print reachable objects")       \
                                                                             \
   develop(bool, G1TraceMarkStackOverflow, false,                            \
           "If true, extra debugging code for CM restart for ovflw.")        \
                                                                             \
-  product(bool, G1VerifyMarkingInEvac, false,                               \
-          "If true, verify marking info during evacuation")                 \
-                                                                            \
   develop(intx, G1PausesBtwnConcMark, -1,                                   \
           "If positive, fixed number of pauses between conc markings")      \
                                                                             \
-  product(intx, G1EfficiencyPctCausesMark, 80,                              \
-          "The cum gc efficiency since mark fall-off that causes "          \
-          "new marking")                                                    \
-                                                                            \
-  product(bool, TraceConcurrentMark, false,                                 \
-          "Trace concurrent mark")                                          \
-                                                                            \
-  product(bool, SummarizeG1ConcMark, false,                                 \
+  diagnostic(bool, G1SummarizeConcurrentMark, false,                        \
           "Summarize concurrent mark info")                                 \
                                                                             \
-  product(bool, SummarizeG1RSStats, false,                                  \
+  diagnostic(bool, G1SummarizeRSetStats, false,                             \
           "Summarize remembered set processing info")                       \
                                                                             \
-  product(bool, SummarizeG1ZFStats, false,                                  \
+  diagnostic(bool, G1SummarizeZFStats, false,                               \
           "Summarize zero-filling info")                                    \
                                                                             \
-  product(bool, TraceG1Refine, false,                                       \
+  develop(bool, G1TraceConcurrentRefinement, false,                         \
           "Trace G1 concurrent refinement")                                 \
                                                                             \
   develop(bool, G1ConcMark, true,                                           \
           "If true, run concurrent marking for G1")                         \
                                                                             \
-  product(intx, G1CMStackSize, 2 * 1024 * 1024,                             \
+  product(intx, G1MarkStackSize, 2 * 1024 * 1024,                           \
           "Size of the mark stack for concurrent marking.")                 \
                                                                             \
-  product(intx, G1CMRegionStackSize, 1024 * 1024,                           \
+  product(intx, G1MarkRegionStackSize, 1024 * 1024,                         \
           "Size of the region stack for concurrent marking.")               \
                                                                             \
   develop(bool, G1ConcRefine, true,                                         \
@@ -121,7 +99,7 @@
           "Number of heap regions of alloc ahead of starting collection "   \
           "pause to start concurrent refinement (initially)")               \
                                                                             \
-  product(bool, G1SmoothConcRefine, true,                                   \
+  develop(bool, G1SmoothConcRefine, true,                                   \
           "Attempts to smooth out the overhead of concurrent refinement")   \
                                                                             \
   develop(bool, G1ConcZeroFill, true,                                       \
@@ -157,7 +135,7 @@
   develop(bool, G1SATBPrintStubs, false,                                    \
           "If true, print generated stubs for the SATB barrier")            \
                                                                             \
-  product(intx, G1ExpandByPctOfAvail, 20,                                   \
+  product(intx, G1ExpandByPercentOfAvailable, 20,                           \
           "When expanding, % of uncommitted space to claim.")               \
                                                                             \
   develop(bool, G1RSBarrierRegionFilter, true,                              \
@@ -179,18 +157,9 @@
           "If true, verify that no dirty cards remain after RS log "        \
           "processing.")                                                    \
                                                                             \
-  product(intx, G1MinPausesBetweenMarks, 2,                                 \
-          "Number of inefficient pauses necessary to trigger marking.")     \
-                                                                            \
-  product(intx, G1InefficientPausePct, 80,                                  \
-          "Threshold of an 'inefficient' pauses (as % of cum efficiency.")  \
-                                                                            \
   develop(bool, G1RSCountHisto, false,                                      \
           "If true, print a histogram of RS occupancies after each pause")  \
                                                                             \
-  product(bool, G1TraceFileOverwrite, false,                                \
-          "Allow the trace file to be overwritten")                         \
-                                                                            \
   develop(intx, G1PrintRegionLivenessInfo, 0,                               \
           "When > 0, print the occupancies of the <n> best and worst"       \
           "regions.")                                                       \
@@ -198,9 +167,6 @@
   develop(bool, G1PrintParCleanupStats, false,                              \
           "When true, print extra stats about parallel cleanup.")           \
                                                                             \
-  product(bool, G1DoAgeCohortChecks, false,                                 \
-          "When true, check well-formedness of age cohort structures.")     \
-                                                                            \
   develop(bool, G1DisablePreBarrier, false,                                 \
           "Disable generation of pre-barrier (i.e., marking barrier)   ")   \
                                                                             \
@@ -214,17 +180,17 @@
   develop(intx, G1ConcRSLogCacheSize, 10,                                   \
           "Log base 2 of the length of conc RS hot-card cache.")            \
                                                                             \
-  product(bool, G1ConcRSCountTraversals, false,                             \
+  develop(bool, G1ConcRSCountTraversals, false,                             \
           "If true, gather data about the number of times CR traverses "    \
           "cards ")                                                         \
                                                                             \
-  product(intx, G1ConcRSHotCardLimit, 4,                                    \
+  develop(intx, G1ConcRSHotCardLimit, 4,                                    \
           "The threshold that defines (>=) a hot card.")                    \
                                                                             \
   develop(bool, G1PrintOopAppls, false,                                     \
           "When true, print applications of closures to external locs.")    \
                                                                             \
-  product(intx, G1LogRSRegionEntries, 7,                                    \
+  develop(intx, G1LogRSRegionEntries, 7,                                    \
           "Log_2 of max number of regions for which we keep bitmaps.")      \
                                                                             \
   develop(bool, G1RecordHRRSOops, false,                                    \
@@ -254,11 +220,11 @@
           "It determines whether the system will calculate an optimum "     \
           "scan-only set.")                                                 \
                                                                             \
-  product(intx, G1MinReservePerc, 10,                                       \
+  product(intx, G1MinReservePercent, 10,                                    \
           "It determines the minimum reserve we should have in the heap "   \
           "to minimize the probability of promotion failure.")              \
                                                                             \
-  product(bool, G1TraceRegions, false,                                      \
+  diagnostic(bool, G1PrintRegions, false,                                   \
           "If set G1 will print information on which regions are being "    \
           "allocated and which are reclaimed.")                             \
                                                                             \
@@ -268,24 +234,24 @@
   develop(bool, G1HRRSFlushLogBuffersOnVerify, false,                       \
           "Forces flushing of log buffers before verification.")            \
                                                                             \
-  product(bool, G1UseSurvivorSpace, true,                                   \
+  product(bool, G1UseSurvivorSpaces, true,                                  \
           "When true, use survivor space.")                                 \
                                                                             \
-  product(bool, G1FixedTenuringThreshold, false,                            \
+  develop(bool, G1FixedTenuringThreshold, false,                            \
           "When set, G1 will not adjust the tenuring threshold")            \
                                                                             \
-  product(bool, G1FixedEdenSize, false,                                     \
+  develop(bool, G1FixedEdenSize, false,                                     \
           "When set, G1 will not allocate unused survivor space regions")   \
                                                                             \
-  product(uintx, G1FixedSurvivorSpaceSize, 0,                               \
+  develop(uintx, G1FixedSurvivorSpaceSize, 0,                               \
           "If non-0 is the size of the G1 survivor space, "                 \
           "otherwise SurvivorRatio is used to determine the size")          \
                                                                             \
-  experimental(bool, G1EnableParallelRSetUpdating, false,                   \
+  experimental(bool, G1ParallelRSetUpdatingEnabled, false,                  \
           "Enables the parallelization of remembered set updating "         \
           "during evacuation pauses")                                       \
                                                                             \
-  experimental(bool, G1EnableParallelRSetScanning, false,                   \
+  experimental(bool, G1ParallelRSetScanningEnabled, false,                  \
           "Enables the parallelization of remembered set scanning "         \
           "during evacuation pauses")
 
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Thu May 14 09:53:35 2009 -0700
@@ -160,12 +160,6 @@
     if (!g1h->is_obj_dead(cur_oop, hr)) {
       // Bottom lies entirely below top, so we can call the
       // non-memRegion version of oop_iterate below.
-#ifndef PRODUCT
-      if (G1VerifyMarkingInEvac) {
-        VerifyLiveClosure vl_cl(g1h);
-        cur_oop->oop_iterate(&vl_cl);
-      }
-#endif
       cur_oop->oop_iterate(cl);
     }
     cur = next_obj;
@@ -197,12 +191,6 @@
   // or it was allocated after marking finished, then we add it. Otherwise
   // we can safely ignore the object.
   if (!g1h->is_obj_dead(oop(bottom), _hr)) {
-#ifndef PRODUCT
-    if (G1VerifyMarkingInEvac) {
-      VerifyLiveClosure vl_cl(g1h);
-      oop(bottom)->oop_iterate(&vl_cl, mr);
-    }
-#endif
     oop_size = oop(bottom)->oop_iterate(cl2, mr);
   } else {
     oop_size = oop(bottom)->size();
@@ -232,12 +220,6 @@
 
     // Last object. Need to do dead-obj filtering here too.
     if (!g1h->is_obj_dead(oop(bottom), _hr)) {
-#ifndef PRODUCT
-      if (G1VerifyMarkingInEvac) {
-        VerifyLiveClosure vl_cl(g1h);
-        oop(bottom)->oop_iterate(&vl_cl, mr);
-      }
-#endif
       oop(bottom)->oop_iterate(cl2, mr);
     }
   }
@@ -713,12 +695,12 @@
     G1CollectedHeap::heap()->print();
     gclog_or_tty->print_cr("");
   }
-  if (G1VerifyConcMark &&
+  if (VerifyDuringGC &&
       G1VerifyConcMarkPrintReachable &&
       vl_cl.failures()) {
     g1->concurrent_mark()->print_prev_bitmap_reachable();
   }
-  guarantee(!vl_cl.failures(), "should not have had any failures");
+  guarantee(!vl_cl.failures(), "region verification failed");
   guarantee(p == top(), "end of last object must match end of space");
 }
 
--- a/hotspot/src/share/vm/opto/connode.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/opto/connode.cpp	Thu May 14 09:53:35 2009 -0700
@@ -128,6 +128,10 @@
       // Swapped Cmp is OK
       (phase->eqv(cmp->in(2),f) &&
        phase->eqv(cmp->in(1),t)) ) {
+    // Give up this identity check for floating points because it may choose incorrect
+    // value around 0.0 and -0.0
+    if ( cmp->Opcode()==Op_CmpF || cmp->Opcode()==Op_CmpD )
+      return NULL;
     // Check for "(t==f)?t:f;" and replace with "f"
     if( b->_test._test == BoolTest::eq )
       return f;
--- a/hotspot/src/share/vm/opto/divnode.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/opto/divnode.cpp	Thu May 14 09:53:35 2009 -0700
@@ -298,8 +298,10 @@
 
   // 6732154: Construct both w1 and w2 before transforming, so t
   // doesn't go dead prematurely.
+  // 6837011: We need to transform w2 before w1 because the
+  // transformation of w1 could return t.
+  w2 = phase->transform(w2);
   w1 = phase->transform(w1);
-  w2 = phase->transform(w2);
 
   // w1 = u0*v1 + w1;
   Node* u0v1 = phase->transform(new (phase->C, 3) MulLNode(u0, v1));
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Thu May 14 09:53:35 2009 -0700
@@ -1288,10 +1288,14 @@
                      Abstract_VM_Version::parallel_worker_threads());
   if (ParallelGCThreads == 0) {
     FLAG_SET_DEFAULT(ParallelGCThreads,
-                     Abstract_VM_Version::parallel_worker_threads
-());
+                     Abstract_VM_Version::parallel_worker_threads());
   }
   no_shared_spaces();
+
+  // Set the maximum pause time goal to be a reasonable default.
+  if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
+    FLAG_SET_DEFAULT(MaxGCPauseMillis, 200);
+  }
 }
 
 void Arguments::set_server_heap_size() {
--- a/hotspot/src/share/vm/runtime/dtraceJSDT.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/runtime/dtraceJSDT.cpp	Thu May 14 09:53:35 2009 -0700
@@ -60,6 +60,11 @@
       methodHandle h_method =
         methodHandle(THREAD, JNIHandles::resolve_jmethod_id(probe->method));
       nmethod* nm = AdapterHandlerLibrary::create_dtrace_nmethod(h_method);
+      if (nm == NULL) {
+        delete probes;
+        THROW_MSG_0(vmSymbols::java_lang_RuntimeException(),
+          "Unable to register DTrace probes (CodeCache: no room for DTrace nmethods).");
+      }
       h_method()->set_not_compilable(CompLevel_highest_tier);
       h_method()->set_code(h_method, nm);
       probes->nmethod_at_put(count++, nm);
--- a/hotspot/src/share/vm/runtime/globals.hpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Thu May 14 09:53:35 2009 -0700
@@ -1819,7 +1819,11 @@
           "Decay factor to TenuredGenerationSizeIncrement")                 \
                                                                             \
   product(uintx, MaxGCPauseMillis, max_uintx,                               \
-          "Adaptive size policy maximum GC pause time goal in msec")        \
+          "Adaptive size policy maximum GC pause time goal in msec, "       \
+          "or (G1 Only) the max. GC time per MMU time slice")               \
+                                                                            \
+  product(intx, GCPauseIntervalMillis, 500,                                 \
+          "Time slice for MMU specification")                               \
                                                                             \
   product(uintx, MaxGCMinorPauseMillis, max_uintx,                          \
           "Adaptive size policy maximum GC minor pause time goal in msec")  \
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Thu May 14 09:53:35 2009 -0700
@@ -1776,7 +1776,14 @@
 GrowableArray<uint64_t>* AdapterHandlerLibrary::_fingerprints = NULL;
 GrowableArray<AdapterHandlerEntry* >* AdapterHandlerLibrary::_handlers = NULL;
 const int AdapterHandlerLibrary_size = 16*K;
-u_char                   AdapterHandlerLibrary::_buffer[AdapterHandlerLibrary_size + 32];
+BufferBlob* AdapterHandlerLibrary::_buffer = NULL;
+
+BufferBlob* AdapterHandlerLibrary::buffer_blob() {
+  // Should be called only when AdapterHandlerLibrary_lock is active.
+  if (_buffer == NULL) // Initialize lazily
+      _buffer = BufferBlob::create("adapters", AdapterHandlerLibrary_size);
+  return _buffer;
+}
 
 void AdapterHandlerLibrary::initialize() {
   if (_fingerprints != NULL) return;
@@ -1812,7 +1819,9 @@
   assert(ic_miss != NULL, "must have handler");
 
   int result;
+  NOT_PRODUCT(int code_size);
   BufferBlob *B = NULL;
+  AdapterHandlerEntry* entry = NULL;
   uint64_t fingerprint;
   {
     MutexLocker mu(AdapterHandlerLibrary_lock);
@@ -1850,42 +1859,45 @@
 
     // Create I2C & C2I handlers
     ResourceMark rm;
-    // Improve alignment slightly
-    u_char *buf = (u_char*)(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
-    CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
-    short buffer_locs[20];
-    buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs,
-                                           sizeof(buffer_locs)/sizeof(relocInfo));
-    MacroAssembler _masm(&buffer);
 
-    // Fill in the signature array, for the calling-convention call.
-    int total_args_passed = method->size_of_parameters(); // All args on stack
+    BufferBlob*  buf = buffer_blob(); // the temporary code buffer in CodeCache
+    if (buf != NULL) {
+      CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
+      short buffer_locs[20];
+      buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs,
+                                             sizeof(buffer_locs)/sizeof(relocInfo));
+      MacroAssembler _masm(&buffer);
 
-    BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed);
-    VMRegPair  * regs   = NEW_RESOURCE_ARRAY(VMRegPair  ,total_args_passed);
-    int i=0;
-    if( !method->is_static() )  // Pass in receiver first
-      sig_bt[i++] = T_OBJECT;
-    for( SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
-      sig_bt[i++] = ss.type();  // Collect remaining bits of signature
-      if( ss.type() == T_LONG || ss.type() == T_DOUBLE )
-        sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
+      // Fill in the signature array, for the calling-convention call.
+      int total_args_passed = method->size_of_parameters(); // All args on stack
+
+      BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed);
+      VMRegPair  * regs   = NEW_RESOURCE_ARRAY(VMRegPair  ,total_args_passed);
+      int i=0;
+      if( !method->is_static() )  // Pass in receiver first
+        sig_bt[i++] = T_OBJECT;
+      for( SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
+        sig_bt[i++] = ss.type();  // Collect remaining bits of signature
+        if( ss.type() == T_LONG || ss.type() == T_DOUBLE )
+          sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
+      }
+      assert( i==total_args_passed, "" );
+
+      // Now get the re-packed compiled-Java layout.
+      int comp_args_on_stack;
+
+      // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage
+      comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
+
+      entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
+                                                     total_args_passed,
+                                                     comp_args_on_stack,
+                                                     sig_bt,
+                                                     regs);
+
+      B = BufferBlob::create(AdapterHandlerEntry::name, &buffer);
+      NOT_PRODUCT(code_size = buffer.code_size());
     }
-    assert( i==total_args_passed, "" );
-
-    // Now get the re-packed compiled-Java layout.
-    int comp_args_on_stack;
-
-    // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage
-    comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
-
-    AdapterHandlerEntry* entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
-                                                                        total_args_passed,
-                                                                        comp_args_on_stack,
-                                                                        sig_bt,
-                                                                        regs);
-
-    B = BufferBlob::create(AdapterHandlerEntry::name, &buffer);
     if (B == NULL) {
       // CodeCache is full, disable compilation
       // Ought to log this but compile log is only per compile thread
@@ -1912,9 +1924,9 @@
       tty->cr();
       tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = 0x%llx, %d bytes generated)",
                     _handlers->length(), (method->is_static() ? "static" : "receiver"),
-                    method->signature()->as_C_string(), fingerprint, buffer.code_size() );
+                    method->signature()->as_C_string(), fingerprint, code_size );
       tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry());
-      Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + buffer.code_size());
+      Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + code_size);
     }
 #endif
 
@@ -1982,42 +1994,44 @@
       return nm;
     }
 
-    // Improve alignment slightly
-    u_char* buf = (u_char*)(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
-    CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
-    // Need a few relocation entries
-    double locs_buf[20];
-    buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
-    MacroAssembler _masm(&buffer);
+    ResourceMark rm;
 
-    // Fill in the signature array, for the calling-convention call.
-    int total_args_passed = method->size_of_parameters();
+    BufferBlob*  buf = buffer_blob(); // the temporary code buffer in CodeCache
+    if (buf != NULL) {
+      CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
+      double locs_buf[20];
+      buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
+      MacroAssembler _masm(&buffer);
 
-    BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed);
-    VMRegPair  * regs   = NEW_RESOURCE_ARRAY(VMRegPair  ,total_args_passed);
-    int i=0;
-    if( !method->is_static() )  // Pass in receiver first
-      sig_bt[i++] = T_OBJECT;
-    SignatureStream ss(method->signature());
-    for( ; !ss.at_return_type(); ss.next()) {
-      sig_bt[i++] = ss.type();  // Collect remaining bits of signature
-      if( ss.type() == T_LONG || ss.type() == T_DOUBLE )
-        sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
+      // Fill in the signature array, for the calling-convention call.
+      int total_args_passed = method->size_of_parameters();
+
+      BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed);
+      VMRegPair*   regs = NEW_RESOURCE_ARRAY(VMRegPair,total_args_passed);
+      int i=0;
+      if( !method->is_static() )  // Pass in receiver first
+        sig_bt[i++] = T_OBJECT;
+      SignatureStream ss(method->signature());
+      for( ; !ss.at_return_type(); ss.next()) {
+        sig_bt[i++] = ss.type();  // Collect remaining bits of signature
+        if( ss.type() == T_LONG || ss.type() == T_DOUBLE )
+          sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
+      }
+      assert( i==total_args_passed, "" );
+      BasicType ret_type = ss.type();
+
+      // Now get the compiled-Java layout as input arguments
+      int comp_args_on_stack;
+      comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
+
+      // Generate the compiled-to-native wrapper code
+      nm = SharedRuntime::generate_native_wrapper(&_masm,
+                                                  method,
+                                                  total_args_passed,
+                                                  comp_args_on_stack,
+                                                  sig_bt,regs,
+                                                  ret_type);
     }
-    assert( i==total_args_passed, "" );
-    BasicType ret_type = ss.type();
-
-    // Now get the compiled-Java layout as input arguments
-    int comp_args_on_stack;
-    comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
-
-    // Generate the compiled-to-native wrapper code
-    nm = SharedRuntime::generate_native_wrapper(&_masm,
-                                                method,
-                                                total_args_passed,
-                                                comp_args_on_stack,
-                                                sig_bt,regs,
-                                                ret_type);
   }
 
   // Must unlock before calling set_code
@@ -2077,18 +2091,20 @@
       return nm;
     }
 
-    // Improve alignment slightly
-    u_char* buf = (u_char*)
-        (((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
-    CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
-    // Need a few relocation entries
-    double locs_buf[20];
-    buffer.insts()->initialize_shared_locs(
+    ResourceMark rm;
+
+    BufferBlob*  buf = buffer_blob(); // the temporary code buffer in CodeCache
+    if (buf != NULL) {
+      CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
+      // Need a few relocation entries
+      double locs_buf[20];
+      buffer.insts()->initialize_shared_locs(
         (relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
-    MacroAssembler _masm(&buffer);
+      MacroAssembler _masm(&buffer);
 
-    // Generate the compiled-to-native wrapper code
-    nm = SharedRuntime::generate_dtrace_nmethod(&_masm, method);
+      // Generate the compiled-to-native wrapper code
+      nm = SharedRuntime::generate_dtrace_nmethod(&_masm, method);
+    }
   }
   return nm;
 }
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Wed May 06 14:14:54 2009 -0700
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Thu May 14 09:53:35 2009 -0700
@@ -557,12 +557,13 @@
 
 class AdapterHandlerLibrary: public AllStatic {
  private:
-  static u_char                   _buffer[];  // the temporary code buffer
+  static BufferBlob* _buffer; // the temporary code buffer in CodeCache
   static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection
   static GrowableArray<AdapterHandlerEntry*> * _handlers; // the corresponding handlers
   enum {
     AbstractMethodHandler = 1 // special handler for abstract methods
   };
+  static BufferBlob* buffer_blob();
   static void initialize();
   static int get_create_adapter_index(methodHandle method);
   static address get_i2c_entry( int index ) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6837011/Test6837011.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2009 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.
+ *
+ * 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
+ * @bug 6837011
+ * @summary SIGSEGV in PhaseIdealLoop in 32bit jvm
+ *
+ * @run main/othervm -Xcomp -XX:CompileOnly=Test6837011.main Test6837011
+ */
+
+public class Test6837011 {
+    static boolean var_3 = true;
+
+    public static void main(String[] args) {
+        double var_5;
+        char var_7 = 1;
+        double var_11 = 0;
+
+        do {
+            var_11++;
+            var_5 = (var_7 /= ( var_3 ? ~1L : 3 ) );
+        } while (var_11 < 1);
+    }
+}
--- a/jaxp/.hgtags	Wed May 06 14:14:54 2009 -0700
+++ b/jaxp/.hgtags	Thu May 14 09:53:35 2009 -0700
@@ -31,3 +31,5 @@
 946a9f0c493261fa6a010dc33e61b9b535ba80c1 jdk7-b54
 039945fba683ee6773a721e2bd4e449f6133769a jdk7-b55
 c197c6801271c60f9c9f5d18fcc95b59e76dcd54 jdk7-b56
+e4851e9f7be26fc52a628be06ffa8aaea0919bd7 jdk7-b57
+13bf67d8c6341b841d268985cabaf747f2652bc8 jdk7-b58
--- a/jaxp/src/share/classes/com/sun/org/apache/xalan/internal/client/XSLTProcessorApplet.java	Wed May 06 14:14:54 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,792 +0,0 @@
-/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * $Id: XSLTProcessorApplet.java,v 1.2.4.1 2005/09/15 02:20:05 jeffsuttor Exp $
- */
-package com.sun.org.apache.xalan.internal.client;
-
-import java.applet.Applet;
-import java.awt.Graphics;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Enumeration;
-
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import com.sun.org.apache.xalan.internal.res.XSLMessages;
-import com.sun.org.apache.xalan.internal.res.XSLTErrorResources;
-
-/**
- * Provides applet host for the XSLT processor. To perform transformations on an HTML client:
- * <ol>
- * <li>Use an &lt;applet&gt; tag to embed this applet in the HTML client.</li>
- * <li>Use the DocumentURL and StyleURL PARAM tags or the {@link #setDocumentURL} and
- * {@link #setStyleURL} methods to specify the XML source document and XSL stylesheet.</li>
- * <li>Call the {@link #getHtmlText} method (or one of the transformToHtml() methods)
- * to perform the transformation and return the result as a String.</li>
- * </ol>
- *
- * This class extends Applet which ultimately causes this class to implement Serializable.
- * This is a serious restriction on this class. All fields that are not transient and not
- * static are written-out/read-in during serialization. So even private fields essentially
- * become part of the API. Developers need to take care when modifying fields.
- * @xsl.usage general
- */
-public class XSLTProcessorApplet extends Applet
-{
-
-  /**
-   * The stylesheet processor.
-   * This field is now transient because a
-   * javax.xml.transform.TransformerFactory from JAXP
-   * makes no claims to be serializable.
-   */
-  transient TransformerFactory m_tfactory = null;
-
-  /**
-   * @serial
-   */
-  private String m_styleURL;
-
-  /**
-   * @serial
-   */
-  private String m_documentURL;
-
-  // Parameter names.  To change a name of a parameter, you need only make
-  // a single change.  Simply modify the value of the parameter string below.
-  //--------------------------------------------------------------------------
-
-  /**
-   * @serial
-   */
-  private final String PARAM_styleURL = "styleURL";
-
-  /**
-   * @serial
-   */
-  private final String PARAM_documentURL = "documentURL";
-
-
-  // We'll keep the DOM trees around, so tell which trees
-  // are cached.
-
-  /**
-   * @serial
-   */
-  private String m_styleURLOfCached = null;
-
-  /**
-   * @serial
-   */
-  private String m_documentURLOfCached = null;
-
-  /**
-   * Save this for use on the worker thread; may not be necessary.
-   * @serial
-   */
-  private URL m_codeBase = null;
-
-  /**
-   * @serial
-   */
-  private String m_treeURL = null;
-
-  /**
-   * DocumentBase URL
-   * @serial
-   */
-  private URL m_documentBase = null;
-
-  /**
-   * Thread stuff for the trusted worker thread.
-   */
-  transient private Thread m_callThread = null;
-
-  /**
-   */
-  transient private TrustedAgent m_trustedAgent = null;
-
-  /**
-   * Thread for running TrustedAgent.
-   */
-  transient private Thread m_trustedWorker = null;
-
-  /**
-   * Where the worker thread puts the HTML text.
-   */
-  transient private String m_htmlText = null;
-
-  /**
-   * Where the worker thread puts the document/stylesheet text.
-   */
-  transient private String m_sourceText = null;
-
-  /**
-   * Stylesheet attribute name and value that the caller can set.
-   */
-  transient private String m_nameOfIDAttrOfElemToModify = null;
-
-  /**
-   */
-  transient private String m_elemIdToModify = null;
-
-  /**
-   */
-  transient private String m_attrNameToSet = null;
-
-  /**
-   */
-  transient private String m_attrValueToSet = null;
-
-  /**
-   * The XSLTProcessorApplet constructor takes no arguments.
-   */
-  public XSLTProcessorApplet(){}
-
-  /**
-   * Get basic information about the applet
-   * @return A String with the applet name and author.
-   */
-  public String getAppletInfo()
-  {
-    return "Name: XSLTProcessorApplet\r\n" + "Author: Scott Boag";
-  }
-
-  /**
-   * Get descriptions of the applet parameters.
-   * @return A two-dimensional array of Strings with Name, Type, and Description
-   * for each parameter.
-   */
-  public String[][] getParameterInfo()
-  {
-
-    String[][] info =
-    {
-      { PARAM_styleURL, "String", "URL to an XSL stylesheet" },
-      { PARAM_documentURL, "String", "URL to an XML document" },
-    };
-
-    return info;
-  }
-
-  /**
-   * Standard applet initialization.
-   */
-  public void init()
-  {
-
-    // PARAMETER SUPPORT
-    //          The following code retrieves the value of each parameter
-    // specified with the <PARAM> tag and stores it in a member
-    // variable.
-    //----------------------------------------------------------------------
-    String param;
-
-    // styleURL: Parameter description
-    //----------------------------------------------------------------------
-    param = getParameter(PARAM_styleURL);
-
-    // stylesheet parameters
-    m_parameters = new Hashtable();
-
-    if (param != null)
-      setStyleURL(param);
-
-    // documentURL: Parameter description
-    //----------------------------------------------------------------------
-    param = getParameter(PARAM_documentURL);
-
-    if (param != null)
-      setDocumentURL(param);
-
-    m_codeBase = this.getCodeBase();
-    m_documentBase = this.getDocumentBase();
-
-    // If you use a ResourceWizard-generated "control creator" class to
-    // arrange controls in your applet, you may want to call its
-    // CreateControls() method from within this method. Remove the following
-    // call to resize() before adding the call to CreateControls();
-    // CreateControls() does its own resizing.
-    //----------------------------------------------------------------------
-    resize(320, 240);
-  }
-
-    /**
-   *  Automatically called when the HTML client containing the applet loads.
-   *  This method starts execution of the applet thread.
-   */
-  public void start()
-  {
-      //check if user code's on the stack before invoking the worker thread
-     boolean passed = false;
-     try {
-       java.security.AccessController.checkPermission(new java.security.AllPermission());
-     } catch (SecurityException se) {
-         //expected
-         passed = true;
-     }
-     if (!passed) {
-         throw new SecurityException("The XSLTProcessorApplet class must be extended and its method start() overridden.");
-     }
-
-    m_trustedAgent = new TrustedAgent();
-    Thread currentThread = Thread.currentThread();
-    m_trustedWorker = new Thread(currentThread.getThreadGroup(),
-                                 m_trustedAgent);
-    m_trustedWorker.start();
-    try
-    {
-      m_tfactory = TransformerFactory.newInstance();
-      this.showStatus("Causing Transformer and Parser to Load and JIT...");
-
-      // Prime the pump so that subsequent transforms are faster.
-      StringReader xmlbuf = new StringReader("<?xml version='1.0'?><foo/>");
-      StringReader xslbuf = new StringReader(
-        "<?xml version='1.0'?><xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'><xsl:template match='foo'><out/></xsl:template></xsl:stylesheet>");
-      PrintWriter pw = new PrintWriter(new StringWriter());
-
-      synchronized (m_tfactory)
-      {
-        Templates templates = m_tfactory.newTemplates(new StreamSource(xslbuf));
-        Transformer transformer = templates.newTransformer();
-        transformer.transform(new StreamSource(xmlbuf), new StreamResult(pw));
-      }
-      System.out.println("Primed the pump!");
-      this.showStatus("Ready to go!");
-    }
-    catch (Exception e)
-    {
-      this.showStatus("Could not prime the pump!");
-      System.out.println("Could not prime the pump!");
-      e.printStackTrace();
-    }
-  }
-
-  /**
-   * Do not call; this applet contains no UI or visual components.
-   *
-   */
-  public void paint(Graphics g){}
-
-  /**
-   * Automatically called when the HTML page containing the applet is no longer
-   * on the screen. Stops execution of the applet thread.
-   */
-  public void stop()
-  {
-    if (null != m_trustedWorker)
-    {
-      m_trustedWorker.stop();
-
-      // m_trustedWorker.destroy();
-      m_trustedWorker = null;
-    }
-
-    m_styleURLOfCached = null;
-    m_documentURLOfCached = null;
-  }
-
-  /**
-   * Cleanup; called when applet is terminated and unloaded.
-   */
-  public void destroy()
-  {
-    if (null != m_trustedWorker)
-    {
-      m_trustedWorker.stop();
-
-      // m_trustedWorker.destroy();
-      m_trustedWorker = null;
-    }
-    m_styleURLOfCached = null;
-    m_documentURLOfCached = null;
-  }
-
-  /**
-   * Set the URL to the XSL stylesheet that will be used
-   * to transform the input XML.  No processing is done yet.
-   * @param urlString valid URL string for XSL stylesheet.
-   */
-  public void setStyleURL(String urlString)
-  {
-    m_styleURL = urlString;
-  }
-
-  /**
-   * Set the URL to the XML document that will be transformed
-   * with the XSL stylesheet.  No processing is done yet.
-   * @param urlString valid URL string for XML document.
-   */
-  public void setDocumentURL(String urlString)
-  {
-    m_documentURL = urlString;
-  }
-
-  /**
-   * The processor keeps a cache of the source and
-   * style trees, so call this method if they have changed
-   * or you want to do garbage collection.
-   */
-  public void freeCache()
-  {
-    m_styleURLOfCached = null;
-    m_documentURLOfCached = null;
-  }
-
-  /**
-   * Set an attribute in the stylesheet, which gives the ability
-   * to have some dynamic selection control.
-   * @param nameOfIDAttrOfElemToModify The name of an attribute to search for a unique id.
-   * @param elemId The unique ID to look for.
-   * @param attrName Once the element is found, the name of the attribute to set.
-   * @param value The value to set the attribute to.
-   */
-  public void setStyleSheetAttribute(String nameOfIDAttrOfElemToModify,
-                                     String elemId, String attrName,
-                                     String value)
-  {
-    m_nameOfIDAttrOfElemToModify = nameOfIDAttrOfElemToModify;
-    m_elemIdToModify = elemId;
-    m_attrNameToSet = attrName;
-    m_attrValueToSet = value;
-  }
-
-
-  /**
-   * Stylesheet parameter key/value pair stored in a hashtable
-   */
-  transient Hashtable m_parameters;
-
-  /**
-   * Submit a stylesheet parameter.
-   *
-   * @param key stylesheet parameter key
-   * @param expr the parameter expression to be submitted.
-   * @see javax.xml.transform.Transformer#setParameter(String,Object)
-   */
-  public void setStylesheetParam(String key, String expr)
-  {
-    m_parameters.put(key, expr);
-  }
-
-  /**
-   * Given a String containing markup, escape the markup so it
-   * can be displayed in the browser.
-   *
-   * @param s String to escape
-   *
-   * The escaped string.
-   */
-  public String escapeString(String s)
-  {
-    StringBuffer sb = new StringBuffer();
-    int length = s.length();
-
-    for (int i = 0; i < length; i++)
-    {
-      char ch = s.charAt(i);
-
-      if ('<' == ch)
-      {
-        sb.append("&lt;");
-      }
-      else if ('>' == ch)
-      {
-        sb.append("&gt;");
-      }
-      else if ('&' == ch)
-      {
-        sb.append("&amp;");
-      }
-      else if (0xd800 <= ch && ch < 0xdc00)
-      {
-        // UTF-16 surrogate
-        int next;
-
-        if (i + 1 >= length)
-        {
-          throw new RuntimeException(
-            XSLMessages.createMessage(
-              XSLTErrorResources.ER_INVALID_UTF16_SURROGATE,
-              new Object[]{ Integer.toHexString(ch) }));  //"Invalid UTF-16 surrogate detected: "
-
-          //+Integer.toHexString(ch)+ " ?");
-        }
-        else
-        {
-          next = s.charAt(++i);
-
-          if (!(0xdc00 <= next && next < 0xe000))
-            throw new RuntimeException(
-              XSLMessages.createMessage(
-                XSLTErrorResources.ER_INVALID_UTF16_SURROGATE,
-                new Object[]{
-                  Integer.toHexString(ch) + " "
-                  + Integer.toHexString(next) }));  //"Invalid UTF-16 surrogate detected: "
-
-          //+Integer.toHexString(ch)+" "+Integer.toHexString(next));
-          next = ((ch - 0xd800) << 10) + next - 0xdc00 + 0x00010000;
-        }
-        sb.append("&#x");
-        sb.append(Integer.toHexString(next));
-        sb.append(";");
-      }
-      else
-      {
-        sb.append(ch);
-      }
-    }
-    return sb.toString();
-  }
-
-  /**
-   * Assuming the stylesheet URL and the input XML URL have been set,
-   * perform the transformation and return the result as a String.
-   *
-   * @return A string that contains the contents pointed to by the URL.
-   *
-   */
-  public String getHtmlText()
-  {
-    m_trustedAgent.m_getData = true;
-    m_callThread = Thread.currentThread();
-    try
-    {
-      synchronized (m_callThread)
-      {
-        m_callThread.wait();
-      }
-    }
-    catch (InterruptedException ie)
-    {
-      System.out.println(ie.getMessage());
-    }
-    return m_htmlText;
-  }
-
-  /**
-   * Get an XML document (or stylesheet)
-   *
-   * @param treeURL valid URL string for the document.
-   *
-   * @return document
-   *
-   * @throws IOException
-   */
-  public String getTreeAsText(String treeURL) throws IOException
-  {
-    m_treeURL = treeURL;
-    m_trustedAgent.m_getData = true;
-    m_trustedAgent.m_getSource = true;
-    m_callThread = Thread.currentThread();
-    try
-    {
-      synchronized (m_callThread)
-      {
-        m_callThread.wait();
-      }
-    }
-    catch (InterruptedException ie)
-    {
-      System.out.println(ie.getMessage());
-    }
-    return m_sourceText;
-  }
-
-  /**
-   * Use a Transformer to copy the source document
-   * to a StreamResult.
-   *
-   * @return the document as a string
-   */
-  private String getSource() throws TransformerException
-  {
-    StringWriter osw = new StringWriter();
-    PrintWriter pw = new PrintWriter(osw, false);
-    String text = "";
-    try
-    {
-      URL docURL = new URL(m_documentBase, m_treeURL);
-      synchronized (m_tfactory)
-      {
-        Transformer transformer = m_tfactory.newTransformer();
-        StreamSource source = new StreamSource(docURL.toString());
-        StreamResult result = new StreamResult(pw);
-        transformer.transform(source, result);
-        text = osw.toString();
-      }
-    }
-    catch (MalformedURLException e)
-    {
-      e.printStackTrace();
-      throw new RuntimeException(e.getMessage());
-    }
-    catch (Exception any_error)
-    {
-      any_error.printStackTrace();
-    }
-    return text;
-  }
-
-  /**
-   * Get the XML source Tree as a text string suitable
-   * for display in a browser.  Note that this is for display of the
-   * XML itself, not for rendering of HTML by the browser.
-   *
-   * @return XML source document as a string.
-   * @throws Exception thrown if tree can not be converted.
-   */
-  public String getSourceTreeAsText() throws Exception
-  {
-    return getTreeAsText(m_documentURL);
-  }
-
-  /**
-   * Get the XSL style Tree as a text string suitable
-   * for display in a browser.  Note that this is for display of the
-   * XML itself, not for rendering of HTML by the browser.
-   *
-   * @return The XSL stylesheet as a string.
-   * @throws Exception thrown if tree can not be converted.
-   */
-  public String getStyleTreeAsText() throws Exception
-  {
-    return getTreeAsText(m_styleURL);
-  }
-
-  /**
-   * Get the HTML result Tree as a text string suitable
-   * for display in a browser.  Note that this is for display of the
-   * XML itself, not for rendering of HTML by the browser.
-   *
-   * @return Transformation result as unmarked text.
-   * @throws Exception thrown if tree can not be converted.
-   */
-  public String getResultTreeAsText() throws Exception
-  {
-    return escapeString(getHtmlText());
-  }
-
-  /**
-   * Process a document and a stylesheet and return
-   * the transformation result.  If one of these is null, the
-   * existing value (of a previous transformation) is not affected.
-   *
-   * @param doc URL string to XML document
-   * @param style URL string to XSL stylesheet
-   *
-   * @return HTML transformation result
-   */
-  public String transformToHtml(String doc, String style)
-  {
-
-    if (null != doc)
-    {
-      m_documentURL = doc;
-    }
-
-    if (null != style)
-    {
-      m_styleURL = style;
-    }
-
-    return getHtmlText();
-  }
-
-  /**
-   * Process a document and a stylesheet and return
-   * the transformation result. Use the xsl:stylesheet PI to find the
-   * document, if one exists.
-   *
-   * @param doc  URL string to XML document containing an xsl:stylesheet PI.
-   *
-   * @return HTML transformation result
-   */
-  public String transformToHtml(String doc)
-  {
-
-    if (null != doc)
-    {
-      m_documentURL = doc;
-    }
-
-    m_styleURL = null;
-
-    return getHtmlText();
-  }
-
-
-  /**
-   * Process the transformation.
-   *
-   * @return The transformation result as a string.
-   *
-   * @throws TransformerException
-   */
-  private String processTransformation() throws TransformerException
-  {
-    String htmlData = null;
-    this.showStatus("Waiting for Transformer and Parser to finish loading and JITing...");
-
-    synchronized (m_tfactory)
-    {
-     URL documentURL = null;
-      URL styleURL = null;
-      StringWriter osw = new StringWriter();
-      PrintWriter pw = new PrintWriter(osw, false);
-      StreamResult result = new StreamResult(pw);
-
-      this.showStatus("Begin Transformation...");
-      try
-      {
-        documentURL = new URL(m_codeBase, m_documentURL);
-        StreamSource xmlSource = new StreamSource(documentURL.toString());
-
-        styleURL = new URL(m_codeBase, m_styleURL);
-        StreamSource xslSource = new StreamSource(styleURL.toString());
-
-        Transformer transformer = m_tfactory.newTransformer(xslSource);
-
-
-        Enumeration m_keys = m_parameters.keys();
-        while (m_keys.hasMoreElements()){
-          Object key = m_keys.nextElement();
-          Object expression = m_parameters.get(key);
-          transformer.setParameter((String) key, expression);
-        }
-        transformer.transform(xmlSource, result);
-      }
-      catch (TransformerConfigurationException tfe)
-      {
-        tfe.printStackTrace();
-        throw new RuntimeException(tfe.getMessage());
-      }
-      catch (MalformedURLException e)
-      {
-        e.printStackTrace();
-        throw new RuntimeException(e.getMessage());
-      }
-
-      this.showStatus("Transformation Done!");
-      htmlData = osw.toString();
-    }
-    return htmlData;
-  }
-
-  /**
-   * This class maintains a worker thread that that is
-   * trusted and can do things like access data.  You need
-   * this because the thread that is called by the browser
-   * is not trusted and can't access data from the URLs.
-   */
-  class TrustedAgent implements Runnable
-  {
-
-    /**
-     * Specifies whether the worker thread should perform a transformation.
-     */
-    public boolean m_getData = false;
-
-    /**
-     * Specifies whether the worker thread should get an XML document or XSL stylesheet.
-     */
-    public boolean m_getSource = false;
-
-    /**
-     * The real work is done from here.
-     *
-     */
-    public void run()
-    {
-      while (true)
-      {
-        m_trustedWorker.yield();
-
-        if (m_getData)  // Perform a transformation or get a document.
-        {
-          try
-          {
-            m_getData = false;
-            m_htmlText = null;
-            m_sourceText = null;
-            if (m_getSource)  // Get a document.
-            {
-              m_getSource = false;
-              m_sourceText = getSource();
-            }
-            else              // Perform a transformation.
-              m_htmlText = processTransformation();
-          }
-          catch (Exception e)
-          {
-            e.printStackTrace();
-          }
-          finally
-          {
-            synchronized (m_callThread)
-            {
-              m_callThread.notify();
-            }
-          }
-        }
-        else
-        {
-          try
-          {
-            m_trustedWorker.sleep(50);
-          }
-          catch (InterruptedException ie)
-          {
-            ie.printStackTrace();
-          }
-        }
-      }
-    }
-  }
-
-  // For compatiblity with old serialized objects
-  // We will change non-serialized fields and change methods
-  // and not have this break us.
-  private static final long serialVersionUID=4618876841979251422L;
-
-  // For compatibility when de-serializing old objects
-  private void readObject(java.io.ObjectInputStream inStream) throws IOException, ClassNotFoundException
-  {
-      inStream.defaultReadObject();
-
-      // Needed assignment of non-serialized fields
-
-      // A TransformerFactory is not guaranteed to be serializable,
-      // so we create one here
-      m_tfactory = TransformerFactory.newInstance();
-  }
-}
--- a/jaxp/src/share/classes/com/sun/org/apache/xalan/internal/client/package.html	Wed May 06 14:14:54 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-<!--
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
--->
-<!--
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
-<!-- $Id: package.html,v 1.1.2.1 2005/08/01 02:11:22 jeffsuttor Exp $ -->
-<html>
-  <title>Xalan Client Package.</title>
-  <body>
-    <p>Implementation of Xalan applet.<p>
- </body>
-</html>
-
-
--- a/jaxws/.hgtags	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/.hgtags	Thu May 14 09:53:35 2009 -0700
@@ -31,3 +31,5 @@
 50ea00dc5f143fe00025233e704903c37f8464aa jdk7-b54
 e0eebd978b830c09e7862cff3f77a914c15651c9 jdk7-b55
 0f7fbf85f7a1d9c027a863b9955c623352ed1292 jdk7-b56
+68257a5eb19afc11aee7eb19f7250f9b9eec7c05 jdk7-b57
+5fb4fbea81c3609916da00417fdd15dbd9e39e97 jdk7-b58
--- a/jaxws/src/share/classes/com/sun/codemodel/internal/JClassContainer.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/codemodel/internal/JClassContainer.java	Thu May 14 09:53:35 2009 -0700
@@ -145,6 +145,7 @@
      *      newly created Annotation Type Declaration
      * @exception JClassAlreadyExistsException
      *      When the specified class/interface was already created.
+
      */
     public JDefinedClass _annotationTypeDeclaration(String name) throws JClassAlreadyExistsException;
 
@@ -156,6 +157,7 @@
      *      newly created Enum
      * @exception JClassAlreadyExistsException
      *      When the specified class/interface was already created.
+
      */
     public JDefinedClass _enum (String name) throws JClassAlreadyExistsException;
 
--- a/jaxws/src/share/classes/com/sun/codemodel/internal/JDefinedClass.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/codemodel/internal/JDefinedClass.java	Thu May 14 09:53:35 2009 -0700
@@ -428,6 +428,7 @@
      *      newly created Annotation Type Declaration
      * @exception JClassAlreadyExistsException
      *      When the specified class/interface was already created.
+
      */
     public JDefinedClass _annotationTypeDeclaration(String name) throws JClassAlreadyExistsException {
         return _class (JMod.PUBLIC,name,ClassType.ANNOTATION_TYPE_DECL);
--- a/jaxws/src/share/classes/com/sun/codemodel/internal/JForEach.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/codemodel/internal/JForEach.java	Thu May 14 09:53:35 2009 -0700
@@ -33,17 +33,17 @@
  */
 public final class JForEach implements JStatement {
 
-    private final JType type;
-    private final String var;
-    private JBlock body = null; // lazily created
-    private final JExpression collection;
+        private final JType type;
+        private final String var;
+        private JBlock body = null; // lazily created
+        private final JExpression collection;
     private final JVar loopVar;
 
-    public JForEach(JType vartype, String variable, JExpression collection) {
+        public JForEach(JType vartype, String variable, JExpression collection) {
 
-        this.type = vartype;
-        this.var = variable;
-        this.collection = collection;
+                this.type = vartype;
+                this.var = variable;
+                this.collection = collection;
         loopVar = new JVar(JMods.forVar(JMod.NONE), type, var, collection);
     }
 
@@ -51,24 +51,24 @@
     /**
      * Returns a reference to the loop variable.
      */
-    public JVar var() {
-        return loopVar;
-    }
+        public JVar var() {
+                return loopVar;
+        }
 
-    public JBlock body() {
-        if (body == null)
-            body = new JBlock();
-        return body;
-    }
+        public JBlock body() {
+                if (body == null)
+                        body = new JBlock();
+                return body;
+        }
 
-    public void state(JFormatter f) {
-        f.p("for (");
-        f.g(type).id(var).p(": ").g(collection);
-        f.p(')');
-        if (body != null)
-            f.g(body).nl();
-        else
-            f.p(';').nl();
-    }
+        public void state(JFormatter f) {
+                f.p("for (");
+                f.g(type).id(var).p(": ").g(collection);
+                f.p(')');
+                if (body != null)
+                        f.g(body).nl();
+                else
+                        f.p(';').nl();
+        }
 
 }
--- a/jaxws/src/share/classes/com/sun/codemodel/internal/JMethod.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/codemodel/internal/JMethod.java	Thu May 14 09:53:35 2009 -0700
@@ -38,49 +38,49 @@
  */
 public class JMethod extends JGenerifiableImpl implements JDeclaration, JAnnotatable {
 
-    /**
-     * Modifiers for this method
-     */
-    private JMods mods;
+        /**
+         * Modifiers for this method
+         */
+        private JMods mods;
 
-    /**
-     * Return type for this method
-     */
-    private JType type = null;
+        /**
+         * Return type for this method
+         */
+        private JType type = null;
 
-    /**
-     * Name of this method
-     */
-    private String name = null;
+        /**
+         * Name of this method
+         */
+        private String name = null;
 
-    /**
-     * List of parameters for this method's declaration
-     */
-    private final List<JVar> params = new ArrayList<JVar>();
+        /**
+         * List of parameters for this method's declaration
+         */
+        private final List<JVar> params = new ArrayList<JVar>();
 
-    /**
-     * Set of exceptions that this method may throw.
+        /**
+         * Set of exceptions that this method may throw.
      * A set instance lazily created.
-     */
-    private Set<JClass> _throws;
+         */
+        private Set<JClass> _throws;
 
-    /**
-     * JBlock of statements that makes up the body this method
-     */
-    private JBlock body = null;
+        /**
+         * JBlock of statements that makes up the body this method
+         */
+        private JBlock body = null;
 
-    private JDefinedClass outer;
+        private JDefinedClass outer;
 
-    /**
-     * javadoc comments for this JMethod
-     */
-    private JDocComment jdoc = null;
+        /**
+         * javadoc comments for this JMethod
+         */
+        private JDocComment jdoc = null;
 
-    /**
-     * Variable parameter for this method's varargs declaration
-     * introduced in J2SE 1.5
-     */
-    private JVar varParam = null;
+        /**
+         * Variable parameter for this method's varargs declaration
+         * introduced in J2SE 1.5
+         */
+        private JVar varParam = null;
 
     /**
      * Annotations on this variable. Lazily created.
@@ -88,9 +88,9 @@
     private List<JAnnotationUse> annotations = null;
 
 
-    private boolean isConstructor() {
-        return type == null;
-    }
+        private boolean isConstructor() {
+                return type == null;
+        }
 
     /** To set the default value for the
      *  annotation member
@@ -98,40 +98,40 @@
     private JExpression defaultValue = null;
 
 
-    /**
-     * JMethod constructor
-     *
-     * @param mods
-     *        Modifiers for this method's declaration
-     *
-     * @param type
-     *        Return type for the method
-     *
-     * @param name
-     *        Name of this method
-     */
-    JMethod(JDefinedClass outer, int mods, JType type, String name) {
-        this.mods = JMods.forMethod(mods);
-        this.type = type;
-        this.name = name;
-        this.outer = outer;
-    }
+        /**
+         * JMethod constructor
+         *
+         * @param mods
+         *        Modifiers for this method's declaration
+         *
+         * @param type
+         *        Return type for the method
+         *
+         * @param name
+         *        Name of this method
+         */
+        JMethod(JDefinedClass outer, int mods, JType type, String name) {
+                this.mods = JMods.forMethod(mods);
+                this.type = type;
+                this.name = name;
+                this.outer = outer;
+        }
 
-    /**
-     * Constructor constructor
-     *
-     * @param mods
-     *        Modifiers for this constructor's declaration
-     *
-     * @param _class
-     *        JClass containing this constructor
-     */
-    JMethod(int mods, JDefinedClass _class) {
-        this.mods = JMods.forMethod(mods);
-        this.type = null;
-        this.name = _class.name();
-        this.outer = _class;
-    }
+        /**
+         * Constructor constructor
+         *
+         * @param mods
+         *        Modifiers for this constructor's declaration
+         *
+         * @param _class
+         *        JClass containing this constructor
+         */
+        JMethod(int mods, JDefinedClass _class) {
+                this.mods = JMods.forMethod(mods);
+                this.type = null;
+                this.name = _class.name();
+                this.outer = _class;
+        }
 
     private Set<JClass> getThrows() {
         if(_throws==null)
@@ -139,56 +139,56 @@
         return _throws;
     }
 
-    /**
-     * Add an exception to the list of exceptions that this
-     * method may throw.
-     *
-     * @param exception
-     *        Name of an exception that this method may throw
-     */
-    public JMethod _throws(JClass exception) {
+        /**
+         * Add an exception to the list of exceptions that this
+         * method may throw.
+         *
+         * @param exception
+         *        Name of an exception that this method may throw
+         */
+        public JMethod _throws(JClass exception) {
         getThrows().add(exception);
-        return this;
-    }
+                return this;
+        }
 
-    public JMethod _throws(Class exception) {
-        return _throws(outer.owner().ref(exception));
-    }
+        public JMethod _throws(Class exception) {
+                return _throws(outer.owner().ref(exception));
+        }
 
-    /**
-     * Add the specified variable to the list of parameters
-     * for this method signature.
-     *
-     * @param type
-     *        JType of the parameter being added
-     *
-     * @param name
-     *        Name of the parameter being added
-     *
-     * @return New parameter variable
-     */
-    public JVar param(int mods, JType type, String name) {
-        JVar v = new JVar(JMods.forVar(mods), type, name, null);
-        params.add(v);
-        return v;
-    }
+        /**
+         * Add the specified variable to the list of parameters
+         * for this method signature.
+         *
+         * @param type
+         *        JType of the parameter being added
+         *
+         * @param name
+         *        Name of the parameter being added
+         *
+         * @return New parameter variable
+         */
+        public JVar param(int mods, JType type, String name) {
+                JVar v = new JVar(JMods.forVar(mods), type, name, null);
+                params.add(v);
+                return v;
+        }
 
-    public JVar param(JType type, String name) {
-        return param(JMod.NONE, type, name);
-    }
+        public JVar param(JType type, String name) {
+                return param(JMod.NONE, type, name);
+        }
 
-    public JVar param(int mods, Class type, String name) {
-        return param(mods, outer.owner()._ref(type), name);
-    }
+        public JVar param(int mods, Class type, String name) {
+                return param(mods, outer.owner()._ref(type), name);
+        }
 
-    public JVar param(Class type, String name) {
-        return param(outer.owner()._ref(type), name);
-    }
+        public JVar param(Class type, String name) {
+                return param(outer.owner()._ref(type), name);
+        }
 
-    /**
-     * @see #varParam(JType, String)
-     */
-    public JVar varParam(Class type, String name) {
+        /**
+         * @see #varParam(JType, String)
+         */
+        public JVar varParam(Class type, String name) {
         return varParam(outer.owner()._ref(type),name);
     }
 
@@ -210,25 +210,25 @@
      *      method signature.
      */
     public JVar varParam(JType type, String name) {
-        if (!hasVarArgs()) {
+                if (!hasVarArgs()) {
 
             varParam =
-                new JVar(
-                    JMods.forVar(JMod.NONE),
-                    type.array(),
-                    name,
-                    null);
-            return varParam;
-        } else {
-            throw new IllegalStateException(
-                "Cannot have two varargs in a method,\n"
-                    + "Check if varParam method of JMethod is"
-                    + " invoked more than once");
+                                new JVar(
+                                        JMods.forVar(JMod.NONE),
+                                        type.array(),
+                                        name,
+                                        null);
+                        return varParam;
+                } else {
+                        throw new IllegalStateException(
+                                "Cannot have two varargs in a method,\n"
+                                        + "Check if varParam method of JMethod is"
+                                        + " invoked more than once");
+
+                }
 
         }
 
-    }
-
     /**
      * Adds an annotation to this variable.
      * @param clazz
@@ -256,17 +256,17 @@
         return TypedAnnotationWriter.create(clazz,this);
     }
 
-    /**
-     * Check if there are any varargs declared
-     * for this method signature.
-     */
-    public boolean hasVarArgs() {
-        return this.varParam!=null;
-    }
+        /**
+         * Check if there are any varargs declared
+         * for this method signature.
+         */
+        public boolean hasVarArgs() {
+                return this.varParam!=null;
+        }
 
-    public String name() {
-        return name;
-    }
+        public String name() {
+                return name;
+        }
 
     /**
      * Changes the name of the method.
@@ -276,11 +276,11 @@
     }
 
     /**
-     * Returns the return type.
-     */
-    public JType type() {
-        return type;
-    }
+         * Returns the return type.
+         */
+        public JType type() {
+                return type;
+        }
 
     /**
      * Overrides the return type.
@@ -290,72 +290,72 @@
     }
 
     /**
-     * Returns all the parameter types in an array.
-     * @return
-     *      If there's no parameter, an empty array will be returned.
-     */
-    public JType[] listParamTypes() {
-        JType[] r = new JType[params.size()];
-        for (int i = 0; i < r.length; i++)
-            r[i] = params.get(i).type();
-        return r;
-    }
+         * Returns all the parameter types in an array.
+         * @return
+         *      If there's no parameter, an empty array will be returned.
+         */
+        public JType[] listParamTypes() {
+                JType[] r = new JType[params.size()];
+                for (int i = 0; i < r.length; i++)
+                        r[i] = params.get(i).type();
+                return r;
+        }
 
-    /**
-     * Returns  the varags parameter type.
-     * @return
-     * If there's no vararg parameter type, null will be returned.
-     */
-    public JType listVarParamType() {
-        if (varParam != null)
-            return varParam.type();
-        else
-            return null;
-    }
+        /**
+         * Returns  the varags parameter type.
+         * @return
+         * If there's no vararg parameter type, null will be returned.
+         */
+        public JType listVarParamType() {
+                if (varParam != null)
+                        return varParam.type();
+                else
+                        return null;
+        }
 
-    /**
-     * Returns all the parameters in an array.
-     * @return
-     *      If there's no parameter, an empty array will be returned.
-     */
-    public JVar[] listParams() {
-        return params.toArray(new JVar[params.size()]);
-    }
+        /**
+         * Returns all the parameters in an array.
+         * @return
+         *      If there's no parameter, an empty array will be returned.
+         */
+        public JVar[] listParams() {
+                return params.toArray(new JVar[params.size()]);
+        }
 
-    /**
-     * Returns the variable parameter
-     * @return
-     *      If there's no parameter, null will be returned.
-     */
-    public JVar listVarParam() {
-        return varParam;
-    }
+        /**
+         * Returns the variable parameter
+         * @return
+         *      If there's no parameter, null will be returned.
+         */
+        public JVar listVarParam() {
+                return varParam;
+        }
 
-    /**
-     * Returns true if the method has the specified signature.
-     */
-    public boolean hasSignature(JType[] argTypes) {
-        JVar[] p = listParams();
-        if (p.length != argTypes.length)
-            return false;
+        /**
+         * Returns true if the method has the specified signature.
+         */
+        public boolean hasSignature(JType[] argTypes) {
+                JVar[] p = listParams();
+                if (p.length != argTypes.length)
+                        return false;
 
-        for (int i = 0; i < p.length; i++)
-            if (!p[i].type().equals(argTypes[i]))
-                return false;
+                for (int i = 0; i < p.length; i++)
+                        if (!p[i].type().equals(argTypes[i]))
+                                return false;
 
-        return true;
-    }
+                return true;
+        }
 
-    /**
-     * Get the block that makes up body of this method
-     *
-     * @return Body of method
-     */
-    public JBlock body() {
-        if (body == null)
-            body = new JBlock();
-        return body;
-    }
+        /**
+         * Get the block that makes up body of this method
+         *
+         * @return Body of method
+         */
+        public JBlock body() {
+                if (body == null)
+                        body = new JBlock();
+                return body;
+        }
 
     /**
      * Specify the default value for this annotation member
@@ -367,37 +367,37 @@
         this.defaultValue = value;
     }
 
-    /**
-     * Creates, if necessary, and returns the class javadoc for this
-     * JDefinedClass
-     *
-     * @return JDocComment containing javadocs for this class
-     */
-    public JDocComment javadoc() {
-        if (jdoc == null)
-            jdoc = new JDocComment(owner());
-        return jdoc;
-    }
+        /**
+         * Creates, if necessary, and returns the class javadoc for this
+         * JDefinedClass
+         *
+         * @return JDocComment containing javadocs for this class
+         */
+        public JDocComment javadoc() {
+                if (jdoc == null)
+                        jdoc = new JDocComment(owner());
+                return jdoc;
+        }
 
-    public void declare(JFormatter f) {
-        if (jdoc != null)
-            f.g(jdoc);
+        public void declare(JFormatter f) {
+                if (jdoc != null)
+                        f.g(jdoc);
 
         if (annotations != null){
             for (JAnnotationUse a : annotations)
                 f.g(a).nl();
         }
 
-        // declare the generics parameters
-        super.declare(f);
+                // declare the generics parameters
+                super.declare(f);
 
-        f.g(mods);
-        if (!isConstructor())
-            f.g(type);
-        f.id(name).p('(').i();
+                f.g(mods);
+                if (!isConstructor())
+                        f.g(type);
+                f.id(name).p('(').i();
         // when parameters are printed in new lines, we want them to be indented.
         // there's a good chance no newlines happen, too, but just in case it does.
-        boolean first = true;
+                boolean first = true;
         for (JVar var : params) {
             if (!first)
                 f.p(',');
@@ -406,33 +406,33 @@
             f.b(var);
             first = false;
         }
-        if (hasVarArgs()) {
-            if (!first)
-                f.p(',');
-            f.g(varParam.type().elementType());
-            f.p("... ");
-            f.id(varParam.name());
-        }
+                if (hasVarArgs()) {
+                        if (!first)
+                                f.p(',');
+                        f.g(varParam.type().elementType());
+                        f.p("... ");
+                        f.id(varParam.name());
+                }
 
-        f.o().p(')');
-        if (_throws!=null && !_throws.isEmpty()) {
-            f.nl().i().p("throws").g(_throws).nl().o();
-        }
+                f.o().p(')');
+                if (_throws!=null && !_throws.isEmpty()) {
+                        f.nl().i().p("throws").g(_throws).nl().o();
+                }
 
         if (defaultValue != null) {
             f.p("default ");
             f.g(defaultValue);
         }
-        if (body != null) {
-            f.s(body);
-        } else if (
-            !outer.isInterface() && !outer.isAnnotationTypeDeclaration() && !mods.isAbstract() && !mods.isNative()) {
-            // Print an empty body for non-native, non-abstract methods
-            f.s(new JBlock());
-        } else {
-            f.p(';').nl();
+                if (body != null) {
+                        f.s(body);
+                } else if (
+                        !outer.isInterface() && !outer.isAnnotationTypeDeclaration() && !mods.isAbstract() && !mods.isNative()) {
+                        // Print an empty body for non-native, non-abstract methods
+                        f.s(new JBlock());
+                } else {
+                        f.p(';').nl();
+                }
         }
-    }
 
     /**
      * @return
@@ -447,10 +447,10 @@
      * @deprecated use {@link #mods()}
      */
     public JMods getMods() {
-        return mods;
-    }
+                return mods;
+        }
 
-    protected JCodeModel owner() {
-        return outer.owner();
-    }
+        protected JCodeModel owner() {
+                return outer.owner();
+        }
 }
--- a/jaxws/src/share/classes/com/sun/codemodel/internal/JMods.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/codemodel/internal/JMods.java	Thu May 14 09:53:35 2009 -0700
@@ -41,17 +41,17 @@
         = JMod.FINAL;
 
     private static int FIELD
-    = (JMod.PUBLIC | JMod.PRIVATE | JMod.PROTECTED
-       | JMod.STATIC | JMod.FINAL
-       | JMod.TRANSIENT | JMod.VOLATILE);
+        = (JMod.PUBLIC | JMod.PRIVATE | JMod.PROTECTED
+           | JMod.STATIC | JMod.FINAL
+           | JMod.TRANSIENT | JMod.VOLATILE);
 
     private static int METHOD
-    = (JMod.PUBLIC | JMod.PRIVATE | JMod.PROTECTED | JMod.FINAL
-       | JMod.ABSTRACT | JMod.STATIC | JMod.NATIVE | JMod.SYNCHRONIZED);
+        = (JMod.PUBLIC | JMod.PRIVATE | JMod.PROTECTED | JMod.FINAL
+           | JMod.ABSTRACT | JMod.STATIC | JMod.NATIVE | JMod.SYNCHRONIZED);
 
     private static int CLASS
-    = (JMod.PUBLIC | JMod.PRIVATE | JMod.PROTECTED
-       | JMod.STATIC | JMod.FINAL | JMod.ABSTRACT );
+        = (JMod.PUBLIC | JMod.PRIVATE | JMod.PROTECTED
+           | JMod.STATIC | JMod.FINAL | JMod.ABSTRACT );
 
     private static int INTERFACE = JMod.PUBLIC;
 
--- a/jaxws/src/share/classes/com/sun/codemodel/internal/util/SingleByteEncoder.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/codemodel/internal/util/SingleByteEncoder.java	Thu May 14 09:53:35 2009 -0700
@@ -24,7 +24,7 @@
  */
 
 /*
- * @(#)SingleByteEncoder.java       1.14 03/01/23
+ * @(#)SingleByteEncoder.java   1.14 03/01/23
  */
 
 package com.sun.codemodel.internal.util;
@@ -51,109 +51,109 @@
     private final Surrogate.Parser sgp = new Surrogate.Parser();
 
     protected SingleByteEncoder(Charset cs,
-                            short[] index1, String index2,
-                            int mask1, int mask2, int shift)
+                                short[] index1, String index2,
+                                int mask1, int mask2, int shift)
     {
-       super(cs, 1.0f, 1.0f);
-       this.index1 = index1;
-       this.index2 = index2;
-       this.mask1 = mask1;
-       this.mask2 = mask2;
-       this.shift = shift;
+        super(cs, 1.0f, 1.0f);
+        this.index1 = index1;
+        this.index2 = index2;
+        this.mask1 = mask1;
+        this.mask2 = mask2;
+        this.shift = shift;
     }
 
     public boolean canEncode(char c) {
-       char testEncode;
-       testEncode = index2.charAt(index1[(c & mask1) >> shift]
-                               + (c & mask2));
-       if (testEncode == '\u0000')
-           return false;
-       else
-           return true;
+        char testEncode;
+        testEncode = index2.charAt(index1[(c & mask1) >> shift]
+                                   + (c & mask2));
+        if (testEncode == '\u0000')
+            return false;
+        else
+            return true;
     }
 
     private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
-       char[] sa = src.array();
-       int sp = src.arrayOffset() + src.position();
-       int sl = src.arrayOffset() + src.limit();
-       sp = (sp <= sl ? sp : sl);
-       byte[] da = dst.array();
-       int dp = dst.arrayOffset() + dst.position();
-       int dl = dst.arrayOffset() + dst.limit();
-       dp = (dp <= dl ? dp : dl);
+        char[] sa = src.array();
+        int sp = src.arrayOffset() + src.position();
+        int sl = src.arrayOffset() + src.limit();
+        sp = (sp <= sl ? sp : sl);
+        byte[] da = dst.array();
+        int dp = dst.arrayOffset() + dst.position();
+        int dl = dst.arrayOffset() + dst.limit();
+        dp = (dp <= dl ? dp : dl);
 
-       try {
-           while (sp < sl) {
-              char c = sa[sp];
-              if (Surrogate.is(c)) {
-                  if (sgp.parse(c, sa, sp, sl) < 0)
-                     return sgp.error();
-                  return sgp.unmappableResult();
-              }
-              if (c >= '\uFFFE')
-                  return CoderResult.unmappableForLength(1);
-              if (dl - dp < 1)
-                  return CoderResult.OVERFLOW;
+        try {
+            while (sp < sl) {
+                char c = sa[sp];
+                if (Surrogate.is(c)) {
+                    if (sgp.parse(c, sa, sp, sl) < 0)
+                        return sgp.error();
+                    return sgp.unmappableResult();
+                }
+                if (c >= '\uFFFE')
+                    return CoderResult.unmappableForLength(1);
+                if (dl - dp < 1)
+                    return CoderResult.OVERFLOW;
 
-              char e = index2.charAt(index1[(c & mask1) >> shift]
-                                   + (c & mask2));
+                char e = index2.charAt(index1[(c & mask1) >> shift]
+                                       + (c & mask2));
 
-              // If output byte is zero because input char is zero
-              // then character is mappable, o.w. fail
-              if (e == '\u0000' && c != '\u0000')
-                  return CoderResult.unmappableForLength(1);
+                // If output byte is zero because input char is zero
+                // then character is mappable, o.w. fail
+                if (e == '\u0000' && c != '\u0000')
+                    return CoderResult.unmappableForLength(1);
 
-              sp++;
-              da[dp++] = (byte)e;
-           }
-           return CoderResult.UNDERFLOW;
-       } finally {
-           src.position(sp - src.arrayOffset());
-           dst.position(dp - dst.arrayOffset());
-       }
+                sp++;
+                da[dp++] = (byte)e;
+            }
+            return CoderResult.UNDERFLOW;
+        } finally {
+            src.position(sp - src.arrayOffset());
+            dst.position(dp - dst.arrayOffset());
+        }
     }
 
     private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
-       int mark = src.position();
-       try {
-           while (src.hasRemaining()) {
-              char c = src.get();
-              if (Surrogate.is(c)) {
-                  if (sgp.parse(c, src) < 0)
-                     return sgp.error();
-                  return sgp.unmappableResult();
-              }
-              if (c >= '\uFFFE')
-                  return CoderResult.unmappableForLength(1);
-              if (!dst.hasRemaining())
-                  return CoderResult.OVERFLOW;
+        int mark = src.position();
+        try {
+            while (src.hasRemaining()) {
+                char c = src.get();
+                if (Surrogate.is(c)) {
+                    if (sgp.parse(c, src) < 0)
+                        return sgp.error();
+                    return sgp.unmappableResult();
+                }
+                if (c >= '\uFFFE')
+                    return CoderResult.unmappableForLength(1);
+                if (!dst.hasRemaining())
+                    return CoderResult.OVERFLOW;
 
-              char e = index2.charAt(index1[(c & mask1) >> shift]
-                                   + (c & mask2));
+                char e = index2.charAt(index1[(c & mask1) >> shift]
+                                       + (c & mask2));
 
-              // If output byte is zero because input char is zero
-              // then character is mappable, o.w. fail
-              if (e == '\u0000' && c != '\u0000')
-                  return CoderResult.unmappableForLength(1);
+                // If output byte is zero because input char is zero
+                // then character is mappable, o.w. fail
+                if (e == '\u0000' && c != '\u0000')
+                    return CoderResult.unmappableForLength(1);
 
-              mark++;
-              dst.put((byte)e);
-           }
-           return CoderResult.UNDERFLOW;
-       } finally {
-           src.position(mark);
-       }
+                mark++;
+                dst.put((byte)e);
+            }
+            return CoderResult.UNDERFLOW;
+        } finally {
+            src.position(mark);
+        }
     }
 
     protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
-       if (true && src.hasArray() && dst.hasArray())
-           return encodeArrayLoop(src, dst);
-       else
-           return encodeBufferLoop(src, dst);
+        if (true && src.hasArray() && dst.hasArray())
+            return encodeArrayLoop(src, dst);
+        else
+            return encodeBufferLoop(src, dst);
     }
 
     public byte encode(char inputChar) {
-       return (byte)index2.charAt(index1[(inputChar & mask1) >> shift] +
-              (inputChar & mask2));
+        return (byte)index2.charAt(index1[(inputChar & mask1) >> shift] +
+                (inputChar & mask2));
     }
 }
--- a/jaxws/src/share/classes/com/sun/codemodel/internal/util/Surrogate.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/codemodel/internal/util/Surrogate.java	Thu May 14 09:53:35 2009 -0700
@@ -112,7 +112,7 @@
 
         public Parser() { }
 
-        private int character;                // UCS-4
+        private int character;          // UCS-4
         private CoderResult error = CoderResult.UNDERFLOW;
         private boolean isPair;
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/client/p2p/HttpSOAPConnection.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/client/p2p/HttpSOAPConnection.java	Thu May 14 09:53:35 2009 -0700
@@ -55,12 +55,19 @@
  */
 public class HttpSOAPConnection extends SOAPConnection {
 
-    protected static Logger log =
+    public static final String vmVendor = System.getProperty("java.vendor.url");
+    private static final String sunVmVendor = "http://java.sun.com/";
+    private static final String ibmVmVendor = "http://www.ibm.com/";
+    private static final boolean isSunVM = sunVmVendor.equals(vmVendor) ? true: false;
+    private static final boolean isIBMVM = ibmVmVendor.equals(vmVendor) ? true : false;
+    private static final String JAXM_URLENDPOINT="javax.xml.messaging.URLEndpoint";
+
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.HTTP_CONN_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.client.p2p.LocalStrings");
 
-    public static String defaultProxyHost = null;
-    public static int defaultProxyPort = -1;
+    public static final String defaultProxyHost = null;
+    public static  final int defaultProxyPort = -1;
 
     MessageFactory messageFactory = null;
 
@@ -72,6 +79,9 @@
 
         try {
             messageFactory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL);
+        } catch (NoSuchMethodError ex) {
+                    //fallback to default SOAP 1.1 in this case for backward compatibility
+                    messageFactory = MessageFactory.newInstance();
         } catch (Exception ex) {
             log.log(Level.SEVERE, "SAAJ0001.p2p.cannot.create.msg.factory", ex);
             throw new SOAPExceptionImpl("Unable to create message factory", ex);
@@ -96,13 +106,18 @@
         }
 
         Class urlEndpointClass = null;
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
 
         try {
-            urlEndpointClass = Class.forName("javax.xml.messaging.URLEndpoint");
-        } catch (Exception ex) {
-            //Do nothing. URLEndpoint is available only when JAXM is there.
-            log.finest("SAAJ0090.p2p.endpoint.available.only.for.JAXM");
-        }
+                if (loader != null) {
+                        urlEndpointClass = loader.loadClass(JAXM_URLENDPOINT);
+                } else {
+                        urlEndpointClass = Class.forName(JAXM_URLENDPOINT);
+                    }
+                } catch (ClassNotFoundException ex) {
+                    //Do nothing. URLEndpoint is available only when JAXM is there.
+                    log.finest("SAAJ0090.p2p.endpoint.available.only.for.JAXM");
+                }
 
         if (urlEndpointClass != null) {
             if (urlEndpointClass.isInstance(endPoint)) {
@@ -639,10 +654,23 @@
 
         return ret;
     }
+    //private static String SSL_PKG = "com.sun.net.ssl.internal.www.protocol";
+    //private static String SSL_PROVIDER =
+              //  "com.sun.net.ssl.internal.ssl.Provider";
+    private static final String SSL_PKG;
+    private static  final String SSL_PROVIDER;
 
-    private static String SSL_PKG = "com.sun.net.ssl.internal.www.protocol";
-    private static String SSL_PROVIDER =
-        "com.sun.net.ssl.internal.ssl.Provider";
+
+    static {
+                if (isIBMVM) {
+                    SSL_PKG ="com.ibm.net.ssl.internal.www.protocol";
+                    SSL_PROVIDER ="com.ibm.net.ssl.internal.ssl.Provider";
+                } else {
+                    //if not IBM VM default to Sun.
+                    SSL_PKG = "com.sun.net.ssl.internal.www.protocol";
+                    SSL_PROVIDER ="com.sun.net.ssl.internal.ssl.Provider";
+                }
+            }
     private void initHttps() {
         //if(!setHttps) {
         String pkgs = System.getProperty("java.protocol.handler.pkgs");
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -70,7 +70,7 @@
  */
 public class AttachmentPartImpl extends AttachmentPart {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: EnvelopeFactory.java,v 1.24 2006/01/27 12:49:26 vj135062 Exp $
- * $Revision: 1.24 $
- * $Date: 2006/01/27 12:49:26 $
+ *
+ *
+ *
  */
 
 
@@ -55,7 +55,7 @@
  */
 public class EnvelopeFactory {
 
-    protected static Logger
+    protected static final Logger
         log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
         "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ImageDataContentHandler.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ImageDataContentHandler.java	Thu May 14 09:53:35 2009 -0700
@@ -49,7 +49,7 @@
 public class ImageDataContentHandler extends Component
     implements DataContentHandler {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/MessageFactoryImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/MessageFactoryImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: MessageFactoryImpl.java,v 1.23 2006/01/27 12:49:27 vj135062 Exp $
- * $Revision: 1.23 $
- * $Date: 2006/01/27 12:49:27 $
+ *
+ *
+ *
  */
 
 
@@ -54,15 +54,15 @@
  */
 public class MessageFactoryImpl extends MessageFactory {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
-    protected static OutputStream listener;
+    protected  OutputStream listener;
 
     protected boolean lazyAttachments = false;
 
-    public static OutputStream listen(OutputStream newListener) {
+    public  OutputStream listen(OutputStream newListener) {
         OutputStream oldListener = listener;
         listener = newListener;
         return oldListener;
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/MessageImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/MessageImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: MessageImpl.java,v 1.5 2006/12/12 10:16:33 kumarjayanti Exp $
- * $Revision: 1.5 $
- * $Date: 2006/12/12 10:16:33 $
+ *
+ *
+ *
  */
 
 
@@ -69,7 +69,7 @@
     public static final String CONTENT_ID             = "Content-ID";
     public static final String CONTENT_LOCATION       = "Content-Location";
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SAAJMetaFactoryImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SAAJMetaFactoryImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -37,7 +37,7 @@
 
 public class SAAJMetaFactoryImpl extends SAAJMetaFactory {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPDocumentImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPDocumentImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: SOAPDocumentImpl.java,v 1.15 2006/01/27 12:49:29 vj135062 Exp $
+ *
  */
 
 
@@ -45,7 +45,7 @@
 
 public class SOAPDocumentImpl extends DocumentImpl implements SOAPDocument {
 
-    protected static Logger log =
+    protected static final  Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPFactoryImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPFactoryImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: SOAPFactoryImpl.java,v 1.21 2006/01/27 12:49:29 vj135062 Exp $
- * $Revision: 1.21 $
- * $Date: 2006/01/27 12:49:29 $
+ *
+ *
+ *
  */
 
 
@@ -50,7 +50,7 @@
 
 public abstract class SOAPFactoryImpl extends SOAPFactory {
 
-    protected static Logger
+    protected static final Logger
         log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                                "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPPartImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/SOAPPartImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: SOAPPartImpl.java,v 1.1.1.1 2006/01/27 13:10:55 kumarjayanti Exp $
- * $Revision: 1.1.1.1 $
- * $Date: 2006/01/27 13:10:55 $
+ *
+ *
+ *
  */
 
 
@@ -59,7 +59,7 @@
  * @author Anil Vijendran (anil@sun.com)
  */
 public abstract class SOAPPartImpl extends SOAPPart implements SOAPDocument {
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/CDATAImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/CDATAImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: CDATAImpl.java,v 1.19 2006/01/27 12:49:34 vj135062 Exp $
- * $Revision: 1.19 $
- * $Date: 2006/01/27 12:49:34 $
+ *
+ *
+ *
  */
 
 
@@ -43,7 +43,7 @@
     extends com.sun.org.apache.xerces.internal.dom.CDATASectionImpl
     implements javax.xml.soap.Text {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/CommentImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/CommentImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: CommentImpl.java,v 1.17 2006/01/27 12:49:34 vj135062 Exp $
- * $Revision: 1.17 $
- * $Date: 2006/01/27 12:49:34 $
+ *
+ *
+ *
  */
 
 
@@ -47,7 +47,7 @@
     extends com.sun.org.apache.xerces.internal.dom.CommentImpl
     implements javax.xml.soap.Text, org.w3c.dom.Comment {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
     protected static ResourceBundle rb =
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: ElementImpl.java,v 1.6 2006/11/16 16:01:14 kumarjayanti Exp $
- * $Revision: 1.6 $
- * $Date: 2006/11/16 16:01:14 $
+ *
+ *
+ *
  */
 
 
@@ -60,7 +60,7 @@
 
     protected QName elementQName;
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/TextImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/TextImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: TextImpl.java,v 1.19 2006/01/27 12:49:36 vj135062 Exp $
- * $Revision: 1.19 $
- * $Date: 2006/01/27 12:49:36 $
+ *
+ *
+ *
  */
 
 
@@ -43,7 +43,7 @@
     extends com.sun.org.apache.xerces.internal.dom.TextImpl
     implements javax.xml.soap.Text, org.w3c.dom.Text {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_IMPL_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.impl.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/name/NameImpl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/name/NameImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,9 +23,9 @@
  * have any questions.
  */
 /*
- * $Id: NameImpl.java,v 1.48 2006/01/27 12:49:38 vj135062 Exp $
- * $Revision: 1.48 $
- * $Date: 2006/01/27 12:49:38 $
+ *
+ *
+ *
  */
 
 
@@ -63,7 +63,7 @@
     protected String prefix = "";
     private String qualifiedName = null;
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.NAMING_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.name.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/Fault1_1Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/Fault1_1Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Fault1_1Impl.java,v 1.1.1.1 2006/01/27 13:10:57 kumarjayanti Exp $
+ *
  */
 
 
@@ -57,7 +57,7 @@
 
 public class Fault1_1Impl extends FaultImpl {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(
             LogDomainConstants.SOAP_VER1_1_DOMAIN,
             "com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/Header1_1Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/Header1_1Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Header1_1Impl.java,v 1.29 2006/01/27 12:49:41 vj135062 Exp $
+ *
  */
 
 
@@ -50,7 +50,7 @@
 
 public class Header1_1Impl extends HeaderImpl {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/HeaderElement1_1Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/HeaderElement1_1Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: HeaderElement1_1Impl.java,v 1.29 2006/01/27 12:49:41 vj135062 Exp $
+ *
  */
 
 
@@ -49,7 +49,7 @@
 
 public class HeaderElement1_1Impl extends HeaderElementImpl {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/Message1_1Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/Message1_1Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Message1_1Impl.java,v 1.24 2006/01/27 12:49:41 vj135062 Exp $
+ *
  */
 
 
@@ -48,7 +48,7 @@
 
 public class Message1_1Impl extends MessageImpl implements SOAPConstants {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/SOAPPart1_1Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_1/SOAPPart1_1Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: SOAPPart1_1Impl.java,v 1.1.1.1 2006/01/27 13:10:57 kumarjayanti Exp $
+ *
  */
 
 
@@ -48,7 +48,7 @@
 
 public class SOAPPart1_1Impl extends SOAPPartImpl implements SOAPConstants {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Body1_2Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Body1_2Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Body1_2Impl.java,v 1.32 2006/01/27 12:49:44 vj135062 Exp $
+ *
  */
 
 
@@ -50,7 +50,7 @@
 
 public class Body1_2Impl extends BodyImpl {
 
-    protected static Logger log =
+    protected static  final Logger log =
         Logger.getLogger(Body1_2Impl.class.getName(),
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Detail1_2Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Detail1_2Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Detail1_2Impl.java,v 1.24 2006/01/27 12:49:45 vj135062 Exp $
+ *
  */
 
 
@@ -47,7 +47,7 @@
 
 public class Detail1_2Impl extends DetailImpl {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(Detail1_2Impl.class.getName(),
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Envelope1_2Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Envelope1_2Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Envelope1_2Impl.java,v 1.26 2006/01/27 12:49:47 vj135062 Exp $
+ *
  */
 
 
@@ -47,7 +47,7 @@
 
 public class Envelope1_2Impl extends EnvelopeImpl {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(Envelope1_2Impl.class.getName(),
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Fault1_2Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Fault1_2Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Fault1_2Impl.java,v 1.1.1.1 2006/01/27 13:10:57 kumarjayanti Exp $
+ *
  */
 
 
@@ -51,7 +51,7 @@
 
 public class Fault1_2Impl extends FaultImpl {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(
             LogDomainConstants.SOAP_VER1_2_DOMAIN,
             "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Header1_2Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/Header1_2Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: Header1_2Impl.java,v 1.36 2006/01/27 12:49:48 vj135062 Exp $
+ *
  */
 
 
@@ -53,7 +53,7 @@
 
 public class Header1_2Impl extends HeaderImpl {
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(
             LogDomainConstants.SOAP_VER1_2_DOMAIN,
             "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/HeaderElement1_2Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/HeaderElement1_2Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: HeaderElement1_2Impl.java,v 1.29 2006/01/27 12:49:48 vj135062 Exp $
+ *
  */
 
 
@@ -47,7 +47,7 @@
 
 public class HeaderElement1_2Impl extends HeaderElementImpl {
 
-    private static Logger log =
+    private static final Logger log =
         Logger.getLogger(HeaderElement1_2Impl.class.getName(),
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/SOAPPart1_2Impl.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/soap/ver1_2/SOAPPart1_2Impl.java	Thu May 14 09:53:35 2009 -0700
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * $Id: SOAPPart1_2Impl.java,v 1.1.1.1 2006/01/27 13:10:57 kumarjayanti Exp $
+ *
  */
 
 
@@ -47,7 +47,7 @@
 
 public class SOAPPart1_2Impl extends SOAPPartImpl implements SOAPConstants{
 
-    protected static Logger log =
+    protected static final Logger log =
         Logger.getLogger(SOAPPart1_2Impl.class.getName(),
                          "com.sun.xml.internal.messaging.saaj.soap.ver1_2.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/util/RejectDoctypeSaxFilter.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/util/RejectDoctypeSaxFilter.java	Thu May 14 09:53:35 2009 -0700
@@ -45,12 +45,12 @@
  * because they are not legal in SOAP.  If the user of this class sets a
  * LexicalHandler, then it forwards events to that handler.
  *
- * $Id: RejectDoctypeSaxFilter.java,v 1.13 2006/01/27 12:49:52 vj135062 Exp $
+ *
  * @author Edwin Goei
  */
 
 public class RejectDoctypeSaxFilter extends XMLFilterImpl implements XMLReader, LexicalHandler{
-    protected static Logger log =
+    protected static final Logger log =
     Logger.getLogger(LogDomainConstants.UTIL_DOMAIN,
     "com.sun.xml.internal.messaging.saaj.util.LocalStrings");
 
--- a/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/util/transform/EfficientStreamingTransformer.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/messaging/saaj/util/transform/EfficientStreamingTransformer.java	Thu May 14 09:53:35 2009 -0700
@@ -62,20 +62,22 @@
 public class EfficientStreamingTransformer
     extends javax.xml.transform.Transformer {
 
-  static final String version;
-  static final String vendor;
+  //static final String version;
+  //static final String vendor;
 
-  protected static TransformerFactory transformerFactory = TransformerFactory.newInstance();
+  protected static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
 
-  static {
-        version = System.getProperty("java.vm.version");
-        vendor = System.getProperty("java.vm.vendor");
-        if (vendor.startsWith("Sun") &&
-            (version.startsWith("1.4") || version.startsWith("1.3"))) {
-            transformerFactory =
-                new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl();
-        }
-  }
+   //removing support for Java 1.4 and 1.3 : CR6658158
+    /*static {
+    version = System.getProperty("java.vm.version");
+    vendor = System.getProperty("java.vm.vendor");
+    if (vendor.startsWith("Sun") &&
+    (version.startsWith("1.4") || version.startsWith("1.3"))) {
+    transformerFactory =
+    new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl();
+    }
+}
+*/
 
     /**
      * TransformerFactory instance.
--- a/jaxws/src/share/classes/com/sun/xml/internal/txw2/DatatypeWriter.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/txw2/DatatypeWriter.java	Thu May 14 09:53:35 2009 -0700
@@ -25,6 +25,9 @@
 
 package com.sun.xml.internal.txw2;
 
+import java.util.AbstractList;
+import java.util.Collections;
+import java.util.List;
 import javax.xml.namespace.QName;
 
 /**
@@ -53,50 +56,60 @@
      */
     void print(DT dt, NamespaceResolver resolver, StringBuilder buf);
 
+    static final List<DatatypeWriter<?>> BUILTIN = Collections.unmodifiableList(new AbstractList() {
 
-    static final DatatypeWriter<?>[] BUILDIN = new DatatypeWriter<?>[] {
-        new DatatypeWriter<String>() {
-            public Class<String> getType() {
-                return String.class;
+        private DatatypeWriter<?>[] BUILTIN_ARRAY = new DatatypeWriter<?>[] {
+            new DatatypeWriter<String>() {
+                public Class<String> getType() {
+                    return String.class;
+                }
+                public void print(String s, NamespaceResolver resolver, StringBuilder buf) {
+                    buf.append(s);
+                }
+            },
+            new DatatypeWriter<Integer>() {
+                public Class<Integer> getType() {
+                    return Integer.class;
+                }
+                public void print(Integer i, NamespaceResolver resolver, StringBuilder buf) {
+                    buf.append(i);
+                }
+            },
+            new DatatypeWriter<Float>() {
+                public Class<Float> getType() {
+                    return Float.class;
+                }
+                public void print(Float f, NamespaceResolver resolver, StringBuilder buf) {
+                    buf.append(f);
+                }
+            },
+            new DatatypeWriter<Double>() {
+                public Class<Double> getType() {
+                    return Double.class;
+                }
+                public void print(Double d, NamespaceResolver resolver, StringBuilder buf) {
+                    buf.append(d);
+                }
+            },
+            new DatatypeWriter<QName>() {
+                public Class<QName> getType() {
+                    return QName.class;
+                }
+                public void print(QName qn, NamespaceResolver resolver, StringBuilder buf) {
+                    String p = resolver.getPrefix(qn.getNamespaceURI());
+                    if(p.length()!=0)
+                        buf.append(p).append(':');
+                    buf.append(qn.getLocalPart());
+                }
             }
-            public void print(String s, NamespaceResolver resolver, StringBuilder buf) {
-                buf.append(s);
-            }
-        },
-        new DatatypeWriter<Integer>() {
-            public Class<Integer> getType() {
-                return Integer.class;
-            }
-            public void print(Integer i, NamespaceResolver resolver, StringBuilder buf) {
-                buf.append(i);
-            }
-        },
-        new DatatypeWriter<Float>() {
-            public Class<Float> getType() {
-                return Float.class;
-            }
-            public void print(Float f, NamespaceResolver resolver, StringBuilder buf) {
-                buf.append(f);
-            }
-        },
-        new DatatypeWriter<Double>() {
-            public Class<Double> getType() {
-                return Double.class;
-            }
-            public void print(Double d, NamespaceResolver resolver, StringBuilder buf) {
-                buf.append(d);
-            }
-        },
-        new DatatypeWriter<QName>() {
-            public Class<QName> getType() {
-                return QName.class;
-            }
-            public void print(QName qn, NamespaceResolver resolver, StringBuilder buf) {
-                String p = resolver.getPrefix(qn.getNamespaceURI());
-                if(p.length()!=0)
-                    buf.append(p).append(':');
-                buf.append(qn.getLocalPart());
-            }
+        };
+
+        public DatatypeWriter<?> get(int n) {
+          return BUILTIN_ARRAY[n];
         }
-    };
+
+        public int size() {
+          return BUILTIN_ARRAY.length;
+        }
+      });
 }
--- a/jaxws/src/share/classes/com/sun/xml/internal/txw2/Document.java	Wed May 06 14:14:54 2009 -0700
+++ b/jaxws/src/share/classes/com/sun/xml/internal/txw2/Document.java	Thu May 14 09:53:35 2009 -0700
@@ -76,7 +76,7 @@
 
     Document(XmlSerializer out) {
         this.out = out;
-        for( DatatypeWriter dw : DatatypeWriter.BUILDIN )
+        for( DatatypeWriter dw : DatatypeWriter.BUILTIN )
             datatypeWriters.put(dw.getType(),dw);
     }
 
--- a/jdk/.hgtags	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/.hgtags	Thu May 14 09:53:35 2009 -0700
@@ -32,3 +32,4 @@
 522bb5aa17e0c0cff00b1ed7d1b51bc4db2cfef9 jdk7-b55
 7fd3bc37afe36f8f6165ba679db1229716db822a jdk7-b56
 d5a1223e961891564de25c39fba6f2442d0fb045 jdk7-b57
+9ba256e2e5c161b89e638390f998baa175ec9abe jdk7-b58
--- a/jdk/make/common/Release.gmk	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/make/common/Release.gmk	Thu May 14 09:53:35 2009 -0700
@@ -52,6 +52,9 @@
                         com.sun.java.swing.plaf.motif    \
                         com.sun.java.swing.plaf.gtk
 
+# This is a stopgap until 6839872 is fixed.
+EXCLUDE_PROPWARN_PKGS += sun.dyn
+
 # 64-bit solaris has a few special cases. We define the variable
 # SOLARIS64 for use in this Makefile to easily test those cases
 ifeq ($(PLATFORM), solaris)
--- a/jdk/make/docs/CORE_PKGS.gmk	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/make/docs/CORE_PKGS.gmk	Thu May 14 09:53:35 2009 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+# Copyright 2001-2008 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
@@ -55,6 +55,7 @@
 # This is a list of regular expressions. So foo.* matches "foo" and "foo.bar".
 #
 ACTIVE_JSR_PKGS= \
+  java.dyn \
   java.sql  \
   javax.activation  \
   javax.annotation.*  \
@@ -96,6 +97,7 @@
   java.awt.print                                 \
   java.beans                                     \
   java.beans.beancontext                         \
+  java.dyn                                       \
   java.io                                        \
   java.lang                                      \
   java.lang.annotation                           \
--- a/jdk/make/java/Makefile	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/make/java/Makefile	Thu May 14 09:53:35 2009 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
+# Copyright 1995-2009 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
@@ -39,7 +39,7 @@
 # Others
 #    Note: java_crw_demo java_hprof_demo are demos but must be delivered built in sdk
 SUBDIRS += security npt java_crw_demo java_hprof_demo \
-	    math awt util text applet net nio \
+	    math awt util text applet net nio dyn \
 	    sql rmi jar beans logging management instrument
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/java/dyn/Makefile	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,44 @@
+#
+# Copyright 2008-2009 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.
+#
+
+BUILDDIR = ../..
+
+PACKAGE = java.dyn
+PRODUCT = java
+include $(BUILDDIR)/common/Defs.gmk
+
+AUTO_FILES_JAVA_DIRS = java/dyn sun/dyn
+
+# The sources built here use new language syntax to generate
+# method handle calls.  Let's be sure we are using that format.
+#LANGUAGE_VERSION = -source 7
+#CLASS_VERSION = -target 7
+
+# Actually, it will be less disruptive to compile with the same
+# -target option as the rest of the system, and just turn on
+# the specific compiler option we need here:
+OTHER_JAVACFLAGS = -XDinvokedynamic
+
+include $(BUILDDIR)/common/Classes.gmk
--- a/jdk/src/share/classes/java/awt/GraphicsDevice.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/awt/GraphicsDevice.java	Thu May 14 09:53:35 2009 -0700
@@ -282,7 +282,7 @@
                 w.setOpacity(1.0f);
             }
             Color bgColor = w.getBackground();
-            if (bgColor.getAlpha() < 255) {
+            if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
                 bgColor = new Color(bgColor.getRed(), bgColor.getGreen(),
                                     bgColor.getBlue(), 255);
                 w.setBackground(bgColor);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/CallSite.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+import sun.dyn.util.BytecodeName;
+
+/**
+ * An {@code invokedynamic} call site, as reified by the
+ * containing class's bootstrap method.
+ * Every call site object corresponds to a distinct instance
+ * of the <code>invokedynamic</code> instruction, and vice versa.
+ * Every call site has one state variable, called the {@code target}.
+ * It is typed as a {@link MethodHandle}.  This state is never null, and
+ * it is the responsibility of the bootstrap method to produce call sites
+ * which have been pre-linked to an initial target method.
+ * <p>
+ * (Note:  The bootstrap method may elect to produce call sites of a
+ * language-specific subclass of {@code CallSite}.  In such a case,
+ * the subclass may claim responsibility for initializing its target to
+ * a non-null value, by overriding {@link #initialTarget}.)
+ * <p>
+ * An {@code invokedynamic} instruction which has not yet been executed
+ * is said to be <em>unlinked</em>.  When an unlinked call site is executed,
+ * the containing class's bootstrap method is called to manufacture a call site,
+ * for the instruction.  If the bootstrap method does not assign a non-null
+ * value to the new call site's target variable, the method {@link #initialTarget}
+ * is called to produce the new call site's first target method.
+ * <p>
+ * @see Linkage#registerBootstrapMethod(java.lang.Class, java.dyn.MethodHandle)
+ * @author John Rose, JSR 292 EG
+ */
+public class CallSite {
+    // Fields used only by the JVM.  Do not use or change.
+    private Object vmmethod;
+    int callerMID, callerBCI;  // supplied by the JVM
+
+    MethodHandle target;
+    final Object caller;  // usually a class
+    final String name;
+    final MethodType type;
+
+    /**
+     * Make a call site given the parameters from a call to the bootstrap method.
+     * The resulting call site is in an unlinked state, which means that before
+     * it is returned from a bootstrap method call it must be provided with
+     * a target method via a call to {@link CallSite#setTarget}.
+     * @param caller the class in which the relevant {@code invokedynamic} instruction occurs
+     * @param name the name specified by the {@code invokedynamic} instruction
+     * @param type the method handle type derived from descriptor of the {@code invokedynamic} instruction
+     */
+    public CallSite(Object caller, String name, MethodType type) {
+        this.caller = caller;
+        this.name = name;
+        this.type = type;
+    }
+
+    private static void privateInitializeCallSite(CallSite site, int callerMID, int callerBCI) {
+        site.callerMID = callerMID;
+        site.callerBCI = callerBCI;
+        if (site.target == null)
+            site.setTarget(site.initialTarget());
+    }
+
+    /**
+     * Just after a call site is created by a bootstrap method handle,
+     * if the target has not been initialized by the factory method itself,
+     * the method {@code initialTarget} is called to produce an initial
+     * non-null target.  (Live call sites must never have null targets.)
+     * <p>
+     * If the bootstrap method itself does not initialize the call site,
+     * this method must be overridden, because it just raises an
+     * {@code InvokeDynamicBootstrapError}, which in turn causes the
+     * linkage of the {@code invokedynamic} instruction to terminate
+     * abnormally.
+     */
+    protected MethodHandle initialTarget() {
+        throw new InvokeDynamicBootstrapError("target must be initialized before call site is linked: "+this);
+    }
+
+    /**
+     * Report the current linkage state of the call site.  (This is mutable.)
+     * The value maybe null only if the call site is currently unlinked.
+     * When a linked call site is invoked, the target method is used directly.
+     * When an unlinked call site is invoked, its bootstrap method receives
+     * the call, as if via {@link Linkage#bootstrapInvokeDynamic}.
+     * <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 current linkage state of the call site
+     * @see #setTarget
+     */
+    public MethodHandle getTarget() {
+        return target;
+    }
+
+    /**
+     * Link or relink the call site, by setting its target method.
+     * <p>
+     * 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.
+     * @param target the new target, or null if it is to be unlinked
+     * @throws NullPointerException if the proposed new target is null
+     * @throws WrongMethodTypeException if the proposed new target
+     *         has a method type that differs from the call site's {@link #type()}
+     */
+    public void setTarget(MethodHandle target) {
+        checkTarget(target);
+        this.target = target;
+    }
+
+    protected void checkTarget(MethodHandle target) {
+        target.type();  // provoke NPE
+        if (!canSetTarget(target))
+            throw new WrongMethodTypeException(String.valueOf(target));
+    }
+
+    protected boolean canSetTarget(MethodHandle target) {
+        return (target != null && target.type() == type());
+    }
+
+    /**
+     * Report the class containing the call site.
+     * This is an immutable property of the call site, set from the first argument to the constructor.
+     * @return class containing the call site
+     */
+    public Class<?> callerClass() {
+        return (Class) caller;
+    }
+
+    /**
+     * Report the method name specified in the {@code invokedynamic} instruction.
+     * This is an immutable property of the call site, set from the second argument to the constructor.
+     * <p>
+     * Note that the name is a JVM bytecode name, and as such can be any
+     * non-empty string, as long as it does not contain certain "dangerous"
+     * characters such as slash {@code '/'} and dot {@code '.'}.
+     * See the Java Virtual Machine specification for more details.
+     * <p>
+     * Application such as a language runtimes may need to encode
+     * arbitrary program element names and other configuration information
+     * into the name.  A standard convention for doing this is
+     * <a href="http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm">specified here</a>.
+     * @return method name specified by the call site
+     */
+    public String name() {
+        return name;
+    }
+
+    /**
+     * Report the method name specified in the {@code invokedynamic} instruction,
+     * as a series of components, individually demangled according to
+     * the standard convention
+     * <a href="http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm">specified here</a>.
+     * <p>
+     * Non-empty runs of characters between dangerous characters are demangled.
+     * Each component is either a completely arbitrary demangled string,
+     * or else a character constant for a punctuation character, typically ':'.
+     * (In principle, the character can be any dangerous character that the
+     * JVM lets through in a method name, such as '$' or ']'.
+     * Runtime implementors are encouraged to use colon ':' for building
+     * structured names.)
+     * <p>
+     * In the common case where the name contains no dangerous characters,
+     * the result is an array whose only element array is the demangled
+     * name at the call site.  Such a demangled name can be any sequence
+     * of any number of any unicode characters.
+     * @return method name components specified by the call site
+     */
+    public Object[] nameComponents() {
+        return BytecodeName.parseBytecodeName(name);
+    }
+
+    /**
+     * Report the resolved result and parameter types of this call site,
+     * which are derived from its bytecode-level invocation descriptor.
+     * The types are packaged into a {@link MethodType}.
+     * Any linked target of this call site must be exactly this method type.
+     * This is an immutable property of the call site, set from the third argument to the constructor.
+     * @return method type specified by the call site
+     */
+    public MethodType type() {
+        return type;
+    }
+
+    @Override
+    public String toString() {
+        return "CallSite#"+hashCode()+"["+name+type+" => "+target+"]";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/InvokeDynamic.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+/**
+ * Syntactic marker to request javac to emit an {@code invokedynamic} instruction.
+ * An {@code invokedynamic} instruction is a 5-byte bytecoded instruction
+ * which begins with an opcode byte of value 186 ({@code 0xBA}),
+ * and is followed by a two-byte index of a {@code NameAndType} constant
+ * pool entry, then by two zero bytes.  The constant pool reference gives
+ * the method name and argument and return types of the call site; there
+ * is no other information provided at the call site.
+ * <p>
+ * The {@code invokedynamic} instruction is incomplete without a target method.
+ * The target method is a property of the reified call site object
+ * (of type {@link CallSite}) which is in a one-to-one association with each
+ * corresponding {@code invokedynamic} instruction.  The call site object
+ * is initially produced by a <em>bootstrap method</em> associated with
+ * the call site, via the various overloadings of {@link Linkage#registerBootstrapMethod}.
+ * <p>
+ * The type {@code InvokeDynamic} has no particular meaning as a
+ * class or interface supertype, or an object type; it can never be instantiated.
+ * Logically, it denotes a source of all dynamically typed methods.
+ * It may be viewed as a pure syntactic marker (an importable one) of static calls.
+ * @author John Rose, JSR 292 EG
+ */
+public final class InvokeDynamic {
+    private InvokeDynamic() { throw new InternalError(); }  // do not instantiate
+
+    // no statically defined static methods
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+/**
+ * Thrown to indicate that an {@code invokedynamic} instruction has
+ * failed to find its bootstrap method, or the bootstrap method has
+ * failed to provide a call site with a non-null target.
+ * <p>
+ * The boostrap method must have been declared during a class's initialization
+ * by a call to {@link Linkage#registerBootstrapMethod}.
+ *
+ * @author John Rose, JSR 292 EG
+ */
+public class InvokeDynamicBootstrapError extends LinkageError {
+    /**
+     * Constructs a {@code InvokeDynamicBootstrapError} with no detail message.
+     */
+    public InvokeDynamicBootstrapError() {
+        super();
+    }
+
+    /**
+     * Constructs a {@code InvokeDynamicBootstrapError} with the specified
+     * detail message.
+     *
+     * @param s the detail message.
+     */
+    public InvokeDynamicBootstrapError(String s) {
+        super(s);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/JavaMethodHandle.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+/**
+ * A Java method handle extends the basic method handle type with additional
+ * programmer defined methods and fields.
+ * Its behavior as a method handle is determined at instance creation time,
+ * by providing the new instance with an "entry point" method handle
+ * to handle calls.  This entry point must accept a leading argument
+ * whose type is the Java method handle itself or a supertype, and the
+ * entry point is always called with the Java method handle itself as
+ * the first argument.  This is similar to ordinary virtual methods, which also
+ * accept the receiver object {@code this} as an implicit leading argument.
+ * The {@code MethodType} of the Java method handle is the same as that
+ * of the entry point method handle, with the leading parameter type
+ * omitted.
+ * <p>
+ * Here is an example of usage:
+ * <p><blockquote><pre>
+ *     class Greeter extends JavaMethodHandle {
+ *         public void run() { System.out.println("hello, "+greetee); }
+ *         private final String greetee;
+ *         Greeter(String greetee) {
+ *             super(RUN);
+ *             this.greetee = greetee;
+ *         }
+ *         // the entry point function is computed once:
+ *         private static final MethodHandle RUN
+ *             = MethodHandles.findVirtual(MyMethodHandle.class, "run",
+ *                   MethodType.make(void.class));
+ *     }
+ *     Greeter greeter = new Greeter("world");
+ *     greeter.run();  // prints "hello, world"
+ *     MethodHandle mh = greeter;
+ *     mh.invoke();  // also prints "hello, world"
+ * </pre></blockquote>
+ * <p>
+ * In this example, the method {@code run} provides the entry point.
+ * The entry point need not be a constant value; it may be independently
+ * computed in each call to the constructor.  The entry point does not
+ * even need to be a method on the Java method handle class, though
+ * that is the typical case.
+ * @see MethodHandle
+ * @author John Rose, JSR 292 EG
+ */
+public abstract class JavaMethodHandle
+        // Note: This is an implementation inheritance hack, and will be removed
+        // with a JVM change which moves the required hidden behavior onto this class.
+        extends sun.dyn.BoundMethodHandle
+{
+    /**
+     * When creating a, pass in {@code entryPoint}, any method handle which
+     * can take the current object
+     * @param entryPoint
+     */
+    protected JavaMethodHandle(MethodHandle entryPoint) {
+        super(entryPoint, 0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/Linkage.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+import java.util.WeakHashMap;
+import sun.reflect.Reflection;
+import static sun.dyn.util.VerifyAccess.checkBootstrapPrivilege;
+
+/**
+ * Static methods which control the linkage of invokedynamic call sites.
+ * @author John Rose, JSR 292 EG
+ */
+public class Linkage {
+    private Linkage() {}  // do not instantiate
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Register a <em>bootstrap method</em> to use when linking a given caller class.
+     * It must be a method handle of a type equivalent to {@link CallSite#CallSite}.
+     * In other words, it must act as a factory method which accepts the arguments
+     * to {@code CallSite}'s constructor (a class, a string, and a method type),
+     * and returns a {@code CallSite} object (possibly of a subclass of {@code CallSite}).
+     * <p>
+     * The registration will fail with an {@code IllegalStateException} if any of the following conditions hold:
+     * <ul>
+     * <li>The caller of this method is in a different package than the {@code callerClass},
+     *     and there is a security manager, and its {@code checkPermission} call throws
+     *     when passed {@link LinkagePermission}("registerBootstrapMethod",callerClass).
+     * <li>The given class already has a bootstrap method from a previous
+     *     call to this method.
+     * <li>The given class is already fully initialized.
+     * <li>The given class is in the process of initialization, in another thread.
+     * </ul>
+     * Because of these rules, a class may install its own bootstrap method in
+     * a static initializer.
+     */
+    public static
+    void registerBootstrapMethod(Class callerClass, MethodHandle mh) {
+        Class callc = Reflection.getCallerClass(2);
+        checkBootstrapPrivilege(callc, callerClass, "registerBootstrapMethod");
+        checkBSM(mh);
+        synchronized (bootstrapMethods) {
+            if (bootstrapMethods.containsKey(callerClass))
+                throw new IllegalStateException("bootstrap method already declared in "+callerClass);
+            bootstrapMethods.put(callerClass, mh);
+        }
+    }
+
+    static void checkBSM(MethodHandle mh) {
+        if (mh == null)  throw new IllegalArgumentException("null bootstrap method");
+        if (mh.type() == OLD_BOOTSTRAP_METHOD_TYPE) // FIXME: delete at EDR/PFD
+            throw new WrongMethodTypeException("bootstrap method must be a CallSite factory");
+        if (mh.type() != BOOTSTRAP_METHOD_TYPE)
+            throw new WrongMethodTypeException(mh.toString());
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Simplified version of registerBootstrapMethod for self-registration,
+     * to be called from a static initializer.
+     * Finds a static method of the required type in the
+     * given class, and installs it on the caller.
+     * @throws IllegalArgumentException if there is no such method
+     */
+    public static
+    void registerBootstrapMethod(Class<?> runtime, String name) {
+        Class callc = Reflection.getCallerClass(2);
+        MethodHandle bootstrapMethod =
+            MethodHandles.findStaticFrom(callc, runtime, name, BOOTSTRAP_METHOD_TYPE);
+        // FIXME: exception processing wrong here
+        checkBSM(bootstrapMethod);
+        Linkage.registerBootstrapMethod(callc, bootstrapMethod);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Simplified version of registerBootstrapMethod for self-registration,
+     * to be called from a static initializer.
+     * Finds a static method of the required type in the
+     * caller's class, and installs it on the caller.
+     * @throws IllegalArgumentException if there is no such method
+     */
+    public static
+    void registerBootstrapMethod(String name) {
+        Class callc = Reflection.getCallerClass(2);
+        MethodHandle bootstrapMethod =
+            MethodHandles.findStaticFrom(callc, callc, name, BOOTSTRAP_METHOD_TYPE);
+        // FIXME: exception processing wrong here
+        checkBSM(bootstrapMethod);
+        Linkage.registerBootstrapMethod(callc, bootstrapMethod);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Report the bootstrap method registered for a given class.
+     * Returns null if the class has never yet registered a bootstrap method,
+     * or if the class has explicitly registered a null bootstrap method.
+     * Only callers privileged to set the bootstrap method may inquire
+     * about it, because a bootstrap method is potentially a back-door entry
+     * point into its class.
+     */
+    public static
+    MethodHandle getBootstrapMethod(Class callerClass) {
+        Class callc = Reflection.getCallerClass(2);
+        checkBootstrapPrivilege(callc, callerClass, "registerBootstrapMethod");
+        synchronized (bootstrapMethods) {
+            return bootstrapMethods.get(callerClass);
+        }
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * The type of any bootstrap method is a three-argument method
+     * {@code (Class, String, MethodType)} returning a {@code CallSite}.
+     */
+    public static final MethodType BOOTSTRAP_METHOD_TYPE
+            = MethodType.make(CallSite.class,
+                              Class.class, String.class, MethodType.class);
+
+    private static final MethodType OLD_BOOTSTRAP_METHOD_TYPE
+            = MethodType.make(Object.class,
+                              CallSite.class, Object[].class);
+
+    private static final WeakHashMap<Class, MethodHandle> bootstrapMethods =
+            new WeakHashMap<Class, MethodHandle>();
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Invalidate all <code>invokedynamic</code> call sites everywhere.
+     * <p>
+     * When this method returns, every <code>invokedynamic</code> instruction
+     * will invoke its bootstrap method on next call.
+     * <p>
+     * It is unspecified whether call sites already known to the Java
+     * code will continue to be associated with <code>invokedynamic</code>
+     * instructions.  If any call site is still so associated, its
+     * {@link CallSite#getTarget()} method is guaranteed to return null
+     * the invalidation operation completes.
+     * <p>
+     * Invalidation operations are likely to be slow.  Use them sparingly.
+     */
+    public static
+    Object invalidateAll() {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            security.checkPermission(new LinkagePermission("invalidateAll"));
+        }
+        throw new UnsupportedOperationException("NYI");
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Invalidate all <code>invokedynamic</code> call sites associated
+     * with the given class.
+     * (These are exactly those sites which report the given class
+     * via the {@link CallSite#callerClass()} method.)
+     * <p>
+     * When this method returns, every matching <code>invokedynamic</code>
+     * instruction will invoke its bootstrap method on next call.
+     * <p>
+     * For additional semantics of call site invalidation,
+     * see {@link #invalidateAll()}.
+     */
+    public static
+    Object invalidateCallerClass(Class<?> callerClass) {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            security.checkPermission(new LinkagePermission("invalidateAll", callerClass));
+        }
+        throw new UnsupportedOperationException("NYI");
+    }
+
+    private static Object doNotBootstrap(CallSite site, Object... arguments) {
+        throw new UnsupportedOperationException("call site must not have null target: "+site);
+    }
+
+    private static final MethodHandle DO_NOT_BOOTSTRAP =
+            MethodHandles.Lookup.IMPL_LOOKUP.findStatic(Linkage.class, "doNotBootstrap",
+                OLD_BOOTSTRAP_METHOD_TYPE);
+
+    // Up-call from the JVM.  Obsolete.  FIXME: Delete from VM then from here.
+    static
+    MethodHandle findBootstrapMethod(Class callerClass, Class searchBootstrapClass) {
+        return DO_NOT_BOOTSTRAP;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/LinkagePermission.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+import java.security.*;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+
+/**
+ * This class is for runtime permissions. A RuntimePermission
+ * contains a name (also referred to as a "target name") but
+ * no actions list; you either have the named permission
+ * or you don't.
+ *
+ * <P>
+ * The target name is the name of the runtime permission (see below). The
+ * naming convention follows the  hierarchical property naming convention.
+ * Also, an asterisk
+ * may appear at the end of the name, following a ".", or by itself, to
+ * signify a wildcard match. For example: "loadLibrary.*" or "*" is valid,
+ * "*loadLibrary" or "a*b" is not valid.
+ * <P>
+ * The following table lists all the possible RuntimePermission target names,
+ * and for each provides a description of what the permission allows
+ * and a discussion of the risks of granting code the permission.
+ * <P>
+ *
+ * <table border=1 cellpadding=5 summary="permission target name,
+ *  what the target allows,and associated risks">
+ * <tr>
+ * <th>Permission Target Name</th>
+ * <th>What the Permission Allows</th>
+ * <th>Risks of Allowing this Permission</th>
+ * </tr>
+ *
+ * <tr>
+ *   <td>registerBootstrapMethod.{class name}</td>
+ *   <td>Specifying a bootstrap method for invokedynamic, within a class of the given name</td>
+ *   <td>An attacker could attempt to attach a bootstrap method to a class which
+ *       has just been loaded, thus gaining control of its invokedynamic calls.</td>
+ * </tr>
+ *
+ * <tr>
+ *   <td>invalidateAll</td>
+ *   <td>Force the relinking of invokedynamic call sites everywhere.</td>
+ *   <td>This could allow an attacker to slow down the system, or perhaps surface timing bugs in a dynamic language implementations, by forcing redundant relinking operations.</td>
+ * </tr>
+ *
+ *
+ * <tr>
+ *   <td>invalidateCallerClass.{class name}</td>
+ *   <td>Force the relinking of invokedynamic call sites in the given class.</td>
+ *   <td>See {@code invalidateAll}.</td>
+ * </tr>
+ * </table>
+ *
+ * @see java.security.BasicPermission
+ * @see java.lang.SecurityManager
+ *
+ * @author John Rose, JSR 292 EG
+ */
+
+public final class LinkagePermission extends BasicPermission {
+    /**
+     * Create a new LinkagePermission with the given name.
+     * The name is the symbolic name of the LinkagePermission, such as
+     * "registerBootstrapMethod", "invalidateClass.*", etc. An asterisk
+     * may appear at the end of the name, following a ".", or by itself, to
+     * signify a wildcard match.
+     *
+     * @param name the name of the LinkagePermission
+     */
+    public LinkagePermission(String name) {
+        super(name);
+    }
+
+    /**
+     * Create a new LinkagePermission with the given name on the given class.
+     * Equivalent to {@code LinkagePermission(name+"."+clazz.getName())}.
+     *
+     * @param name the name of the LinkagePermission
+     * @param clazz the class affected by the permission
+     */
+    public LinkagePermission(String name, Class<?> clazz) {
+        super(name + "." + clazz.getName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/MethodHandle.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+//import sun.dyn.*;
+
+import sun.dyn.Access;
+import sun.dyn.MethodHandleImpl;
+
+/**
+ * A method handle is a typed reference to the entry point of a method.
+ * <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 exactly matches
+ * the method handle's own type.
+ * <p>
+ * Every method handle confesses its type via the <code>type</code> accessor.
+ * The structure of this type is a series of classes, one of which is
+ * the return type of the method (or <code>void.class</code> if none).
+ * <p>
+ * Every method handle appears as an object containing a method named
+ * <code>invoke</code>, whose signature exactly matches
+ * the method handle's type.
+ * A normal Java method call (using the <code>invokevirtual</code> instruction)
+ * can invoke this method from Java source code (if language support is present).
+ * <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</code> instruction,
+ * via a {@code CONSTANT_NameAndType} constant pool entry.)
+ * The call looks within the receiver object for a method
+ * named <code>invoke</code> of the intended method type.
+ * The call fails with a {@link WrongMethodTypeException}
+ * if the method does not exist, even if there is an <code>invoke</code>
+ * method of a closely similar signature.
+ * <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.
+ * They should not be passed to untrusted code.
+ * <p>
+ * Bytecode in an extended JVM can directly call a method handle's
+ * <code>invoke</code> from an <code>invokevirtual</code> instruction.
+ * The receiver class type must be <code>MethodHandle</code> and the method name
+ * must be <code>invoke</code>.  The signature of the invocation
+ * (after resolving symbolic type names) must exactly match the method type
+ * of the target method.
+ * <p>
+ * Bytecode in an extended JVM can directly obtain a method handle
+ * for any accessible method from a <code>ldc</code> instruction
+ * which refers to a <code>CONSTANT_Methodref</code> or
+ * <code>CONSTANT_InterfaceMethodref</code> constant pool entry.
+ * <p>
+ * All JVMs can also use a reflective API called <code>MethodHandles</code>
+ * for creating and calling method handles.
+ * <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
+ * receiver argument, prepended before any other arguments.
+ * In the method handle's type, the initial receiver argument is typed
+ * according to the class under which the method was initially requested.
+ * (E.g., if a non-static method handle is obtained via <code>ldc</code>,
+ * the type of the receiver is the class named in the constant pool entry.)
+ * <p>
+ * 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
+ * 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</code> instruction to the same method.
+ *
+ * @see MethodType
+ * @see MethodHandles
+ * @author John Rose, JSR 292 EG
+ */
+public abstract class MethodHandle
+        // Note: This is an implementation inheritance hack, and will be removed
+        // with a JVM change which moves the required hidden state onto this class.
+        extends MethodHandleImpl
+{
+    // interface MethodHandle<T extends MethodType<R,A...>>
+    // { T type(); <R,A...> public R invoke(A...); }
+
+    final private MethodType type;
+
+    /**
+     * Report the type of this method handle.
+     * Every invocation of this method handle must exactly match this type.
+     * @return the method handle type
+     */
+    public MethodType type() {
+        return type;
+    }
+
+    /**
+     * The constructor for MethodHandle may only be called by privileged code.
+     * Subclasses may be in other packages, but must possess
+     * a token which they obtained from MH with a security check.
+     * @param token non-null object which proves access permission
+     * @param type type (permanently assigned) of the new method handle
+     */
+    protected MethodHandle(Access token, MethodType type) {
+        super(token);
+        this.type = type;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/MethodHandles.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,1104 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+import java.lang.reflect.Constructor;
+import sun.dyn.Access;
+import sun.dyn.MemberName;
+import sun.dyn.MethodHandleImpl;
+import sun.dyn.util.VerifyAccess;
+import sun.dyn.util.Wrapper;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import sun.dyn.Invokers;
+import sun.dyn.MethodTypeImpl;
+import sun.reflect.Reflection;
+import static sun.dyn.MemberName.newIllegalArgumentException;
+import static sun.dyn.MemberName.newNoAccessException;
+
+/**
+ * Fundamental operations and utilities for MethodHandle.
+ * <p>
+ * <em>API Note:</em>  The matching of method types in this API cannot
+ * be completely checked by Java's generic type system for three reasons:
+ * <ol>
+ * <li>Method types range over all possible arities,
+ * from no arguments to an arbitrary number of arguments.
+ * Generics are not variadic, and so cannot represent this.</li>
+ * <li>Method types can specify arguments of primitive types,
+ * which Java generic types cannot range over.</li>
+ * <li>Method types can optionally specify varargs (ellipsis).</li>
+ * </ol>
+ * @author John Rose, JSR 292 EG
+ */
+public class MethodHandles {
+
+    private MethodHandles() { }  // do not instantiate
+
+    private static final Access IMPL_TOKEN = Access.getToken();
+    private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory(IMPL_TOKEN);
+    static { MethodHandleImpl.initStatics(); }
+    // See IMPL_LOOKUP below.
+
+    //// Method handle creation from ordinary methods.
+
+    public static Lookup lookup() {
+        return new Lookup();
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * A factory object for creating method handles, when the creation
+     * requires access checking.  Method handles do not perform
+     * access checks when they are called; this is a major difference
+     * from reflective {@link Method}, which performs access checking
+     * against every caller, on every call.  Method handle access
+     * restrictions are enforced when a method handle is created.
+     * The caller class against which those restrictions are enforced
+     * is known as the "lookup class".  {@link Lookup} embodies an
+     * authenticated lookup class, and 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
+     * {@code 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 {@code 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.
+     * <p>
+     * Note that access checks only apply to named and reflected methods.
+     * Other method handle creation methods, such as {@link #convertArguments},
+     * do not require any access checks, and can be done independently
+     * of any lookup class.
+     * <p>
+     * <em>A note about error conditions:<em>  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 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}.
+     * At least some of these error conditions are likely to be
+     * represented by checked exceptions in the final version of this API.
+     */
+    public static final
+    class Lookup {
+        private final Class<?> lookupClass;
+
+        /** Which class is performing the lookup?  It is this class against
+         *  which checks are performed for visibility and access permissions.
+         *  <p>
+         *  This value is null if and only if this lookup is {@link #PUBLIC_LOOKUP}.
+         */
+        public Class<?> lookupClass() {
+            return lookupClass;
+        }
+
+        /** Embody the current class (the lookupClass) as a lookup class
+         * for method handle creation.
+         * Must be called by from a method in this package,
+         * which in turn is called by a method not in this package.
+         * Also, don't make it private, lest javac interpose
+         * an access$N method.
+         */
+        Lookup() {
+            Class caller = getCallerClassAtEntryPoint();
+            // make sure we haven't accidentally picked up this class:
+            checkUnprivilegedlookupClass(caller);
+            this.lookupClass = caller;
+        }
+
+        private Lookup(Class<?> lookupClass) {
+            this.lookupClass = lookupClass;
+        }
+
+        private static final Class<?> PUBLIC_ONLY = sun.dyn.empty.Empty.class;
+
+        /** Version of lookup which is trusted minimally.
+         *  It can only be used to create method handles to
+         *  publicly accessible members.
+         */
+        public static final Lookup PUBLIC_LOOKUP = new Lookup(PUBLIC_ONLY);
+
+        /** Package-private version of lookup which is trusted. */
+        static final Lookup IMPL_LOOKUP = new Lookup(null);
+        static { MethodHandleImpl.initLookup(IMPL_TOKEN, IMPL_LOOKUP); }
+
+        private static void checkUnprivilegedlookupClass(Class<?> lookupClass) {
+            String name = lookupClass.getName();
+            if (name.startsWith("java.dyn.") || name.startsWith("sun.dyn."))
+                throw newIllegalArgumentException("illegal lookupClass: "+lookupClass);
+        }
+
+        @Override
+        public String toString() {
+            if (lookupClass == PUBLIC_ONLY)
+                return "public";
+            if (lookupClass == null)
+                return "privileged";
+            return lookupClass.getName();
+        }
+
+        // call this from an entry point method in Lookup with extraFrames=0.
+        private static Class<?> getCallerClassAtEntryPoint() {
+            final int CALLER_DEPTH = 4;
+            // 0: Reflection.getCC, 1: getCallerClassAtEntryPoint,
+            // 2: Lookup.<init>, 3: MethodHandles.*, 4: caller
+            // Note:  This should be the only use of getCallerClass in this file.
+            return Reflection.getCallerClass(CALLER_DEPTH);
+        }
+
+        /**
+         * Produce a method handle for a static method.
+         * The type of the method handle will be that of the method.
+         * 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.
+         * @param defc 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 SecurityException <em>TBD</em>
+         * @exception NoAccessException if the method does not exist or access checking fails
+         */
+        public
+        MethodHandle findStatic(Class<?> defc, String name, MethodType type) throws NoAccessException {
+            MemberName method = IMPL_NAMES.resolveOrFail(new MemberName(defc, name, type, Modifier.STATIC), true, lookupClass);
+            checkStatic(true, method, lookupClass);
+            //throw NoSuchMethodException
+            return MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, lookupClass);
+        }
+
+        /**
+         * Produce a method handle for a virtual method.
+         * The type of the method handle will be that of the method,
+         * with the receiver type ({@code defc}) prepended.
+         * The method and all its argument types must be accessible to the lookup class.
+         * <p>
+         * (<em>BUG NOTE:</em> The type {@code Object} may be prepended instead
+         * of the receiver type, if the receiver type is not on the boot class path.
+         * This is due to a temporary JVM limitation, in which MethodHandle
+         * claims to be unable to access such classes.  To work around this
+         * bug, use {@code convertArguments} to normalize the type of the leading
+         * argument to a type on the boot class path, such as {@code Object}.)
+         * <p>
+         * When called, the handle will treat the first argument as a receiver
+         * and dispatch on the receiver's type to determine which method
+         * implementation to enter.
+         * (The dispatching action is identical with that performed by an
+         * {@code invokevirtual} or {@code invokeinterface} instruction.)
+         * @param defc 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 SecurityException <em>TBD</em>
+         * @exception NoAccessException if the method does not exist or access checking fails
+         */
+        public MethodHandle findVirtual(Class<?> defc, String name, MethodType type) throws NoAccessException {
+            MemberName method = IMPL_NAMES.resolveOrFail(new MemberName(defc, name, type), true, lookupClass);
+            checkStatic(false, method, lookupClass);
+            return MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClass);
+        }
+
+        /**
+         * Produce 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,
+         * with a suitably restricted receiver type (such as {@code caller}) prepended.
+         * The method and all its argument types must be accessible
+         * to the caller.
+         * <p>
+         * When called, the handle will treat the first argument as a receiver,
+         * but will not dispatch on the receiver's type.
+         * (This direct invocation action is identical with that performed by an
+         * {@code invokespecial} instruction.)
+         * <p>
+         * If the explicitly specified caller class is not identical with the
+         * lookup class, a security check TBD is performed.
+         * @param defc the class or interface from which the method is accessed
+         * @param name the name of the method, or "<init>" for a constructor
+         * @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 SecurityException <em>TBD</em>
+         * @exception NoAccessException if the method does not exist or access checking fails
+         */
+        public MethodHandle findSpecial(Class<?> defc, String name, MethodType type,
+                                        Class<?> specialCaller) throws NoAccessException {
+            checkSpecialCaller(specialCaller, lookupClass);
+            MemberName method = IMPL_NAMES.resolveOrFail(new MemberName(defc, name, type), false, specialCaller);
+            checkStatic(false, method, lookupClass);
+            if (name.equals("<init>")) {
+                throw newNoAccessException("cannot directly invoke a constructor", method, null);
+            } else if (defc.isInterface() || !defc.isAssignableFrom(specialCaller)) {
+                throw newNoAccessException("method must be in a superclass of lookup class", method, lookupClass);
+            }
+            return MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, specialCaller);
+        }
+
+        /**
+         * Produce 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.
+         * The type of the method handle will be that of the method.
+         * The given receiver will be bound into the method handle.
+         * <p>
+         * Equivalent to the following expression:
+         * <code>
+         * {@link #insertArgument}({@link #findVirtual}(defc, name, type), receiver)
+         * </code>
+         * @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 SecurityException <em>TBD</em>
+         * @exception NoAccessException if the method does not exist or access checking fails
+         */
+        public MethodHandle bind(Object receiver, String name, MethodType type) throws NoAccessException {
+            Class<? extends Object> rcvc = receiver.getClass(); // may get NPE
+            MemberName reference = new MemberName(rcvc, name, type);
+            MemberName method = IMPL_NAMES.resolveOrFail(reference, true, lookupClass);
+            checkStatic(false, method, lookupClass);
+            MethodHandle dmh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClass);
+            MethodHandle bmh = MethodHandleImpl.bindReceiver(IMPL_TOKEN, dmh, receiver);
+            if (bmh == null)
+                throw newNoAccessException(method, lookupClass);
+            return bmh;
+        }
+
+        /**
+         * Make a direct method handle to <i>m</i>, if the lookup class has permission.
+         * If <i>m</i> is non-static, the receiver argument is treated as an initial argument.
+         * If <i>m</i> is virtual, overriding is respected on every call.
+         * Unlike the Core Reflection API, exceptions are <em>not</em> wrapped.
+         * The type of the method handle will be that of the method,
+         * with the receiver type prepended (but only if it is non-static).
+         * 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.
+         * @param m the reflected method
+         * @return a method handle which can invoke the reflected method
+         * @exception NoAccessException if access checking fails
+         */
+        public MethodHandle unreflect(Method m) throws NoAccessException {
+            return unreflectImpl(new MemberName(m), m.isAccessible(), true, lookupClass);
+        }
+
+        /**
+         * Produce a method handle for a reflected method.
+         * It will bypass checks for overriding methods on the receiver,
+         * as if by the {@code invokespecial} instruction.
+         * The type of the method handle will be that of the method,
+         * with the receiver type prepended.
+         * 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.
+         * @param m the reflected method
+         * @return a method handle which can invoke the reflected method
+         * @exception NoAccessException if access checking fails
+         */
+        public MethodHandle unreflectSpecial(Method m, Class<?> specialCaller) throws NoAccessException {
+            checkSpecialCaller(specialCaller, lookupClass);
+            MemberName mname = new MemberName(m);
+            checkStatic(false, mname, lookupClass);
+            return unreflectImpl(mname, m.isAccessible(), false, specialCaller);
+        }
+
+        /**
+         * Produce a method handle for a reflected constructor.
+         * The type of the method handle will be that of the constructor.
+         * The method handle will perform a {@code newInstance} operation,
+         * creating a new instance of the constructor's class on the
+         * arguments passed to the method handle.
+         * <p>
+         * If the constructor'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.
+         * @param ctor the reflected constructor
+         * @return a method handle which can invoke the reflected constructor
+         * @exception NoAccessException if access checking fails
+         */
+        public MethodHandle unreflectConstructor(Constructor ctor) throws NoAccessException {
+            MemberName m = new MemberName(ctor);
+            return unreflectImpl(m, ctor.isAccessible(), false, lookupClass);
+        }
+
+        /**
+         * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+         * Produce 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.  Its sole argument will be the field's containing class
+         * (but only if it is non-static).
+         * If the method's {@code accessible} flag is not set,
+         * 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
+         */
+        public MethodHandle unreflectGetter(Field f) throws NoAccessException {
+            return MethodHandleImpl.accessField(IMPL_TOKEN, new MemberName(f), false, lookupClass);
+        }
+
+        /**
+         * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+         * Produce a method handle giving write access to a reflected field.
+         * The type of the method handle will have a void return type.
+         * Its last argument will be the field's value type.
+         * Its other argument will be the field's containing class
+         * (but only if it is non-static).
+         * If the method's {@code accessible} flag is not set,
+         * 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
+         */
+        public MethodHandle unreflectSetter(Field f) throws NoAccessException {
+            return MethodHandleImpl.accessField(IMPL_TOKEN, new MemberName(f), true, lookupClass);
+        }
+
+    }
+
+    static /*must not be public*/
+    MethodHandle findStaticFrom(Class<?> lookupClass,
+                                Class<?> defc, String name, MethodType type) throws NoAccessException {
+        MemberName method = IMPL_NAMES.resolveOrFail(new MemberName(defc, name, type, Modifier.STATIC), true, lookupClass);
+        checkStatic(true, method, lookupClass);
+        return MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, lookupClass);
+    }
+
+    static void checkStatic(boolean wantStatic, MemberName m, Class<?> lookupClass) {
+        if (wantStatic != m.isStatic()) {
+            String message = wantStatic ? "expected a static method" : "expected a non-static method";
+            throw newNoAccessException(message, m, lookupClass);
+        }
+    }
+
+    static void checkSpecialCaller(Class<?> specialCaller, Class<?> lookupClass) {
+        if (lookupClass == Lookup.IMPL_LOOKUP.lookupClass())
+            return;  // privileged action
+        if (lookupClass == null ||  // public-only access
+            !VerifyAccess.isSamePackageMember(specialCaller, lookupClass))
+            throw newNoAccessException("no private access", new MemberName(specialCaller), lookupClass);
+    }
+
+    // Helper for creating handles on reflected methods and constructors.
+    static MethodHandle unreflectImpl(MemberName m, boolean isAccessible,
+                                      boolean doDispatch, Class<?> lookupClass) {
+        MethodType mtype = m.getInvocationType();
+        Class<?> defc = m.getDeclaringClass();
+        int mods = m.getModifiers();
+        if (m.isStatic()) {
+            if (!isAccessible &&
+                    VerifyAccess.isAccessible(defc, mods, false, lookupClass) == null)
+                throw newNoAccessException(m, lookupClass);
+        } else {
+            Class<?> constraint;
+            if (isAccessible) {
+                // abbreviated access check for "unlocked" method
+                constraint = doDispatch ? defc : lookupClass;
+            } else {
+                constraint = VerifyAccess.isAccessible(defc, mods, doDispatch, lookupClass);
+            }
+            if (constraint != defc && !constraint.isAssignableFrom(defc)) {
+                if (!defc.isAssignableFrom(constraint))
+                    throw newNoAccessException("receiver must be in caller class", m, lookupClass);
+                mtype = mtype.changeParameterType(0, constraint);
+            }
+        }
+        return MethodHandleImpl.findMethod(IMPL_TOKEN, m, doDispatch, lookupClass);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce 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  IllegalArgumentException if arrayClass is not an array type
+     */
+    public static
+    MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
+        return MethodHandleImpl.accessArrayElement(IMPL_TOKEN, arrayClass, false);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce 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 IllegalArgumentException if arrayClass is not an array type
+     */
+    public static
+    MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
+        return MethodHandleImpl.accessArrayElement(IMPL_TOKEN, arrayClass, true);
+    }
+
+
+    /// method handle invocation (reflective style)
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Call the {@code invoke} method of a given method handle,
+     * with arguments that exactly match the parameter types of the method handle.
+     * The length of the arguments array must equal the parameter count
+     * of the target's type.
+     * The arguments array is spread into separate arguments, and
+     * basic reference and unboxing conversions are applied.
+     * <p>
+     * In order to match the type of the target, the following argument
+     * conversions are applied as necessary:
+     * <ul>
+     * <li>reference casting
+     * <li>unboxing
+     * </ul>
+     * The following conversions are not applied:
+     * <ul>
+     * <li>primitive conversions (e.g., {@code byte} to {@code int}
+     * <li>varargs conversions other than the initial spread
+     * <li>any application-specific conversions (e.g., string to number)
+     * </ul>
+     * The result returned by the call is boxed if it is a primitive,
+     * or forced to null if the return type is void.
+     * <p>
+     * This call is a convenience method for the following code:
+     * <pre>
+     *   MethodHandle invoker = MethodHandles.genericInvoker(target.type(), 0, true);
+     *   Object result = invoker.invoke(arguments);
+     * </pre>
+     * @param target the method handle to invoke
+     * @param arguments the arguments to pass to the target
+     * @return the result returned by the target
+     */
+    public static
+    Object invoke(MethodHandle target, Object... arguments) {
+        int argc = arguments == null ? 0 : arguments.length;
+        MethodType type = target.type();
+        if (argc <= 4) {
+            MethodHandle invoker = invokers(type).genericInvoker();
+            switch (argc) {
+                case 0:  return invoker.<Object>invoke(target);
+                case 1:  return invoker.<Object>invoke(target,
+                                    arguments[0]);
+                case 2:  return invoker.<Object>invoke(target,
+                                    arguments[0], arguments[1]);
+                case 3:  return invoker.<Object>invoke(target,
+                                    arguments[0], arguments[1], arguments[2]);
+                case 4:  return invoker.<Object>invoke(target,
+                                    arguments[0], arguments[1], arguments[2], arguments[3]);
+            }
+        }
+        MethodHandle invoker = invokers(type).varargsInvoker();
+        return invoker.<Object>invoke(target, arguments);
+    }
+
+    public static
+    Object invoke_0(MethodHandle target) {
+        MethodHandle invoker = invokers(target.type()).genericInvoker();
+        return invoker.<Object>invoke(target);
+    }
+    public static
+    Object invoke_1(MethodHandle target, Object a0) {
+        MethodHandle invoker = invokers(target.type()).genericInvoker();
+        return invoker.<Object>invoke(target, a0);
+    }
+    public static
+    Object invoke_2(MethodHandle target, Object a0, Object a1) {
+        MethodHandle invoker = invokers(target.type()).genericInvoker();
+        return invoker.<Object>invoke(target, a0, a1);
+    }
+    public static
+    Object invoke_3(MethodHandle target, Object a0, Object a1, Object a2) {
+        MethodHandle invoker = invokers(target.type()).genericInvoker();
+        return invoker.<Object>invoke(target, a0, a1, a2);
+    }
+    public static
+    Object invoke_4(MethodHandle target, Object a0, Object a1, Object a2, Object a3) {
+        MethodHandle invoker = invokers(target.type()).genericInvoker();
+        return invoker.<Object>invoke(target, a0, a1, a2, a3);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Give a method handle which will invoke any method handle of the
+     * given type on a standard set of {@code Object} type arguments.
+     * The 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
+     * <li>an optional {@code Object[]} array containing more arguments
+     * </ul>
+     * The invoker will spread the varargs array (if present), apply
+     * reference casts as necessary, and unbox primitive arguments.
+     * 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 is a convenience method equivalent to the following code:
+     * <pre>
+     * MethodHandle invoker = exactInvoker(type);
+     * MethodType genericType = MethodType.makeGeneric(objectArgCount, varargs);
+     * genericType = genericType.insertParameterType(0, MethodHandle.class);
+     * if (!varargs)
+     *     return convertArguments(invoker, genericType);
+     * else
+     *     return spreadArguments(invoker, genericType);
+     * </pre>
+     * @param type the desired target type
+     * @param objectArgCount number of fixed (non-varargs) {@code Object} arguments
+     * @param varargs if true, the invoker will accept a final {@code Object[]} argument
+     * @return a method handle suitable for invoking any method handle of the given type
+     */
+    static public
+    MethodHandle genericInvoker(MethodType type, int objectArgCount, boolean varargs) {
+        return invokers(type).genericInvoker();
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Give a method handle which will take a invoke any method handle of the
+     * given type.  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 is a convenience method equivalent to the following code:
+     * <pre>
+     *     MethodHandles.lookup().findVirtual(MethodHandle.class, "invoke", type);
+     * </pre>
+     * @param type the desired target type
+     * @return a method handle suitable for invoking any method handle of the given type
+     */
+    static public
+    MethodHandle exactInvoker(MethodType type) {
+        return invokers(type).exactInvoker();
+    }
+
+    static private 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.
+     * The following checks and conversions are made:
+     * <ul>
+     * <li>If T0 and T1 are references, then a cast to T1 is applied.
+     *     (The types do not need to be related in any particular way.)
+     * <li>If T0 and T1 are primitives, then a widening or narrowing
+     *     conversion is applied, if one exists.
+     * <li>If T0 is a primitive and T1 a reference, and
+     *     T0 has a wrapper type TW, a boxing conversion to TW is applied,
+     *     possibly followed by a reference conversion.
+     *     T1 must be TW or a supertype.
+     * <li>If T0 is a reference and T1 a primitive, and
+     *     T1 has a wrapper type TW, an unboxing conversion is applied,
+     *     possibly preceded by a reference conversion.
+     *     T0 must be TW or a supertype.
+     * <li>If T1 is void, the return value is discarded
+     * <li>If T0 is void and T1 a reference, a null value is introduced.
+     * <li>If T0 is void and T1 a primitive, a zero value is introduced.
+     * </ul>
+     * If the value is discarded, null will be returned.
+     * @param valueType
+     * @param value
+     * @return the value, converted if necessary
+     * @throws java.lang.ClassCastException if a cast fails
+     */
+    static
+    <T0, T1> T1 checkValue(Class<T0> t0, Class<T1> t1, Object value)
+       throws ClassCastException
+    {
+        if (t0 == t1) {
+            // no conversion needed; just reassert the same type
+            if (t0.isPrimitive())
+                return Wrapper.asPrimitiveType(t1).cast(value);
+            else
+                return Wrapper.OBJECT.cast(value, t1);
+        }
+        boolean prim0 = t0.isPrimitive(), prim1 = t1.isPrimitive();
+        if (!prim0) {
+            // check contract with caller
+            Wrapper.OBJECT.cast(value, t0);
+            if (!prim1) {
+                return Wrapper.OBJECT.cast(value, t1);
+            }
+            // convert reference to primitive by unboxing
+            Wrapper w1 = Wrapper.forPrimitiveType(t1);
+            return w1.cast(value, t1);
+        }
+        // check contract with caller:
+        Wrapper.asWrapperType(t0).cast(value);
+        Wrapper w1 = Wrapper.forPrimitiveType(t1);
+        return w1.cast(value, t1);
+    }
+
+    static
+    Object checkValue(Class<?> T1, Object value)
+       throws ClassCastException
+    {
+        Class<?> T0;
+        if (value == null)
+            T0 = Object.class;
+        else
+            T0 = value.getClass();
+        return checkValue(T0, T1, value);
+    }
+
+    /// method handle modification (creation from other method handles)
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce a method handle which adapts the type of the
+     * given method handle to a new type, by pairwise argument conversion,
+     * and/or varargs conversion.
+     * The original type and new type must have the same number of
+     * arguments, or else one or both them the must be varargs types.
+     * The resulting method handle is guaranteed to confess a type
+     * which is equal to the desired new type, with any varargs property erased.
+     * <p>
+     * If the original type and new type are equal, returns target.
+     * <p>
+     * The following conversions are applied as needed both to
+     * arguments and return types.  Let T0 and T1 be the differing
+     * new and old parameter types (or old and new return types)
+     * for corresponding values passed by the new and old method types.
+     * <p>
+     * If an ordinary (non-varargs) parameter of the new type is
+     * to be boxed in a varargs parameter of the old type of type T1[],
+     * then T1 is the element type of the varargs array.
+     * Otherwise, if a varargs parameter of the new type of type T0[]
+     * is to be spread into one or more outgoing old type parameters,
+     * then T0 is the element type of the
+     * If the new type is varargs and the old type is not, the varargs
+     * argument will be checked and must be a non-null array of exactly
+     * the right length.  If there are no parameters in the old type
+     * corresponding to the new varargs parameter, the varargs argument
+     * is also allowed to be null.
+     * <p>
+     * Given those types T0, T1, one of the following conversions is applied
+     * if possible:
+     * <ul>
+     * <li>If T0 and T1 are references, then a cast to T2 is applied,
+     *     where T2 is Object if T1 is an interface, else T1.
+     *     (The types do not need to be related in any particular way.
+     *     The treatment of interfaces follows the usage of the bytecode verifier.)
+     * <li>If T0 and T1 are primitives, then a Java casting
+     *     conversion (JLS 5.5) is applied, if one exists.
+     * <li>If T0 and T1 are primitives and one is boolean,
+     *     the boolean is treated as a one-bit unsigned integer.
+     *     (This treatment follows the usage of the bytecode verifier.)
+     *     A conversion from another primitive type behaves as if
+     *     it first converts to byte, and then masks all but the low bit.
+     * <li>If T0 is a primitive and T1 a reference, a boxing
+     *     conversion is applied if one exists, possibly followed by
+     *     an reference conversion to a superclass.
+     *     T1 must be a wrapper class or a supertype of one.
+     *     If T1 is a wrapper class, T0 is converted if necessary
+     *     to T1's primitive type by one of the preceding conversions.
+     *     Otherwise, T0 is boxed, and its wrapper converted to T1.
+     * <li>If T0 is a reference and T1 a primitive, an unboxing
+     *     conversion is applied if one exists, possibly preceded by
+     *     a reference conversion to a wrapper class.
+     *     T0 must be a wrapper class or a supertype of one.
+     *     If T0 is a wrapper class, its primitive value is converted
+     *     if necessary to T1 by one of the preceding conversions.
+     *     Otherwise, T0 is converted directly to the wrapper type for T1,
+     *     which is then unboxed.
+     * <li>If T1 is void, any returned value is discarded
+     * <li>If T0 is void and T1 a reference, a null value is introduced.
+     * <li>If T0 is void and T1 a primitive, a zero value is introduced.
+     * </ul>
+     * @param target the method handle to invoke after arguments are retyped
+     * @param newType the expected type of the new method handle
+     * @return a method handle which delegates to {@code target} after performing
+     *           any necessary argument conversions, and arranges for any
+     *           necessary return value conversions
+     * @throws WrongMethodTypeException if the conversion cannot be made
+     */
+    public static
+    MethodHandle convertArguments(MethodHandle target, MethodType newType) {
+        MethodType oldType = target.type();
+        if (oldType.equals(newType))
+            return target;
+        MethodHandle res = MethodHandleImpl.convertArguments(IMPL_TOKEN, target,
+                                                 newType, oldType, null);
+        if (res == null)
+            throw newIllegalArgumentException("cannot convert to "+newType+": "+target);
+        return res;
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce 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 confess a type
+     * which is equal to the desired new type.
+     * <p>
+     * The given array controls the reordering.
+     * Call {@code #I} the number of incoming parameters (the value
+     * {@code newType.parameterCount()}, and call {@code #O} the number
+     * of outgoing parameters (the value {@code target.type().parameterCount()}).
+     * Then the length of the reordering array must be {@code #O},
+     * and each element must be a non-negative number less than {@code #I}.
+     * For every {@code N} less than {@code #O}, the {@code N}-th
+     * outgoing argument will be taken from the {@code I}-th incoming
+     * argument, where {@code I} is {@code reorder[N]}.
+     * <p>
+     * The reordering array need not specify an actual permutation.
+     * An incoming argument will be duplicated if its index appears
+     * more than once in the array, and an incoming argument will be dropped
+     * if its index does not appear in the array.
+     * <p>
+     * Pairwise conversions are applied as needed to arguments and return
+     * values, as with {@link #convertArguments}.
+     * @param target the method handle to invoke after arguments are reordered
+     * @param newType the expected type of the new method handle
+     * @param reorder a string which controls the reordering
+     * @return a method handle which delegates to {@code target} after performing
+     *           any necessary argument motion and conversions, and arranges for any
+     *           necessary return value conversions
+     */
+    public static
+    MethodHandle permuteArguments(MethodHandle target, MethodType newType, int[] reorder) {
+        MethodType oldType = target.type();
+        checkReorder(reorder, newType, oldType);
+        return MethodHandleImpl.convertArguments(IMPL_TOKEN, target,
+                                                 newType, oldType,
+                                                 reorder);
+    }
+
+    private static void checkReorder(int[] reorder, MethodType newType, MethodType oldType) {
+        if (reorder.length == oldType.parameterCount()) {
+            int limit = newType.parameterCount();
+            boolean bad = false;
+            for (int i : reorder) {
+                if (i < 0 || i >= limit) {
+                    bad = true; break;
+                }
+            }
+            if (!bad)  return;
+        }
+        throw newIllegalArgumentException("bad reorder array");
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce a method handle which adapts the type of the
+     * given method handle to a new type, by spreading the final argument.
+     * The resulting method handle is guaranteed to confess a type
+     * which is equal to the desired new type.
+     * <p>
+     * The final parameter type of the new type must be an array type T[].
+     * This is the type of what is called the <i>spread</i> argument.
+     * All other arguments of the new type are called <i>ordinary</i> arguments.
+     * <p>
+     * The ordinary arguments of the new type are pairwise converted
+     * to the initial parameter types of the old type, according to the
+     * rules in {@link #convertArguments}.
+     * Any additional arguments in the old type
+     * are converted from the array element type T,
+     * again according to the rules in {@link #convertArguments}.
+     * The return value is converted according likewise.
+     * <p>
+     * The call verifies that the spread argument is in fact an array
+     * of exactly the type length, i.e., the excess number of
+     * arguments in the old type over the ordinary arguments in the new type.
+     * If there are no excess arguments, the spread argument is also
+     * allowed to be null.
+     * @param target the method handle to invoke after the argument is prepended
+     * @param newType the expected type of the new method handle
+     * @return a new method handle which spreads its final argument,
+     *         before calling the original method handle
+     */
+    public static
+    MethodHandle spreadArguments(MethodHandle target, MethodType newType) {
+        MethodType oldType = target.type();
+        int inargs  = newType.parameterCount();
+        int outargs = oldType.parameterCount();
+        int spreadPos = inargs - 1;
+        int numSpread = (outargs - spreadPos);
+        MethodHandle res = null;
+        if (spreadPos >= 0 && numSpread >= 0) {
+            res = MethodHandleImpl.spreadArguments(IMPL_TOKEN, target, newType, spreadPos);
+        }
+        if (res == null) {
+            throw newIllegalArgumentException("cannot spread "+newType+" to " +oldType);
+        }
+        return res;
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce a method handle which adapts the type of the
+     * given method handle to a new type, by collecting a series of
+     * trailing arguments into an array.
+     * The resulting method handle is guaranteed to confess a type
+     * which is equal to the desired new type.
+     * <p>
+     * This method is inverse to {@link #spreadArguments}.
+     * The final parameter type of the old type must be an array type T[],
+     * which is the type of what is called the <i>spread</i> argument.
+     * The trailing arguments of the new type which correspond to
+     * the spread argument are all converted to type T and collected
+     * into an array before the original method is called.
+     * <p>
+     * ISSUE: Unify this with combineArguments.  CollectArguments
+     * is combineArguments with (a) new Object[]{...} as a combiner,
+     * and (b) the combined arguments dropped, in favor of the combined result.
+     * @param target the method handle to invoke after the argument is prepended
+     * @param newType the expected type of the new method handle
+     * @return a new method handle which collects some trailings argument
+     *         into an array, before calling the original method handle
+     */
+    public static
+    MethodHandle collectArguments(MethodHandle target, MethodType newType) {
+        MethodType oldType = target.type();
+        int inargs  = newType.parameterCount();
+        int outargs = oldType.parameterCount();
+        int collectPos = outargs - 1;
+        int numCollect = (inargs - collectPos);
+        if (collectPos < 0 || numCollect < 0)
+            throw newIllegalArgumentException("wrong number of arguments");
+        return MethodHandleImpl.collectArguments(IMPL_TOKEN, target, newType, collectPos);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce a method handle which calls the original method handle,
+     * after inserting the given argument at the given position.
+     * The type of the new method handle will drop the corresponding argument
+     * type from the original handle's type.
+     * <p>
+     * The given argument object must match the dropped argument type.
+     * If the dropped argument type is a primitive, the argument object
+     * must be a wrapper, and is unboxed to produce the primitive.
+     * <p>
+     * The  <i>pos</i> may range between zero and <i>N</i> (inclusively),
+     * where <i>N</i> is the number of argument types in <i>target</i>,
+     * meaning to insert the new argument as the first or last (respectively),
+     * or somewhere in between.
+     * @param target the method handle to invoke after the argument is inserted
+     * @param pos where to insert the argument (zero for the first)
+     * @param value the argument to insert
+     * @return a new method handle which inserts an additional argument,
+     *         before calling the original method handle
+     */
+    public static
+    MethodHandle insertArgument(MethodHandle target, int pos, Object value) {
+        MethodType oldType = target.type();
+        ArrayList<Class<?>> ptypes =
+                new ArrayList<Class<?>>(oldType.parameterList());
+        int outargs = oldType.parameterCount();
+        int inargs  = outargs - 1;
+        if (pos < 0 || pos >= outargs)
+            throw newIllegalArgumentException("no argument type to append");
+        Class<?> valueType = ptypes.remove(pos);
+        value = checkValue(valueType, value);
+        if (pos == 0 && !valueType.isPrimitive()) {
+            // At least for now, make bound method handles a special case.
+            // This lets us get by with minimal JVM support, at the expense
+            // of generating signature-specific adapters as Java bytecodes.
+            MethodHandle bmh = MethodHandleImpl.bindReceiver(IMPL_TOKEN, target, value);
+            if (bmh != null)  return bmh;
+            // else fall through to general adapter machinery
+        }
+        return MethodHandleImpl.bindArgument(IMPL_TOKEN, target, pos, value);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Produce 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.
+     * <p>
+     * The <i>pos</i> may range between zero and <i>N-1</i>,
+     * where <i>N</i> is the number of argument types in <i>target</i>,
+     * meaning to drop the first or last argument (respectively),
+     * or an argument somewhere in between.
+     * @param target the method handle to invoke after the argument is dropped
+     * @param valueTypes the type(s) of the argument to drop
+     * @param pos which argument to drop (zero for the first)
+     * @return a new method handle which drops an argument of the given type,
+     *         before calling the original method handle
+     */
+    public static
+    MethodHandle dropArguments(MethodHandle target, int pos, Class<?>... valueTypes) {
+        if (valueTypes.length == 0)  return target;
+        MethodType oldType = target.type();
+        int outargs = oldType.parameterCount();
+        int inargs  = outargs + valueTypes.length;
+        if (pos < 0 || pos >= inargs)
+            throw newIllegalArgumentException("no argument type to remove");
+        ArrayList<Class<?>> ptypes =
+                new ArrayList<Class<?>>(oldType.parameterList());
+        ptypes.addAll(pos, Arrays.asList(valueTypes));
+        MethodType newType = MethodType.make(oldType.returnType(), ptypes);
+        return MethodHandleImpl.dropArguments(IMPL_TOKEN, target, newType, pos);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Make a method handle which adapts a target method handle,
+     * by guarding it with a test, a boolean-valued method handle.
+     * If the guard fails, a fallback handle is called instead.
+     * All three method handles must have the same corresponding
+     * argument and return types, except that the return type
+     * of the test must be boolean.
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>
+     * signature T(A...);
+     * boolean test(A...);
+     * T target(A...);
+     * T fallback(A...);
+     * T adapter(A... a) {
+     *   if (test(a...))
+     *     return target(a...);
+     *   else
+     *     return fallback(a...);
+     * }
+     * </pre></blockquote>
+     * @param test method handle used for test, must return boolean
+     * @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 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}).
+     */
+    public static
+    MethodHandle guardWithTest(MethodHandle test,
+                               MethodHandle target,
+                               MethodHandle fallback) {
+        if (target.type() != fallback.type())
+            throw newIllegalArgumentException("target and fallback types do not match");
+        if (target.type().changeReturnType(boolean.class) != test.type())
+            throw newIllegalArgumentException("target and test types do not match");
+        /* {
+            MethodHandle invoke = findVirtual(MethodHandle.class, "invoke", target.type());
+            static MethodHandle choose(boolean z, MethodHandle t, MethodHandle f) {
+                return z ? t : f;
+            }
+            static MethodHandle compose(MethodHandle f, MethodHandle g) {
+                Class<?> initargs = g.type().parameterArray();
+                f = dropArguments(f, 1, initargs);  // ignore 2nd copy of args
+                return combineArguments(f, g);
+            }
+            // choose = \z.(z ? target : fallback)
+            MethodHandle choose = findVirtual(MethodHandles.class, "choose",
+                    MethodType.make(boolean.class, MethodHandle.class, MethodHandle.class));
+            choose = appendArgument(choose, target);
+            choose = appendArgument(choose, fallback);
+            MethodHandle dispatch = compose(choose, test);
+            // dispatch = \(a...).(test(a...) ? target : fallback)
+            return combineArguments(invoke, dispatch, 0);
+            // return \(a...).((test(a...) ? target : fallback).invoke(a...))
+        } */
+        return MethodHandleImpl.makeGuardWithTest(IMPL_TOKEN, test, target, fallback);
+    }
+
+    /**
+     * <em>PROVISIONAL API, WORK IN PROGRESS:</em>
+     * Adapt a target method handle {@code target} by first processing
+     * its arguments, and then calling the target.
+     * The initial processing is performed by a second method handle, the {@code combiner}.
+     * After this, control passes to the {@code target}, with the same arguments.
+     * <p>
+     * The return value of the {@code combiner} is inserted into the argument list
+     * for the {@code target} at the indicated position {@code pos}, if it is non-negative.
+     * Except for this inserted argument (if any), the argument types of
+     * the target {@code target} and the {@code combiner} must be identical.
+     * <p>
+     * (Note that {@link #dropArguments} can be used to remove any arguments
+     * that either the {@code combiner} or {@code target} does not wish to receive.)
+     * <p>
+     * The combiner handle must have the same argument types as the
+     * target handle, but must return {@link MethodHandle} instead of
+     * the ultimate return type.  The returned method handle, in turn,
+     * is required to have exactly the given final method type.
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>
+     * signature V(A[pos]..., B...);
+     * signature T(A[pos]..., V, B...);
+     * T target(A... a, V v, B... b);
+     * V combiner(A..., B...);
+     * T adapter(A... a, B... b) {
+     *   V v = combiner(a..., b...);
+     *   return target(a..., v, b...);
+     * }
+     * </pre></blockquote>
+     * @param target the method handle to invoke after arguments are combined
+     * @param pos where the return value of {@code combiner} is to
+     *          be inserted as an argument to {@code target}
+     * @param combiner method handle to call initially on the incoming arguments
+     * @return method handle which incorporates the specified dispatch logic
+     * @throws IllegalArgumentException if {@code combiner} does not itself
+     *          return either void or the {@code pos}-th argument of {@code target},
+     *          or does not have the same argument types as {@code target}
+     *          (minus the inserted argument)
+     */
+    public static
+    MethodHandle combineArguments(MethodHandle target, int pos, MethodHandle combiner) {
+        MethodType mhType = target.type();
+        Class<?> combineType = combiner.type().returnType();
+        MethodType incomingArgs;
+        if (pos < 0) {
+            // No inserted argument; target & combiner must have same argument types.
+            incomingArgs = mhType;
+            if (!incomingArgs.changeReturnType(combineType).equals(combiner.type()))
+                throw newIllegalArgumentException("target and combiner types do not match");
+        } else {
+            // Inserted argument.
+            if (pos >= mhType.parameterCount()
+                || mhType.parameterType(pos) != combineType)
+                throw newIllegalArgumentException("inserted combiner argument does not match target");
+            incomingArgs = mhType.dropParameterType(pos);
+        }
+        if (!incomingArgs.changeReturnType(combineType).equals(combiner.type())) {
+            throw newIllegalArgumentException("target and combiner types do not match");
+        }
+        return MethodHandleImpl.combineArguments(IMPL_TOKEN, target, combiner, pos);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/MethodType.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,575 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import sun.dyn.Access;
+import sun.dyn.Invokers;
+import sun.dyn.MethodTypeImpl;
+import sun.dyn.util.BytecodeSignature;
+import static sun.dyn.MemberName.newIllegalArgumentException;
+
+/**
+ * Run-time token used to match call sites with method handles.
+ * The structure is a return type accompanied by any number of parameter types.
+ * The types (primitive, void, and reference) are represented by Class objects.
+ * All instances of <code>MethodType</code> are immutable.
+ * Two instances are completely interchangeable if they compare equal.
+ * Equality depends exactly on the return and parameter types.
+ * <p>
+ * This type can be created only by factory methods, which manage interning.
+ *
+ * @author John Rose, JSR 292 EG
+ */
+public final
+class MethodType {
+    private final Class<?>   rtype;
+    private final Class<?>[] ptypes;
+    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
+
+    private static final Access IMPL_TOKEN = Access.getToken();
+
+    // share a cache with a friend in this package
+    Invokers getInvokers() { return invokers; }
+    void setInvokers(Invokers inv) { invokers = inv; }
+
+    static {
+        // This hack allows the implementation package special access to
+        // the internals of MethodType.  In particular, the Form has all sorts
+        // of cached information useful to the implementation code.
+        MethodTypeImpl.setMethodTypeFriend(IMPL_TOKEN, new MethodTypeImpl.MethodTypeFriend() {
+            public Class<?>[] ptypes(MethodType mt)        { return mt.ptypes; }
+            public MethodTypeImpl form(MethodType mt)      { return mt.form; }
+            public void setForm(MethodType mt, MethodTypeImpl form) {
+                assert(mt.form == null);
+                mt.form = (MethodTypeForm) form;
+            }
+            public MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted) {
+                return MethodType.makeImpl(rtype, ptypes, trusted);
+            }
+            public MethodTypeImpl newMethodTypeForm(MethodType mt) {
+                return new MethodTypeForm(mt);
+            }
+            public Invokers getInvokers(MethodType mt)    { return mt.invokers; }
+            public void setInvokers(MethodType mt, Invokers inv) { mt.invokers = inv; }
+        });
+    }
+
+    private MethodType(Class<?> rtype, Class<?>[] ptypes) {
+        checkRtype(rtype);
+        checkPtypes(ptypes);
+        this.rtype = rtype;
+        this.ptypes = ptypes;
+    }
+
+    private void checkRtype(Class<?> rtype) {
+        rtype.equals(rtype);  // null check
+    }
+    private void checkPtypes(Class<?>[] ptypes) {
+        for (Class<?> ptype : ptypes) {
+            ptype.equals(ptype);  // null check
+            if (ptype == void.class)
+                throw newIllegalArgumentException("void parameter: "+this);
+        }
+    }
+
+    static final HashMap<MethodType,MethodType> internTable
+            = new HashMap<MethodType, MethodType>();
+
+    static final Class<?>[] NO_PTYPES = {};
+
+    /** Find or create an instance of the given method type.
+     * @param rtype  the return type
+     * @param ptypes the parameter types
+     * @return the interned method type with the given parts
+     * @throws NullPointerException if rtype or any ptype is null
+     * @throws IllegalArgumentException if any of the ptypes is void
+     */
+    public static
+    MethodType make(Class<?> rtype, Class<?>[] ptypes) {
+        return makeImpl(rtype, ptypes, false);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}. */
+    public static
+    MethodType make(Class<?> rtype, List<? extends Class<?>> ptypes) {
+        return makeImpl(rtype, ptypes.toArray(NO_PTYPES), true);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     *  The leading parameter type is prepended to the remaining array.
+     */
+    public static
+    MethodType make(Class<?> rtype, Class<?> ptype0, Class<?>... ptypes) {
+        Class<?>[] ptypes1 = new Class<?>[1+ptypes.length];
+        ptypes1[0] = ptype0;
+        System.arraycopy(ptypes, 0, ptypes1, 1, ptypes.length);
+        return makeImpl(rtype, ptypes1, true);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     *  The resulting method has no parameter types.
+     */
+    public static
+    MethodType make(Class<?> rtype) {
+        return makeImpl(rtype, NO_PTYPES, true);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     *  The resulting method has the single given parameter type.
+     */
+    public static
+    MethodType make(Class<?> rtype, Class<?> ptype0) {
+        return makeImpl(rtype, new Class<?>[]{ ptype0 }, true);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     *  The resulting method has the same parameter types as {@code ptypes},
+     *  and the specified return type.
+     */
+    public static
+    MethodType make(Class<?> rtype, MethodType ptypes) {
+        return makeImpl(rtype, ptypes.ptypes, true);
+    }
+
+    /**
+     * Sole factory method to find or create an interned method type.
+     * @param rtype desired return type
+     * @param ptypes desired parameter types
+     * @param trusted whether the ptypes can be used without cloning
+     * @return the unique method type of the desired structure
+     */
+    private static
+    MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted) {
+        if (ptypes == null || ptypes.length == 0) {
+            ptypes = NO_PTYPES; trusted = true;
+        }
+        MethodType mt1 = new MethodType(rtype, ptypes);
+        MethodType mt0;
+        synchronized (internTable) {
+            mt0 = internTable.get(mt1);
+            if (mt0 != null)
+                return mt0;
+        }
+        if (!trusted)
+            // defensively copy the array passed in by the user
+            mt1 = new MethodType(rtype, ptypes.clone());
+        // promote the object to the Real Thing, and reprobe
+        MethodTypeImpl.initForm(IMPL_TOKEN, mt1);
+        synchronized (internTable) {
+            mt0 = internTable.get(mt1);
+            if (mt0 != null)
+                return mt0;
+            internTable.put(mt1, mt1);
+        }
+        return mt1;
+    }
+
+    // Entry point from JVM.  TODO: Change the name & signature.
+    private static MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes,
+            boolean ignore1, boolean ignore2) {
+        return makeImpl(rtype, ptypes, true);
+    }
+
+    private static final MethodType[] objectOnlyTypes = new MethodType[20];
+
+    /**
+     * Convenience method for {@link #make(java.lang.Class, java.lang.Class[], boolean)}.
+     * All parameters and the return type will be Object, except the final varargs parameter if any.
+     * @param objectArgCount number of parameters (excluding the varargs parameter if any)
+     * @param varargs whether there will be a varargs parameter, of type Object[]
+     * @return a totally generic method type, given only its count of parameters and varargs
+     * @see #makeGeneric(int)
+     */
+    public static
+    MethodType makeGeneric(int objectArgCount, boolean varargs) {
+        MethodType mt;
+        int ivarargs = (!varargs ? 0 : 1);
+        int ootIndex = objectArgCount*2 + ivarargs;
+        if (ootIndex < objectOnlyTypes.length) {
+            mt = objectOnlyTypes[ootIndex];
+            if (mt != null)  return mt;
+        }
+        Class<?>[] ptypes = new Class<?>[objectArgCount + ivarargs];
+        Arrays.fill(ptypes, Object.class);
+        if (ivarargs != 0)  ptypes[objectArgCount] = Object[].class;
+        mt = makeImpl(Object.class, ptypes, true);
+        if (ootIndex < objectOnlyTypes.length) {
+            objectOnlyTypes[ootIndex] = mt;     // cache it here also!
+        }
+        return mt;
+    }
+
+    /**
+     * 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
+     * @see #makeGeneric(int, boolean)
+     */
+    public static
+    MethodType makeGeneric(int objectArgCount) {
+        return makeGeneric(objectArgCount, false);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[], boolean)}.
+     * @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
+     */
+    public MethodType changeParameterType(int num, Class<?> nptype) {
+        if (parameterType(num) == nptype)  return this;
+        Class<?>[] nptypes = ptypes.clone();
+        nptypes[num] = nptype;
+        return makeImpl(rtype, nptypes, true);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[], boolean)}.
+     * @param num    the position (zero-based) of the inserted parameter type
+     * @param nptype a new parameter type to insert into the parameter list
+     * @return the same type, except with the selected parameter inserted
+     */
+    public MethodType insertParameterType(int num, Class<?> nptype) {
+        int len = ptypes.length;
+        Class<?>[] nptypes = Arrays.copyOfRange(ptypes, 0, len+1);
+        System.arraycopy(nptypes, num, nptypes, num+1, len-num);
+        nptypes[num] = nptype;
+        return makeImpl(rtype, nptypes, true);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[], boolean)}.
+     * @param num    the index (zero-based) of the parameter type to remove
+     * @return the same type, except with the selected parameter removed
+     */
+    public MethodType dropParameterType(int num) {
+        int len = ptypes.length;
+        Class<?>[] nptypes;
+        if (num == 0) {
+            nptypes = Arrays.copyOfRange(ptypes, 1, len);
+        } else {
+            nptypes = Arrays.copyOfRange(ptypes, 0, len-1);
+            System.arraycopy(ptypes, num+1, nptypes, num, (len-1)-num);
+        }
+        return makeImpl(rtype, nptypes, true);
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[], boolean)}.
+     * @param nrtype a return parameter type to replace the old one with
+     * @return the same type, except with the return type change
+     */
+    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.
+     * @return true if any of the types are primitives
+     */
+    public boolean hasPrimitives() {
+        return form.hasPrimitives();
+    }
+
+    /** Convenience method.
+     * Report if this type contains a wrapper argument or return value.
+     * Wrappers are types which box primitive values, such as {@link Integer}.
+     * @return true if any of the types are wrappers
+     */
+    public boolean hasWrappers() {
+        return unwrap() != this;
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     * Erase all reference types to Object.
+     * @return a version of the original type with all reference types replaced
+     */
+    public MethodType erase() {
+        return form.erasedType();
+    }
+
+    /** Convenience method for {@link #makeGeneric(int)}.
+     * Convert all types, both reference and primitive, to Object.
+     * @return a version of the original type with all types replaced
+     */
+    public MethodType generic() {
+        return makeGeneric(parameterCount());
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     * Convert all primitive types to their corresponding wrapper types.
+     * A {@code void} return type is changed to the type {@code java.lang.Void}.
+     * @return a version of the original type with all primitive types replaced
+     */
+    public MethodType wrap() {
+        return hasPrimitives() ? wrapWithPrims(this) : this;
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     * Convert all wrapper types to their corresponding primitive types.
+     * 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
+     */
+    public MethodType unwrap() {
+        MethodType noprims = !hasPrimitives() ? this : wrapWithPrims(this);
+        return unwrapWithNoPrims(noprims);
+    }
+
+    private static MethodType wrapWithPrims(MethodType pt) {
+        assert(pt.hasPrimitives());
+        MethodType wt = pt.wrapAlt;
+        if (wt == null) {
+            // fill in lazily
+            wt = MethodTypeImpl.canonicalize(pt, MethodTypeImpl.WRAP, MethodTypeImpl.WRAP);
+            assert(wt != null);
+            pt.wrapAlt = wt;
+        }
+        return wt;
+    }
+
+    private static MethodType unwrapWithNoPrims(MethodType wt) {
+        assert(!wt.hasPrimitives());
+        MethodType uwt = wt.wrapAlt;
+        if (uwt == null) {
+            // fill in lazily
+            uwt = MethodTypeImpl.canonicalize(wt, MethodTypeImpl.UNWRAP, MethodTypeImpl.UNWRAP);
+            if (uwt == null)
+                uwt = wt;    // type has no wrappers or prims at all
+            wt.wrapAlt = uwt;
+        }
+        return uwt;
+    }
+
+    /** @param num the index (zero-based) of the desired parameter type
+     *  @return the selected parameter type
+     */
+    public Class<?> parameterType(int num) {
+        return ptypes[num];
+    }
+    /** @return the number of parameter types */
+    public int parameterCount() {
+        return ptypes.length;
+    }
+    /** @return the return type */
+    public Class<?> returnType() {
+        return rtype;
+    }
+
+    /**
+     * Convenience method to present the arguments as a list.
+     * @return the parameter types (as an immutable list)
+     */
+    public List<Class<?>> parameterList() {
+        return Collections.unmodifiableList(Arrays.asList(ptypes));
+    }
+
+    /**
+     * Convenience method to present the arguments as an array.
+     * @return the parameter types (as a fresh copy if necessary)
+     */
+    public Class<?>[] parameterArray() {
+        return ptypes.clone();
+    }
+
+    /**
+     * Compares the specified object with this type for equality.
+     * That is, it returns <tt>true</tt> if and only if the specified object
+     * is also a method type with exactly the same parameters and return type.
+     * @param x object to compare
+     * @see Object#equals(Object)
+     */
+    @Override
+    public boolean equals(Object x) {
+        return this == x || x instanceof MethodType && equals((MethodType)x);
+    }
+
+    private boolean equals(MethodType that) {
+        return this.rtype == that.rtype
+            && Arrays.equals(this.ptypes, that.ptypes);
+    }
+
+    /**
+     * Returns the hash code value for this method type.
+     * It is defined to be the same as the hashcode of a List
+     * whose elements are the return type followed by the
+     * parameter types.
+     * @return the hash code value for this method type
+     * @see Object#hashCode()
+     * @see #equals(Object)
+     * @see List#hashCode()
+     */
+    @Override
+    public int hashCode() {
+      int hashCode = 31 + rtype.hashCode();
+      for (Class<?> ptype : ptypes)
+          hashCode = 31*hashCode + ptype.hashCode();
+      return hashCode;
+    }
+
+    /**
+     * The string representation of a method type is a
+     * parenthesis enclosed, comma separated list of type names,
+     * followed immediately by the return type.
+     * <p>
+     * If a type name is array, it the base type followed
+     * by [], rather than the Class.getName of the array type.
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("(");
+        for (int i = 0; i < ptypes.length; i++) {
+            if (i > 0)  sb.append(",");
+            putName(sb, ptypes[i]);
+        }
+        sb.append(")");
+        putName(sb, rtype);
+        return sb.toString();
+    }
+
+    static void putName(StringBuilder sb, Class<?> cls) {
+        int brackets = 0;
+        while (cls.isArray()) {
+            cls = cls.getComponentType();
+            brackets++;
+        }
+        String n = cls.getName();
+        /*
+        if (n.startsWith("java.lang.")) {
+            String nb = n.substring("java.lang.".length());
+            if (nb.indexOf('.') < 0)  n = nb;
+        } else if (n.indexOf('.') < 0) {
+            n = "."+n;          // anonymous package
+        }
+        */
+        sb.append(n);
+        while (brackets > 0) {
+            sb.append("[]");
+            brackets--;
+        }
+    }
+
+    /// Queries which have to do with the bytecode architecture
+
+    /** 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
+     * 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
+     */
+    public int parameterSlotCount() {
+        return form.parameterSlotCount();
+    }
+
+    /** Number of JVM stack slots which carry all parameters 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
+     * according to their trailing edge.  Thus, to obtain the depth
+     * in the outgoing call stack of parameter {@code N}, obtain
+     * the {@code parameterSlotDepth} of its trailing edge
+     * at position {@code N+1}.
+     * <p>
+     * Parameters of type {@code long} and {@code double} occupy
+     * two stack slots (for historical reasons) and all others occupy one.
+     * Therefore, the number returned is the number of arguments
+     * <em>including</em> and <em>after</em> the given parameter,
+     * <em>plus</em> the number of long or double arguments
+     * at or after after the argument for the given parameter.
+     * <p>
+     * This method is included for the benfit of applications that must
+     * generate bytecodes that process method handles and invokedynamic.
+     * @param num an index (zero-based, inclusive) within the parameter types
+     * @return the index of the (shallowest) JVM stack slot transmitting the
+     *         given parameter
+     */
+    public int parameterSlotDepth(int num) {
+        if (num < 0 || num > ptypes.length)
+            parameterType(num);  // force a range check
+        return form.parameterToArgSlot(num-1);
+    }
+
+    /** 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.
+     * <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 (0, 1, or 2) for this type's return value
+     */
+    public int returnSlotCount() {
+        return form.returnSlotCount();
+    }
+
+    /** Convenience method for {@link #make(java.lang.Class, java.lang.Class[])}.
+     * Find or create an instance (interned) of the given method type.
+     * Any class or interface name embedded in the signature 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).
+     * <p>
+     * Note that it is possible to build method types which cannot be
+     * constructed by this method, because their component types are
+     * 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 bytecodeSignature a bytecode-level signature string "(T...)T"
+     * @param loader the class loader in which to look up the types
+     * @return a method type matching the bytecode-level signature
+     * @throws IllegalArgumentException if the string is not well-formed
+     * @throws TypeNotPresentException if a named type cannot be found
+     */
+    public static MethodType fromBytecodeString(String bytecodeSignature, ClassLoader loader)
+        throws IllegalArgumentException, TypeNotPresentException
+    {
+        List<Class<?>> types = BytecodeSignature.parseMethod(bytecodeSignature, loader);
+        Class<?> rtype = types.remove(types.size() - 1);
+        Class<?>[] ptypes = types.toArray(NO_PTYPES);
+        return makeImpl(rtype, ptypes, true);
+    }
+
+    /**
+     * Create a bytecode signature representation of the type.
+     * Note that this is not a strict inverse of
+     * <p>
+     * This method is included for the benfit of applications that must
+     * generate bytecodes that process method handles and invokedynamic.
+     * {@link #fromBytecodeString(java.lang.String, java.lang.ClassLoader)},
+     * because the latter requires a suitable class loader argument.
+     * @return the bytecode signature representation
+     */
+    public String toBytecodeString() {
+        return BytecodeSignature.unparse(this);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/MethodTypeForm.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+/**
+ * TO DO:  Temporary shim; remove after refactoring effects are complete in JVM.
+ * @author John Rose
+ */
+import sun.dyn.MethodTypeImpl;
+
+class MethodTypeForm extends MethodTypeImpl {
+
+    MethodTypeForm(MethodType erasedType) {
+        super(erasedType);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/NoAccessException.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+/**
+ * Thrown to indicate that a caller has attempted to create a method handle
+ * which calls a method 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 on behalf of the method handle creator,
+ * at the time of creation.
+ * @author John Rose, JSR 292 EG
+ */
+public class NoAccessException extends RuntimeException {
+    /**
+     * 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/WrongMethodTypeException.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package java.dyn;
+
+/**
+ * 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.
+ * <p>
+ * This exception may also be thrown when two method handles are
+ * composed, and the system detects that their types cannot be
+ * matched up correctly.  This amounts to an early evaluation
+ * of the type mismatch, at method handle construction time,
+ * instead of when the mismatched method handle is called.
+ *
+ * @author John Rose, JSR 292 EG
+ */
+public class WrongMethodTypeException extends RuntimeException {
+    /**
+     * Constructs a {@code WrongMethodTypeException} with no detail message.
+     */
+    public WrongMethodTypeException() {
+        super();
+    }
+
+    /**
+     * Constructs a {@code WrongMethodTypeException} with the specified
+     * detail message.
+     *
+     * @param s the detail message.
+     */
+    public WrongMethodTypeException(String s) {
+        super(s);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/dyn/package-info.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+/**
+ * This package contains dynamic language support provided directly by
+ * the Java core class libraries and virtual machine.
+ * @author John Rose, JSR 292 EG
+ */
+
+package java.dyn;
--- a/jdk/src/share/classes/java/io/Console.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/io/Console.java	Thu May 14 09:53:35 2009 -0700
@@ -503,20 +503,25 @@
 
     // Set up JavaIOAccess in SharedSecrets
     static {
-
-        // Add a shutdown hook to restore console's echo state should
-        // it be necessary.
-        sun.misc.SharedSecrets.getJavaLangAccess()
-            .registerShutdownHook(0 /* shutdown hook invocation order */,
-                new Runnable() {
-                    public void run() {
-                        try {
-                            if (echoOff) {
-                                echo(true);
-                            }
-                        } catch (IOException x) { }
-                    }
-                });
+        try {
+            // Add a shutdown hook to restore console's echo state should
+            // it be necessary.
+            sun.misc.SharedSecrets.getJavaLangAccess()
+                .registerShutdownHook(0 /* shutdown hook invocation order */,
+                    false /* only register if shutdown is not in progress */,
+                    new Runnable() {
+                        public void run() {
+                            try {
+                                if (echoOff) {
+                                    echo(true);
+                                }
+                            } catch (IOException x) { }
+                        }
+                    });
+        } catch (IllegalStateException e) {
+            // shutdown is already in progress and console is first used
+            // by a shutdown hook
+        }
 
         sun.misc.SharedSecrets.setJavaIOAccess(new sun.misc.JavaIOAccess() {
             public Console console() {
--- a/jdk/src/share/classes/java/io/DeleteOnExitHook.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/io/DeleteOnExitHook.java	Thu May 14 09:53:35 2009 -0700
@@ -34,23 +34,31 @@
  */
 
 class DeleteOnExitHook {
+    private static LinkedHashSet<String> files = new LinkedHashSet<String>();
     static {
-         sun.misc.SharedSecrets.getJavaLangAccess()
-             .registerShutdownHook(2 /* Shutdown hook invocation order */,
-                 new Runnable() {
-                     public void run() {
-                        runHooks();
-                     }
-                 });
+        // DeleteOnExitHook must be the last shutdown hook to be invoked.
+        // Application shutdown hooks may add the first file to the
+        // delete on exit list and cause the DeleteOnExitHook to be
+        // registered during shutdown in progress. So set the
+        // registerShutdownInProgress parameter to true.
+        sun.misc.SharedSecrets.getJavaLangAccess()
+            .registerShutdownHook(2 /* Shutdown hook invocation order */,
+                true /* register even if shutdown in progress */,
+                new Runnable() {
+                    public void run() {
+                       runHooks();
+                    }
+                }
+        );
     }
 
-    private static LinkedHashSet<String> files = new LinkedHashSet<String>();
-
     private DeleteOnExitHook() {}
 
     static synchronized void add(String file) {
-        if(files == null)
+        if(files == null) {
+            // DeleteOnExitHook is running. Too late to add a file
             throw new IllegalStateException("Shutdown in progress");
+        }
 
         files.add(file);
     }
--- a/jdk/src/share/classes/java/lang/ApplicationShutdownHooks.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/lang/ApplicationShutdownHooks.java	Thu May 14 09:53:35 2009 -0700
@@ -35,17 +35,26 @@
  */
 
 class ApplicationShutdownHooks {
+    /* The set of registered hooks */
+    private static IdentityHashMap<Thread, Thread> hooks;
     static {
-        Shutdown.add(1 /* shutdown hook invocation order */,
-            new Runnable() {
-                public void run() {
-                    runHooks();
+        try {
+            Shutdown.add(1 /* shutdown hook invocation order */,
+                false /* not registered if shutdown in progress */,
+                new Runnable() {
+                    public void run() {
+                        runHooks();
+                    }
                 }
-            });
+            );
+            hooks = new IdentityHashMap<Thread, Thread>();
+        } catch (IllegalStateException e) {
+            // application shutdown hooks cannot be added if
+            // shutdown is in progress.
+            hooks = null;
+        }
     }
 
-    /* The set of registered hooks */
-    private static IdentityHashMap<Thread, Thread> hooks = new IdentityHashMap<Thread, Thread>();
 
     private ApplicationShutdownHooks() {}
 
--- a/jdk/src/share/classes/java/lang/Shutdown.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/lang/Shutdown.java	Thu May 14 09:53:35 2009 -0700
@@ -53,6 +53,9 @@
     private static final int MAX_SYSTEM_HOOKS = 10;
     private static final Runnable[] hooks = new Runnable[MAX_SYSTEM_HOOKS];
 
+    // the index of the currently running shutdown hook to the hooks array
+    private static int currentRunningHook = 0;
+
     /* The preceding static fields are protected by this lock */
     private static class Lock { };
     private static Object lock = new Lock();
@@ -68,17 +71,39 @@
     }
 
 
-    /* Add a new shutdown hook.  Checks the shutdown state and the hook itself,
+    /**
+     * Add a new shutdown hook.  Checks the shutdown state and the hook itself,
      * but does not do any security checks.
+     *
+     * The registerShutdownInProgress parameter should be false except
+     * registering the DeleteOnExitHook since the first file may
+     * be added to the delete on exit list by the application shutdown
+     * hooks.
+     *
+     * @params slot  the slot in the shutdown hook array, whose element
+     *               will be invoked in order during shutdown
+     * @params registerShutdownInProgress true to allow the hook
+     *               to be registered even if the shutdown is in progress.
+     * @params hook  the hook to be registered
+     *
+     * @throw IllegalStateException
+     *        if registerShutdownInProgress is false and shutdown is in progress; or
+     *        if registerShutdownInProgress is true and the shutdown process
+     *           already passes the given slot
      */
-    static void add(int slot, Runnable hook) {
+    static void add(int slot, boolean registerShutdownInProgress, Runnable hook) {
         synchronized (lock) {
-            if (state > RUNNING)
-                throw new IllegalStateException("Shutdown in progress");
-
             if (hooks[slot] != null)
                 throw new InternalError("Shutdown hook at slot " + slot + " already registered");
 
+            if (!registerShutdownInProgress) {
+                if (state > RUNNING)
+                    throw new IllegalStateException("Shutdown in progress");
+            } else {
+                if (state > HOOKS || (state == HOOKS && slot <= currentRunningHook))
+                    throw new IllegalStateException("Shutdown in progress");
+            }
+
             hooks[slot] = hook;
         }
     }
@@ -86,11 +111,15 @@
     /* Run all registered shutdown hooks
      */
     private static void runHooks() {
-        /* We needn't bother acquiring the lock just to read the hooks field,
-         * since the hooks can't be modified once shutdown is in progress
-         */
-        for (Runnable hook : hooks) {
+        for (int i=0; i < MAX_SYSTEM_HOOKS; i++) {
             try {
+                Runnable hook;
+                synchronized (lock) {
+                    // acquire the lock to make sure the hook registered during
+                    // shutdown is visible here.
+                    currentRunningHook = i;
+                    hook = hooks[i];
+                }
                 if (hook != null) hook.run();
             } catch(Throwable t) {
                 if (t instanceof ThreadDeath) {
--- a/jdk/src/share/classes/java/lang/System.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/lang/System.java	Thu May 14 09:53:35 2009 -0700
@@ -1171,8 +1171,8 @@
             public void blockedOn(Thread t, Interruptible b) {
                 t.blockedOn(b);
             }
-            public void registerShutdownHook(int slot, Runnable r) {
-                Shutdown.add(slot, r);
+            public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
+                Shutdown.add(slot, registerShutdownInProgress, hook);
             }
         });
     }
--- a/jdk/src/share/classes/java/util/zip/ZipFile.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/util/zip/ZipFile.java	Thu May 14 09:53:35 2009 -0700
@@ -154,7 +154,7 @@
      * @param file the ZIP file to be opened for reading
      * @param mode the mode in which the file is to be opened
      * @param charset
-     *        the {@link java.nio.charset.Charset {@code charset}} to
+     *        the {@linkplain java.nio.charset.Charset charset} to
      *        be used to decode the ZIP entry name and comment that are not
      *        encoded by using UTF-8 encoding (indicated by entry's general
      *        purpose flag).
@@ -206,7 +206,7 @@
      *
      * @param name the name of the zip file
      * @param charset
-     *        the {@link java.nio.charset.Charset {@code charset}} to
+     *        the {@linkplain java.nio.charset.Charset charset} to
      *        be used to decode the ZIP entry name and comment that are not
      *        encoded by using UTF-8 encoding (indicated by entry's general
      *        purpose flag).
@@ -230,7 +230,7 @@
      * Opens a ZIP file for reading given the specified File object.
      * @param file the ZIP file to be opened for reading
      * @param charset
-     *        The {@link java.nio.charset.Charset {@code charset}} to be
+     *        The {@linkplain java.nio.charset.Charset charset} to be
      *        used to decode the ZIP entry name and comment (ignored if
      *        the <a href="package-summary.html#lang_encoding"> language
      *        encoding bit</a> of the ZIP entry's general purpose bit
--- a/jdk/src/share/classes/java/util/zip/ZipInputStream.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/util/zip/ZipInputStream.java	Thu May 14 09:53:35 2009 -0700
@@ -84,7 +84,7 @@
      * @param in the actual input stream
      *
      * @param charset
-     *        The {@link java.nio.charset.Charset {@code charset}} to be
+     *        The {@linkplain java.nio.charset.Charset charset} to be
      *        used to decode the ZIP entry name (ignored if the
      *        <a href="package-summary.html#lang_encoding"> language
      *        encoding bit</a> of the ZIP entry's general purpose bit
--- a/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Wed May 06 14:14:54 2009 -0700
+++ b/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Thu May 14 09:53:35 2009 -0700
@@ -108,7 +108,7 @@
      *
      * @param out the actual output stream
      *
-     * @param charset the {@link java.nio.charset.Charset </code>charset<code>}
+     * @param charset the {@linkplain java.nio.charset.Charset charset}
      *                to be used to encode the entry names and comments
      *
      * @since 1.7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/dyn/Access.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package sun.dyn;
+
+import sun.reflect.Reflection;
+
+/**
+ * Access control to this package.
+ * Classes in other packages can attempt to acquire the access token,
+ * but will fail if they are not recognized as friends.
+ * Certain methods in this package, although public, require a non-null
+ * access token in order to proceed; they act like package-private methods.
+ * @author jrose
+ */
+
+public class Access {
+
+    private Access() { }
+
+    /**
+     * The heart of this pattern:  The list of classes which are
+     * permitted to acquire the access token, and become honorary
+     * members of this package.
+     */
+    private static final String[] FRIENDS = {
+        "java.dyn.", "sun.dyn."
+    };
+
+    /**
+     * The following object is NOT public.  That's the point of the pattern.
+     * It is package-private, so that any member of this package
+     * can acquire the access token, and give it away to trusted friends.
+     */
+    static final Access TOKEN = new Access();
+
+    /**
+     * @return Access.TOKEN, if the caller is a friend of this package
+     */
+    public static Access getToken() {
+        Class<?> callc = Reflection.getCallerClass(2);
+        if (isFriend(callc))
+            return TOKEN;
+        else
+            throw new IllegalAccessError("bad caller: " + callc);
+    }
+
+    /** Is the given name the name of a class which could be our friend? */
+    public static boolean isFriendName(String name) {
+        for (String friend : FRIENDS) {
+            if (name.startsWith(friend))
+                return true;
+        }
+        return false;
+    }
+
+    /** Is the given class a friend?  True if {@link #isFriendName},
+     *  and the given class also shares a class loader with us.
+     */
+    public static boolean isFriend(Class<?> c) {
+        return isFriendName(c.getName()) && c.getClassLoader() == CLASS_LOADER;
+    }
+
+    private static final ClassLoader CLASS_LOADER = Access.class.getClassLoader();
+
+    /**
+     * Throw an IllegalAccessError if the caller does not possess
+     * the Access.TOKEN.
+     * @param must be Access.TOKEN
+     */
+    public static void check(Access token) {
+        if (token == null)
+            fail();
+        // else it must be the unique Access.TOKEN
+        assert(token == Access.TOKEN);
+    }
+    private static void fail() {
+        final int CALLER_DEPTH = 3;
+        // 0: Reflection.getCC, 1: this.fail, 2: Access.*, 3: caller
+        Class<?> callc = Reflection.getCallerClass(CALLER_DEPTH);
+        throw new IllegalAccessError("bad caller: " + callc);
+    }
+
+    static {
+        //sun.reflect.Reflection.registerMethodsToFilter(MH.class, "getToken");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/dyn/AdapterMethodHandle.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,728 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package sun.dyn;
+
+import sun.dyn.util.VerifyType;
+import sun.dyn.util.Wrapper;
+import java.dyn.*;
+import java.util.Arrays;
+import static sun.dyn.MethodHandleNatives.Constants.*;
+import static sun.dyn.MethodHandleImpl.newIllegalArgumentException;
+
+/**
+ * This method handle performs simple conversion or checking of a single argument.
+ * @author jrose
+ */
+public class AdapterMethodHandle extends BoundMethodHandle {
+
+    //MethodHandle vmtarget;   // next AMH or BMH in chain or final DMH
+    //Object       argument;   // parameter to the conversion if needed
+    //int          vmargslot;  // which argument slot is affected
+    private final int conversion;  // the type of conversion: RETYPE_ONLY, etc.
+
+    // Constructors in this class *must* be package scoped or private.
+    private AdapterMethodHandle(MethodHandle target, MethodType newType,
+                long conv, Object convArg) {
+        super(newType, convArg, newType.parameterSlotDepth(1+convArgPos(conv)));
+        this.conversion = convCode(conv);
+        if (MethodHandleNatives.JVM_SUPPORT) {
+            // JVM might update VM-specific bits of conversion (ignore)
+            MethodHandleNatives.init(this, target, convArgPos(conv));
+        }
+    }
+    private AdapterMethodHandle(MethodHandle target, MethodType newType,
+                long conv) {
+        this(target, newType, conv, null);
+    }
+
+    private static final Access IMPL_TOKEN = Access.getToken();
+
+    // TO DO:  When adapting another MH with a null conversion, clone
+    // the target and change its type, instead of adding another layer.
+
+    /** Can a JVM-level adapter directly implement the proposed
+     *  argument conversions, as if by MethodHandles.convertArguments?
+     */
+    public static boolean canPairwiseConvert(MethodType newType, MethodType oldType) {
+        // same number of args, of course
+        int len = newType.parameterCount();
+        if (len != oldType.parameterCount())
+            return false;
+
+        // Check return type.  (Not much can be done with it.)
+        Class<?> exp = newType.returnType();
+        Class<?> ret = oldType.returnType();
+        if (!VerifyType.isNullConversion(ret, exp))
+            return false;
+
+        // Check args pairwise.
+        for (int i = 0; i < len; i++) {
+            Class<?> src = newType.parameterType(i); // source type
+            Class<?> dst = oldType.parameterType(i); // destination type
+            if (!canConvertArgument(src, dst))
+                return false;
+        }
+
+        return true;
+    }
+
+    /** Can a JVM-level adapter directly implement the proposed
+     *  argument conversion, as if by MethodHandles.convertArguments?
+     */
+    public static boolean canConvertArgument(Class<?> src, Class<?> dst) {
+        // ? Retool this logic to use RETYPE_ONLY, CHECK_CAST, etc., as opcodes,
+        // so we don't need to repeat so much decision making.
+        if (VerifyType.isNullConversion(src, dst)) {
+            return true;
+        } else if (src.isPrimitive()) {
+            if (dst.isPrimitive())
+                return canPrimCast(src, dst);
+            else
+                return canBoxArgument(src, dst);
+        } else {
+            if (dst.isPrimitive())
+                return canUnboxArgument(src, dst);
+            else
+                return true;  // any two refs can be interconverted
+        }
+    }
+
+    /**
+     * Create a JVM-level adapter method handle to conform the given method
+     * handle to the similar newType, using only pairwise argument conversions.
+     * For each argument, convert incoming argument to the exact type needed.
+     * Only null conversions are allowed on the return value (until
+     * the JVM supports ricochet adapters).
+     * The argument conversions allowed are casting, unboxing,
+     * integral widening or narrowing, and floating point widening or narrowing.
+     * @param token access check
+     * @param newType required call type
+     * @param target original method handle
+     * @return an adapter to the original handle with the desired new type,
+     *          or the original target if the types are already identical
+     *          or null if the adaptation cannot be made
+     */
+    public static MethodHandle makePairwiseConvert(Access token,
+                MethodType newType, MethodHandle target) {
+        Access.check(token);
+        MethodType oldType = target.type();
+        if (newType == oldType)  return target;
+
+        if (!canPairwiseConvert(newType, oldType))
+            return null;
+        // (after this point, it is an assertion error to fail to convert)
+
+        // Find last non-trivial conversion (if any).
+        int lastConv = newType.parameterCount()-1;
+        while (lastConv >= 0) {
+            Class<?> src = newType.parameterType(lastConv); // source type
+            Class<?> dst = oldType.parameterType(lastConv); // destination type
+            if (VerifyType.isNullConversion(src, dst)) {
+                --lastConv;
+            } else {
+                break;
+            }
+        }
+        // Now build a chain of one or more adapters.
+        MethodHandle adapter = target;
+        MethodType midType = oldType.changeReturnType(newType.returnType());
+        for (int i = 0; i <= lastConv; i++) {
+            Class<?> src = newType.parameterType(i); // source type
+            Class<?> dst = midType.parameterType(i); // destination type
+            if (VerifyType.isNullConversion(src, dst)) {
+                // do nothing: difference is trivial
+                continue;
+            }
+            // Work the current type backward toward the desired caller type:
+            if (i != lastConv) {
+                midType = midType.changeParameterType(i, src);
+            } else {
+                // When doing the last (or only) real conversion,
+                // force all remaining null conversions to happen also.
+                assert(VerifyType.isNullConversion(newType, midType.changeParameterType(i, src)));
+                midType = newType;
+            }
+
+            // Tricky case analysis follows.
+            // It parallels canConvertArgument() above.
+            if (src.isPrimitive()) {
+                if (dst.isPrimitive()) {
+                    adapter = makePrimCast(token, midType, adapter, i, dst);
+                } else {
+                    adapter = makeBoxArgument(token, midType, adapter, i, dst);
+                }
+            } else {
+                if (dst.isPrimitive()) {
+                    // Caller has boxed a primitive.  Unbox it for the target.
+                    // The box type must correspond exactly to the primitive type.
+                    // This is simpler than the powerful set of widening
+                    // conversions supported by reflect.Method.invoke.
+                    // Those conversions require a big nest of if/then/else logic,
+                    // which we prefer to make a user responsibility.
+                    adapter = makeUnboxArgument(token, midType, adapter, i, dst);
+                } else {
+                    // Simple reference conversion.
+                    // Note:  Do not check for a class hierarchy relation
+                    // between src and dst.  In all cases a 'null' argument
+                    // will pass the cast conversion.
+                    adapter = makeCheckCast(token, midType, adapter, i, dst);
+                }
+            }
+            assert(adapter != null);
+            assert(adapter.type() == midType);
+        }
+        if (adapter.type() != newType) {
+            // Only trivial conversions remain.
+            adapter = makeRetypeOnly(IMPL_TOKEN, newType, adapter);
+            assert(adapter != null);
+            // Actually, that's because there were no non-trivial ones:
+            assert(lastConv == -1);
+        }
+        assert(adapter.type() == newType);
+        return adapter;
+    }
+
+    /**
+     * Create a JVM-level adapter method handle to permute the arguments
+     * of the given method.
+     * @param token access check
+     * @param newType required call type
+     * @param target original method handle
+     * @param argumentMap for each target argument, position of its source in newType
+     * @return an adapter to the original handle with the desired new type,
+     *          or the original target if the types are already identical
+     *          and the permutation is null
+     * @throws IllegalArgumentException if the adaptation cannot be made
+     *          directly by a JVM-level adapter, without help from Java code
+     */
+    public static MethodHandle makePermutation(Access token,
+                MethodType newType, MethodHandle target,
+                int[] argumentMap) {
+        MethodType oldType = target.type();
+        boolean nullPermutation = true;
+        for (int i = 0; i < argumentMap.length; i++) {
+            int pos = argumentMap[i];
+            if (pos != i)
+                nullPermutation = false;
+            if (pos < 0 || pos >= newType.parameterCount()) {
+                argumentMap = new int[0]; break;
+            }
+        }
+        if (argumentMap.length != oldType.parameterCount())
+            throw newIllegalArgumentException("bad permutation: "+Arrays.toString(argumentMap));
+        if (nullPermutation) {
+            MethodHandle res = makePairwiseConvert(token, newType, target);
+            // well, that was easy
+            if (res == null)
+                throw newIllegalArgumentException("cannot convert pairwise: "+newType);
+            return res;
+        }
+
+        // Check return type.  (Not much can be done with it.)
+        Class<?> exp = newType.returnType();
+        Class<?> ret = oldType.returnType();
+        if (!VerifyType.isNullConversion(ret, exp))
+            throw newIllegalArgumentException("bad return conversion for "+newType);
+
+        // See if the argument types match up.
+        for (int i = 0; i < argumentMap.length; i++) {
+            int j = argumentMap[i];
+            Class<?> src = newType.parameterType(j);
+            Class<?> dst = oldType.parameterType(i);
+            if (!VerifyType.isNullConversion(src, dst))
+                throw newIllegalArgumentException("bad argument #"+j+" conversion for "+newType);
+        }
+
+        // Now figure out a nice mix of SWAP, ROT, DUP, and DROP adapters.
+        // A workable greedy algorithm is as follows:
+        // Drop unused outgoing arguments (right to left: shallowest first).
+        // Duplicate doubly-used outgoing arguments (left to right: deepest first).
+        // Then the remaining problem is a true argument permutation.
+        // Marshal the outgoing arguments as required from left to right.
+        // That is, find the deepest outgoing stack position that does not yet
+        // have the correct argument value, and correct at least that position
+        // by swapping or rotating in the misplaced value (from a shallower place).
+        // If the misplaced value is followed by one or more consecutive values
+        // (also misplaced)  issue a rotation which brings as many as possible
+        // into position.  Otherwise make progress with either a swap or a
+        // rotation.  Prefer the swap as cheaper, but do not use it if it
+        // breaks a slot pair.  Prefer the rotation over the swap if it would
+        // preserve more consecutive values shallower than the target position.
+        // When more than one rotation will work (because the required value
+        // is already adjacent to the target position), then use a rotation
+        // which moves the old value in the target position adjacent to
+        // one of its consecutive values.  Also, prefer shorter rotation
+        // spans, since they use fewer memory cycles for shuffling.
+
+        throw new UnsupportedOperationException("NYI");
+    }
+
+    private static byte basicType(Class<?> type) {
+        if (type == null)  return T_VOID;
+        switch (Wrapper.forBasicType(type)) {
+            case BOOLEAN:  return T_BOOLEAN;
+            case CHAR:     return T_CHAR;
+            case FLOAT:    return T_FLOAT;
+            case DOUBLE:   return T_DOUBLE;
+            case BYTE:     return T_BYTE;
+            case SHORT:    return T_SHORT;
+            case INT:      return T_INT;
+            case LONG:     return T_LONG;
+            case OBJECT:   return T_OBJECT;
+            case VOID:     return T_VOID;
+        }
+        return 99; // T_ILLEGAL or some such
+    }
+
+    /** Number of stack slots for the given type.
+     *  Two for T_DOUBLE and T_FLOAT, one for the rest.
+     */
+    private static int type2size(int type) {
+        assert(type >= T_BOOLEAN && type <= T_OBJECT);
+        return (type == T_FLOAT || type == T_DOUBLE) ? 2 : 1;
+    }
+
+    /** Construct an adapter conversion descriptor for a single-argument conversion. */
+    private static long makeConv(int convOp, int argnum, int src, int dest) {
+        assert(src  == (src  & 0xF));
+        assert(dest == (dest & 0xF));
+        assert(convOp >= OP_CHECK_CAST && convOp <= OP_PRIM_TO_REF);
+        long stackMove = type2size(dest) - type2size(src);
+        return ((long) argnum << 32 |
+                (long) convOp << CONV_OP_SHIFT |
+                (int)  src    << CONV_SRC_TYPE_SHIFT |
+                (int)  dest   << CONV_DEST_TYPE_SHIFT |
+                stackMove     << CONV_STACK_MOVE_SHIFT
+                );
+    }
+    private static long makeConv(int convOp, int argnum, int stackMove) {
+        assert(convOp >= OP_SWAP_ARGS && convOp <= OP_SPREAD_ARGS);
+        byte src = 0, dest = 0;
+        if (convOp >= OP_COLLECT_ARGS && convOp <= OP_SPREAD_ARGS)
+            src = dest = T_OBJECT;
+        return ((long) argnum << 32 |
+                (long) convOp << CONV_OP_SHIFT |
+                (int)  src    << CONV_SRC_TYPE_SHIFT |
+                (int)  dest   << CONV_DEST_TYPE_SHIFT |
+                stackMove     << CONV_STACK_MOVE_SHIFT
+                );
+    }
+    private static long makeConv(int convOp) {
+        assert(convOp == OP_RETYPE_ONLY);
+        return (long) convOp << CONV_OP_SHIFT;   // stackMove, src, dst, argnum all zero
+    }
+    private static int convCode(long conv) {
+        return (int)conv;
+    }
+    private static int convArgPos(long conv) {
+        return (int)(conv >>> 32);
+    }
+    private static boolean convOpSupported(int convOp) {
+        assert(convOp >= 0 && convOp <= CONV_OP_LIMIT);
+        return ((1<<convOp) & CONV_OP_IMPLEMENTED_MASK) != 0;
+    }
+
+    /** One of OP_RETYPE_ONLY, etc. */
+    int conversionOp() { return (conversion & CONV_OP_MASK) >> CONV_OP_SHIFT; }
+
+    @Override
+    public String toString() {
+        return addTypeString(this, "Adapted[" + basicToString(nonAdapter((MethodHandle)vmtarget)) + "]");
+    }
+
+    private static MethodHandle nonAdapter(MethodHandle mh) {
+        return (MethodHandle)
+            MethodHandleNatives.getTarget(mh, ETF_DIRECT_HANDLE);
+    }
+
+    /* Return one plus the position of the first non-trivial difference
+     * between the given types.  This is not a symmetric operation;
+     * we are considering adapting the targetType to adapterType.
+     * Trivial differences are those which could be ignored by the JVM
+     * without subverting the verifier.  Otherwise, adaptable differences
+     * are ones for which we could create an adapter to make the type change.
+     * Return zero if there are no differences (other than trivial ones).
+     * Return 1+N if N is the only adaptable argument difference.
+     * Return the -2-N where N is the first of several adaptable
+     * argument differences.
+     * Return -1 if there there are differences which are not adaptable.
+     */
+    private static int diffTypes(MethodType adapterType,
+                                 MethodType targetType,
+                                 boolean raw) {
+        int diff;
+        diff = diffReturnTypes(adapterType, targetType, raw);
+        if (diff != 0)  return diff;
+        int nargs = adapterType.parameterCount();
+        if (nargs != targetType.parameterCount())
+            return -1;
+        diff = diffParamTypes(adapterType, 0, targetType, 0, nargs, raw);
+        //System.out.println("diff "+adapterType);
+        //System.out.println("  "+diff+" "+targetType);
+        return diff;
+    }
+    private static int diffReturnTypes(MethodType adapterType,
+                                       MethodType targetType,
+                                       boolean raw) {
+        Class<?> src = targetType.returnType();
+        Class<?> dst = adapterType.returnType();
+        if ((!raw
+             ? VerifyType.canPassUnchecked(src, dst)
+             : VerifyType.canPassRaw(src, dst)
+             ) > 0)
+            return 0;  // no significant difference
+        if (raw && !src.isPrimitive() && !dst.isPrimitive())
+            return 0;  // can force a reference return (very carefully!)
+        //if (false)  return 1;  // never adaptable!
+        return -1;  // some significant difference
+    }
+    private static int diffParamTypes(MethodType adapterType, int tstart,
+                                      MethodType targetType, int astart,
+                                      int nargs, boolean raw) {
+        assert(nargs >= 0);
+        int res = 0;
+        for (int i = 0; i < nargs; i++) {
+            Class<?> src  = adapterType.parameterType(tstart+i);
+            Class<?> dest = targetType.parameterType(astart+i);
+            if ((!raw
+                 ? VerifyType.canPassUnchecked(src, dest)
+                 : VerifyType.canPassRaw(src, dest)
+                ) <= 0) {
+                // found a difference; is it the only one so far?
+                if (res != 0)
+                    return -1-res; // return -2-i for prev. i
+                res = 1+i;
+            }
+        }
+        return res;
+    }
+
+    /** Can a retyping adapter (alone) validly convert the target to newType? */
+    public static boolean canRetypeOnly(MethodType newType, MethodType targetType) {
+        return canRetypeOnly(newType, targetType, false);
+    }
+    /** Can a retyping adapter (alone) convert the target to newType?
+     *  It is allowed to widen subword types and void to int, to make bitwise
+     *  conversions between float/int and double/long, and to perform unchecked
+     *  reference conversions on return.  This last feature requires that the
+     *  caller be trusted, and perform explicit cast conversions on return values.
+     */
+    static boolean canRawRetypeOnly(MethodType newType, MethodType targetType) {
+        return canRetypeOnly(newType, targetType, true);
+    }
+    static boolean canRetypeOnly(MethodType newType, MethodType targetType, boolean raw) {
+        if (!convOpSupported(OP_RETYPE_ONLY))  return false;
+        int diff = diffTypes(newType, targetType, raw);
+        // %%% This assert is too strong.  Factor diff into VerifyType and reconcile.
+        assert((diff == 0) == VerifyType.isNullConversion(newType, targetType));
+        return diff == 0;
+    }
+
+    /** Factory method:  Performs no conversions; simply retypes the adapter.
+     *  Allows unchecked argument conversions pairwise, if they are safe.
+     *  Returns null if not possible.
+     */
+    public static MethodHandle makeRetypeOnly(Access token,
+                MethodType newType, MethodHandle target) {
+        return makeRetypeOnly(token, newType, target, false);
+    }
+    public static MethodHandle makeRawRetypeOnly(Access token,
+                MethodType newType, MethodHandle target) {
+        return makeRetypeOnly(token, newType, target, true);
+    }
+    static MethodHandle makeRetypeOnly(Access token,
+                MethodType newType, MethodHandle target, boolean raw) {
+        Access.check(token);
+        if (!canRetypeOnly(newType, target.type(), raw))
+            return null;
+        // TO DO:  clone the target guy, whatever he is, with new type.
+        return new AdapterMethodHandle(target, newType, makeConv(OP_RETYPE_ONLY));
+    }
+
+    /** Can a checkcast adapter validly convert the target to newType?
+     *  The JVM supports all kind of reference casts, even silly ones.
+     */
+    public static boolean canCheckCast(MethodType newType, MethodType targetType,
+                int arg, Class<?> castType) {
+        if (!convOpSupported(OP_CHECK_CAST))  return false;
+        Class<?> src = newType.parameterType(arg);
+        Class<?> dst = targetType.parameterType(arg);
+        if (!canCheckCast(src, castType)
+                || !VerifyType.isNullConversion(castType, dst))
+            return false;
+        int diff = diffTypes(newType, targetType, false);
+        return (diff == arg+1);  // arg is sole non-trivial diff
+    }
+    /** Can an primitive conversion adapter validly convert src to dst? */
+    public static boolean canCheckCast(Class<?> src, Class<?> dst) {
+        return (!src.isPrimitive() && !dst.isPrimitive());
+    }
+
+    /** Factory method:  Forces a cast at the given argument.
+     *  The castType is the target of the cast, and can be any type
+     *  with a null conversion to the corresponding target parameter.
+     *  Return null if this cannot be done.
+     */
+    public static MethodHandle makeCheckCast(Access token,
+                MethodType newType, MethodHandle target,
+                int arg, Class<?> castType) {
+        Access.check(token);
+        if (!canCheckCast(newType, target.type(), arg, castType))
+            return null;
+        long conv = makeConv(OP_CHECK_CAST, arg, 0);
+        return new AdapterMethodHandle(target, newType, conv, castType);
+    }
+
+    /** Can an primitive conversion adapter validly convert the target to newType?
+     *  The JVM currently supports all conversions except those between
+     *  floating and integral types.
+     */
+    public static boolean canPrimCast(MethodType newType, MethodType targetType,
+                int arg, Class<?> convType) {
+        if (!convOpSupported(OP_PRIM_TO_PRIM))  return false;
+        Class<?> src = newType.parameterType(arg);
+        Class<?> dst = targetType.parameterType(arg);
+        if (!canPrimCast(src, convType)
+                || !VerifyType.isNullConversion(convType, dst))
+            return false;
+        int diff = diffTypes(newType, targetType, false);
+        return (diff == arg+1);  // arg is sole non-trivial diff
+    }
+    /** Can an primitive conversion adapter validly convert src to dst? */
+    public static boolean canPrimCast(Class<?> src, Class<?> dst) {
+        if (src == dst || !src.isPrimitive() || !dst.isPrimitive()) {
+            return false;
+        } else if (Wrapper.forPrimitiveType(dst).isFloating()) {
+            // both must be floating types
+            return Wrapper.forPrimitiveType(src).isFloating();
+        } else {
+            // both are integral, and all combinations work fine
+            assert(Wrapper.forPrimitiveType(src).isIntegral() &&
+                   Wrapper.forPrimitiveType(dst).isIntegral());
+            return true;
+        }
+    }
+
+    /** Factory method:  Truncate the given argument with zero or sign extension,
+     *  and/or convert between single and doubleword versions of integer or float.
+     *  The convType is the target of the conversion, and can be any type
+     *  with a null conversion to the corresponding target parameter.
+     *  Return null if this cannot be done.
+     */
+    public static MethodHandle makePrimCast(Access token,
+                MethodType newType, MethodHandle target,
+                int arg, Class<?> convType) {
+        Access.check(token);
+        MethodType oldType = target.type();
+        Class<?> src = newType.parameterType(arg);
+        Class<?> dst = oldType.parameterType(arg);
+        if (!canPrimCast(newType, oldType, arg, convType))
+            return null;
+        long conv = makeConv(OP_PRIM_TO_PRIM, arg, basicType(src), basicType(convType));
+        return new AdapterMethodHandle(target, newType, conv);
+    }
+
+    /** Can an unboxing conversion validly convert src to dst?
+     *  The JVM currently supports all kinds of casting and unboxing.
+     *  The convType is the unboxed type; it can be either a primitive or wrapper.
+     */
+    public static boolean canUnboxArgument(MethodType newType, MethodType targetType,
+                int arg, Class<?> convType) {
+        if (!convOpSupported(OP_REF_TO_PRIM))  return false;
+        Class<?> src = newType.parameterType(arg);
+        Class<?> dst = targetType.parameterType(arg);
+        Class<?> boxType = Wrapper.asWrapperType(convType);
+        convType = Wrapper.asPrimitiveType(convType);
+        if (!canCheckCast(src, boxType)
+                || boxType == convType
+                || !VerifyType.isNullConversion(convType, dst))
+            return false;
+        int diff = diffTypes(newType, targetType, false);
+        return (diff == arg+1);  // arg is sole non-trivial diff
+    }
+    /** Can an primitive unboxing adapter validly convert src to dst? */
+    public static boolean canUnboxArgument(Class<?> src, Class<?> dst) {
+        return (!src.isPrimitive() && Wrapper.asPrimitiveType(dst).isPrimitive());
+    }
+
+    /** Factory method:  Unbox the given argument.
+     *  Return null if this cannot be done.
+     */
+    public static MethodHandle makeUnboxArgument(Access token,
+                MethodType newType, MethodHandle target,
+                int arg, Class<?> convType) {
+        MethodType oldType = target.type();
+        Class<?> src = newType.parameterType(arg);
+        Class<?> dst = oldType.parameterType(arg);
+        Class<?> boxType = Wrapper.asWrapperType(convType);
+        Class<?> primType = Wrapper.asPrimitiveType(convType);
+        if (!canUnboxArgument(newType, oldType, arg, convType))
+            return null;
+        MethodType castDone = newType;
+        if (!VerifyType.isNullConversion(src, boxType))
+            castDone = newType.changeParameterType(arg, boxType);
+        long conv = makeConv(OP_REF_TO_PRIM, arg, T_OBJECT, basicType(primType));
+        MethodHandle adapter = new AdapterMethodHandle(target, castDone, conv, boxType);
+        if (castDone == newType)
+            return adapter;
+        return makeCheckCast(token, newType, adapter, arg, boxType);
+    }
+
+    /** Can an primitive boxing adapter validly convert src to dst? */
+    public static boolean canBoxArgument(Class<?> src, Class<?> dst) {
+        if (!convOpSupported(OP_PRIM_TO_REF))  return false;
+        throw new UnsupportedOperationException("NYI");
+    }
+
+    /** Factory method:  Unbox the given argument.
+     *  Return null if this cannot be done.
+     */
+    public static MethodHandle makeBoxArgument(Access token,
+                MethodType newType, MethodHandle target,
+                int arg, Class<?> convType) {
+        // this is difficult to do in the JVM because it must GC
+        return null;
+    }
+
+    // TO DO: makeSwapArguments, makeRotateArguments, makeDuplicateArguments
+
+    /** Can an adapter simply drop arguments to convert the target to newType? */
+    public static boolean canDropArguments(MethodType newType, MethodType targetType,
+                int dropArgPos, int dropArgCount) {
+        if (dropArgCount == 0)
+            return canRetypeOnly(newType, targetType);
+        if (!convOpSupported(OP_DROP_ARGS))  return false;
+        if (diffReturnTypes(newType, targetType, false) != 0)
+            return false;
+        int nptypes = newType.parameterCount();
+        // parameter types must be the same up to the drop point
+        if (dropArgPos != 0 && diffParamTypes(newType, 0, targetType, 0, dropArgPos, false) != 0)
+            return false;
+        int afterPos = dropArgPos + dropArgCount;
+        int afterCount = nptypes - afterPos;
+        if (dropArgPos < 0 || dropArgPos >= nptypes ||
+            dropArgCount < 1 || afterPos > nptypes ||
+            targetType.parameterCount() != nptypes - dropArgCount)
+            return false;
+        // parameter types after the drop point must also be the same
+        if (afterCount != 0 && diffParamTypes(newType, afterPos, targetType, dropArgPos, afterCount, false) != 0)
+            return false;
+        return true;
+    }
+
+    /** Factory method:  Drop selected arguments.
+     *  Allow unchecked retyping of remaining arguments, pairwise.
+     *  Return null if this is not possible.
+     */
+    public static MethodHandle makeDropArguments(Access token,
+                MethodType newType, MethodHandle target,
+                int dropArgPos, int dropArgCount) {
+        Access.check(token);
+        if (dropArgCount == 0)
+            return makeRetypeOnly(IMPL_TOKEN, newType, target);
+        MethodType mt = target.type();
+        int argCount  = mt.parameterCount();
+        if (!canDropArguments(newType, mt, dropArgPos, dropArgCount))
+            return null;
+        int dropSlotCount, dropSlotPos;
+        if (dropArgCount >= argCount) {
+            assert(dropArgPos == argCount-1);
+            dropSlotPos = 0;
+            dropSlotCount = mt.parameterSlotCount();
+        } else {
+            // arglist: [0: keep... | dpos: drop... | dpos+dcount: keep... ]
+            int lastDroppedArg = dropArgPos + dropArgCount - 1;
+            int lastKeptArg    = dropArgPos - 1;  // might be -1, which is OK
+            dropSlotPos      = mt.parameterSlotDepth(1+lastDroppedArg);
+            int lastKeptSlot = mt.parameterSlotDepth(1+lastKeptArg);
+            dropSlotCount = lastKeptSlot - dropSlotPos;
+            assert(dropSlotCount >= dropArgCount);
+        }
+        long conv = makeConv(OP_DROP_ARGS, dropArgPos, +dropSlotCount);
+        return new AdapterMethodHandle(target, newType, dropSlotCount, conv);
+    }
+
+    /** Can an adapter spread an argument to convert the target to newType? */
+    public static boolean canSpreadArguments(MethodType newType, MethodType targetType,
+                Class<?> spreadArgType, int spreadArgPos, int spreadArgCount) {
+        if (!convOpSupported(OP_SPREAD_ARGS))  return false;
+        if (diffReturnTypes(newType, targetType, false) != 0)
+            return false;
+        int nptypes = newType.parameterCount();
+        // parameter types must be the same up to the spread point
+        if (spreadArgPos != 0 && diffParamTypes(newType, 0, targetType, 0, spreadArgPos, false) != 0)
+            return false;
+        int afterPos = spreadArgPos + spreadArgCount;
+        int afterCount = nptypes - afterPos;
+        if (spreadArgPos < 0 || spreadArgPos >= nptypes ||
+            spreadArgCount < 0 ||
+            targetType.parameterCount() != nptypes - 1 + spreadArgCount)
+            return false;
+        // parameter types after the spread point must also be the same
+        if (afterCount != 0 && diffParamTypes(newType, spreadArgPos+1, targetType, afterPos, afterCount, false) != 0)
+            return false;
+        // match the array element type to the spread arg types
+        Class<?> rawSpreadArgType = newType.parameterType(spreadArgPos);
+        if (rawSpreadArgType != spreadArgType && !canCheckCast(rawSpreadArgType, spreadArgType))
+            return false;
+        for (int i = 0; i < spreadArgCount; i++) {
+            Class<?> src = VerifyType.spreadArgElementType(spreadArgType, i);
+            Class<?> dst = targetType.parameterType(spreadArgPos + i);
+            if (src == null || !VerifyType.isNullConversion(src, dst))
+                return false;
+        }
+        return true;
+    }
+
+    /** Factory method:  Spread selected argument. */
+    public static MethodHandle makeSpreadArguments(Access token,
+                MethodType newType, MethodHandle target,
+                Class<?> spreadArgType, int spreadArgPos, int spreadArgCount) {
+        Access.check(token);
+        MethodType mt = target.type();
+        int argCount  = mt.parameterCount();
+        if (!canSpreadArguments(newType, mt, spreadArgType, spreadArgPos, spreadArgCount))
+            return null;
+        int spreadSlotCount, spreadSlotPos;
+        if (spreadArgCount >= argCount) {
+            assert(spreadArgPos == argCount-1);
+            spreadSlotPos = 0;
+            spreadSlotCount = mt.parameterSlotCount();
+        } else {
+            // arglist: [0: keep... | dpos: spread... | dpos+dcount: keep... ]
+            int lastSpreadArg = spreadArgPos + spreadArgCount - 1;
+            int lastKeptArg   = spreadArgPos - 1;  // might be -1, which is OK
+            spreadSlotPos     = mt.parameterSlotDepth(1+lastSpreadArg);
+            int lastKeptSlot  = mt.parameterSlotDepth(1+lastKeptArg);
+            spreadSlotCount = lastKeptSlot - spreadSlotPos;
+            assert(spreadSlotCount >= spreadArgCount);
+        }
+        long conv = makeConv(OP_SPREAD_ARGS, spreadArgPos, spreadSlotCount);
+        return new AdapterMethodHandle(target, newType, conv, spreadArgType);
+    }
+
+    // TO DO: makeCollectArguments, makeFlyby, makeRicochet
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/dyn/BoundMethodHandle.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package sun.dyn;
+
+import sun.dyn.util.VerifyType;
+import sun.dyn.util.Wrapper;
+import java.dyn.*;
+
+/**
+ * The flavor of method handle which emulates an invoke instruction
+ * on a predetermined argument.  The JVM dispatches to the correct method
+ * when the handle is created, not when it is invoked.
+ * @author jrose
+ */
+public class BoundMethodHandle extends MethodHandle  {
+    //MethodHandle vmtarget;           // next BMH or final DMH or methodOop
+    private final Object argument;     // argument to insert
+    private final int    vmargslot;    // position at which it is inserted
+
+    // Constructors in this class *must* be package scoped or private.
+
+    /** Bind a direct MH to its receiver (or first ref. argument).
+     *  The JVM will pre-dispatch the MH if it is not already static.
+     */
+    BoundMethodHandle(DirectMethodHandle mh, Object argument) {
+        super(Access.TOKEN, mh.type().dropParameterType(0));
+        // check the type now, once for all:
+        this.argument = checkReferenceArgument(argument, mh, 0);
+        this.vmargslot = this.type().parameterSlotCount();
+        if (MethodHandleNatives.JVM_SUPPORT) {
+            this.vmtarget = null;  // maybe updated by JVM
+            MethodHandleNatives.init(this, mh, 0);
+        } else {
+            this.vmtarget = mh;
+        }
+     }
+
+    private static final int REF_ARG = 0, PRIM_ARG = 1, SELF_ARG = 2;
+
+    /** Insert an argument into an arbitrary method handle.
+     *  If argnum is zero, inserts the first argument, etc.
+     *  The argument type must be a reference.
+     */
+    BoundMethodHandle(MethodHandle mh, Object argument, int argnum) {
+        this(mh, argument, argnum, mh.type().parameterType(argnum).isPrimitive() ? PRIM_ARG : REF_ARG);
+    }
+
+    /** Insert an argument into an arbitrary method handle.
+     *  If argnum is zero, inserts the first argument, etc.
+     */
+    BoundMethodHandle(MethodHandle mh, Object argument, int argnum, int whichArg) {
+        super(Access.TOKEN, mh.type().dropParameterType(argnum));
+        if (whichArg == PRIM_ARG)
+            this.argument = bindPrimitiveArgument(argument, mh, argnum);
+        else {
+            if (whichArg == SELF_ARG)  argument = this;
+            this.argument = checkReferenceArgument(argument, mh, argnum);
+        }
+        this.vmargslot = this.type().parameterSlotDepth(argnum);
+        if (MethodHandleNatives.JVM_SUPPORT) {
+            this.vmtarget = null;  // maybe updated by JVM
+            MethodHandleNatives.init(this, mh, argnum);
+        } else {
+            this.vmtarget = mh;
+        }
+    }
+
+    /** For the AdapterMethodHandle subclass.
+     */
+    BoundMethodHandle(MethodType type, Object argument, int vmargslot) {
+        super(Access.TOKEN, type);
+        this.argument = argument;
+        this.vmargslot = vmargslot;
+        assert(this.getClass() == AdapterMethodHandle.class);
+    }
+
+    /** Initialize the current object as a method handle, binding it
+     *  as the {@code argnum}th argument of the method handle {@code entryPoint}.
+     *  The invocation type of the resulting method handle will be the
+     *  same as {@code entryPoint},  except that the {@code argnum}th argument
+     *  type will be dropped.
+     */
+    public BoundMethodHandle(MethodHandle entryPoint, int argnum) {
+        this(entryPoint, null, argnum, SELF_ARG);
+
+        // Note:  If the conversion fails, perhaps because of a bad entryPoint,
+        // the MethodHandle.type field will not be filled in, and therefore
+        // no MH.invoke call will ever succeed.  The caller may retain a pointer
+        // to the broken method handle, but no harm can be done with it.
+    }
+
+    /** Initialize the current object as a method handle, binding it
+     *  as the first argument of the method handle {@code entryPoint}.
+     *  The invocation type of the resulting method handle will be the
+     *  same as {@code entryPoint},  except that the first argument
+     *  type will be dropped.
+     */
+    public BoundMethodHandle(MethodHandle entryPoint) {
+        this(entryPoint, null, 0, SELF_ARG);
+    }
+
+    /** Make sure the given {@code argument} can be used as {@code argnum}-th
+     *  parameter of the given method handle {@code mh}, which must be a reference.
+     *  <p>
+     *  If this fails, throw a suitable {@code WrongMethodTypeException},
+     *  which will prevent the creation of an illegally typed bound
+     *  method handle.
+     */
+    final static Object checkReferenceArgument(Object argument, MethodHandle mh, int argnum) {
+        Class<?> ptype = mh.type().parameterType(argnum);
+        if (ptype.isPrimitive()) {
+            // fail
+        } else if (argument == null) {
+            return null;
+        } else if (VerifyType.isNullReferenceConversion(argument.getClass(), ptype)) {
+            return argument;
+        }
+        throw badBoundArgumentException(argument, mh, argnum);
+    }
+
+    /** Make sure the given {@code argument} can be used as {@code argnum}-th
+     *  parameter of the given method handle {@code mh}, which must be a primitive.
+     *  <p>
+     *  If this fails, throw a suitable {@code WrongMethodTypeException},
+     *  which will prevent the creation of an illegally typed bound
+     *  method handle.
+     */
+    final static Object bindPrimitiveArgument(Object argument, MethodHandle mh, int argnum) {
+        Class<?> ptype = mh.type().parameterType(argnum);
+        Wrapper  wrap = Wrapper.forPrimitiveType(ptype);
+        Object   zero  = wrap.zero();
+        if (zero == null) {
+            // fail
+        } else if (argument == null) {
+            if (ptype != int.class && wrap.isSubwordOrInt())
+                return Integer.valueOf(0);
+            else
+                return zero;
+        } else if (VerifyType.isNullReferenceConversion(argument.getClass(), zero.getClass())) {
+            if (ptype != int.class && wrap.isSubwordOrInt())
+                return Wrapper.INT.wrap(argument);
+            else
+                return argument;
+        }
+        throw badBoundArgumentException(argument, mh, argnum);
+    }
+
+    final static RuntimeException badBoundArgumentException(Object argument, MethodHandle mh, int argnum) {
+        String atype = (argument == null) ? "null" : argument.getClass().toString();
+        return new WrongMethodTypeException("cannot bind "+atype+" argument to parameter #"+argnum+" of "+mh.type());
+    }
+
+    @Override
+    public String toString() {
+        return "Bound[" + super.toString() + "]";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/dyn/CallSiteImpl.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package sun.dyn;
+
+import java.dyn.*;
+
+/**
+ * The CallSite privately created by the JVM at every invokedynamic instruction.
+ * @author jrose
+ */
+class CallSiteImpl extends CallSite {
+    // Fields used only by the JVM.  Do not use or change.
+    private Object vmmethod;
+
+    // Values supplied by the JVM:
+    int callerMID, callerBCI;
+
+    private CallSiteImpl(Class<?> caller, String name, MethodType type) {
+        super(caller, name, type);
+    }
+
+    @Override
+    public void setTarget(MethodHandle mh) {
+        checkTarget(mh);
+        if (MethodHandleNatives.JVM_SUPPORT)
+            MethodHandleNatives.linkCallSite(this, (MethodHandle) mh);
+        else
+            super.setTarget(mh);
+    }
+
+    private static final MethodHandle PRIVATE_INITIALIZE_CALL_SITE =
+            MethodHandleImpl.IMPL_LOOKUP.findStatic(CallSite.class, "privateInitializeCallSite",
+                MethodType.make(void.class, CallSite.class, int.class, int.class));
+
+    // this is the up-call from the JVM:
+    static CallSite makeSite(Class<?> caller, String name, MethodType type,
+                             int callerMID, int callerBCI) {
+        MethodHandle bsm = Linkage.getBootstrapMethod(caller);
+        if (bsm == null)
+            throw new InvokeDynamicBootstrapError("class has no bootstrap method: "+caller);
+        CallSite site = bsm.<CallSite>invoke(caller, name, type);
+        if (site == null)
+            throw new InvokeDynamicBootstrapError("class bootstrap method failed to create a call site: "+caller);
+        PRIVATE_INITIALIZE_CALL_SITE.<void>invoke(site, callerMID, callerBCI);
+        return site;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/dyn/DirectMethodHandle.java	Thu May 14 09:53:35 2009 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008-2009 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.
+ */
+
+package sun.dyn;
+
+import java.dyn.*;
+import static sun.dyn.MethodHandleNatives.Constants.*;
+
+/**
+ * The flavor of method handle which emulates invokespecial or invokestatic.
+ * @author jrose
+ */
+class DirectMethodHandle extends MethodHandle {
+    //inherited oop    vmtarget;    // methodOop or virtual class/interface oop
+    private final int  vmindex;     // method index within class or interface
+    { vmindex = VM_INDEX_UNINITIALIZED; }  // JVM may change this
+
+    // Constructors in this class *must* be package scoped or private.
+    DirectMethodHandle(MethodType mtype, MemberName m, boolean doDispatch, Class<?> lookupClass) {
+        super(Access.TO